21 #include <TGeoGlobalMagField.h>
22 #include "TGeoManager.h"
24 #include "AliAnalysisManager.h"
25 #include "AliGeomManager.h"
26 #include "AliCDBManager.h"
27 #include "AliGRPManager.h"
28 #include "AliVEvent.h"
29 #include "AliInputEventHandler.h"
37 fFallBackToRaw(kFALSE),
45 fSpecCDBUri.SetOwner();
51 fFallBackToRaw(fallback),
60 DefineInput (0, TChain::Class());
75 AliCDBManager *cdb = AliCDBManager::Instance();
77 if (!cdb->IsDefaultStorageSet()) {
81 if (
fRun<139674) year = 2010;
82 else if (
fRun<170718) year = 2011;
83 else if (
fRun<194479) year = 2012;
84 else if (
fRun<199999) year = 2013;
85 else if (
fRun<208504) year = 2014;
86 else if (
fRun<247170) year = 2015;
87 else if (
fRun<267255) year = 2016;
91 if (today.GetYear()!=year) AliErrorF(
"Adjust CDB connect, we are now in %d!",today.GetYear());
96 if (inpStor ==
"cvmfs:") {
97 fStorage = Form(
"local:///cvmfs/alice.cern.ch/calibration/data/%4d/OCDB",year);
100 else if (inpStor.BeginsWith(
"local:///cvmfs") && inpStor.EndsWith(
"/OCDB")) {
102 tmp.ReplaceAll(
"local://",
"");
103 TString strYold = tmp(TRegexp(
"/[0-9][0-9][0-9][0-9]/OCDB"));
104 TString strYnew = Form(
"/%4d/OCDB",year);
105 if (strYold.IsNull()) tmp += strYnew;
106 else tmp.ReplaceAll(strYold,strYnew);
108 fStorage = Form(
"local://%s", tmp.Data());
113 cvmfspath = cvmfspath.ReplaceAll(
"local://",
"");
114 if(
gSystem->AccessPathName(cvmfspath.Data(),kFileExists)) {
116 AliErrorF(
"could not access %s, switching to raw://",
fStorage.Data());
119 else AliFatalF(
"could not access %s, fallback to raw:// disabled",
fStorage.Data());
122 AliInfoF(
"Setting default storage to %s",
fStorage.Data());
129 UInt_t vsv = obj->GetUniqueID();
130 Int_t ver = int(vsv>>16)-1;
131 Int_t subver = int(vsv&0xffff)-1;
132 cdb->SetSpecificStorage(obj->GetName(), obj->GetTitle(), ver, subver);
135 if (cdb->GetRun()!=
fRun) {
140 if (
gSystem->AccessPathName(
"OCDB.root",kFileExists)==0) cdb->SetSnapshotMode(
"OCDB.root");
143 AliInfo(
"AliCDBconnect: #### Loading GRP to init B-field...");
144 if(!
fGRPManager->ReadGRPEntry()) AliFatal(
"Cannot get GRP entry");
145 if(!
fGRPManager->SetMagField()) AliFatal(
"Problem with magnetic field setup");
149 AliInfo(
"AliCDBconnect: #### Loading geometry...");
150 AliGeomManager::LoadGeometry(
"geometry.root");
151 if(!AliGeomManager::ApplyAlignObjsFromCDB(
"GRP ITS TPC TRD TOF EMCAL PHOS MUON")) AliWarning(
"Problem with align objects");
162 if (!mgr) AliFatal(
"No analysis manager");
168 AliInfo(
"Run number is not available at this stage, InitGRP will be called in the execution loop");
177 if (!mgr) AliFatal(
"No analysis manager");
178 AliAnalysisTask::ConnectInputData(option);
179 Int_t run = AliAnalysisManager::GetAnalysisManager()->GetRunFromPath();
181 AliWarning(
"AliTaskCDBconnect: Could not set run from path");
196 if (!mgr) AliFatal(
"No analysis manager");
197 AliInputEventHandler* inp = (AliInputEventHandler*)mgr->GetInputEventHandler();
198 if (!inp) AliFatal(
"No input event handler connected");
199 AliVEvent* ev = inp->GetEvent();
200 if (!ev) AliFatal(
"No event returned");
201 int run = ev->GetRunNumber();
203 if (
fRun != run && run>0) {
214 if (version<0) version = -1;
215 if (subVersion<0) subVersion = -1;
216 nmpath->SetUniqueID((
UInt_t(version+1)<<16)+
UInt_t(subVersion+1));
ClassImp(AliTaskCDBconnect) AliTaskCDBconnect
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="")