]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/MakePMDZeroMisAlignment.C
added verbosity to QA histograms (Yves)
[u/mrichter/AliRoot.git] / PMD / MakePMDZeroMisAlignment.C
1 void MakePMDZeroMisAlignment(){
2   // Create TClonesArray of zero misalignment objects for PMD
3   //
4   // Macro to randomly displace the 4 sectors of the PMD
5   // in each plane. Each sector (to be misaligned) 
6   // of PMD houses the following :
7   // (a) 6 modules of preshower plane
8   // (b) 6 modules of veto plane
9   // (c) The FEE boards on back plane of each module
10   // (d) 6 modules of convertor plates
11   // The clustering is done module-wise
12   // The actual amount displacement will be provided
13   // by the survey data and has to be converted into
14   // displacement in x,y,z,theta, phi and psi 
15   
16   
17   // Now specify the path of the module to be misaligned
18   // as followed in the PMD geant
19   
20   /*
21      _____________
22     |    |        |
23     | 1  |   3    |
24     |    |________|
25     |____|___|    |
26     |        | 2  |
27     |   4    |    |
28     |________|____|
29     
30     // Misalignment Matrix is expected to be
31     // same for sectors 1 and 4 
32     // and for the sectors 2 and 3
33     // As these will be mounted on the same
34     // Steel plate 
35  */
36
37   const char* macroname = "MakePMDZeroMisAlignment.C";
38
39   //Create a TClonesArray of Align Object to store displacement Angles
40   TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
41   TClonesArray &alobj = *array;
42   
43   Int_t iIndex=0; //  let all modules have index=0 in a layer with no LUT
44   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
45   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
46   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
47   Int_t i, j=0;
48
49   for(i=1; i<=4; i++){
50     TString snSector(Form("PMD/Sector%d",i));
51     new(alobj[j++]) AliAlignObjParams(snSector.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
52   }
53
54   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
55     // Create a File to store the alignment data
56     const char* filename = "PMDzeroMisalignment.root";
57     TFile f(filename,"RECREATE");
58     if(!f){
59       Error(macroname,"cannot open file for output\n");
60       return;
61     }
62     Info(macroname,"Saving alignment objects to the file %s", filename);
63     f.cd();
64     f.WriteObject(array,"PMDAlignObjs","kSingleKey");
65     f.Close();
66   }else{
67   // save in CDB storage
68     TString Storage = gSystem->Getenv("STORAGE");
69     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
70       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
71       return;
72     }
73     Info(macroname,"Saving alignment objects in CDB storage %s",
74          Storage.Data());
75     AliCDBManager* cdb = AliCDBManager::Instance();
76     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
77     if(!storage){
78       Error(macroname,"Unable to open storage %s\n",Storage.Data());
79       return;
80     }
81     AliCDBMetaData* md = new AliCDBMetaData();
82     md->SetResponsible("");
83     md->SetComment("Zero misalignment for PMD");
84     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
85     AliCDBId id("PMD/Align/Data",0,AliCDBRunRange::Infinity());
86     storage->Put(array,id,md);
87   }
88   array->Delete();
89
90 }