3 #if !defined(__CINT__) || defined(__MAKECINT__)
6 #include "TGeoManager.h"
7 #include "TObjString.h"
8 #include "TClonesArray.h"
10 #include "AliGeomManager.h"
11 #include "AliCDBManager.h"
12 #include "AliCDBStorage.h"
13 #include "AliCDBPath.h"
14 #include "AliCDBEntry.h"
16 #include "AliCDBMetaData.h"
17 #include "AliMisAligner.h"
18 #include "AliZDCMisAligner.h"
22 void MakeAlignmentObjs(const char* detList="ALL", const char* CDBstorage = "local://$HOME/ResidualMisAlignment", const char* outDir="", const char* misalType="residual", Bool_t partialGeom=kFALSE){
23 // Make residual misalignment objects for all detectors
24 // Pass different "CDBstorage" argument if needed (e.g. to fill
25 // conditions' data base on alien) or set it to null string to have
26 // the objects saved locally on file
27 // This macro defines the default name and place for the detector-macros
28 // in charge of producing the residual misalignment objects as
29 // $ALICE_ROOT/DET/MakeDETResidualMisAlignment.C
32 const char* macroName = "MakeAlignmentObjs";
33 TString cdbStorage(CDBstorage);
35 if(cdbStorage.IsNull() && oDir.IsNull())
37 Error(macroName, "Output undefined! Set either the CDB storage or the output directory!");
43 TString modList(detList);
44 if(modList=="ALL") modList="ACORDE EMCAL FMD HMPID ITS MUON PMD PHOS T0 TRD TPC TOF VZERO ZDC";
45 Info(macroName, "Processing detectors: %s \n", modList.Data());
46 Printf("Creating %s misalignment for detectors: %s \n", misalType, modList.Data());
47 if(modList.Contains("ZDC")){
48 AliZDCMisAligner* misAlignerZDC = new AliZDCMisAligner();
49 misAligners.Add(new TObjString("ZDC"), misAlignerZDC);
52 // Load geometry from CDB; update geometry before loading it if we are going to load
53 // the alignment objects to the CDB
54 AliCDBManager* cdb = AliCDBManager::Instance();
55 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
57 AliCDBStorage* storage = 0;
59 if(cdbStorage.IsNull()){ //if we produce the objects into a file
60 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
61 }else{ // if we produce the objects in a CDB storage
62 // update geometry in it
63 Info(macroName, "Updating geometry in CDB storage %s",cdbStorage.Data());
64 gROOT->ProcessLine(".L $ALICE_ROOT/GRP/UpdateCDBIdealGeom.C");
66 UpdateCDBIdealGeom(cdbStorage.Data(),"$ALICE_ROOT/test/fpprod/Config.C");
68 UpdateCDBIdealGeom(cdbStorage.Data(),"$ALICE_ROOT/macros/Config.C");
70 // load the same geometry from given CDB storage
71 AliCDBPath path("GRP","Geometry","Data");
72 storage = cdb->GetStorage(cdbStorage.Data());
73 AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
74 if(!entry) Fatal(macroName,"Couldn't load geometry data from CDB!");
76 TGeoManager* geom = (TGeoManager*) entry->GetObject();
77 if (!geom) Fatal(macroName,"Couldn't find TGeoManager in the specified CDB entry!");
78 AliGeomManager::SetGeometry(geom);
81 // run macro for non-sensitive modules
82 // (presently generates only FRAME alignment objects)
83 // gSystem->Exec("aliroot -b -q $ALICE_ROOT/GRP/MakeSTRUCTResMisAlignment.C"); !!!!!!!!!!!!!!!!!!!!!!!!!
85 // run macros for sensitive modules
88 TClonesArray* objsArray = 0;
90 TObjArray *detArray = modList.Tokenize(' ');
93 while((ostr = (TObjString*) iter.Next())){
94 TString str(ostr->String());
98 fileName += str.Data();
99 fileName += misalType;
100 fileName += "MisAlignment.root";
102 TString arName(str.Data());
103 arName += "AlignObjs";
105 AliMisAligner* misAligner = dynamic_cast<AliMisAligner*> (misAligners.GetValue(str));
106 misAligner->SetMisalType(misalType);
107 objsArray = misAligner->MakeAlObjsArray();
108 //Printf("objsArray has %d entries",objsArray->GetEntriesFast());
109 //objsArray->Print();
110 if(!cdbStorage.IsNull())
113 strId+="/Align/Data";
114 AliCDBId id(strId.Data(),0,AliCDBRunRange::Infinity());
115 AliCDBMetaData *md = misAligner->GetCDBMetaData();
116 md->SetAliRootVersion(ALIROOT_SVN_BRANCH);
117 storage->Put(objsArray, id, md);
120 TFile file(fileName.Data(),"RECREATE");
122 Error(macroName,"cannot open file for output\n");
125 Info(macroName,"Saving alignment objects to the file %s", fileName);
127 file.WriteObject(objsArray,arName.Data(),"kSingleKey");