]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/MakeEMCALFullMisAlignment.C
fix event range call in rec macro
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALFullMisAlignment.C
1 void MakeEMCALFullMisAlignment(){
2   // Create TClonesArray of full misalignment objects for EMCAL
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
5   TClonesArray &alobj = *array;
6   const char* macroname = "MakeEMCALFullMisAlignment.C";
7
8   // Activate CDB storage and load geometry from CDB
9   AliCDBManager* cdb = AliCDBManager::Instance();
10   if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
11   cdb->SetRun(0);
12   
13   AliCDBStorage* storage;
14   
15   if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
16     TString Storage = gSystem->Getenv("STORAGE");
17     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
18       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
19       return;
20     }
21     storage = cdb->GetStorage(Storage.Data());
22     if(!storage){
23       Error(macroname,"Unable to open storage %s\n",Storage.Data());
24       return;
25     }
26     AliCDBPath path("GRP","Geometry","Data");
27     AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
28     if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
29     entry->SetOwner(0);
30     TGeoManager* geom = (TGeoManager*) entry->GetObject();
31     AliGeomManager::SetGeometry(geom);
32   }else{
33     AliGeomManager::LoadGeometry(); //load geom from default CDB storage
34   }    
35
36   Double_t dx, dy, dz, dpsi, dtheta, dphi;
37   TRandom *rnd   = new TRandom(4321);
38   Double_t sigmatr = 0.1; // max shift in cm w.r.t. local RS
39   Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS
40
41   // null shifts and rotations
42
43   const TString basepath = "EMCAL/FullSupermodule";
44   const TString hbasepath = "EMCAL/HalfSupermodule";
45   TString pathstr;
46
47   Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
48   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
49   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy volume identity
50   Int_t i;
51   Int_t j=0;
52
53   for(i=0; i<10; i++){
54     dx = rnd->Gaus(0.,sigmatr);
55     dy = rnd->Gaus(0.,sigmatr);
56     dz = rnd->Gaus(0.,sigmatr);
57     dpsi = rnd->Gaus(0.,sigmarot);
58     dtheta = rnd->Gaus(0.,sigmarot);
59     dphi = rnd->Gaus(0.,sigmarot);
60     pathstr=basepath;
61     pathstr+=(i+1);
62     cout<<pathstr<<"  "<<dx<<"  "<<dy<<"  "<<dz<<"  "<<dpsi<<"  "<<dtheta<<"  "<<dphi<<"\n";
63     new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
64   }
65
66   for(i=0; i<2; i++){
67     dx = rnd->Gaus(0.,sigmatr);
68     dy = rnd->Gaus(0.,sigmatr);
69     dz = rnd->Gaus(0.,sigmatr);
70     dpsi = rnd->Gaus(0.,sigmarot);
71     dtheta = rnd->Gaus(0.,sigmarot);
72     dphi = rnd->Gaus(0.,sigmarot);
73     pathstr=hbasepath;
74     pathstr+=(i+1);
75     new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
76   }
77
78   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
79     // save on file
80     const char* filename = "EMCALfullMisalignment.root";
81     TFile f(filename,"RECREATE");
82     if(!f){
83       Error(macroname,"cannot open file for output\n");
84       return;
85     }
86     Info(macroname,"Saving alignment objects to the file %s", filename);
87     f.cd();
88     f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
89     f.Close();
90   }else{
91     // save in CDB storage
92     AliCDBMetaData* md = new AliCDBMetaData();
93     md->SetResponsible("Jennifer Clay");
94     md->SetComment("Full misalignment for EMCAL");
95     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
96     AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
97     storage->Put(array,id,md);
98   }
99
100   array->Delete();
101
102 }
103