5454
5555namespace fs = std ::filesystem ;
5656
57- constexpr auto mMatCorr {o2 ::base ::Propagator ::MatCorrType ::USEMatCorrNONE };
57+ constexpr auto mMatCorr {o2 ::base ::Propagator ::MatCorrType ::USEMatCorrTGeo };
5858constexpr float mMaxStep {2 };
5959
6060constexpr float rapMax {0.9 };
@@ -79,6 +79,7 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
7979 const std ::string & tpcTracksFileName = "tpctracks.root" ,
8080 const std ::string & itsTracksFileName = "o2trac_its.root" ,
8181 const std ::string & itstpcTracksFileName = "o2match_itstpc.root" ,
82+ const std ::string & geomFileName = "o2sim_geometry.root" ,
8283 const std ::string & magFileName = "o2sim_grp.root" )
8384{
8485 gROOT -> SetBatch ();
@@ -88,28 +89,12 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
8889 gStyle -> SetPadTickX (1 );
8990 gStyle -> SetPadTickY (1 );
9091 gErrorIgnoreLevel = 2001 ; // suppress warnings
91- ProcInfo_t procInfo ;
9292
9393 const int nPtBins = 35 ;
9494 const int nPtBinsEff = 39 ;
9595 double ptLimits [nPtBins ] = {0.05 , 0.1 , 0.15 , 0.2 , 0.25 , 0.3 , 0.35 , 0.4 , 0.45 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 , 1. , 1.1 , 1.2 , 1.3 , 1.4 , 1.5 , 1.6 , 1.7 , 1.8 , 1.9 , 2. , 2.2 , 2.5 , 3. , 4. , 5. , 6. , 8. , 10. , 15. , 20. };
9696 double ptLimitsEff [nPtBinsEff ] = {0.05 , 0.06 , 0.07 , 0.08 , 0.09 , 0.1 , 0.15 , 0.2 , 0.25 , 0.3 , 0.35 , 0.4 , 0.45 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 , 1. , 1.1 , 1.2 , 1.3 , 1.4 , 1.5 , 1.6 , 1.7 , 1.8 , 1.9 , 2. , 2.2 , 2.5 , 3. , 4. , 5. , 6. , 8. , 10. , 15. , 20. };
9797
98- const std ::regex tf_pattern (R "(tf\d+)" );
99- auto tf_matcher = [& tf_pattern ](fs ::path const & p ) -> bool {
100- return std ::regex_search (p .string (), tf_pattern );
101- };
102- auto tf_sorter = [& tf_pattern ](fs ::path const & a , fs ::path const & b ) -> bool {
103- const auto & as = a .string (), & bs = b .string ();
104- std ::smatch am , bm ;
105- if (std ::regex_search (as , am , tf_pattern ) && std ::regex_search (bs , bm , tf_pattern )) {
106- return std ::stoi (am .str ().substr (2 )) < std ::stoi (bm .str ().substr (2 ));
107- } else {
108- LOGP (fatal , "TF Regex matching failed" );
109- return false;
110- }
111- };
112-
11398 const int nSpecies = 4 ;
11499 std ::array < int , nSpecies > pdgCodes {11 , 211 , 321 , 2212 };
115100 auto fGaus = new TF1 ("fGaus" , "gaus" , -200. , 200. );
@@ -119,6 +104,7 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
119104 {321 , "Kaons" },
120105 {2212 , "Protons" }};
121106 std ::map < int , int > colors {{11 , kOrange + 7 }, {211 , kRed + 1 }, {321 , kAzure + 4 }, {2212 , kGreen + 2 }};
107+
122108 /// ITS
123109 std ::map < int , TH1F * > hDcaxyResAllLayersITS = {
124110 {11 , new TH1F ("hDcaxyResElectronsAllLayersITS" , "ITS;#it{p}_{T} (GeV/#it{c});#sigma(DCA_{#it{xy}}) (#mum)" , nPtBins - 1 , ptLimits )},
@@ -287,6 +273,21 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
287273 o2 ::dataformats ::VertexBase collision ;
288274 o2 ::dataformats ::DCA impactParameter ;
289275
276+ const std ::regex tf_pattern (R "(tf\d+)" );
277+ auto tf_matcher = [& tf_pattern ](fs ::path const & p ) -> bool {
278+ return std ::regex_search (p .string (), tf_pattern );
279+ };
280+ auto tf_sorter = [& tf_pattern ](fs ::path const & a , fs ::path const & b ) -> bool {
281+ const auto & as = a .string (), & bs = b .string ();
282+ std ::smatch am , bm ;
283+ if (std ::regex_search (as , am , tf_pattern ) && std ::regex_search (bs , bm , tf_pattern )) {
284+ return std ::stoi (am .str ().substr (2 )) < std ::stoi (bm .str ().substr (2 ));
285+ } else {
286+ LOGP (fatal , "TF Regex matching failed" );
287+ return false;
288+ }
289+ };
290+
290291 const auto origWD {fs ::current_path ()};
291292 const auto tfDirs = find_dirs (fs ::current_path (), tf_matcher , tf_sorter );
292293 for (const auto& tfDir : tfDirs ) {
@@ -305,16 +306,17 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
305306 static bool initOnce {false};
306307 if (!initOnce ) {
307308 initOnce = true;
309+ o2 ::base ::GeometryManager ::loadGeometry (geomFileName );
308310 o2 ::base ::Propagator ::initFieldFromGRP (magFileName );
309311 bz = o2 ::base ::Propagator ::Instance ()-> getNominalBz ();
310312 }
311313
312314 LOGP (info , "Loading ITS Tracks" );
313- auto fITSTracks = TFile ::Open (itsTracksFileName .c_str (), "READ" );
315+ std :: unique_ptr < TFile > fITSTracks ( TFile ::Open (itsTracksFileName .c_str (), "READ" ) );
314316 auto tITSTracks = fITSTracks -> Get < TTree > ("o2sim" );
315- std ::vector < o2 ::its ::TrackITS > * itsTracks {nullptr} ;
317+ auto itsTracks = new std ::vector < o2 ::its ::TrackITS > () ;
316318 tITSTracks -> SetBranchAddress ("ITSTrack" , & itsTracks );
317- std ::vector < o2 ::MCCompLabel > * itsTrkLab {nullptr} ;
319+ auto itsTrkLab = new std ::vector < o2 ::MCCompLabel > ( ) ;
318320 tITSTracks -> SetBranchAddress ("ITSTrackMCTruth" , & itsTrkLab );
319321
320322 for (Long64_t iEntry {0 }; tITSTracks -> LoadTree (iEntry ) >= 0 ; ++ iEntry ) {
@@ -367,18 +369,19 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
367369 }
368370
369371 LOGP (info , "Loading ITS-TPC Tracks" );
370- auto fITSTPCTracks = TFile ::Open (itstpcTracksFileName .c_str (), "READ ");
372+ std :: unique_ptr < TFile > fITSTPCTracks ( TFile ::Open (itstpcTracksFileName .c_str (), "READ" ) );
371373 auto tITSTPCTracks = fITSTPCTracks -> Get < TTree > ("matchTPCITS" );
372- std ::vector < o2 ::dataformats ::TrackTPCITS > * itstpcTracks { nullptr } ;
374+ auto itstpcTracks = new std ::vector < o2 ::dataformats ::TrackTPCITS > ( ) ;
373375 tITSTPCTracks -> SetBranchAddress ("TPCITS" , & itstpcTracks );
374- std ::vector < o2 ::MCCompLabel > * itstpcTrkLab { nullptr } ;
376+ auto itstpcTrkLab = new std ::vector < o2 ::MCCompLabel > ( ) ;
375377 tITSTPCTracks -> SetBranchAddress ("MatchMCTruth" , & itstpcTrkLab );
378+
376379 // TPC Tracks
377- auto fTPCTracks = TFile ::Open (tpcTracksFileName .c_str (), "READ ");
380+ std :: unique_ptr < TFile > fTPCTracks ( TFile ::Open (tpcTracksFileName .c_str (), "READ" ) );
378381 auto tTPCTracks = fTPCTracks -> Get < TTree > ("tpcrec" );
379- std ::vector < o2 ::tpc ::TrackTPC > * tpcTracks { nullptr } ;
382+ auto tpcTracks = new std ::vector < o2 ::tpc ::TrackTPC > ( ) ;
380383 tTPCTracks -> SetBranchAddress ("TPCTracks" , & tpcTracks );
381- std ::vector < o2 ::MCCompLabel > * tpcTrkLab { nullptr } ;
384+ auto tpcTrkLab = new std ::vector < o2 ::MCCompLabel > ( ) ;
382385 tTPCTracks -> SetBranchAddress ("TPCTracksMCTruth" , & tpcTrkLab );
383386 for (Long64_t iEntry {0 }; tITSTPCTracks -> LoadTree (iEntry ) >= 0 ; ++ iEntry ) {
384387 tITSTPCTracks -> GetEntry (iEntry );
@@ -436,26 +439,10 @@ void CheckDCA(const std::string& collisioncontextFileName = "collisioncontext.ro
436439 }
437440 }
438441 }
439-
440- delete itsTracks ;
441- delete itsTrkLab ;
442- delete tpcTracks ;
443- delete tpcTrkLab ;
444- delete itstpcTracks ;
445- delete itstpcTrkLab ;
446- delete tITSTracks ;
447- delete tTPCTracks ;
448- delete tITSTPCTracks ;
449- delete fITSTracks ;
450- delete fTPCTracks ;
451- delete fITSTPCTracks ;
452-
453- gSystem -> GetProcInfo (& procInfo );
454- LOGF (info , "MemVirtual (%ld), MemResident (%ld)" , procInfo .fMemVirtual , procInfo .fMemResident );
455- LOGP (info , "Done with {:?}" , tfDir .c_str ());
456- if (procInfo .fMemResident > 200'000'000 ) {
457- LOGP (error , "Exceeding 200GBs stopping!" );
458- break ;
442+ for (size_t src {0 }; src < mcReader .getNSources (); ++ src ) {
443+ for (size_t eve {0 }; eve < mcReader .getNEvents (src ); ++ eve ) {
444+ mcReader .releaseTracksForSourceAndEvent (src , eve );
445+ }
459446 }
460447 }
461448 LOGP (info , "Restoring original CWD to {:?}" , origWD .c_str ());
0 commit comments