AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
[u/mrichter/AliRoot.git] / ITS / MakeITSZeroMisAlignment.C
CommitLineData
d3a9c52a 1void MakeITSZeroMisAlignment(){
2 // Create TClonesArray of zero misalignment objects for ITS
3 //
90dbf5fb 4 TClonesArray *array = new TClonesArray("AliAlignObjParams",4000);
d3a9c52a 5 TClonesArray &alobj = *array;
6
dfe9c69d 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 }
d3a9c52a 13 // needed for the constructors with local coordinates not to fail
14
90dbf5fb 15 AliAlignObjParams a;
d3a9c52a 16
17 Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0., globalZ=0.;
ae079791 18 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
d3a9c52a 19
20 Int_t j = 0;
21
90dbf5fb 22 new(alobj[j]) AliAlignObjParams("ITS", 0, dx, dy, globalZ, dpsi, dtheta, dphi, kTRUE);
d3a9c52a 23 j++;
24
ae079791 25 for ( Int_t l = AliGeomManager::kSPD1; l <= AliGeomManager::kSSD2; l++) {
d3a9c52a 26
ae079791 27 printf("%i modules in layer %i\n", AliGeomManager::LayerSize(l), l);
28 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(l); iModule++) {
d3a9c52a 29
ae079791 30 iLayer = AliGeomManager::kInvalidLayer;
d3a9c52a 31
32 switch (l) {
33 case 1: {
ae079791 34 iLayer = AliGeomManager::kSPD1;
d3a9c52a 35 }; break;
36 case 2: {
ae079791 37 iLayer = AliGeomManager::kSPD2;
d3a9c52a 38 }; break;
39 case 3: {
ae079791 40 iLayer = AliGeomManager::kSDD1;
d3a9c52a 41 }; break;
42 case 4: {
ae079791 43 iLayer = AliGeomManager::kSDD2;
d3a9c52a 44 }; break;
45 case 5: {
ae079791 46 iLayer = AliGeomManager::kSSD1;
d3a9c52a 47 }; break;
48 case 6: {
ae079791 49 iLayer = AliGeomManager::kSSD2;
d3a9c52a 50 }; break;
51 default: Printf("Wrong layer index in ITS (%d) !",l);
52 };
ae079791 53 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
54 const char *symname = AliGeomManager::SymName(volid);
d3a9c52a 55
90dbf5fb 56 new(alobj[j]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
d3a9c52a 57 j++;
58
59 }
60 }
61
dfe9c69d 62 const char* macroname = "MakeITSZeroMisAlignment.C";
5bd470e1 63 if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
d3a9c52a 64 // save on file
dfe9c69d 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();
d3a9c52a 73 f.WriteObject(array,"ITSAlignObjs","kSingleKey");
74 f.Close();
75 }else{
76 // save in CDB storage
dfe9c69d 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 }
d3a9c52a 90 AliCDBMetaData *md= new AliCDBMetaData();
91 md->SetResponsible("Ludovic Gaudichet");
92 md->SetComment("Alignment objects with zero ITS misalignment");
5bd470e1 93 md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
dfe9c69d 94 AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
d3a9c52a 95 storage->Put(array,id, md);
96 }
97
98 array->Delete();
99
100}
101
102