1010// or submit itself to any jurisdiction.
1111
1212#include " ITSStudies/ITSBeamBackgroundStudy.h"
13+ #include " ITSStudies/ITSStudiesConfigParam.h"
1314#include " DataFormatsGlobalTracking/RecoContainer.h"
1415#include " DetectorsBase/GRPGeomHelper.h"
1516#include " DataFormatsParameters/GRPObject.h"
2627#include < algorithm>
2728#include < limits>
2829#include < cmath>
30+ #include < cstdint>
2931
3032#include < TTree.h>
3133#include < TH2.h>
@@ -95,8 +97,9 @@ class ITSBeamBackgroundStudy : public Task
9597 int targetClusterMinCol = 128 ; // definition of anomalous cluster
9698 int targetClusterMaxRow = 29 ; // definition of anomalous cluster
9799
98- int mDumpEveryTF = 5 ; // use -1 to save only at the end
99- int mSkimmedOnlyAfterTF = 150 ;
100+ int mDumpEveryTF = ITSBeamBackgroundStudyParamConfig::Instance().dumpEveryTF;
101+ int mSkimmedOnlyAfterTF = ITSBeamBackgroundStudyParamConfig::Instance().skimmedOnlyAfterTF;
102+ bool mSaveClusterParameters = ITSBeamBackgroundStudyParamConfig::Instance().saveClusterParameters;
100103 std::string mOutputChip = " chipevents" ;
101104 std::string mOutoutChipSkim = " chipeventstarget" ;
102105
@@ -131,8 +134,10 @@ class ITSBeamBackgroundStudy : public Task
131134void ITSBeamBackgroundStudy::updateTimeDependentParams (ProcessingContext& pc)
132135{
133136 o2::base::GRPGeomHelper::instance ().checkUpdates (pc);
134- mGeom = o2::its::GeometryTGeo::Instance ();
135- mGeom ->fillMatrixCache (o2::math_utils::bit2Mask (o2::math_utils::TransformType::L2G ));
137+ if (mSaveClusterParameters ) {
138+ mGeom = o2::its::GeometryTGeo::Instance ();
139+ mGeom ->fillMatrixCache (o2::math_utils::bit2Mask (o2::math_utils::TransformType::L2G ));
140+ }
136141}
137142
138143void ITSBeamBackgroundStudy::init (InitContext& ic)
@@ -151,6 +156,7 @@ void ITSBeamBackgroundStudy::init(InitContext& ic)
151156void ITSBeamBackgroundStudy::prepareOutput ()
152157{
153158 LOGP (info, " Setting up trees and histograms. They will be dumped on file every {} TFs" , mDumpEveryTF );
159+ LOGP (info, " Skimmed-only output after TF {}; saving cluster parameters: {}" , mSkimmedOnlyAfterTF , mSaveClusterParameters );
154160
155161 TimeWindowCut = new TH1F (" ZDC bkg region" , " ZNAr, ZNCr, -ZNAl, -ZNCl" , 8 , 0 , 8 );
156162 TimeWindowCut->SetBinContent (1 , TimeWindowZNAr.first );
@@ -186,12 +192,14 @@ void ITSBeamBackgroundStudy::prepareOutput()
186192 ITSChipEvtTree->Branch (" bc" , &Tbc, " bc/I" );
187193 ITSChipEvtTree->Branch (" chip" , &Tchip, " chip/I" );
188194 ITSChipEvtTree->Branch (" phi" , &Tphi, " phi/D" );
189- ITSChipEvtTree->Branch (" cluster_phi" , &TclusterPhi);
190- ITSChipEvtTree->Branch (" cluster_r" , &TclusterR);
191- ITSChipEvtTree->Branch (" cluster_z" , &TclusterZ);
192- ITSChipEvtTree->Branch (" cluster_size" , &TclusterSize);
193- ITSChipEvtTree->Branch (" cluster_colspan" , &TclusterColSpan);
194- ITSChipEvtTree->Branch (" cluster_rowspan" , &TclusterRowSpan);
195+ if (mSaveClusterParameters ) {
196+ ITSChipEvtTree->Branch (" cluster_phi" , &TclusterPhi);
197+ ITSChipEvtTree->Branch (" cluster_r" , &TclusterR);
198+ ITSChipEvtTree->Branch (" cluster_z" , &TclusterZ);
199+ ITSChipEvtTree->Branch (" cluster_size" , &TclusterSize);
200+ ITSChipEvtTree->Branch (" cluster_colspan" , &TclusterColSpan);
201+ ITSChipEvtTree->Branch (" cluster_rowspan" , &TclusterRowSpan);
202+ }
195203 ITSChipEvtTree->Branch (" zdctag" , &TZDCtag, " zdctag/I" );
196204 ITSChipEvtTree->Branch (" nhit" , &Tnhit, " nhit/I" );
197205 ITSChipEvtTree->Branch (" nhit_no1pix" , &Tnhit_no1pix, " nhit_no1pix/I" );
@@ -560,23 +568,24 @@ void ITSBeamBackgroundStudy::process(o2::globaltracking::RecoContainer& recoData
560568 if (newchip) {
561569 MAPsize[chipid] = std::vector<int >{};
562570 MAPcols[chipid] = std::vector<int >{};
563- MAProws[chipid] = std::vector<int >{};
564571 MAPntarget[chipid] = 0 ;
565572 MAPcoo_mincol[chipid] = coo_col;
566573 MAPcoo_maxcol[chipid] = coo_col + colspan;
567574 }
568575
569576 MAPsize[chipid].push_back (npix);
570577 MAPcols[chipid].push_back (colspan);
571- MAProws[chipid].push_back (rowspan);
572- // Grouped topologies store a rounded COG in the compact cluster; invalid
573- // pattern IDs store the bounding-box corner instead.
574- const auto pattID = compClus.getPatternID ();
575- auto local = pattID == o2::itsmft::CompCluster::InvalidPatternID
576- ? mDict ->getClusterCoordinates <float >(compClus, patti, false )
577- : (mDict ->isGroup (pattID) ? mDict ->getClusterCoordinates <float >(compClus, patti)
578- : mDict ->getClusterCoordinates <float >(compClus));
579- MAPcoordinates[chipid].push_back (mGeom ->getMatrixL2G (chipid)(local));
578+ if (mSaveClusterParameters ) {
579+ MAProws[chipid].push_back (rowspan);
580+ // Grouped topologies store a rounded COG in the compact cluster; invalid
581+ // pattern IDs store the bounding-box corner instead.
582+ const auto pattID = compClus.getPatternID ();
583+ auto local = pattID == o2::itsmft::CompCluster::InvalidPatternID
584+ ? mDict ->getClusterCoordinates <float >(compClus, patti, false )
585+ : (mDict ->isGroup (pattID) ? mDict ->getClusterCoordinates <float >(compClus, patti)
586+ : mDict ->getClusterCoordinates <float >(compClus));
587+ MAPcoordinates[chipid].push_back (mGeom ->getMatrixL2G (chipid)(local));
588+ }
580589 if (colspan >= targetClusterMinCol && rowspan <= targetClusterMaxRow) {
581590 // Anomalous cluster found
582591 MAPntarget[chipid] += 1 ;
@@ -587,7 +596,7 @@ void ITSBeamBackgroundStudy::process(o2::globaltracking::RecoContainer& recoData
587596
588597 } // end of loop over clusters in rof
589598
590- if (ntarget_in_rof == 0 && mTFn > mSkimmedOnlyAfterTF + 2 ) { // extra 2 to avoid edge effects?
599+ if (ntarget_in_rof == 0 && static_cast < int64_t >( mTFn ) > static_cast < int64_t >( mSkimmedOnlyAfterTF ) + 2 ) { // extra 2 to avoid edge effects?
591600 // do not need extra computations for this rof since it will not be saved in any case
592601 continue ;
593602 }
@@ -615,16 +624,18 @@ void ITSBeamBackgroundStudy::process(o2::globaltracking::RecoContainer& recoData
615624 Tphi = ChipToPhi (ic);
616625
617626 Tnclus = MAPsize[ic].size ();
618- TclusterSize = MAPsize[ic]; // Save before sorting the sizes for the summaries.
619- TclusterColSpan = MAPcols[ic];
620- TclusterRowSpan = MAProws[ic];
621- TclusterPhi.clear ();
622- TclusterR.clear ();
623- TclusterZ.clear ();
624- for (const auto & global : MAPcoordinates[ic]) {
625- TclusterPhi.push_back (std::atan2 (global.Y (), global.X ()));
626- TclusterR.push_back (std::hypot (global.X (), global.Y ()));
627- TclusterZ.push_back (global.Z ());
627+ if (mSaveClusterParameters ) {
628+ TclusterSize = MAPsize[ic]; // Save before sorting the sizes for the summaries.
629+ TclusterColSpan = MAPcols[ic];
630+ TclusterRowSpan = MAProws[ic];
631+ TclusterPhi.clear ();
632+ TclusterR.clear ();
633+ TclusterZ.clear ();
634+ for (const auto & global : MAPcoordinates[ic]) {
635+ TclusterPhi.push_back (std::atan2 (global.Y (), global.X ()));
636+ TclusterR.push_back (std::hypot (global.X (), global.Y ()));
637+ TclusterZ.push_back (global.Z ());
638+ }
628639 }
629640 Tmincol = MAPcoo_mincol[ic];
630641 Tmaxcol = MAPcoo_maxcol[ic];
@@ -741,12 +752,15 @@ DataProcessorSpec getITSBeamBackgroundStudy(mask_t srcTracksMask, mask_t srcClus
741752
742753 dataRequest->requestTracks (srcTracksMask, useMC);
743754
744- auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false , // orbitResetTime
745- true , // GRPECS=true
746- false , // GRPLHCIF
747- false , // GRPMagField
748- false , // askMatLUT
749- o2::base::GRPGeomRequest::Aligned, // geometry
755+ const auto geometry = ITSBeamBackgroundStudyParamConfig::Instance ().saveClusterParameters
756+ ? o2::base::GRPGeomRequest::Aligned
757+ : o2::base::GRPGeomRequest::None;
758+ auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false , // orbitResetTime
759+ true , // GRPECS=true
760+ false , // GRPLHCIF
761+ false , // GRPMagField
762+ false , // askMatLUT
763+ geometry,
750764 dataRequest->inputs ,
751765 true );
752766 return DataProcessorSpec{
0 commit comments