]>
Commit | Line | Data |
---|---|---|
6ea93b32 | 1 | // $Id$ |
2 | // | |
980821ba | 3 | // Task to setup emcal related global objects. |
6ea93b32 | 4 | // |
cd231d42 | 5 | // Author: C.Loizides |
6ea93b32 | 6 | |
b933ccf0 | 7 | #include "AliEmcalSetupTask.h" |
6ea93b32 | 8 | #include <TClonesArray.h> |
6ea93b32 | 9 | #include <TGeoGlobalMagField.h> |
dec5f256 | 10 | #include <TGeoManager.h> |
11 | #include "AliAODEvent.h" | |
6ea93b32 | 12 | #include "AliAnalysisManager.h" |
13 | #include "AliCDBManager.h" | |
14 | #include "AliEMCALGeometry.h" | |
15 | #include "AliESDEvent.h" | |
6ea93b32 | 16 | #include "AliGeomManager.h" |
dec5f256 | 17 | #include "AliMagF.h" |
6ea93b32 | 18 | #include "AliOADBContainer.h" |
19 | ||
20 | ClassImp(AliEmcalSetupTask) | |
21 | ||
22 | //________________________________________________________________________ | |
23 | AliEmcalSetupTask::AliEmcalSetupTask() : | |
24 | AliAnalysisTaskSE(), | |
25 | fOcdbPath(), | |
26 | fOadbPath("$ALICE_ROOT/OADB/EMCAL"), | |
277be17b | 27 | fGeoPath("."), |
6ea93b32 | 28 | fIsInit(kFALSE) |
29 | { | |
30 | // Constructor. | |
31 | } | |
32 | ||
33 | //________________________________________________________________________ | |
34 | AliEmcalSetupTask::AliEmcalSetupTask(const char *name) : | |
35 | AliAnalysisTaskSE(name), | |
36 | fOcdbPath(), | |
37 | fOadbPath("$ALICE_ROOT/OADB/EMCAL"), | |
4b4fc849 | 38 | fGeoPath("$ALICE_ROOT/OADB/EMCAL"), |
6ea93b32 | 39 | fIsInit(kFALSE) |
40 | { | |
41 | // Constructor. | |
42 | fBranchNames = "ESD:AliESDHeader.,AliESDRun."; | |
43 | } | |
44 | ||
45 | //________________________________________________________________________ | |
46 | AliEmcalSetupTask::~AliEmcalSetupTask() | |
47 | { | |
48 | // Destructor. | |
49 | } | |
50 | ||
51 | //________________________________________________________________________ | |
52 | void AliEmcalSetupTask::UserExec(Option_t *) | |
53 | { | |
54 | // Main loop, called for each event. | |
55 | ||
56 | if (fIsInit) | |
57 | return; | |
58 | ||
6ea93b32 | 59 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); |
60 | if (!am) { | |
61 | AliError("Manager zero, returning"); | |
62 | return; | |
63 | } | |
64 | am->LoadBranch("AliESDRun."); | |
65 | am->LoadBranch("AliESDHeader."); | |
66 | ||
dec5f256 | 67 | Int_t runno = InputEvent()->GetRunNumber(); |
a1a56aea | 68 | TString geoname("EMCAL_COMPLETE12SMV1"); |
4b4fc849 | 69 | Int_t year = 2013; |
a1a56aea | 70 | if (runno<=139517) { |
71 | year = 2010; | |
72 | geoname = "EMCAL_FIRSTYEARV1"; | |
4b4fc849 | 73 | } else if ((runno>139517) && (runno<=170593)) { |
64a8dac7 | 74 | year = 2011; |
75 | geoname = "EMCAL_COMPLETEV1"; | |
4b4fc849 | 76 | } else if ((runno>170593) && (runno<=193766)) { |
77 | year = 2012; | |
6ea93b32 | 78 | } |
79 | ||
6ea93b32 | 80 | AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(geoname); |
81 | if (!geom) { | |
82 | AliFatal(Form("Can not create geometry: %s",geoname.Data())); | |
83 | return; | |
84 | } | |
85 | ||
86 | AliCDBManager *man = 0; | |
87 | if (fOcdbPath.Length()>0) { | |
88 | AliInfo(Form("Setting up OCDB")); | |
89 | man = AliCDBManager::Instance(); | |
90 | man->SetDefaultStorage(fOcdbPath); | |
91 | man->SetRun(runno); | |
92 | } | |
93 | ||
94 | TGeoManager *geo = AliGeomManager::GetGeometry(); | |
95 | if (!geo) { | |
64a8dac7 | 96 | TString fname(gSystem->ExpandPathName(Form("%s/geometry_%d.root", fGeoPath.Data(), year))); |
6ea93b32 | 97 | if (gSystem->AccessPathName(fname)==0) { |
98 | AliInfo(Form("Loading geometry from %s", fname.Data())); | |
99 | AliGeomManager::LoadGeometry(fname); | |
100 | } else if (man) { | |
101 | AliInfo(Form("Loading geometry from OCDB")); | |
102 | AliGeomManager::LoadGeometry(); | |
103 | } | |
104 | } | |
105 | if (geo) { | |
106 | AliGeomManager::ApplyAlignObjsFromCDB("EMCAL"); | |
107 | AliInfo(Form("Locking geometry")); | |
108 | geo->LockGeometry(); | |
109 | } | |
110 | ||
111 | if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map | |
ddc5a41b | 112 | InputEvent()->InitMagneticField(); |
6ea93b32 | 113 | } |
114 | ||
115 | if (fOadbPath.Length()>0) { | |
116 | AliOADBContainer emcalgeoCont(Form("emcal")); | |
117 | emcalgeoCont.InitFromFile(Form("%s/EMCALlocal2master.root",fOadbPath.Data()), | |
118 | Form("AliEMCALgeo")); | |
119 | TObjArray *mobj=dynamic_cast<TObjArray*>(emcalgeoCont.GetObject(runno,"EmcalMatrices")); | |
120 | if (mobj) { | |
121 | for(Int_t mod=0; mod < (geom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ | |
122 | //AliInfo(Form("Misalignment matrix %d", mod)); | |
123 | geom->SetMisalMatrix((TGeoHMatrix*) mobj->At(mod),mod); | |
124 | } | |
125 | } | |
126 | } | |
127 | ||
128 | fIsInit = kTRUE; | |
129 | } |