]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/MakeITSFullMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / ITS / MakeITSFullMisAlignment.C
1 void MakeITSFullMisAlignment(){
2   // Create TClonesArray of full misalignment objects for ITS
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjAngles",4000);
5   TClonesArray &alobj = *array;
6    
7   if(!AliGeomManager::GetGeometry()){
8     if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
9       AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
10       AliCDBManager::Instance()->SetRun(0);
11     AliGeomManager::LoadGeometry();
12   }
13   // needed for the constructors with local coordinates not to fail
14
15   Double_t globalZ = 0.015; // in cm, = 150 microns
16   Double_t mecanicalPrec = 0.0020;
17
18   Double_t resFact = 0.;
19   Double_t spdXY   = 0.0015*resFact;
20   Double_t sddXYZ  = 0.0030*resFact;
21   Double_t ssdXY   = 0.0020*resFact;
22   Double_t rot     = 0.018;
23  
24   Double_t spdZ    = 0.002;
25   Double_t ssdZ    = 0.010;
26
27
28   TRandom *rnd   = new TRandom(65416087);
29   AliAlignObjAngles a;
30
31   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
32
33   Int_t j = 0;
34   new(alobj[j++]) AliAlignObjAngles("ITS", 0, dx, dy, globalZ, dpsi, dtheta, dphi, kTRUE);
35   AliAlignObjAngles* its_alobj = (AliAlignObjAngles*) array->UncheckedAt(0);
36   its_alobj->ApplyToGeometry();
37
38   for ( Int_t l = AliGeomManager::kSPD1; l <= AliGeomManager::kSSD2; l++) {
39     
40     printf("%i modules in layer %i\n", AliGeomManager::LayerSize(l), l);
41     for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(l); iModule++) {
42
43       dpsi   = rnd->Gaus(0., rot);
44       dtheta = rnd->Gaus(0., rot);
45       dphi   = rnd->Gaus(0., rot);
46
47       AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; 
48       switch (l) {
49       case 1: {
50         iLayer = AliGeomManager::kSPD1;
51         dx = rnd->Gaus(0., spdXY + mecanicalPrec);
52         dy = rnd->Gaus(0., spdXY + mecanicalPrec);
53         dz = rnd->Gaus(0., spdZ + mecanicalPrec);
54       }; break;
55       case 2: {
56         iLayer = AliGeomManager::kSPD2;
57         dx = rnd->Gaus(0., spdXY + mecanicalPrec);
58         dy = rnd->Gaus(0., spdXY + mecanicalPrec);
59         dz = rnd->Gaus(0., spdZ + mecanicalPrec);
60       }; break;
61       case 3: {
62         iLayer = AliGeomManager::kSDD1;
63         dx = rnd->Gaus(0., sddXYZ + mecanicalPrec);
64         dy = rnd->Gaus(0., sddXYZ + mecanicalPrec);
65         dz = rnd->Gaus(0., sddXYZ + mecanicalPrec);
66       }; break;
67       case 4: {
68         iLayer = AliGeomManager::kSDD2;
69         dx = rnd->Gaus(0., sddXYZ + mecanicalPrec);
70         dy = rnd->Gaus(0., sddXYZ + mecanicalPrec);
71         dz = rnd->Gaus(0., sddXYZ + mecanicalPrec);
72       }; break;
73       case 5: {
74         iLayer = AliGeomManager::kSSD1;
75         dx = rnd->Gaus(0., ssdXY + mecanicalPrec);
76         dy = rnd->Gaus(0., ssdXY + mecanicalPrec);
77         dz = rnd->Gaus(0., ssdZ + mecanicalPrec);
78       }; break;
79       case 6: {
80         iLayer = AliGeomManager::kSSD2;
81         dx = rnd->Gaus(0., ssdXY + mecanicalPrec);
82         dy = rnd->Gaus(0., ssdXY + mecanicalPrec);
83         dz = rnd->Gaus(0., ssdZ + mecanicalPrec);
84       }; break;
85       default: Printf("Wrong layer index in ITS (%d) !",l);
86       };
87       UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
88       const char *symname = AliGeomManager::SymName(volid);
89
90       new(alobj[j++]) AliAlignObjAngles(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
91
92     }
93   }
94
95   const char* macroname = "MakeITSFullMisAlignment.C";
96   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
97     // save on file
98     const char* filename = "ITSfullMisalignment.root";
99     TFile f(filename,"RECREATE");
100     if(!f){
101       Error(macroname,"cannot open file for output\n");
102       return;
103     }
104     Info(macroname,"Saving alignment objects to the file %s", filename);
105     f.cd();
106     f.WriteObject(array,"ITSAlignObjs","kSingleKey");
107     f.Close();
108   }else{
109     // save in CDB storage
110     TString Storage = gSystem->Getenv("STORAGE");
111     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
112       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
113       return;
114     }
115     Info(macroname,"Saving alignment objects in CDB storage %s",
116          Storage.Data());
117     AliCDBManager* cdb = AliCDBManager::Instance();
118     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
119     if(!storage){
120       Error(macroname,"Unable to open storage %s\n",Storage.Data());
121       return;
122     }
123     AliCDBMetaData *md= new AliCDBMetaData();
124     md->SetResponsible("Ludovic Gaudichet");
125     md->SetComment("Alignment objects with actual ITS misalignment");
126     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
127     AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
128     storage->Put(array,id, md);
129   }
130
131   array->Delete();
132
133 }
134
135
136