3535#include "SimulationDataFormat/MCCompLabel.h"
3636#include "SimulationDataFormat/MCTruthContainer.h"
3737#include "DataFormatsITS/TrackITS.h"
38+ #include "DataFormatsITSMFT/ROFRecord.h"
39+ #include "SimulationDataFormat/DigitizationContext.h"
3840
3941#endif
4042#include "DataFormatsITSMFT/CompCluster.h"
@@ -57,19 +59,29 @@ struct ParticleInfo {
5759 unsigned short clusters = 0u ;
5860 unsigned char isReco = 0u ;
5961 unsigned char isFake = 0u ;
60- bool isPrimary = 0u ;
62+ bool isPrimary = false;
63+ int bcInROF {-1 };
64+ int rofId {-1 };
6165 unsigned char storedStatus = 2 ; /// not stored = 2, fake = 1, good = 0
6266 o2 ::its ::TrackITS track ;
67+
68+ void print () const
69+ {
70+ LOGP (info , "event={} pdg={} pt={} eta={} phi={} mother={} clusters={:7b} isReco={} isFake={} isPrimary={} bcInROF={} rofId={} | {}" , event , pdg , pt , eta , phi , mother , clusters , isReco , isFake , isPrimary , bcInROF , rofId , track .asString ());
71+ }
6372};
6473
6574#pragma link C++ class ParticleInfo + ;
6675
6776void CheckTracksCA (bool doFakeClStud = false,
77+ bool doDRofStud = true,
6878 std ::string tracfile = "o2trac_its.root" ,
6979 std ::string magfile = "o2sim_grp.root" ,
7080 std ::string clusfile = "o2clus_its.root" ,
7181 std ::string kinefile = "o2sim_Kine.root" )
7282{
83+ constexpr int64_t roFrameLengthInBC = 198 ; // for pp=198
84+ constexpr int64_t roFrameBiasInBC = 64 ; // ITS delay accounted for in digitization
7385
7486 using namespace o2 ::itsmft ;
7587 using namespace o2 ::its ;
@@ -94,6 +106,10 @@ void CheckTracksCA(bool doFakeClStud = false,
94106 o2 ::dataformats ::MCEventHeader * mcEvent = nullptr ;
95107 mcTree -> SetBranchAddress ("MCEventHeader." , & mcEvent );
96108
109+ auto* dc = o2 ::steer ::DigitizationContext ::loadFromFile ("collisioncontext.root" );
110+ const auto& irs = dc -> getEventRecords ();
111+ dc -> printCollisionSummary (false, 20 );
112+
97113 // Clusters
98114 TFile ::Open (clusfile .data ());
99115 TTree * clusTree = (TTree * )gFile -> Get ("o2sim" );
@@ -112,6 +128,8 @@ void CheckTracksCA(bool doFakeClStud = false,
112128 // Track MC labels
113129 std ::vector < o2 ::MCCompLabel > * trkLabArr = nullptr ;
114130 recTree -> SetBranchAddress ("ITSTrackMCTruth" , & trkLabArr );
131+ std ::vector < o2 ::itsmft ::ROFRecord > rofRecVec , * rofRecVecP = & rofRecVec ;
132+ recTree -> SetBranchAddress ("ITSTracksROF" , & rofRecVecP );
115133
116134 std ::cout << "** Filling particle table ... " << std ::flush ;
117135 int lastEventIDcl = -1 , cf = 0 ;
@@ -123,6 +141,7 @@ void CheckTracksCA(bool doFakeClStud = false,
123141 mcTree -> GetEvent (n );
124142 info [n ].resize (mcArr -> size ());
125143 hZvertex -> Fill (mcEvent -> GetZ ());
144+ const auto& ir = irs [mcEvent -> GetEventID () - 1 ]; // event id start from 1
126145 for (unsigned int mcI {0 }; mcI < mcArr -> size (); ++ mcI ) {
127146 auto part = mcArr -> at (mcI );
128147 info [n ][mcI ].event = n ;
@@ -134,6 +153,10 @@ void CheckTracksCA(bool doFakeClStud = false,
134153 info [n ][mcI ].phi = part .GetPhi ();
135154 info [n ][mcI ].eta = part .GetEta ();
136155 info [n ][mcI ].isPrimary = part .isPrimary ();
156+ if (!ir .isDummy ()) {
157+ info [n ][mcI ].bcInROF = (ir .toLong () - roFrameBiasInBC ) % roFrameLengthInBC ;
158+ info [n ][mcI ].rofId = (ir .toLong () - roFrameBiasInBC ) / roFrameLengthInBC ;
159+ }
137160 }
138161 }
139162 std ::cout << "done." << std ::endl ;
@@ -168,7 +191,7 @@ void CheckTracksCA(bool doFakeClStud = false,
168191 std ::cout << "done." << std ::endl ;
169192
170193 std ::cout << "** Analysing tracks ... " << std ::flush ;
171- int unaccounted {0 }, good {0 }, fakes {0 }, total {0 };
194+ int unaccounted {0 }, good {0 }, fakes {0 }, total {0 }, length { 0 } ;
172195 for (int frame = 0 ; frame < recTree -> GetEntriesFast (); frame ++ ) { // Cluster frames
173196 if (!recTree -> GetEvent (frame ))
174197 continue ;
@@ -204,6 +227,11 @@ void CheckTracksCA(bool doFakeClStud = false,
204227
205228 fakes += fake ;
206229 good += !fake ;
230+ if (!fake ) {
231+ for (unsigned int bit {0 }; bit < 7 ; ++ bit ) {
232+ length += bool (info [evID ][trackID ].clusters & (1 << bit ));
233+ }
234+ }
207235 }
208236 }
209237 std ::cout << "done." << std ::endl ;
@@ -213,6 +241,7 @@ void CheckTracksCA(bool doFakeClStud = false,
213241 std ::cout << "\t- Total number of tracks not corresponding to particles: " << unaccounted << " (" << unaccounted * 100. / total << "%)" << std ::endl ;
214242 std ::cout << "\t- Total number of fakes: " << fakes << " (" << fakes * 100. / total << "%)" << std ::endl ;
215243 std ::cout << "\t- Total number of good: " << good << " (" << good * 100. / total << "%)" << std ::endl ;
244+ std ::cout << "\t- Average length of good tracks: " << (double )length / (double )good << std ::endl ;
216245
217246 int nb = 100 ;
218247 double xbins [nb + 1 ], ptcutl = 0.01 , ptcuth = 10. ;
@@ -271,13 +300,13 @@ void CheckTracksCA(bool doFakeClStud = false,
271300
272301 TCanvas * c1 = new TCanvas ;
273302 c1 -> SetLogx ();
274- c1 -> SetGridx ();
275- c1 -> SetGridy ( );
303+ c1 -> SetGrid ();
304+ gPad -> DrawFrame ( ptcutl , 0.001 , ptcuth , 1.03 );
276305 TH1 * sum = (TH1 * )num -> Clone ("sum" );
277306 sum -> Add (fak );
278307 sum -> Divide (sum , den , 1 , 1 );
279308 sum -> SetLineColor (kBlack );
280- sum -> Draw ("hist " );
309+ sum -> Draw ("histesame " );
281310 num -> Divide (num , den , 1 , 1 , "b" );
282311 num -> Draw ("histesame" );
283312 fak -> Divide (fak , den , 1 , 1 , "b" );
@@ -410,4 +439,58 @@ void CheckTracksCA(bool doFakeClStud = false,
410439 }
411440 canvas -> SaveAs ("fakeClusters.png" , "recreate" );
412441 }
442+
443+ if (doDRofStud ) {
444+ constexpr float rofBins {roFrameLengthInBC + 2.f };
445+ TH1F * hBC = new TH1F ("hBC" , "Distance in BC;bcInROF;counts." , rofBins , -0.5 , rofBins - 0.5 );
446+ TH1F * hBCTracksDen = new TH1F ("hBCTracksDen;bcInROF;eff." , "BC Den Tracks" , rofBins , -0.5 , rofBins - 0.5 );
447+ TH1F * hBCTracksNum = new TH1F ("hBCTracksNum;bcInROF;eff." , "BC Num Tracks" , rofBins , -0.5 , rofBins - 0.5 );
448+ TH1F * hBCTracksFake = new TH1F ("hBCTracksFake;bcInROF;eff." , "BC Fake Tracks" , rofBins , -0.5 , rofBins - 0.5 );
449+ TH1F * hBCTracksSum = new TH1F ("hBCTracksSum;bcInROF;eff." , "BC Sum Tracks" , rofBins , -0.5 , rofBins - 0.5 );
450+
451+ for (auto & evInfo : info ) {
452+ for (auto & part : evInfo ) {
453+ int nCl {0 };
454+ for (unsigned int bit {0 }; bit < sizeof (pInfo .clusters ) * 8 ; ++ bit ) {
455+ nCl += bool (part .clusters & (1 << bit ));
456+ }
457+ if (nCl < 5 || part .bcInROF < 0 ) {
458+ continue ;
459+ }
460+ hBC -> Fill (part .bcInROF );
461+ hBCTracksDen -> Fill (part .bcInROF );
462+ if (part .isReco ) {
463+ hBCTracksNum -> Fill (part .bcInROF );
464+ }
465+ if (part .isFake ) {
466+ hBCTracksFake -> Fill (part .bcInROF );
467+ }
468+ }
469+ }
470+
471+ hBCTracksSum -> Add (hBCTracksNum );
472+ hBCTracksSum -> Add (hBCTracksFake );
473+ hBCTracksSum -> Divide (hBCTracksSum , hBCTracksDen , 1. , 1. , "b" );
474+ hBCTracksNum -> Divide (hBCTracksNum , hBCTracksDen , 1. , 1. , "b" );
475+ hBCTracksFake -> Divide (hBCTracksFake , hBCTracksDen , 1. , 1. , "b" );
476+
477+ hBCTracksSum -> SetLineColor (kBlack );
478+ hBCTracksFake -> SetLineColor (2 );
479+
480+ auto c = new TCanvas ;
481+ c -> Divide (2 , 1 );
482+ c -> cd (1 );
483+ hBC -> Draw ();
484+ c -> cd (2 );
485+ gPad -> DrawFrame (-0.5 , 1e-3 , rofBins - 0.5 , 1.1 , "Tracking >4 ITS cls;bcInROF;eff." );
486+ gPad -> SetGrid ();
487+ hBCTracksSum -> Draw ("histe;same" );
488+ hBCTracksNum -> Draw ("histe;same" );
489+ hBCTracksFake -> Draw ("histe;same" );
490+ auto leg = new TLegend ;
491+ leg -> AddEntry (hBCTracksSum , "Sum" );
492+ leg -> AddEntry (hBCTracksNum , "Good" );
493+ leg -> AddEntry (hBCTracksFake , "Fake" );
494+ leg -> Draw ();
495+ }
413496}
0 commit comments