AliPhysics  239578e (239578e)
createTree.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <AliEMCALGeometry.h>
3 #include <TCanvas.h>
4 #include <TClonesArray.h>
5 #include <TClonesArray.h>
6 #include <TDatime.h>
7 #include <TFile.h>
8 #include <TGrid.h>
9 #include <TH2F.h>
10 #include <TLegend.h>
11 #include <TMap.h>
12 #include <TNtuple.h>
13 #include <TObject.h>
14 #include <TProfile.h>
15 #include <TSystem.h>
16 #include "LInfo.h"
17 #include "TInfo.h"
18 #include "plotOCDB_Temperature.C"
19 #include "plotOCDB_LED.C"
20 
21 class TCalCell : public TObject {
22  public:
23  TCalCell() : fLedM(0), fLedR(0), fMonM(0), fMonR(0), fLocT(0), fSMT(0) {;}
24  virtual ~TCalCell() {;}
25  Short_t fId; // cell id
26  Short_t fSM; // super module index
27  Short_t fRow; // row (phi) index
28  Short_t fCol; // col (eta) index
29  Double32_t fLedM; //[0,0,16] led mean
30  Double32_t fLedR; //[0,0,16] led rms
31  Double32_t fMonM; //[0,0,16] mon mean
32  Double32_t fMonR; //[0,0,16] mon rms
33  Double32_t fLocT; //[0,0,16] loc T
34  Double32_t fSMT; //[0,0,16] sm T
35  ClassDef(TCalCell, 1); // CalCell class
36 };
37 
38 class TCalInfo : public TObject {
39  public:
40  TCalInfo() : fRunNo(0), fAvTime(0), fFirstTime(0), fLastTime(0), fMinT(0), fMaxT(0), fFracS(0), fAvgTemp(160), fFracLed(20), fFracMon(20), fCells("TCalCell") {}
41  virtual ~TCalInfo() {;}
42  Int_t fRunNo; // run number
43  UInt_t fAvTime; // average start time
44  UInt_t fFirstTime; // first time
45  UInt_t fLastTime; // last time
46  Float_t fMinT; // min temperature
47  Float_t fMaxT; // max temperature
48  Float_t fFracS; // fraction good sensors
49  TArrayF fAvgTemp; // average temp for each sensor
50  TArrayF fFracLed; // fraction led info for each SM
51  TArrayF fFracMon; // fraction mon info for each SM
52  TClonesArray fCells; // array with cells
53  ClassDef(TCalInfo, 1); // CalInfo class
54 };
55 #endif
56 
57 void createTree(const char *period, const char *ofile="treeout.root",Bool_t doprint=0)
58 {
59  TDraw td(period);
60  td.Compute();
61  LDraw ld(period);
62  ld.Compute();
63 
64  TObjArray *ta = td.GetArray();
65  if (!ta) {
66  cerr << "No time objects for period " << period << endl;
67  return;
68  }
69  TObjArray *la = ld.GetArray();
70  if (!la) {
71  cerr << "No led objects for period " << period << endl;
72  return;
73  }
74 
75  const Int_t rns=la->GetEntries();
76  cout << "Working on period " << period << " with " << rns << " runs" << endl;
77 
78  AliEMCALGeometry *g=AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM");
79  const Int_t kSM=g->GetNumberOfSuperModules();
80  const Int_t kNcells=g->GetNCells();
81  const Int_t gain = 1;
82 
83  TCalInfo *info = new TCalInfo;
84  TFile *out = TFile::Open(ofile,"recreate");
85  out->SetCompressionLevel(9);
86  TTree* fTree = new TTree("tcal", "Temp calibration tree");
87  fTree->SetDirectory(out);
88  fTree->Branch("event", &info, 32000, 99);
89 
90  TClonesArray &carr = info->fCells;
91  Int_t l = 0;
92  Int_t t = 0;
93  for (Int_t i=0;i<rns;++i) {
94  l++;
95  t++;
96  LInfo *linfo = dynamic_cast<LInfo*>(la->At(l));
97  if (!linfo){
98  cout << "skipping due to missing info in LED tree!" << endl;
99  t++;
100  continue;
101  }
102  TInfo *tinfo = dynamic_cast<TInfo*>(ta->At(t));
103  if (!tinfo){
104  cout << "skipping due to missing info in temp tree!" << endl;
105  l++;
106  continue;
107  }
108  Int_t runl = linfo->GetRunNo();
109  Int_t runt = tinfo->GetRunNo();
110  if (runl!=runt) {
111  if (runl > runt){
112  l--;
113  } else {
114  t--;
115  }
116  cout << " Run numbers differ, skipping " << runl << " " << runt << endl;
117  continue;
118  }
119  cout << "Working on run " << runl << endl;
120  gSystem->Sleep(0.5);
121  info->fRunNo = runt;
122  info->fAvTime = tinfo->GetAverageTime();
123  info->fFirstTime = tinfo->GetFirstTime();
124  info->fLastTime = tinfo->GetLastTime();
125  info->fMinT = tinfo->AbsMinT();
126  info->fMaxT = tinfo->AbsMaxT();
127  info->fFracS = tinfo->Fraction();
128  for (Int_t sm=0; sm<kSM; ++sm) {
129  info->fFracLed.SetAt(sm,linfo->FracLeds(sm,gain));
130  info->fFracMon.SetAt(sm,linfo->FracStrips(sm,gain));
131  }
132  for (Int_t n=0; n<160; ++n) {
133  info->fAvgTemp.SetAt(n,tinfo->T(n,3));
134  }
135 
136  Int_t ncells = 0;
137  carr.Clear();
138  carr.ExpandCreate(kNcells);
139 
140  Double_t avg[20];
141  for (Int_t sm=0; sm<kSM; ++sm) {
142  avg[sm]=tinfo->AvgT(sm);
143  }
144 
145  for (Int_t sm=0; sm<kSM; ++sm) {
146  Int_t nrow = g->GetNumberOfCellsInPhiDirection(sm);
147  Int_t ncol = g->GetNumberOfCellsInEtaDirection(sm);
148 
149  TH1 *hmonm = linfo->GetLedMonHist(sm,gain);
150  TH1 *hmonr = linfo->GetLedMonRmsHist(sm,gain);
151  TH2 *hledm = linfo->GetLedHist(sm,gain);
152  TH2 *hledr = linfo->GetLedRmsHist(sm,gain);
153 
154  for (Int_t col=0; col<ncol; ++col) {
155  for (Int_t row=0; row<nrow; ++row) {
156  Int_t id = g->GetAbsCellIdFromCellIndexes(sm,row,col);
157  Int_t ns = TInfo::SensId(sm,row,col);
158  TCalCell *cell = (TCalCell*)carr.At(id);
159  cell->fId = id;
160  cell->fSM = sm;
161  cell->fRow = row;
162  cell->fCol = col;
163  cell->fLedM = hledm->GetBinContent(hledm->FindBin(col,row));
164  cell->fLedR = hledr->GetBinContent(hledr->FindBin(col,row));
165  cell->fMonM = hmonm->GetBinContent(hmonm->FindBin(col/2));
166  cell->fMonR = hmonr->GetBinContent(hmonr->FindBin(col/2));
167  cell->fLocT = tinfo->T(ns,3);
168  cell->fSMT = avg[sm];
169  }
170  }
171  }
172  fTree->Fill();
173  }
174  fTree->Write();
175  out->Close();
176 }
177 
179 {
180  createTree("lhc16f","tree_lhc16f.root");
181  createTree("lhc16g","tree_lhc16g.root");
182  createTree("lhc16h","tree_lhc16h.root");
183  createTree("lhc16i","tree_lhc16i.root");
184  createTree("lhc16j","tree_lhc16j.root");
185  createTree("lhc16k","tree_lhc16k.root");
186  createTree("lhc16l","tree_lhc16g.root");
187  createTree("lhc16o","tree_lhc16g.root");
188  createTree("lhc16p","tree_lhc16g.root");
189  createTree("lhc17p","tree_lhc17p.root");
190  createTree("lhc18d","tree_lhc18d.root");
191 }
double Double_t
Definition: External.C:58
Double32_t fSMT
Definition: createTree.C:34
Double_t FracLeds(Int_t sm, Int_t gain=1) const
Definition: LInfo.cxx:199
TObjArray * GetArray()
Definition: plotOCDB_LED.C:18
UInt_t GetLastTime() const
Definition: TInfo.h:23
Definition: TInfo.h:10
void Compute()
Definition: plotOCDB_LED.C:40
TSystem * gSystem
UInt_t GetAverageTime() const
Definition: TInfo.h:20
Float_t fFracS
Definition: createTree.C:48
UInt_t fFirstTime
Definition: createTree.C:44
TH1 * GetLedMonRmsHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:22
Float_t AbsMaxT(Int_t t=2) const
Definition: TInfo.cxx:23
Short_t fId
Definition: createTree.C:25
TClonesArray fCells
Definition: createTree.C:52
TArrayF fFracMon
Definition: createTree.C:51
Double32_t fMonM
Definition: createTree.C:31
Definition: LInfo.h:13
TH1 * GetLedMonHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:21
virtual ~TCalCell()
Definition: createTree.C:24
int Int_t
Definition: External.C:63
Float_t fMaxT
Definition: createTree.C:47
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
Short_t fRow
Definition: createTree.C:27
Short_t fSM
Definition: createTree.C:26
Double32_t fLedR
Definition: createTree.C:30
Double_t FracStrips(Int_t sm, Int_t gain=1) const
Definition: LInfo.cxx:226
void createTree_all()
Definition: createTree.C:178
Short_t fCol
Definition: createTree.C:28
TH2 * GetLedRmsHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:24
Int_t GetRunNo() const
Definition: LInfo.h:29
UInt_t GetFirstTime() const
Definition: TInfo.h:21
virtual ~TCalInfo()
Definition: createTree.C:41
short Short_t
Definition: External.C:23
void Compute()
TObjArray * GetArray()
UInt_t fAvTime
Definition: createTree.C:43
UInt_t fLastTime
Definition: createTree.C:45
static Int_t SensId(Int_t sm, Int_t row, Int_t col)
Definition: TInfo.cxx:272
Definition: External.C:220
Double32_t fLocT
Definition: createTree.C:33
Int_t fRunNo
Definition: createTree.C:42
Float_t T(Int_t ns, Int_t t) const
Definition: TInfo.cxx:75
TArrayF fAvgTemp
Definition: createTree.C:49
Float_t fMinT
Definition: createTree.C:46
Double32_t fMonR
Definition: createTree.C:32
Float_t AbsMinT(Int_t t=1) const
Definition: TInfo.cxx:10
Double_t Fraction() const
Definition: TInfo.h:28
Float_t AvgT(Int_t sm) const
Definition: TInfo.cxx:36
bool Bool_t
Definition: External.C:53
TCalCell()
Definition: createTree.C:23
TCalInfo()
Definition: createTree.C:40
Double32_t fLedM
Definition: createTree.C:29
Int_t GetRunNo() const
Definition: TInfo.h:25
TH2 * GetLedHist(Int_t sm, Int_t gain=1) const
Definition: LInfo.h:23
TArrayF fFracLed
Definition: createTree.C:50
void createTree(const char *period, const char *ofile="treeout.root", Bool_t doprint=0)
Definition: createTree.C:57
Definition: External.C:196