@@ -82,6 +82,7 @@ struct qVectorsTable {
8282 Configurable<std::vector<int >> cfgnMods{" cfgnMods" , {2 , 3 }, " Modulation of interest" };
8383 Configurable<float > cfgMaxCentrality{" cfgMaxCentrality" , 100 .f , " max. centrality for Q vector calibration" };
8484
85+ Configurable<bool > useCorrectionForRun{" useCorrectionForRun" , true , " Get Qvector corrections based on run number instead of timestamp" };
8586 Configurable<std::string> cfgGainEqPath{" cfgGainEqPath" , " Users/j/junlee/Qvector/GainEq" , " CCDB path for gain equalization constants" };
8687 Configurable<std::string> cfgQvecCalibPath{" cfgQvecCalibPath" , " Analysis/EventPlane/QVecCorrections" , " CCDB pasth for Q-vecteor calibration constants" };
8788
@@ -219,9 +220,10 @@ struct qVectorsTable {
219220 std::string fullPath;
220221
221222 auto timestamp = bc.timestamp ();
223+ auto runnumber = bc.runNumber ();
222224
223- auto offsetFT0 = ccdb-> getForTimeStamp <std::vector<o2::detectors::AlignParam>>(" FT0/Calib/Align" , timestamp);
224- auto offsetFV0 = ccdb-> getForTimeStamp <std::vector<o2::detectors::AlignParam>>(" FV0/Calib/Align" , timestamp);
225+ auto offsetFT0 = getForTsOrRun <std::vector<o2::detectors::AlignParam>>(" FT0/Calib/Align" , timestamp, runnumber );
226+ auto offsetFV0 = getForTsOrRun <std::vector<o2::detectors::AlignParam>>(" FV0/Calib/Align" , timestamp, runnumber );
225227
226228 if (offsetFT0 != nullptr ) {
227229 helperEP.SetOffsetFT0A ((*offsetFT0)[0 ].getX (), (*offsetFT0)[0 ].getY ());
@@ -243,17 +245,17 @@ struct qVectorsTable {
243245 fullPath = cfgQvecCalibPath;
244246 fullPath += " /v" ;
245247 fullPath += std::to_string (ind);
246- auto objqvec = ccdb-> getForTimeStamp <TH3F>(fullPath, timestamp);
248+ auto objqvec = getForTsOrRun <TH3F>(fullPath, timestamp, runnumber );
247249 if (!objqvec) {
248250 fullPath = cfgQvecCalibPath;
249251 fullPath += " /v2" ;
250- objqvec = ccdb-> getForTimeStamp <TH3F>(fullPath, timestamp);
252+ objqvec = getForTsOrRun <TH3F>(fullPath, timestamp, runnumber );
251253 }
252254 objQvec.push_back (objqvec);
253255 }
254256 fullPath = cfgGainEqPath;
255257 fullPath += " /FT0" ;
256- auto objft0Gain = ccdb-> getForTimeStamp <std::vector<float >>(fullPath, timestamp);
258+ auto objft0Gain = getForTsOrRun <std::vector<float >>(fullPath, timestamp, runnumber );
257259 if (!objft0Gain || cfgCorrLevel == 0 ) {
258260 for (auto i{0u }; i < 208 ; i++) {
259261 FT0RelGainConst.push_back (1 .);
@@ -264,7 +266,7 @@ struct qVectorsTable {
264266
265267 fullPath = cfgGainEqPath;
266268 fullPath += " /FV0" ;
267- auto objfv0Gain = ccdb-> getForTimeStamp <std::vector<float >>(fullPath, timestamp);
269+ auto objfv0Gain = getForTsOrRun <std::vector<float >>(fullPath, timestamp, runnumber );
268270 if (!objfv0Gain || cfgCorrLevel == 0 ) {
269271 for (auto i{0u }; i < 48 ; i++) {
270272 FV0RelGainConst.push_back (1 .);
@@ -299,6 +301,21 @@ struct qVectorsTable {
299301 return true ;
300302 }
301303
304+ // / Function to get corrections from CCDB eithr using the timestamp or the runnumber
305+ // / \param fullPath is the path to correction in CCDB
306+ // / \param timestamp is the collision timestamp
307+ // / \param runNumber is the collision run number
308+ // / \return CCDB correction
309+ template <typename CorrectionType>
310+ CorrectionType* getForTsOrRun (std::string const & fullPath, int64_t timestamp, int runNumber)
311+ {
312+ if (useCorrectionForRun) {
313+ return ccdb->getForRun <CorrectionType>(fullPath, runNumber);
314+ } else {
315+ return ccdb->getForTimeStamp <CorrectionType>(fullPath, timestamp);
316+ }
317+ }
318+
302319 template <typename Nmode, typename CollType, typename TrackType>
303320 void CalQvec (const Nmode nmode, const CollType& coll, const TrackType& track, std::vector<float >& QvecRe, std::vector<float >& QvecIm, std::vector<float >& QvecAmp, std::vector<int >& TrkTPCposLabel, std::vector<int >& TrkTPCnegLabel, std::vector<int >& TrkTPCallLabel)
304321 {
0 commit comments