AliRoot Core  edcc906 (edcc906)
MakeEMCALResMisAlignment.C
Go to the documentation of this file.
1 
12 #if !defined(__CINT__)
13 #include <TString.h>
14 #include <TFile.h>
15 #include <TClonesArray.h>
16 #include <TRandom.h>
17 
18 #include "AliRun.h"
19 #include "AliAlignObjParams.h"
20 #include "AliEMCALGeometry.h"
21 #include "AliCDBMetaData.h"
22 #include "AliCDBId.h"
23 #include "AliCDBEntry.h"
24 #include "AliCDBManager.h"
25 #include "AliCDBStorage.h"
26 #endif
27 
33 void MakeEMCALResMisAlignment(TString geoname = "EMCAL_COMPLETE12SMV1_DCAL_8SM")
34 {
35  const char* macroname = "MakeEMCALResMisAlignment.C";
36 
37  if(geoname=="")geoname=AliEMCALGeometry::GetDefaultGeometryName();
38 
39  const AliEMCALGeometry *emcalGeom = AliEMCALGeometry::GetInstance(geoname,"");
40  if(!emcalGeom)
41  {
42  Error("MakeEMCALResMisAlignment","Cannot obtain AliEMCALGeometry singleton\n");
43  return;
44  }
45 
46  TClonesArray *array = new TClonesArray
47  ("AliAlignObjParams",emcalGeom->GetNumberOfSuperModules());
48  TClonesArray &alobj = *array;
49 
50  // Activate CDB storage and load geometry from CDB
52  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
53  cdb->SetRun(0);
54 
55  AliCDBStorage* storage;
56 
57  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") )
58  {
59  TString storageName = gSystem->Getenv("STORAGE");
60  if(!storageName.BeginsWith("local://") && !storageName.BeginsWith("alien://"))
61  {
62  Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",storageName.Data());
63  return;
64  }
65 
66  storage = cdb->GetStorage(storageName.Data());
67  if(!storage)
68  {
69  Error(macroname,"Unable to open storage %s\n",storageName.Data());
70  return;
71  }
72 
73  AliCDBPath path("GRP","Geometry","Data");
74  AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
75  if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
76  entry->SetOwner(0);
77  TGeoManager* geom = (TGeoManager*) entry->GetObject();
79  }
80  else
81  {
82  AliGeomManager::LoadGeometry(); //load geom from default CDB storage
83  }
84 
85  Double_t dx, dy, dz, dpsi, dtheta, dphi;
86 
87  const TString fbasepath = "EMCAL/FullSupermodule";
88  const TString hbasepath = "EMCAL/HalfSupermodule";
89  const TString tbasepath = "EMCAL/OneThrdSupermodule";
90  const TString dbasepath = "EMCAL/DCALSupermodule";
91  const TString debasepath= "EMCAL/DCALExtensionSM";
92  TString pathstr;
93 
94  Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
96  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
97 
98  Int_t i;
99 
100  // RS = local
101  // sigma translation = 1mm
102  // sigma rotation = 0.1 degree
103  TRandom *rnd = new TRandom(4321);
104  Double_t sigmatr = 0.05; // max shift in cm w.r.t. local RS
105  Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS
106 
107  Int_t nSM = emcalGeom->GetEMCGeometry()->GetNumberOfSuperModules();
108  for(i=0; i<nSM; i++)
109  {
110  dx = rnd->Gaus(0.,sigmatr);
111  dy = rnd->Gaus(0.,sigmatr);
112  dz = rnd->Gaus(0.,sigmatr);
113  dpsi = rnd->Gaus(0.,sigmarot);
114  dtheta = rnd->Gaus(0.,sigmarot);
115  dphi = rnd->Gaus(0.,sigmarot);
116 
117  if( emcalGeom->GetSMType(i) == AliEMCALGeometry::kEMCAL_Standard) pathstr=fbasepath;
118  else if(emcalGeom->GetSMType(i) == AliEMCALGeometry::kEMCAL_Half ) pathstr=hbasepath;
119  else if(emcalGeom->GetSMType(i) == AliEMCALGeometry::kEMCAL_3rd ) pathstr=tbasepath;
120  else if(emcalGeom->GetSMType(i) == AliEMCALGeometry::kDCAL_Standard ) pathstr=dbasepath;
121  else if(emcalGeom->GetSMType(i) == AliEMCALGeometry::kDCAL_Ext ) pathstr=debasepath;
122 
123  pathstr+=(i+1);
124  new(alobj[i]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
125  }
126 
127  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") )
128  {
129  // save on file
130  const char* filename = "EMCALresidualMisalignment.root";
131  TFile f(filename,"RECREATE");
132 // if(!f)
133 // {
134 // Error(macroname,"cannot open file for output\n");
135 // return;
136 // }
137 
138  Info(macroname,"Saving alignment objects to the file %s", filename);
139  f.cd();
140  f.WriteObject(array,"EMCALAlignObjs","kSingleKey");
141  f.Close();
142  }
143  else
144  {
145  // save in CDB storage
146  AliCDBMetaData* md = new AliCDBMetaData();
147  md->SetResponsible("Jennifer Klay");
148  md->SetComment("Residual misalignment for EMCAL, produced with sigmatr=0.05 and sigmarot=0.1 in the local RS");
149  md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
150  AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
151  storage->Put(array,id,md);
152  }
153 
154  array->Delete();
155 }
156 
AliCDBEntry * Get(const AliCDBId &query)
void MakeEMCALResMisAlignment(TString geoname="EMCAL_COMPLETE12SMV1_DCAL_8SM")
const TString & GetPath() const
Definition: AliCDBPath.h:38
Bool_t Put(TObject *object, AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate)
Int_t GetRun() const
static const Char_t * GetDefaultGeometryName()
const char * path
void SetComment(const char *comment)
Int_t GetNumberOfSuperModules(void) const
void SetResponsible(const char *yourName)
Int_t GetNumberOfSuperModules() const
TObjArray * array
Definition: AnalyzeLaser.C:12
TObject * GetObject()
Definition: AliCDBEntry.h:56
AliCDBStorage * GetStorage(const char *dbString)
void SetAliRootVersion(const char *version)
static void SetGeometry(TGeoManager *const geom)
Int_t GetSMType(Int_t nSupMod) const
void SetRun(Int_t run)
Definition: AliCDBEntry.h:18
TF1 * f
Definition: interpolTest.C:21
void SetDefaultStorage(const char *dbString)
AliEMCALEMCGeometry * GetEMCGeometry() const
static UShort_t LayerToVolUID(ELayerID layerId, Int_t modId)
void SetOwner(Bool_t owner)
Definition: AliCDBEntry.h:64
static AliEMCALGeometry * GetInstance()
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
TEveGeoShape * geom
Definition: tpc_tracks.C:10
Bool_t IsDefaultStorageSet() const
Definition: AliCDBManager.h:60
static void LoadGeometry(const char *geomFileName=NULL)
static Int_t Infinity()
EMCal geometry, singleton.