3939#include " Framework/HistogramRegistry.h"
4040#include " ITSMFTBase/DPLAlpideParam.h"
4141#include " ITSMFTReconstruction/ChipMappingITS.h"
42+ #include " TableHelper.h"
4243
4344#include < array>
4445#include < cmath>
@@ -74,6 +75,7 @@ struct bcselEntry {
7475// bc selection configurables
7576struct bcselConfigurables : o2::framework::ConfigurableGroup {
7677 std::string prefix = " bcselOpts" ;
78+ o2::framework::Configurable<int > amIneeded{" amIneeded" , -1 , " run BC selection or not. -1: automatic; 0: no; 1: yes" }; // o2-linter: disable=name/configurable (temporary fix)
7779 o2::framework::Configurable<int > confTriggerBcShift{" triggerBcShift" , 0 , " set either custom shift or 999 for apass2/apass3 in LHC22o-t" }; // o2-linter: disable=name/configurable (temporary fix)
7880 o2::framework::Configurable<int > confITSROFrameStartBorderMargin{" ITSROFrameStartBorderMargin" , -1 , " Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1" }; // o2-linter: disable=name/configurable (temporary fix)
7981 o2::framework::Configurable<int > confITSROFrameEndBorderMargin{" ITSROFrameEndBorderMargin" , -1 , " Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1" }; // o2-linter: disable=name/configurable (temporary fix)
@@ -88,6 +90,7 @@ struct bcselConfigurables : o2::framework::ConfigurableGroup {
8890struct evselConfigurables : o2::framework::ConfigurableGroup {
8991 std::string prefix = " evselOpts" ;
9092 bool isMC_metadata = false ;
93+ o2::framework::Configurable<int > amIneeded{" amIneeded" , -1 , " run event selection or not. -1: automatic; 0: no; 1: yes" }; // o2-linter: disable=name/configurable (temporary fix)
9194 o2::framework::Configurable<int > muonSelection{" muonSelection" , 0 , " 0 - barrel, 1 - muon selection with pileup cuts, 2 - muon selection without pileup cuts" };
9295 o2::framework::Configurable<float > maxDiffZvtxFT0vsPV{" maxDiffZvtxFT0vsPV" , 1 ., " maximum difference (in cm) between z-vertex from FT0 and PV" };
9396 o2::framework::Configurable<int > isMC{" isMC" , -1 , " -1 - autoset, 0 - data, 1 - MC" };
@@ -105,6 +108,12 @@ struct evselConfigurables : o2::framework::ConfigurableGroup {
105108 o2::framework::Configurable<int > confNumberOfOrbitsPerTF{" NumberOfOrbitsPerTF" , -1 , " Number of orbits per Time Frame. Take from CCDB if -1" }; // o2-linter: disable=name/configurable (temporary fix)
106109};
107110
111+ // luminosity configurables
112+ struct lumiConfigurables : o2::framework::ConfigurableGroup {
113+ std::string prefix = " lumiOpts" ;
114+ o2::framework::Configurable<int > amIneeded{" amIneeded" , -1 , " run BC selection or not. -1: automatic; 0: no; 1: yes" }; // o2-linter: disable=name/configurable (temporary fix)
115+ };
116+
108117class BcSelectionModule
109118{
110119 public:
@@ -139,12 +148,31 @@ class BcSelectionModule
139148 bool isGoodITSLayer0123 = true ; // default value
140149 bool isGoodITSLayersAll = true ; // default value
141150
142- template <typename TBcSelOpts, typename THistoRegistry>
143- void init (TBcSelOpts const & external_bcselopts, THistoRegistry& histos)
151+ template <typename TContext, typename TBcSelOpts, typename THistoRegistry>
152+ void init (TContext& context, TBcSelOpts const & external_bcselopts, THistoRegistry& histos)
144153 {
145154 // read in configurations from the task where it's used
146155 bcselOpts = external_bcselopts;
147156
157+ if (bcselOpts.amIneeded .value <0 ){
158+ int bcSelNeeded = -1 , evSelNeeded = -1 ;
159+ bcselOpts.amIneeded .value = 0 ;
160+ enableFlagIfTableRequired (context, " BcSels" , bcSelNeeded);
161+ enableFlagIfTableRequired (context, " EvSels" , evSelNeeded);
162+ if (bcSelNeeded==1 ){
163+ bcselOpts.amIneeded .value = 1 ;
164+ LOGF (info, " BC Selection / Autodetection for aod::BcSels: subscription present, will generate." );
165+ }
166+ if (evSelNeeded==1 && bcSelNeeded==0 ){
167+ bcselOpts.amIneeded .value = 1 ;
168+ LOGF (info, " BC Selection / Autodetection for aod::BcSels: not there, but EvSel needed. Will generate." );
169+ }
170+ if (bcSelNeeded == 0 && evSelNeeded == 0 ){
171+ LOGF (info, " BC Selection / Autodetection for aod::BcSels: not required. Skipping generation." );
172+ return ;
173+ }
174+ }
175+
148176 // add counter
149177 histos.add (" bcselection/hCounterInvalidBCTimestamp" , " " , o2::framework::kTH1D , {{1 , 0 ., 1 .}});
150178 }
@@ -237,8 +265,12 @@ class BcSelectionModule
237265
238266 // __________________________________________________
239267 template <typename TCCDB, typename TBCs, typename TBcSelBuffer, typename TBcSelCursor>
240- std::vector<o2::common::eventselection::bcselEntry> processRun2 (TCCDB const & ccdb, TBCs const & bcs, TBcSelBuffer& bcselbuffer, TBcSelCursor& bcsel)
268+ void processRun2 (TCCDB const & ccdb, TBCs const & bcs, TBcSelBuffer& bcselbuffer, TBcSelCursor& bcsel)
241269 {
270+ if (bcselOpts.amIneeded .value == 0 ){
271+ bcselbuffer.clear ();
272+ return ;
273+ }
242274 bcselbuffer.clear ();
243275 for (const auto & bc : bcs) {
244276 par = ccdb->template getForTimeStamp <EventSelectionParams>(" EventSelection/EventSelectionParams" , bc.timestamp ());
@@ -372,6 +404,10 @@ class BcSelectionModule
372404 template <typename TCCDB, typename THistoRegistry, typename TBCs, typename TBcSelBuffer, typename TBcSelCursor>
373405 void processRun3 (TCCDB const & ccdb, THistoRegistry& histos, TBCs const & bcs, TBcSelBuffer& bcselbuffer, TBcSelCursor& bcsel)
374406 {
407+ if (bcselOpts.amIneeded .value == 0 ){
408+ bcselbuffer.clear ();
409+ return ;
410+ }
375411 bcselbuffer.clear ();
376412 if (!configure (ccdb, bcs))
377413 return ; // don't do anything in case configuration reported not ok
@@ -623,12 +659,22 @@ class EventSelectionModule
623659 // (N.B.: will be invisible to the outside, create your own copies)
624660 o2::common::eventselection::evselConfigurables evselOpts;
625661
626- template <typename TEvSelOpts, typename THistoRegistry, typename TMetadataInfo>
627- void init (TEvSelOpts const & external_evselopts, THistoRegistry& histos, TMetadataInfo const & metadataInfo)
662+ template <typename TContext, typename TEvSelOpts, typename THistoRegistry, typename TMetadataInfo>
663+ void init (TContext& context, TEvSelOpts const & external_evselopts, THistoRegistry& histos, TMetadataInfo const & metadataInfo)
628664 {
629665 // read in configurations from the task where it's used
630666 evselOpts = external_evselopts;
631667
668+ if (evselOpts.amIneeded .value <0 ){
669+ enableFlagIfTableRequired (context, " EvSels" , evselOpts.amIneeded .value );
670+ if (evselOpts.amIneeded .value ==0 ){
671+ LOGF (info, " Event Selection / Autodetecting for aod::EvSels: not required, won't generate." );
672+ return ;
673+ }else {
674+ LOGF (info, " Event Selection / Autodetecting for aod::EvSels: subscription present, will generate." );
675+ }
676+ }
677+
632678 if (metadataInfo.isFullyDefined ()) { // Check if the metadata is initialized (only if not forced from the workflow configuration)
633679 if (evselOpts.isMC == -1 ) {
634680 LOGF (info, " Autosetting the MC mode based on metadata (isMC? %i)" , metadataInfo.isMC ());
@@ -678,6 +724,9 @@ class EventSelectionModule
678724 template <typename TCCDB, typename THistoRegistry, typename TCollisions, typename TTracklets, typename TSlicecache, typename TBcSelBuffer, typename TEvselCursor>
679725 void processRun2 (TCCDB const & ccdb, THistoRegistry& histos, TCollisions const & collisions, TTracklets const & tracklets, TSlicecache& cache, TBcSelBuffer const & bcselbuffer, TEvselCursor& evsel)
680726 {
727+ if (evselOpts.amIneeded .value == 0 ){
728+ return ; // dummy process
729+ }
681730 for (const auto & col : collisions) {
682731 auto bc = col.template bc_as <soa::Join<aod::BCs, aod::Run2BCInfos, aod::Timestamps, aod::Run2MatchedToBCSparse>>();
683732 EventSelectionParams* par = ccdb->template getForTimeStamp <EventSelectionParams>(" EventSelection/EventSelectionParams" , bc.timestamp ());
@@ -756,6 +805,9 @@ class EventSelectionModule
756805 template <typename TCCDB, typename THistoRegistry, typename TBCs, typename TCollisions, typename TPVTracks, typename TFT0s, typename TSlicecache, typename TBcSelBuffer, typename TEvselCursor>
757806 void processRun3 (TCCDB const & ccdb, THistoRegistry& histos, TBCs const & bcs, TCollisions const & cols, TPVTracks const & pvTracks, TFT0s const & ft0s, TSlicecache& cache, TBcSelBuffer const & bcselbuffer, TEvselCursor& evsel)
758807 {
808+ if (evselOpts.amIneeded .value == 0 ){
809+ return ; // dummy process
810+ }
759811 if (!configure (ccdb, bcs))
760812 return ; // don't do anything in case configuration reported not ok
761813
@@ -1243,9 +1295,34 @@ class LumiModule
12431295 std::bitset<nBCsPerOrbit> bcPatternB; // bc pattern of colliding bunches
12441296 std::vector<o2::aod::rctsel::RCTFlagsChecker> mRCTFlagsCheckers ;
12451297
1246- template <typename THistoRegistry>
1247- void init (THistoRegistry& histos)
1298+ // declaration of structs here
1299+ // (N.B.: will be invisible to the outside, create your own copies)
1300+ o2::common::eventselection::lumiConfigurables lumiOpts;
1301+
1302+ template <typename TContext, typename TLumiOpts, typename THistoRegistry>
1303+ void init (TContext& context, TLumiOpts const & external_lumiopts, THistoRegistry& histos)
12481304 {
1305+ lumiOpts = external_lumiopts;
1306+
1307+ if (lumiOpts.amIneeded .value <0 ){
1308+ int bcSelNeeded = -1 , evSelNeeded = -1 ;
1309+ lumiOpts.amIneeded .value = 0 ;
1310+ enableFlagIfTableRequired (context, " BcSels" , bcSelNeeded);
1311+ enableFlagIfTableRequired (context, " EvSels" , evSelNeeded);
1312+ if (bcSelNeeded==1 ){
1313+ lumiOpts.amIneeded .value = 1 ;
1314+ LOGF (info, " Luminosity / Autodetection for aod::BcSels: subscription present, will generate." );
1315+ }
1316+ if (evSelNeeded==1 && bcSelNeeded==0 ){
1317+ lumiOpts.amIneeded .value = 1 ;
1318+ LOGF (info, " Luminosity / Autodetection for aod::BcSels: not there, but EvSel needed. Will generate." );
1319+ }
1320+ if (bcSelNeeded == 0 && evSelNeeded == 0 ){
1321+ LOGF (info, " Luminosity / Autodetection for aod::BcSels: not required. Skipping generation." );
1322+ return ;
1323+ }
1324+ }
1325+
12491326 histos.add (" luminosity/hCounterTVX" , " " , framework::kTH1D , {{1 , 0 ., 1 .}});
12501327 histos.add (" luminosity/hCounterTCE" , " " , framework::kTH1D , {{1 , 0 ., 1 .}});
12511328 histos.add (" luminosity/hCounterZEM" , " " , framework::kTH1D , {{1 , 0 ., 1 .}});
@@ -1437,6 +1514,10 @@ class LumiModule
14371514 template <typename TCCDB, typename THistoRegistry, typename TBCs, typename TBcSelBuffer>
14381515 void process (TCCDB& ccdb, THistoRegistry& histos, TBCs const & bcs, TBcSelBuffer const & bcselBuffer)
14391516 {
1517+ if (lumiOpts.amIneeded .value == 0 ){
1518+ return ;
1519+ }
1520+
14401521 if (!configure (ccdb, bcs))
14411522 return ; // don't do anything in case configuration reported not ok
14421523
0 commit comments