@@ -52,7 +52,8 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc)
5252 int dumRep = 0 ;
5353 o2::ctp::LumiInfo lumiObj;
5454 static o2::ctp::LumiInfo lumiPrev;
55- if (getLumiScaleType () == 1 && mInstLumiOverride <= 0 .) {
55+
56+ if (getLumiCTPAvailable () && mInstCTPLumiOverride <= 0 .) {
5657 if (pc.inputs ().get <gsl::span<char >>(" CTPLumi" ).size () == sizeof (o2::ctp::LumiInfo)) {
5758 lumiPrev = lumiObj = pc.inputs ().get <o2::ctp::LumiInfo>(" CTPLumi" );
5859 } else {
@@ -61,10 +62,14 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc)
6162 }
6263 lumiObj = lumiPrev;
6364 }
64- setInstLumi (mInstLumiFactor * (mCTPLumiSource == 0 ? lumiObj.getLumi () : lumiObj.getLumiAlt ()));
65- } else if (getLumiScaleType () == 2 && mInstLumiOverride <= 0 .) {
65+ setInstLumiCTP (mInstLumiCTPFactor * (mLumiCTPSource == 0 ? lumiObj.getLumi () : lumiObj.getLumiAlt ()));
66+ if (getLumiScaleType () == 1 ) {
67+ setInstLumi (getInstLumiCTP ());
68+ }
69+ }
70+ if (getLumiScaleType () == 2 ) {
6671 float tpcScaler = pc.inputs ().get <float >(" tpcscaler" );
67- setInstLumi (mInstLumiFactor * tpcScaler);
72+ setInstLumi (tpcScaler);
6873 }
6974 if (getUseMShapeCorrection ()) {
7075 LOGP (info, " Setting M-Shape map" );
@@ -80,6 +85,7 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc)
8085 if (!mScaleInverse ) {
8186 updateInverse ();
8287 }
88+ reportScaling ();
8389}
8490
8591// ________________________________________________________
@@ -99,9 +105,11 @@ void CorrectionMapsLoader::requestCCDBInputs(std::vector<InputSpec>& inputs, std
99105 LOG (fatal) << " Correction mode unknown! Choose either 0 (default) or 1 (derivative map) for flag corrmap-lumi-mode." ;
100106 }
101107
102- if (gloOpts.lumiType == 1 ) {
108+ if (gloOpts.requestCTPLumi ) {
103109 addInput (inputs, {" CTPLumi" , " CTP" , " LUMI" , 0 , Lifetime::Timeframe});
104- } else if (gloOpts.lumiType == 2 ) {
110+ }
111+
112+ if (gloOpts.lumiType == 2 ) {
105113 addInput (inputs, {" tpcscaler" , o2::header::gDataOriginTPC , " TPCSCALER" , 0 , Lifetime::Timeframe});
106114 }
107115
@@ -126,9 +134,10 @@ void CorrectionMapsLoader::addOptions(std::vector<ConfigParamSpec>& options)
126134void CorrectionMapsLoader::addGlobalOptions (std::vector<ConfigParamSpec>& options)
127135{
128136 // these are options which should be added at the workflow level, since they modify the inputs of the devices
129- addOption (options, ConfigParamSpec{" lumi-type" , o2::framework::VariantType::Int, 0 , {" 1 = require CTP lumi for TPC correction scaling, 2 = require TPC scalers for TPC correction scaling" }});
137+ addOption (options, ConfigParamSpec{" lumi-type" , o2::framework::VariantType::Int, 0 , {" 1 = use CTP lumi for TPC correction scaling, 2 = use TPC scalers for TPC correction scaling" }});
130138 addOption (options, ConfigParamSpec{" corrmap-lumi-mode" , o2::framework::VariantType::Int, 0 , {" scaling mode: (default) 0 = static + scale * full; 1 = full + scale * derivative; 2 = full + scale * derivative (for MC)" }});
131139 addOption (options, ConfigParamSpec{" enable-M-shape-correction" , o2::framework::VariantType::Bool, false , {" Enable M-shape distortion correction" }});
140+ addOption (options, ConfigParamSpec{" disable-ctp-lumi-request" , o2::framework::VariantType::Bool, false , {" do not request CTP lumi (regardless what is used for corrections)" }});
132141}
133142
134143// ________________________________________________________
@@ -138,6 +147,10 @@ CorrectionMapsLoaderGloOpts CorrectionMapsLoader::parseGlobalOptions(const o2::f
138147 tpcopt.lumiType = opts.get <int >(" lumi-type" );
139148 tpcopt.lumiMode = opts.get <int >(" corrmap-lumi-mode" );
140149 tpcopt.enableMShapeCorrection = opts.get <bool >(" enable-M-shape-correction" );
150+ tpcopt.requestCTPLumi = !opts.get <bool >(" disable-ctp-lumi-request" );
151+ if (!tpcopt.requestCTPLumi && tpcopt.lumiType == 1 ) {
152+ LOGP (fatal, " Scaling with CTP Lumi is requested but this input is disabled" );
153+ }
141154 return tpcopt;
142155}
143156
@@ -164,7 +177,7 @@ bool CorrectionMapsLoader::accountCCDBInputs(const ConcreteDataMatcher& matcher,
164177 setCorrMap ((o2::gpu::TPCFastTransform*)obj);
165178 mCorrMap ->rectifyAfterReadingFromFile ();
166179 if (getMeanLumiOverride () == 0 && mCorrMap ->getLumi () > 0 .) {
167- setMeanLumi (mCorrMap ->getLumi ());
180+ setMeanLumi (mCorrMap ->getLumi (), false );
168181 }
169182 LOGP (debug, " MeanLumiOverride={} MeanLumiMap={} -> meanLumi = {}" , getMeanLumiOverride (), mCorrMap ->getLumi (), getMeanLumi ());
170183 setUpdatedMap ();
@@ -182,29 +195,34 @@ bool CorrectionMapsLoader::accountCCDBInputs(const ConcreteDataMatcher& matcher,
182195 }
183196 if (matcher == ConcreteDataMatcher (" TPC" , " CorrMapParam" , 0 )) {
184197 const auto & par = o2::tpc::CorrMapParam::Instance ();
185- mMeanLumiOverride = par.lumiMean ;
198+ mMeanLumiOverride = par.lumiMean ; // negative value switches off corrections !!!
186199 mMeanLumiRefOverride = par.lumiMeanRef ;
187- mInstLumiOverride = par.lumiInst ;
188- mInstLumiFactor = par.lumiInstFactor ;
189- mCTPLumiSource = par.ctpLumiSource ;
200+ mInstCTPLumiOverride = par.lumiInst ;
201+ mInstLumiCTPFactor = par.lumiInstFactor ;
202+ mLumiCTPSource = par.ctpLumiSource ;
190203
191204 if (mMeanLumiOverride != 0 .) {
192205 setMeanLumi (mMeanLumiOverride , false );
193206 }
194207 if (mMeanLumiRefOverride != 0 .) {
195208 setMeanLumiRef (mMeanLumiRefOverride );
196209 }
197- if (mInstLumiOverride != 0 .) {
198- setInstLumi (mInstLumiOverride , false );
210+ if (mInstCTPLumiOverride != 0 .) {
211+ setInstLumiCTP (mInstCTPLumiOverride * mInstLumiCTPFactor );
212+ if (getLumiScaleType () == 1 ) {
213+ setInstLumi (getInstLumiCTP (), false );
214+ }
199215 }
200216 setUpdatedLumi ();
201217 int scaleType = getLumiScaleType ();
202218 const std::array<std::string, 3 > lumiS{" OFF" , " CTP" , " TPC scaler" };
203219 if (scaleType >= lumiS.size ()) {
204220 LOGP (fatal, " Wrong lumi-scale-type provided!" );
205221 }
206- LOGP (info, " TPC correction map params updated (corr.map scaling type={}): override values: lumiMean={} lumiRefMean={} lumiInst={} lumiScaleMode={}, LumiInst scale={}, CTP Lumi source={}" ,
207- lumiS[scaleType], mMeanLumiOverride , mMeanLumiRefOverride , mInstLumiOverride , mLumiScaleMode , mInstLumiFactor , mCTPLumiSource );
222+
223+ LOGP (info, " TPC correction map params updated: SP corrections: {} (corr.map scaling type={}, override values: lumiMean={} lumiRefMean={} lumiScaleMode={}), CTP Lumi: source={} lumiInstOverride={} , LumiInst scale={} " ,
224+ canUseCorrections () ? " ON" : " OFF" ,
225+ lumiS[scaleType], mMeanLumiOverride , mMeanLumiRefOverride , mLumiScaleMode , mLumiCTPSource , mInstCTPLumiOverride , mInstLumiCTPFactor );
208226 }
209227 return false ;
210228}
@@ -216,20 +234,22 @@ void CorrectionMapsLoader::init(o2::framework::InitContext& ic)
216234 LOGP (fatal, " TPC correction lumi scaling mode is not set" );
217235 }
218236 const auto & inputRouts = ic.services ().get <const o2::framework::DeviceSpec>().inputs ;
237+ bool foundCTP = false , foundTPCScl = false , foundMShape = false ;
219238 for (const auto & route : inputRouts) {
220239 if (route.matcher == InputSpec{" CTPLumi" , " CTP" , " LUMI" , 0 , Lifetime::Timeframe}) {
221- if (getLumiScaleType () != 1 ) {
222- LOGP (fatal, " Lumi scaling source CTP is not compatible with TPC correction lumi scaler type {}" , getLumiScaleType ());
223- }
240+ foundCTP = true ;
224241 } else if (route.matcher == InputSpec{" tpcscaler" , o2::header::gDataOriginTPC , " TPCSCALER" , 0 , Lifetime::Timeframe}) {
225- if (getLumiScaleType () != 2 ) {
226- LOGP (fatal, " Lumi scaling source TPCScaler is not compatible with TPC correction lumi scaler type {}" , getLumiScaleType ());
227- }
228- setLumiScaleType (2 );
242+ foundTPCScl = true ;
229243 } else if (route.matcher == InputSpec{" mshape" , o2::header::gDataOriginTPC , " TPCMSHAPE" , 0 , Lifetime::Timeframe}) {
230- enableMShapeCorrection ( true ) ;
244+ foundMShape = true ;
231245 }
232246 }
247+ setLumiCTPAvailable (foundCTP);
248+ enableMShapeCorrection (foundMShape);
249+ if ((getLumiScaleType () == 1 && !foundCTP) || (getLumiScaleType () == 2 && !foundTPCScl)) {
250+ LOGP (fatal, " Lumi scaling source {}({}) is not available for TPC correction" , getLumiScaleType (), getLumiScaleType () == 1 ? " CTP" : " TPCScaler" );
251+ }
252+
233253 if ((getLumiScaleMode () == 1 ) || (getLumiScaleMode () == 2 )) {
234254 mScaleInverse = ic.options ().get <bool >(" do-not-recalculate-inverse-correction" );
235255 } else {
@@ -243,16 +263,18 @@ void CorrectionMapsLoader::init(o2::framework::InitContext& ic)
243263void CorrectionMapsLoader::copySettings (const CorrectionMapsLoader& src)
244264{
245265 setInstLumi (src.getInstLumi (), false );
266+ setInstLumiCTP (src.getInstLumiCTP ());
246267 setMeanLumi (src.getMeanLumi (), false );
268+ setLumiCTPAvailable (src.getLumiCTPAvailable ());
247269 setMeanLumiRef (src.getMeanLumiRef ());
248270 setLumiScaleType (src.getLumiScaleType ());
249271 setMeanLumiOverride (src.getMeanLumiOverride ());
250272 setMeanLumiRefOverride (src.getMeanLumiRefOverride ());
251- setInstLumiOverride (src.getInstLumiOverride ());
273+ setInstCTPLumiOverride (src.getInstCTPLumiOverride ());
252274 setLumiScaleMode (src.getLumiScaleMode ());
253275 enableMShapeCorrection (src.getUseMShapeCorrection ());
254- mInstLumiFactor = src.mInstLumiFactor ;
255- mCTPLumiSource = src.mCTPLumiSource ;
276+ mInstLumiCTPFactor = src.mInstLumiCTPFactor ;
277+ mLumiCTPSource = src.mLumiCTPSource ;
256278 mLumiScaleMode = src.mLumiScaleMode ;
257279 mScaleInverse = src.getScaleInverse ();
258280}
0 commit comments