21 #include <TGeoGlobalMagField.h> 22 #include "TGeoManager.h" 23 #include <TInterpreter.h> 25 #include "AliAnalysisManager.h" 26 #include "AliGeomManager.h" 27 #include "AliCDBManager.h" 28 #include "AliGRPManager.h" 29 #include "AliVEvent.h" 30 #include "AliInputEventHandler.h" 38 fFallBackToRaw(kFALSE),
46 fSpecCDBUri.SetOwner();
52 fFallBackToRaw(fallback),
61 DefineInput (0, TChain::Class());
76 AliCDBManager *cdb = AliCDBManager::Instance();
78 if (!cdb->IsDefaultStorageSet()) {
82 if (
fRun<139674) year = 2010;
83 else if (
fRun<170718) year = 2011;
84 else if (
fRun<194479) year = 2012;
85 else if (
fRun<199999) year = 2013;
86 else if (
fRun<208504) year = 2014;
87 else if (
fRun<247170) year = 2015;
88 else if (
fRun<267255) year = 2016;
89 else if (
fRun<282901) year = 2017;
93 if (today.GetYear()!=year) AliErrorF(
"Adjust CDB connect, we are now in %d!",today.GetYear());
98 if (inpStor ==
"cvmfs:") {
99 fStorage = Form(
"local:///cvmfs/alice.cern.ch/calibration/data/%4d/OCDB",year);
102 else if (inpStor.BeginsWith(
"local:///cvmfs") && inpStor.EndsWith(
"/OCDB")) {
104 tmp.ReplaceAll(
"local://",
"");
105 TString strYold = tmp(TRegexp(
"/[0-9][0-9][0-9][0-9]/OCDB"));
106 TString strYnew = Form(
"/%4d/OCDB",year);
107 if (strYold.IsNull()) tmp += strYnew;
108 else tmp.ReplaceAll(strYold,strYnew);
110 fStorage = Form(
"local://%s", tmp.Data());
115 cvmfspath = cvmfspath.ReplaceAll(
"local://",
"");
116 if(
gSystem->AccessPathName(cvmfspath.Data(),kFileExists)) {
118 AliErrorF(
"could not access %s, switching to raw://",
fStorage.Data());
121 else AliFatalF(
"could not access %s, fallback to raw:// disabled",
fStorage.Data());
124 AliInfoF(
"Setting default storage to %s",
fStorage.Data());
131 UInt_t vsv = obj->GetUniqueID();
132 Int_t ver = int(vsv>>16)-1;
133 Int_t subver = int(vsv&0xffff)-1;
134 cdb->SetSpecificStorage(obj->GetName(), obj->GetTitle(), ver, subver);
137 if (cdb->GetRun()!=
fRun) {
140 if (
gSystem->AccessPathName(
"localOCDBaccessConfig.C", kFileExists)==0) {
142 gInterpreter->ProcessLine(
"localOCDBaccessConfig()");
146 if (
gSystem->AccessPathName(
"OCDB.root",kFileExists)==0) cdb->SetSnapshotMode(
"OCDB.root");
149 AliInfo(
"AliCDBconnect: #### Loading GRP to init B-field...");
150 if(!
fGRPManager->ReadGRPEntry()) AliFatal(
"Cannot get GRP entry");
151 if(!
fGRPManager->SetMagField()) AliFatal(
"Problem with magnetic field setup");
155 AliInfo(
"AliCDBconnect: #### Loading geometry...");
156 AliGeomManager::LoadGeometry(
"geometry.root");
157 if(!AliGeomManager::ApplyAlignObjsFromCDB(
"GRP ITS TPC TRD TOF EMCAL PHOS MUON")) AliWarning(
"Problem with align objects");
168 if (!mgr) AliFatal(
"No analysis manager");
174 AliInfo(
"Run number is not available at this stage, InitGRP will be called in the execution loop");
183 if (!mgr) AliFatal(
"No analysis manager");
184 AliAnalysisTask::ConnectInputData(option);
185 Int_t run = AliAnalysisManager::GetAnalysisManager()->GetRunFromPath();
187 AliWarning(
"AliTaskCDBconnect: Could not set run from path");
202 if (!mgr) AliFatal(
"No analysis manager");
203 AliInputEventHandler* inp = (AliInputEventHandler*)mgr->GetInputEventHandler();
204 if (!inp) AliFatal(
"No input event handler connected");
205 AliVEvent* ev = inp->GetEvent();
206 if (!ev) AliFatal(
"No event returned");
207 int run = ev->GetRunNumber();
209 if (
fRun != run && run>0) {
220 if (version<0) version = -1;
221 if (subVersion<0) subVersion = -1;
222 nmpath->SetUniqueID((
UInt_t(version+1)<<16)+
UInt_t(subVersion+1));
virtual void CreateOutputObjects()
virtual void Exec(Option_t *option)
virtual ~AliTaskCDBconnect()
AliGRPManager * fGRPManager
void SetSpecificStorage(const char *calibType, const char *dbString, Int_t version=-1, Int_t subVersion=-1)
virtual void ConnectInputData(Option_t *option="")