]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/MakeITSZeroMisAlignment.C
AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / ITS / MakeITSZeroMisAlignment.C
1 void MakeITSZeroMisAlignment(){
2   // Create TClonesArray of zero misalignment objects for ITS
3   //
4   TClonesArray *array = new TClonesArray("AliAlignObjParams",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   AliAlignObjParams a;
16
17   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0., globalZ=0.;
18   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; 
19
20   Int_t j = 0;
21
22   new(alobj[j]) AliAlignObjParams("ITS", 0, dx, dy, globalZ, dpsi, dtheta, dphi, kTRUE);
23   j++;
24
25   for ( Int_t l = AliGeomManager::kSPD1; l <= AliGeomManager::kSSD2; l++) {
26     
27     printf("%i modules in layer %i\n", AliGeomManager::LayerSize(l), l);
28     for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(l); iModule++) {
29
30       iLayer = AliGeomManager::kInvalidLayer; 
31
32       switch (l) {
33       case 1: {
34         iLayer = AliGeomManager::kSPD1;
35       }; break;
36       case 2: {
37         iLayer = AliGeomManager::kSPD2;
38       }; break;
39       case 3: {
40         iLayer = AliGeomManager::kSDD1;
41       }; break;
42       case 4: {
43         iLayer = AliGeomManager::kSDD2;
44       }; break;
45       case 5: {
46         iLayer = AliGeomManager::kSSD1;
47       }; break;
48       case 6: {
49         iLayer = AliGeomManager::kSSD2;
50       }; break;
51       default: Printf("Wrong layer index in ITS (%d) !",l);
52       };
53       UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
54       const char *symname = AliGeomManager::SymName(volid);
55
56       new(alobj[j]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
57       j++;
58
59     }
60   }
61
62   const char* macroname = "MakeITSZeroMisAlignment.C";
63   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
64     // save on file
65     const char* filename = "ITSzeroMisalignment.root";
66     TFile f(filename,"RECREATE");
67     if(!f){
68       Error(macroname,"cannot open file for output\n");
69       return;
70     }
71     Info(macroname,"Saving alignment objects to the file %s", filename);
72     f.cd();
73     f.WriteObject(array,"ITSAlignObjs","kSingleKey");
74     f.Close();
75   }else{
76     // save in CDB storage
77     TString Storage = gSystem->Getenv("STORAGE");
78     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
79       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
80       return;
81     }
82     Info(macroname,"Saving alignment objects in CDB storage %s",
83          Storage.Data());
84     AliCDBManager* cdb = AliCDBManager::Instance();
85     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
86     if(!storage){
87       Error(macroname,"Unable to open storage %s\n",Storage.Data());
88       return;
89     }
90     AliCDBMetaData *md= new AliCDBMetaData();
91     md->SetResponsible("Ludovic Gaudichet");
92     md->SetComment("Alignment objects with zero ITS misalignment");
93     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
94     AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
95     storage->Put(array,id, md);
96   }
97
98   array->Delete();
99
100 }
101
102