00001 #include "MapsTrackManager.hh"
00002 #include "MapsTrack.hh"
00003 #include "MapsSensor.hh"
00004 #include "MapsException.hh"
00005 #include <cmath>
00006 #include <algorithm>
00007 #include <iostream>
00008 #include "TRandom2.h"
00009 #include "TFile.h"
00010 #include "TH1F.h"
00011 #include "Operators.h"
00012
00013 int main(int argc, const char **argv) {
00014
00015 if (argc != 3) {
00016 std::cout << "Usage: ExtractEfficiencies <input file> <outputfile>\n";
00017 return 0;
00018 }
00019 std::cout << "Welcome to ExtractEfficiencies...\n";
00020
00021
00022 double cut(0.05);
00023
00024 std::pair<double, double> error(0.1, 0.1);
00025
00026 std::cout << "\tUsing cuts for probability of: \t" << cut << "\n";
00027 std::cout << "\tError parameters: \t" << error << "\n";
00028
00029 std::cout << "\tRecreating from root file...\n";
00030 char input[100];
00031 strcpy(input, argv[1]);
00032
00033
00034 MapsTrackManager mtm2;
00035
00036 mtm2.recreateFromRootFile(input);
00037
00038 std::vector<MapsTrack*>& tracks = mtm2.getTracks();
00039
00040
00041 unsigned ineff(0), eff(0), deadArs(0);
00042 unsigned candidateTracks(0);
00043
00044 for (std::vector<MapsTrack*>::iterator it = tracks.begin(); it
00045 != tracks.end(); it++) {
00046 MapsTrack* t = *it;
00047
00048
00049 t->setTrackError(error);
00050
00051
00052
00053 MapsTrack t3;
00054 t->make3HitTrack(t3);
00055 t3.setTrackError(error);
00056
00057
00058 if (t3.chiSqProb(0) > cut && t3.chiSqProb(1) > cut) {
00059
00060 candidateTracks++;
00061
00062
00063 MapsSensor* s4 = t->fourthSensor();
00064
00065
00066 std::pair<double, double> resid;
00067 unsigned fourthConfirm = t->getFourthHitResidual(t3, resid);
00068
00069 if (fourthConfirm == 0 && t->chiSqProb(0) > cut && t->chiSqProb(1)
00070 > cut) {
00071
00072
00073 s4->registerTrackConfirm(t->fourthSensorThresh(), t->getHits().at(s4), t->timeStamp(), resid);
00074 eff++;
00075 } else {
00076
00077
00078 if(!s4->isDeadArea(t->findXYPrediction(s4->zPosition()))) {
00079 s4->registerTrackMiss(t->fourthSensorThresh(), t->findXYPrediction(s4->zPosition()), t->timeStamp());
00080 ineff++;
00081 } else {
00082 ++deadArs;
00083 }
00084 }
00085
00086 }
00087 }
00088
00089
00090
00091 char output[100];
00092 strcpy(output, argv[2]);
00093 TFile f(output, "recreate");
00094
00095
00096 std::vector<MapsSensor*>& sensors = mtm2.getSensors();
00097 for (std::vector<MapsSensor*>::iterator it = sensors.begin(); it
00098 != sensors.end(); it++) {
00099 MapsSensor* s = *it;
00100 TH1F h;
00101 TH1F g, k;
00102 TH2F j, l, m, n;
00103 s->getEfficiencyCurve(h, 20, 0, 200);
00104 s->getEfficiencyTimestamps(g);
00105 s->getEfficiencyXYPlot(j);
00106 s->getInefficiencyXYPlot(m, true);
00107 s->getInefficiencyTimestamps(k);
00108 s->getFourthHitResidualPlot(l);
00109 s->getEfficiencyByGroup(n);
00110 h.Write();
00111 g.Write();
00112 j.Write();
00113 k.Write();
00114 l.Write();
00115 m.Write();
00116 n.Write();
00117 std::cout.precision(4);
00118 std::cout << "\n" << *s << ": Efficiency: \n";
00119 for (unsigned tMult(7); tMult < 20; tMult++) {
00120 double efficiency = s->getEfficiency(tMult*10);
00121 if (efficiency > -0.9)
00122 std::cout << "\t Thresh: " << tMult*10 << "\t: " << efficiency
00123 * 100 << "\n";
00124 }
00125 }
00126
00127
00128 std::cout << "\tWriting root file: " << output << "\n";
00129 f.Write();
00130 f.Close();
00131
00132
00133 std::cout << "ExtractEfficiencies: summary:\n";
00134 std::cout << "\tTotal candidate tracks:\t" << candidateTracks << "\n";
00135 std::cout << "\tEfficient hits:\t" << eff << "\n";
00136 std::cout << "\tInefficient hits:\t" << ineff << "\n";
00137 std::cout << "\tDead area intersections:\t" << deadArs << "\n";
00138
00139 std::cout << "Have a nice day.\n";
00140
00141 }
00142