AliRoot Core  edcc906 (edcc906)
SetOCDBFromRun1.C
Go to the documentation of this file.
1 
12 #if !defined(__CINT__)
13 #include <TSystem.h>
14 #include <TString.h>
15 #include <TGrid.h>
16 
17 #include <Riostream.h>
18 
19 #include "AliEMCALGeometry.h"
20 #include "AliEMCALCalibData.h"
21 
22 #include "AliCDBManager.h"
23 #include "AliCDBStorage.h"
24 #include "AliCDBEntry.h"
25 #endif
26 
33 void SetOCDBFromRun1(Int_t year = 2010, Bool_t printAll = kFALSE)
34 {
35  TGrid::Connect("alien://");
36 
37  Int_t run = 182325; //2012
38  if(year == 2010) run = 134908;
39  if(year == 2011) run = 159582;
40 
42  man->SetDefaultStorage("raw://");
43  man->SetRun(run);
44  AliCDBStorage *storage = man->GetDefaultStorage();
45 
46  // Instantiate EMCAL geometry for the first time
48  if (year == 2010) geom = AliEMCALGeometry::GetInstance("EMCAL_FIRSTYEARV1"); // 2010
49  else geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1"); // 2011-2012-2013
50 //else geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM"); // Run2
51 
52  const Int_t nSM = geom->GetNumberOfSuperModules();
53 
54  // Get the final OCDB object
55 
56  AliEMCALCalibData* cparam = (AliEMCALCalibData*) (storage->Get("EMCAL/Calib/Data", run)->GetObject());
57 
58  // Access OCDB file with the first version of the calibration
59  TString first = "Run177115_999999999_v2_s0.root";
60  if(year==2010) first = "Run113461_999999999_v3_s0.root";
61  if(year==2011) first = "Run144484_999999999_v3_s0.root";
62 
63  TFile * f = TFile::Open(Form("alien:///alice/data/%d/OCDB/EMCAL/Calib/Data/%s",year,first.Data()),"READ");
64  AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry");
65  AliEMCALCalibData* cparam1 = (AliEMCALCalibData*) cdb->GetObject();
66 
67  // New OCDB container
68  AliEMCALCalibData *cparamnew=new AliEMCALCalibData("EMCAL");
69 
70  // Do the comparison
71  Float_t param = -1;
72  Float_t param1 = -1;
73  Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1;
74  for(Int_t i=0;i < nSM*24*48; i++)
75  {
76  //printf("AbsID %d\n",i);
77  geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta);
78  geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol);
79 
80  Float_t param = -1;
81  if( cparam ) param = cparam ->GetADCchannel(iSM,iCol,iRow);
82 
83  Float_t param1 = -1;
84  if( cparam1 ) param1 = cparam1->GetADCchannel(iSM,iCol,iRow);
85 
86  if (printAll)
87  printf("ID %d, col %d, row %d, sm %d final %1.4f, first %1.4f\n",
88  i,iCol,iRow,iSM,param, param1);
89  cparamnew->SetADCchannel (iSM,iCol,iRow,param );
90  cparamnew->SetADCchannelOnline(iSM,iCol,iRow,param1);
91  }
92 
93  // Create OCDB File
94  AliCDBMetaData md;
95  md.SetComment("Calibration after calibration with pi0, store also first online calibration");
96  md.SetBeamPeriod(0);
97  md.SetResponsible("Gustavo Conesa");
98  md.SetAliRootVersion(gSystem->Getenv("ARVERSION"));
99 
100  // Careful, select here the first run where this calibration is valid
101  Int_t firstRun = 172439; // 2012-13
102  if(year == 2010) firstRun = 113461;
103  if(year == 2011) firstRun = 144484;
104 
105  AliCDBId id("EMCAL/Calib/Data",firstRun,AliCDBRunRange::Infinity()); // create in EMCAL/Calib/Data DBFolder
106 
108  AliCDBStorage* loc = man2->GetStorage(Form("local://%d",year));
109  loc->Put(cparamnew, id, &md);
110 }
111 
112 
void SetADCchannel(Int_t module, Int_t column, Int_t row, Float_t value)
AliCDBEntry * Get(const AliCDBId &query)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TFile * Open(const char *filename, Long64_t &nevents)
Bool_t Put(TObject *object, AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate)
void SetOCDBFromRun1(Int_t year=2010, Bool_t printAll=kFALSE)
Int_t year
year for detector configuration
Definition: Config.C:96
void SetComment(const char *comment)
Int_t GetNumberOfSuperModules(void) const
void SetResponsible(const char *yourName)
Cell energy calibration factors container class.
void GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, Int_t &iphi, Int_t &ieta) const
TObject * GetObject()
Definition: AliCDBEntry.h:56
AliCDBStorage * GetStorage(const char *dbString)
void SetBeamPeriod(UInt_t period)
Bool_t GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi, Int_t &nIeta) const
void SetAliRootVersion(const char *version)
void SetRun(Int_t run)
Definition: AliCDBEntry.h:18
TF1 * f
Definition: interpolTest.C:21
void SetDefaultStorage(const char *dbString)
Float_t GetADCchannel(Int_t module, Int_t column, Int_t row) const
AliCDBStorage * GetDefaultStorage() const
Definition: AliCDBManager.h:61
static AliEMCALGeometry * GetInstance()
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
TEveGeoShape * geom
Definition: tpc_tracks.C:10
void SetADCchannelOnline(Int_t module, Int_t column, Int_t row, Float_t value)
static Int_t Infinity()
EMCal geometry, singleton.