AliRoot Core  edcc906 (edcc906)
MakeMUONFullMisAlignment.C
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 // $Id$
17 
25 
26 #if !defined(__CINT__) || defined(__MAKECINT__)
27 
30 
31 #include "AliGeomManager.h"
32 #include "AliCDBManager.h"
33 #include "AliCDBStorage.h"
34 #include "AliCDBEntry.h"
35 #include "AliCDBId.h"
36 
37 #include <TSystem.h>
38 #include <TError.h>
39 #include <TClonesArray.h>
40 #include <TString.h>
41 #include <TFile.h>
42 #include <Riostream.h>
43 
44 #endif
45 
46 
48 {
49  const char* macroname = "MakeMUONFullMisAlignment.C";
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 = 0;
56 
57  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
58  TString Storage = gSystem->Getenv("STORAGE");
59  if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
60  Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
61  return;
62  }
63  storage = cdb->GetStorage(Storage.Data());
64  if(!storage){
65  Error(macroname,"Unable to open storage %s\n",Storage.Data());
66  return;
67  }
68  AliCDBPath path("GRP","Geometry","Data");
69  AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
70  if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
71  entry->SetOwner(0);
72  TGeoManager* geom = (TGeoManager*) entry->GetObject();
74  }else{
75  AliGeomManager::LoadGeometry(); //load geom from default CDB storage
76  }
77 
78  AliMUONGeometryTransformer transformer;
79  transformer.LoadGeometryData();
80 
81  AliMUONGeometryMisAligner misAligner(0.0, 0.03, 0.0, 0.03, 0.0, 0.03);
82  AliMUONGeometryTransformer* newTransform
83  = misAligner.MisAlign(&transformer, true);
84  const TClonesArray* array = newTransform->GetMisAlignmentData();
85 
86  // 1 mm resolution for chamber full misalignments?
87  misAligner.SetAlignmentResolution(array,-1,0.1,0.1);
88 
89 
90  if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
91  // Save in file
92  const char* filename = "MUONfullMisalignment.root";
93  TFile f(filename,"RECREATE");
94  if (!f.IsOpen()) {
95  Error(macroname,"cannot open file for output\n");
96  return;
97  }
98  Info(macroname,"Saving alignment objects to the file %s", filename);
99  f.cd();
100  f.WriteObject(array,"MUONAlignObjs","kSingleKey");
101  f.Close();
102  }
103  else {
104  // Save in CDB storage
105  AliCDBMetaData* cdbData = new AliCDBMetaData();
106  cdbData->SetResponsible("Dimuon Offline project");
107  cdbData->SetComment("MUON alignment objects with full misalignment");
108  cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
109  AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity());
110  storage->Put(const_cast<TClonesArray*>(array), id, cdbData);
111  }
112  delete newTransform;
113 }
AliCDBEntry * Get(const AliCDBId &query)
const TString & GetPath() const
Definition: AliCDBPath.h:38
AliMUONGeometryTransformer * MisAlign(const AliMUONGeometryTransformer *transformer, Bool_t verbose=kFALSE)
Bool_t Put(TObject *object, AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate)
Int_t GetRun() const
Bool_t LoadGeometryData(const TString &fileName)
Top container class for geometry transformations.
Class for misalignment of geometry transformations.
const char * path
void SetComment(const char *comment)
void SetResponsible(const char *yourName)
TObjArray * array
Definition: AnalyzeLaser.C:12
void SetAlignmentResolution(const TClonesArray *misAlignArray, Int_t chId=-1, Double_t chResX=-1., Double_t chResY=-1., Double_t deResX=-1., Double_t deResY=-1.)
Set alignment resolution to misalign objects to be stored in CDB.
const TClonesArray * GetMisAlignmentData() const
Return the array of misalignment data.
TObject * GetObject()
Definition: AliCDBEntry.h:56
AliCDBStorage * GetStorage(const char *dbString)
void MakeMUONFullMisAlignment()
void SetAliRootVersion(const char *version)
static void SetGeometry(TGeoManager *const geom)
void SetRun(Int_t run)
Definition: AliCDBEntry.h:18
TF1 * f
Definition: interpolTest.C:21
void SetDefaultStorage(const char *dbString)
void SetOwner(Bool_t owner)
Definition: AliCDBEntry.h:64
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()