]> git.uio.no Git - u/mrichter/AliRoot.git/blame - macros/MakeAlignmentObjs.C
adding more options to control the size of the GlobalTriggerDecision.
[u/mrichter/AliRoot.git] / macros / MakeAlignmentObjs.C
CommitLineData
df797e22 1#include "ARVersion.h"
2
3#if !defined(__CINT__) || defined(__MAKECINT__)
4#include "TSystem.h"
5#include "TROOT.h"
6#include "TGeoManager.h"
7#include "TObjString.h"
8#include "TClonesArray.h"
9#include "TError.h"
10#include "AliGeomManager.h"
11#include "AliCDBManager.h"
12#include "AliCDBStorage.h"
13#include "AliCDBPath.h"
14#include "AliCDBEntry.h"
15#include "AliCDBId.h"
16#include "AliCDBMetaData.h"
17#include "AliMisAligner.h"
614b514a 18#include "AliHMPIDMisAligner.h"
19#include "AliITSMisAligner.h"
20#include "AliPMDMisAligner.h"
21#include "AliT0MisAligner.h"
22#include "AliTPCMisAligner.h"
23#include "AliVZEROMisAligner.h"
df797e22 24#include "AliZDCMisAligner.h"
25#include <TString.h>
26#endif
27
614b514a 28void MakeAlignmentObjs(const char* detList="ALL", const char* ocdbOrDir = "local://$HOME/ResidualMisAlignment", const char* misalType="residual", Bool_t partialGeom=kFALSE){
29 // Make alignment objects for all detectors listed in "detList"
30 // for the misalignment scenario passed as argument "misalType".
31 // "ocdbUriDirPath" argument is used as URI for an OCDB if it contains
32 // either the string "local;//" or the string "alien://folder=",
33 // otherwise it is used as the path of the directory where to
34 // put the files containing the alignment objects.
35 // The geometry used is the one produced with $ALICE_ROOT/macros/Config.C
36 // unless "partialGeom" is set to true (=> $ALICE_ROOT/test/fpprod/Config.C).
df797e22 37 //
38
39 const char* macroName = "MakeAlignmentObjs";
614b514a 40 Bool_t toOCDB = kFALSE;
41 TString fileName("");
42 TString ocdbUriDirPath(ocdbOrDir);
43 if(ocdbUriDirPath.IsNull() || ocdbUriDirPath.IsWhitespace())
df797e22 44 {
614b514a 45 Error(macroName, "Output undefined! Set it either to a valid OCDB storage or to the output directory!");
df797e22 46 return;
614b514a 47 }else if(ocdbUriDirPath.Contains("local://") || ocdbUriDirPath.Contains("alien://folder=")){
48 // else ocdbUriDirPath is to be interpreted as an OCDB URI
49 toOCDB=kTRUE;
50 Printf("Objects will be saved in the OCDB %s",ocdbUriDirPath.Data());
51 }else{ // else ocdbUriDirPath is to be interpreted as a directory path
e639bc38 52 gSystem->ExpandPathName(ocdbUriDirPath);
53 if(gSystem->AccessPathName(ocdbUriDirPath.Data()))
54 {
55 Printf("Directory \"%s\" where to save files does not yet exist! ... exiting!",ocdbUriDirPath.Data());
56 return;
57 }else{
58 Printf("Files with alignment objects will be saved in the directory %s",ocdbUriDirPath.Data());
59 }
df797e22 60 }
614b514a 61
df797e22 62 TMap misAligners;
63 TString modList(detList);
64 if(modList=="ALL") modList="ACORDE EMCAL FMD HMPID ITS MUON PMD PHOS T0 TRD TPC TOF VZERO ZDC";
65 Info(macroName, "Processing detectors: %s \n", modList.Data());
66 Printf("Creating %s misalignment for detectors: %s \n", misalType, modList.Data());
614b514a 67 if(modList.Contains("EMCAL")){
68 AliEMCALMisAligner* misAlignerEMCAL = new AliEMCALMisAligner();
69 misAligners.Add(new TObjString("EMCAL"), misAlignerEMCAL);
70 }
71 if(modList.Contains("HMPID")){
72 AliHMPIDMisAligner* misAlignerHMPID = new AliHMPIDMisAligner();
73 misAligners.Add(new TObjString("HMPID"), misAlignerHMPID);
74 }
75 if(modList.Contains("ITS")){
76 AliITSMisAligner* misAlignerITS = new AliITSMisAligner();
77 misAligners.Add(new TObjString("ITS"), misAlignerITS);
78 }
79 if(modList.Contains("PMD")){
80 AliPMDMisAligner* misAlignerPMD = new AliPMDMisAligner();
81 misAligners.Add(new TObjString("PMD"), misAlignerPMD);
82 }
83 if(modList.Contains("T0")){
84 AliT0MisAligner* misAlignerT0 = new AliT0MisAligner();
85 misAligners.Add(new TObjString("T0"), misAlignerT0);
86 }
87 if(modList.Contains("TPC")){
88 AliTPCMisAligner* misAlignerTPC = new AliTPCMisAligner();
89 misAligners.Add(new TObjString("TPC"), misAlignerTPC);
90 }
91 if(modList.Contains("VZERO")){
92 AliVZEROMisAligner* misAlignerVZERO = new AliVZEROMisAligner();
93 misAligners.Add(new TObjString("VZERO"), misAlignerVZERO);
94 }
df797e22 95 if(modList.Contains("ZDC")){
96 AliZDCMisAligner* misAlignerZDC = new AliZDCMisAligner();
97 misAligners.Add(new TObjString("ZDC"), misAlignerZDC);
98 }
99
614b514a 100 // Load geometry from OCDB; update geometry before loading it if we are going to load
101 // the alignment objects to the OCDB
df797e22 102 AliCDBManager* cdb = AliCDBManager::Instance();
103 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
104 cdb->SetRun(0);
105 AliCDBStorage* storage = 0;
106
614b514a 107 if(!toOCDB){ //if we produce the objects into a file
108 AliGeomManager::LoadGeometry(); //load geom from default OCDB storage
109 }else{ // if we produce the objects in a OCDB storage
df797e22 110 // update geometry in it
614b514a 111 Info(macroName, "Updating geometry in OCDB storage %s",ocdbUriDirPath.Data());
df797e22 112 gROOT->ProcessLine(".L $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C");
113 if(partialGeom){
614b514a 114 UpdateCDBIdealGeom(ocdbUriDirPath.Data(),"$ALICE_ROOT/test/fpprod/Config.C");
df797e22 115 }else{
614b514a 116 UpdateCDBIdealGeom(ocdbUriDirPath.Data(),"$ALICE_ROOT/macros/Config.C");
df797e22 117 }
614b514a 118 // load the same geometry from given OCDB storage
df797e22 119 AliCDBPath path("GRP","Geometry","Data");
614b514a 120 storage = cdb->GetStorage(ocdbUriDirPath.Data());
df797e22 121 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
614b514a 122 if(!entry) Fatal(macroName,"Couldn't load geometry data from OCDB!");
df797e22 123 entry->SetOwner(0);
124 TGeoManager* geom = (TGeoManager*) entry->GetObject();
614b514a 125 if (!geom) Fatal(macroName,"Couldn't find TGeoManager in the specified OCDB entry!");
df797e22 126 AliGeomManager::SetGeometry(geom);
127 }
128
129 // run macro for non-sensitive modules
130 // (presently generates only FRAME alignment objects)
131 // gSystem->Exec("aliroot -b -q $ALICE_ROOT/GRP/MakeSTRUCTResMisAlignment.C"); !!!!!!!!!!!!!!!!!!!!!!!!!
132
133 // run macros for sensitive modules
134 TObjString *ostr;
135 TString strId;
136 TClonesArray* objsArray = 0;
137
138 TObjArray *detArray = modList.Tokenize(' ');
139 TIter iter(detArray);
140
141 while((ostr = (TObjString*) iter.Next())){
614b514a 142 TString str(ostr->String()); // DET
143 TString arName(str.Data()); // name of the array in case saved into the file
df797e22 144 arName += "AlignObjs";
145
146 AliMisAligner* misAligner = dynamic_cast<AliMisAligner*> (misAligners.GetValue(str));
147 misAligner->SetMisalType(misalType);
148 objsArray = misAligner->MakeAlObjsArray();
614b514a 149
150 if(toOCDB)
df797e22 151 {
152 strId=str;
153 strId+="/Align/Data";
154 AliCDBId id(strId.Data(),0,AliCDBRunRange::Infinity());
155 AliCDBMetaData *md = misAligner->GetCDBMetaData();
156 md->SetAliRootVersion(ALIROOT_SVN_BRANCH);
157 storage->Put(objsArray, id, md);
158 }else{
159 // save on file
614b514a 160 fileName = ocdbUriDirPath;
e639bc38 161 fileName += "/";
614b514a 162 fileName += str.Data();
163 fileName += misalType;
164 fileName += "MisAlignment.root";
df797e22 165 TFile file(fileName.Data(),"RECREATE");
166 if(!file){
167 Error(macroName,"cannot open file for output\n");
168 return;
169 }
e639bc38 170 Info(macroName,"Saving alignment objects to the file %s", fileName.Data());
df797e22 171 file.cd();
172 file.WriteObject(objsArray,arName.Data(),"kSingleKey");
173 file.Close();
174 }
175 }
176
177 return;
178}