Forgotten ; at the end of the line
[u/mrichter/AliRoot.git] / TOF / MakeTOFZeroMisAlignment.C
CommitLineData
4d6eaa95 1void MakeTOFZeroMisAlignment() {
2 //
b355f61e 3 // Create TClonesArray of zero misalignment objects for TOF
d3a9c52a 4 //
4d6eaa95 5
6 const char* macroname = "MakeTOFZeroMisAlignment.C";
7
90dbf5fb 8 TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
b355f61e 9 TClonesArray &alobj = *array;
b355f61e 10
4d6eaa95 11 // Activate CDB storage to load geometry from CDB
a24be56b 12 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 13 if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
a24be56b 14 cdb->SetRun(0);
15
16 AliCDBStorage* storage;
4d6eaa95 17
18 if ( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ) {
a24be56b 19 TString Storage = gSystem->Getenv("STORAGE");
20 if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
21 Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
22 return;
23 }
24 storage = cdb->GetStorage(Storage.Data());
4d6eaa95 25 if (!storage) {
a24be56b 26 Error(macroname,"Unable to open storage %s\n",Storage.Data());
27 return;
28 }
29 AliCDBPath path("GRP","Geometry","Data");
4d6eaa95 30 AliCDBEntry *entry = (AliCDBEntry*)storage->Get(path.GetPath(),cdb->GetRun());
31 if (!entry)
32 Fatal(macroname,"Could not get the specified CDB entry!");
33
a24be56b 34 entry->SetOwner(0);
35 TGeoManager* geom = (TGeoManager*) entry->GetObject();
36 AliGeomManager::SetGeometry(geom);
4d6eaa95 37 } else
a24be56b 38 AliGeomManager::LoadGeometry(); //load geom from default CDB storage
a24be56b 39
4d6eaa95 40
41 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
ae079791 42 AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
b355f61e 43 Int_t j=0;
4d6eaa95 44 Int_t nSectors=18;
45
46 Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
47 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
48 UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id
49
50 for (Int_t isect = 0; isect < nSectors; isect++) {
51 TString symname(Form("TOF/sm%02d",isect));
52 new(alobj[j++]) AliAlignObjParams(symname.Data(),
53 dvoluid,
54 dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
55 }
b355f61e 56
4d6eaa95 57 Int_t strId=-1;
a24be56b 58 Int_t nstrA=15;
59 Int_t nstrB=19;
60 Int_t nstrC=19;
a24be56b 61 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
62
63 for (Int_t isect = 0; isect < nSectors; isect++) {
64 for (Int_t istr = 1; istr <= nStrips; istr++) {
65 strId++;
85ce4b22 66 if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue;
4d6eaa95 67 new(alobj[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),
68 AliGeomManager::LayerToVolUID(idTOF,strId),
69 dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
a24be56b 70 }
b355f61e 71 }
72
4d6eaa95 73 if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
d3a9c52a 74 // save on file
dfe9c69d 75 const char* filename = "TOFzeroMisalignment.root";
76 TFile f(filename,"RECREATE");
77 if(!f){
78 Error(macroname,"cannot open file for output\n");
79 return;
80 }
81 Info(macroname,"Saving alignment objects to the file %s", filename);
d3a9c52a 82 f.cd();
83 f.WriteObject(array,"TOFAlignObjs","kSingleKey");
84 f.Close();
4d6eaa95 85 } else {
d3a9c52a 86 // save in CDB storage
d3a9c52a 87 AliCDBMetaData* md = new AliCDBMetaData();
88 md->SetResponsible("Silvia Arcelli");
89 md->SetComment("Zero misalignment for TOF");
90 md->SetAliRootVersion("HEAD");
dfe9c69d 91 AliCDBId id("TOF/Align/Data",0,AliCDBRunRange::Infinity());
d3a9c52a 92 storage->Put(array,id,md);
93 }
b355f61e 94
95 array->Delete();
96
97}