18 kDCH,
kDRC,
kDSK,
kEMC,
kGEM,
kLUMI,
kMDT,
kMVD,
kRPC,
kSTT,
kTPC,
kTOF,
kFTS,
kHYPG,
kHYP};
22 gROOT->LoadMacro(
"$VMCWORKDIR/gconfig/rootlogon.C");
25 TDatabasePDG *pdg =
new TDatabasePDG();
30 TString simFileName =
"Sim_Dpm_500.root";
31 TString parFileName =
"Sim_Dpm_500_params.root";
32 TString digiFileName =
"Sim_Dpm_500_digi.root";
33 TString recoFileName =
"Sim_Dpm_500_reco.root";
34 TString outFileName =
"Sim_Dpm_500_streamdisplay.root";
35 TString histofilename =
"onlinetrkmccheck.root";
39 TFile filerecopixel(recoFileName.Data());
42 TTree *recotree = (TTree*)
filereco.Get(
"pndsim");
44 TFile simfile(simFileName.Data());
45 TTree* mctree = (TTree*) simfile.Get(
"pndsim");
46 TClonesArray* mcarray =
new TClonesArray(
"PndMCTrack");
47 mctree->SetBranchAddress(
"MCTrack", &mcarray);
51 allDigiFile +=
"/macro/params/";
54 FairRunAna *
fRun =
new FairRunAna();
55 fRun->SetInputFile(simFileName.Data());
56 fRun->AddFriend(digiFileName.Data());
57 fRun->AddFriend(recoFileName.Data());
58 fRun->SetOutputFile(outFileName.Data());
60 FairRuntimeDb*
rtdb = fRun->GetRuntimeDb();
61 FairParRootFileIo*
parInput1 =
new FairParRootFileIo();
62 parInput1->open(parFileName.Data());
63 FairParAsciiFileIo*
parIo1 =
new FairParAsciiFileIo();
64 parIo1->open(allDigiFile.Data(),
"in");
65 rtdb->setFirstInput(parInput1);
66 rtdb->setSecondInput(parIo1);
71 PndOnlineGeometryManager *online_geometry =
new PndOnlineGeometryManager(rtdb, parFileName.Data());
73 PndOnlineManager *online =
new PndOnlineManager();
74 online->AddGeometryManager(online_geometry);
76 cout <<
"Geo Manager Pointer: " <<
gGeoManager << endl;
79 online->LoadStream(PndOnline::kMVDPixel,
"MVDHitsPixel",stthitlifetime);
80 online->LoadStream(PndOnline::kMVDStrip,
"MVDHitsStrip",stthitlifetime);
83 TClonesArray* tubearray = online_geometry->GetDetectorGeometry(
PndOnline::kSTT);
86 PndOnlineSttTripletFinder *triplet_finder =
new PndOnlineSttTripletFinder(online, tubearray);
87 online->AddTask((FairTask*)triplet_finder);
90 TCanvas*
c1 =
new TCanvas(
"c1");
91 c1->Range(-42,-42,42,42);
92 c1->SetCanvasSize(1200, 1200);
93 TText* mytext =
new TText();
100 int final_time = maximumTime;
102 online->SetHESRRevolutionDuration(delta_t);
106 TObjArray* online_fairhits_stt = 0;
107 TObjArray* online_tracks = 0;
108 TObjArray* online_tracks2 = 0;
109 TObjArray* online_fairhits_mvd = 0;
111 std::vector<double> mctracktime;
112 std::vector<double> mctrackpt;
113 std::vector<double> mctrackphi;
114 std::vector<int> mctrackstatus;
115 std::vector<double> recotracktime;
116 std::vector<double> recotrackpt;
117 std::vector<double> recotrackphi;
118 std::vector<int> recotrackstatus;
119 std::vector<int> recotrackmcid;
120 int goodrecotrack = 0;
121 int badrecotrack = 0;
122 int totalmctracks = 0;
123 int goodmctracks = 0;
124 int totalrecotracks = 0;
125 int goodrecotracks = 0;
126 int norecotracks = 0;
127 int deltaphifailed = 0;
128 int deltaptfailed = 0;
129 int deltabothfailed = 0;
131 int globalmaxmcid = 0;
132 int mctracknonprime = 0;
133 int mctracknonrecomomentum = 0;
135 int mctracknonhit = 0;
136 int mctrackgrandtotal = 0;
137 int mctrackrecoattempt = 0;
138 int foundrecotrackall = 0;
139 int foundrecotrack90 = 0;
140 int foundrecotrack80 = 0;
141 int foundrecotrackbad = 0;
142 int mctracknotrecoed = 0;
143 int lowbetagamma = 0;
144 int pdgcodetoolarge = 0;
146 PndMCBookkeeper foundmapall;
148 PndMCBookkeeper foundmap90;
150 PndMCBookkeeper foundmap80;
152 PndMCBookkeeper foundmapbad;
155 int mctracknullpointers = 0;
156 int recotracknullpointers = 0;
162 TH2D* hmcall =
new TH2D(
"hmcall",
"hmcall", 1500, -14, 16, 75, 0, 1.5);
163 TH2D* hmcprime =
new TH2D(
"hmcprime",
"hmcprime", 1500, -14, 16, 75, 0, 1.5);
164 TH2D* hmcrecoable =
new TH2D(
"hmcrecoable",
"hmcrecoable", 1500, -14, 16, 75, 0, 1.5);
165 TH2D* hdafuq =
new TH2D(
"hdafuq",
"hdafuq", 1500, -14, 16, 75, 0, 1.5);
166 TH2D* hmcrecoed =
new TH2D(
"hmcrecoed",
"hmcrecoed", 1500, -14, 16, 75, 0, 1.5);
167 TH2D* hmcnotrecoed =
new TH2D(
"hmcnotrecoed",
"hmcnotrecoed", 1500, -14, 16, 75, 0, 1.5);
169 TH1D* hphires =
new TH1D(
"hphires",
"hphires", 700, -3.5, 3.5);
170 TH2D* hptres =
new TH2D(
"hptres",
"hptres", 320, -1600, 1600, 200, -1, 1);
171 TH1D* hphiresmcall =
new TH1D(
"hphiresmcall",
"hphiresmcall", 700, -3.5, 3.5);
172 TH2D* hptresmcall =
new TH2D(
"hptresmcall",
"hptresmcall", 320, -1600, 1600, 200, -1, 1);
173 TH1D* hphiresmc90 =
new TH1D(
"hphiresmc90",
"hphiresmc90", 700, -3.5, 3.5);
174 TH2D* hptresmc90 =
new TH2D(
"hptresmc90",
"hptresmc90", 320, -1600, 1600, 200, -1, 1);
175 TH1D* hphiresmc80 =
new TH1D(
"hphiresmc80",
"hphiresmc80", 700, -3.5, 3.5);
176 TH2D* hptresmc80 =
new TH2D(
"hptresmc80",
"hptresmc80", 320, -1600, 1600, 200, -1, 1);
177 TH1D* hphiresmcbad =
new TH1D(
"hphiresmcbad",
"hphiresmcbad", 700, -3.5, 3.5);
178 TH2D* hptresmcbad =
new TH2D(
"hptresmcbad",
"hptresmcbad", 320, -1600, 1600, 200, -1, 1);
180 TH2D* hphithetaresmcall =
new TH2D(
"hphithetaresmcall",
"hphithetaresmcall", 700, -3.5, 3.5, 700, -3.5, 3.5);
181 TH2D* hphithetaresmc90 =
new TH2D(
"hphithetaresmc90",
"hphithetaresmc90", 700, -3.5, 3.5, 700, -3.5, 3.5);
182 TH2D* hphithetaresmc80 =
new TH2D(
"hphithetaresmc80",
"hphithetaresmc80", 700, -3.5, 3.5, 700, -3.5, 3.5);
183 TH2D* hphithetaresmcbad =
new TH2D(
"hphithetaresmcbad",
"hphithetaresmcbad", 700, -3.5, 3.5, 700, -3.5, 3.5);
187 for (current_time = 0; current_time < final_time; current_time += delta_t) {
190 online->ClearTracks();
191 online->LoadHits( delta_t );
196 online_tracks = online->GetTrackObjectList();
200 if (online_tracks->GetEntriesFast() > 0) {
201 PndOnlineTrack* firstTrack = (PndOnlineTrack*) online_tracks->At(firsti);
202 while (firstTrack->DrawMode() != PndOnlineTrack::kVertexMomentumAsCircleHack) {
204 if (firsti > online_tracks->GetEntriesFast()) {
205 cout <<
"No drawable online Track in Array. We have a severe problem." << endl;
208 firstTrack = (PndOnlineTrack*) online_tracks->At(firsti);
210 maxmcid = firstTrack->MCEntryNumber();
211 minmcid = firstTrack->MCEntryNumber();
213 for (
int i = 0;
i < online_tracks->GetEntriesFast();
i++) {
214 PndOnlineTrack* myTrack = (PndOnlineTrack*) online_tracks->At(
i);
215 if (myTrack->DrawMode() != PndOnlineTrack::kVertexMomentumAsCircleHack) {
220 mctree->GetEntry(myTrack->MCEntryNumber());
224 cout <<
"MC Track NULL pointer in event " << myTrack->MCEntryNumber() <<
", track " << myTrack->MCTrackNumber() << endl;
225 cout <<
"Event Majority: " << myTrack->MCEntryMajority() <<
", Track Majority: " << myTrack->MCTrackMajority() << endl;
226 recotracknullpointers++;
233 TVector2 innerhit = TVector2(myTrack->Vertex().x(), myTrack->Vertex().y());
234 TVector2 outerhit = TVector2(myTrack->Momentum().x(), myTrack->Momentum().y());
249 TVector2 circleorigin = myTrack->CircleOrigin();
250 Double_t orfoundrecotrackallthophi = circleorigin.Phi();
251 Double_t circleradius = myTrack->CircleRadius();
252 Int_t clockwise = myTrack->CircleClockwise();
253 Double_t trackphi = myTrack->CirclePhi();
254 Double_t trackpt = circleradius * 2.0 * 2.99792458;
283 if (calcphimc < 0) calcphimc += 2*
TMath::Pi();
285 if (calcphireco < 0) calcphireco += 2*
TMath::Pi();
286 Double_t deltaphi = calcphireco - calcphimc;
294 Int_t chargesign = 1;
317 hphiresmcall->Fill(deltaphi*chargesign);
318 hphithetaresmcall->Fill(mctheta, deltaphi*chargesign);
319 hptresmcall->Fill(mcpt*chargesign, deltapt/mcpt);
321 int mceventid = myTrack->MCEntryNumber();
322 int mctrackid = myTrack->MCTrackNumber();
323 foundmapall.Add(mceventid, mctrackid);
324 if ( (myTrack->MCEntryMajority() > 0.9) && (myTrack->MCTrackMajority() > 0.9) ) {
326 foundmap90.Add(mceventid, mctrackid);
327 hphiresmc90->Fill(deltaphi*chargesign);
328 hphithetaresmc90->Fill(mctheta, deltaphi*chargesign);
329 hptresmc90->Fill(mcpt*chargesign, deltapt/mcpt);
331 if ( (myTrack->MCEntryMajority() > 0.8) && (myTrack->MCTrackMajority() > 0.8) ) {
333 foundmap80.Add(mceventid, mctrackid);
334 hphiresmc80->Fill(deltaphi*chargesign);
335 hphithetaresmc80->Fill(mctheta, deltaphi*chargesign);
336 hptresmc80->Fill(mcpt*chargesign, deltapt/mcpt);
339 foundmapbad.Add(mceventid, mctrackid);
340 hphiresmcbad->Fill(deltaphi*chargesign);
341 hphithetaresmcbad->Fill(mctheta, deltaphi*chargesign);
342 hptresmcbad->Fill(mcpt*chargesign, deltapt/mcpt);
348 cout <<
"Low pt hit" << endl;
351 int mcentrynumber = myTrack->MCEntryNumber();
352 if (mcentrynumber > maxmcid) {
353 maxmcid = mcentrynumber;
355 if (mcentrynumber < minmcid) {
356 minmcid = mcentrynumber;
364 recotrackpt.push_back(trackpt);
365 recotrackphi.push_back(trackphi);
366 recotrackstatus.push_back(0);
367 recotrackmcid.push_back(mcentrynumber);
371 if (maxmcid > globalmaxmcid) {
372 globalmaxmcid = maxmcid;
374 cout <<
"MC ID Range: " << minmcid <<
", " << maxmcid << endl;
376 for (
int j = minmcid; j <= maxmcid; j++) {
377 cout <<
"MC outer loop: " << j << endl;
378 if (j > globalmaxmcid) {
382 cout <<
"MC Entry count: " << mcarray->GetEntriesFast() << endl;
384 for (
int k = 0; k < mcarray->GetEntriesFast(); k++) {
388 cout <<
"MC Track has NULL pointer. Oooops." << endl;
389 mctracknullpointers++;
394 cout <<
"PDG Code too large: " << mctrack->
GetPdgCode() << endl;
406 mctracknonrecomomentum++;
414 mctracknonrecomomentum++;
422 mctracknonrecomomentum++;
431 cout <<
"Low betagamma particle" << endl;
443 cout <<
"Didn't hit." << endl;
447 mctrackrecoattempt++;
452 if (foundmapall.Get(j, k) > 0) {
457 cout <<
"Did not find Event " << j <<
", Track " << k << endl;
461 if (foundmap90.Get(j, k) > 0) {
466 if (foundmap80.Get(j, k) > 0) {
471 if (foundmapbad.Get(j, k) > 0) {
600 for (
int s = 0;
s < mctrackstatus.size();
s++) {
601 if (mctrackstatus.at(
s) > 0) {
606 int recotrackstatusgoodcount = 0;
607 int recotrackstatusbadcount = 0;
609 for (
int s = 0;
s < recotrackstatus.size();
s++) {
610 if (recotrackmcid.at(
s) <= globalmaxmcid) {
611 if (recotrackstatus.at(
s) > 0) {
612 recotrackstatusgoodcount++;
614 recotrackstatusbadcount++;
623 cout <<
"Total reconstructed track count: " << totalrecotracks << endl;
624 cout <<
"Reached MC ID: " << globalmaxmcid << endl;
636 cout <<
"MC Track Grand Total: " << mctrackgrandtotal << endl;
637 cout <<
"MC Track PDG Code too large: " << pdgcodetoolarge << endl;
638 cout <<
"MC Track Non Prime: " << mctracknonprime << endl;
639 cout <<
"MC Track Low Momentum: " << mctracknonrecomomentum << endl;
640 cout <<
" MC Track Low Pt Hit: " << lowpthit << endl;
641 cout <<
"MC Track Low BetaGamma: " << lowbetagamma << endl;
642 cout <<
"Secondary Tracks: " << secondaries << endl;
643 cout <<
"MC Track missed STT: " << mctracknonhit << endl;
644 cout <<
"MC Track to be recoed: " << mctrackrecoattempt << endl;
645 cout <<
"MC Track recoed (all): " << foundrecotrackall << endl;
646 cout <<
"MC Track recoed (90): " << foundrecotrack90 << endl;
647 cout <<
"MC Track recoed (80): " << foundrecotrack80 << endl;
648 cout <<
"MC Track recoed (bad): " << foundrecotrackbad << endl;
649 cout <<
"MC Track not recoed: " << mctracknotrecoed << endl;
652 cout <<
"MC Match Good 90: " << mcidgood90 << endl;
653 cout <<
"MC Match Good 80: " << mcidgood80 << endl;
654 cout <<
"MC Match Bad: " << mcidbad << endl;
655 cout <<
"MC Tracks with NULL pointers in Reco: " << recotracknullpointers << endl;
656 cout <<
"MC Tracks with NULL pointers: " << mctracknullpointers << endl;
660 TFile outputstorage(histofilename,
"UPDATE");
689 cout << endl << endl;
690 cout <<
"Macro finished succesfully." << endl;
691 cout <<
"Real time " << rtime <<
" s, CPU time " << ctime <<
" s" << endl;
TFile filereco("MvdStt_Test_reco.root")
Int_t GetNPoints(DetectorId detId) const
TVector3 GetMomentum() const
TGeoManager * gGeoManager
TFile filedigi("testdigi.root")
FairParRootFileIo * parInput1
FairParAsciiFileIo * parIo1
TVector3 GetStartVertex() const
Int_t GetMotherID() const
void SaveAndUpdateHisto(TH1 *currenthisto, TFile &storagefile)