AliPhysics  63e47e1 (63e47e1)
rotateTree.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <AliEMCALGeometry.h>
3 #include <AliOADBContainer.h>
4 
5 #include <TCanvas.h>
6 #include <TClonesArray.h>
7 #include <TDatime.h>
8 #include <TFile.h>
9 #include <TGraphErrors.h>
10 #include <TGrid.h>
11 #include <TH2F.h>
12 #include <TLegend.h>
13 #include <TMap.h>
14 #include <TNtuple.h>
15 #include <TObject.h>
16 #include <TProfile.h>
17 #include <TProfile2D.h>
18 #include <TSystem.h>
19 #include <TString.h>
20 #include <TRandom3.h>
21 #include "createTree.C"
22 #endif
23 
24 class TCalRun : public TObject {
25 public:
26  TCalRun() : fLedM(-1), fLedR(-1), fMonM(-1), fMonR(-1), fSMT(-1), fLength(0), fRunNo(-1), fBad(0) {;}
27  virtual ~TCalRun() {;}
28  Double32_t fLedM; //[0,0,16] led mean
29  Double32_t fLedR; //[0,0,16] led rms
30  Double32_t fMonM; //[0,0,16] mon mean
31  Double32_t fMonR; //[0,0,16] mon rms
32  Double32_t fSMT; //[0,0,16] sm T
33  UInt_t fLength; // run length in seconds
34  Int_t fRunNo; // run number
35  Short_t fBad; // bad cell
36  ClassDef(TCalRun, 1); // CalRun class
37 };
38 
39 class TCalCellInfo : public TObject {
40 public:
41  TCalCellInfo() : fCellId(-1), fRuns("TCalRun") {}
42  virtual ~TCalCellInfo() {;}
43  Int_t fCellId; // cell IDs
44  TClonesArray fRuns;
45  ClassDef(TCalCellInfo, 1); // CalCellInfo class
46 };
47 
48 void rotateTree( const char *ifile ="treefile.root",
49  const char *ofile ="treefile.root",
50  Int_t referenceRun = -1
51  ) {
52 
53  // Load EMCAL geometry for reference run
54  AliEMCALGeometry *g = AliEMCALGeometry::GetInstanceFromRunNumber(referenceRun);
55  const Int_t kSM = g->GetNumberOfSuperModules();
56  const Int_t kNcells = g->GetNCells();
57 
58  // initialize info from tree created by $ALICE_PHYSICS/PWGPP/EMCAL/TeCMacros/createTree.C
59  TCalInfo *info = 0;
60  TFile *in = TFile::Open(ifile,"read");
61  TTree *treeRuns = (TTree*)in->Get("tcal");
62  treeRuns->SetBranchAddress("event",&info);
63  treeRuns->Branch("event", &info, 32000, 99);
64  Int_t Nev=treeRuns->GetEntries();
65 
66  TCalCellInfo *cellinfo = new TCalCellInfo;
67  TFile *out = TFile::Open(ofile,"recreate");
68  out->SetCompressionLevel(9);
69  TTree* treeCells = new TTree("tcalcell", "Temp calibration cell tree");
70  treeCells->SetDirectory(out);
71  treeCells->Branch("cells", &cellinfo, 32000, 99);
72  TClonesArray &cRunArr = cellinfo->fRuns;
73 
74 
75  for (Int_t k = 0; k < kNcells; k++){
76  if (k%50 == 0)
77  cout << "starting with cell " << k << "/" << kNcells << endl;
78 
79  cellinfo->fCellId = k;
80 
81  cRunArr.Clear();
82  cRunArr.ExpandCreate(Nev);
83 
84  for (Int_t i=0;i<Nev;++i) {
85  treeRuns->GetEvent(i);
86 
87  TCalRun *run = (TCalRun*)cRunArr.At(i);
88  run->fLength = ((ULong_t)info->fLastTime-(ULong_t)info->fFirstTime); // run length in seconds
89  run->fRunNo = info->fRunNo;
90 
91  TClonesArray &cells = info->fCells;
92  TCalCell *cell = static_cast<TCalCell*>(cells.At(k));
93  if (cell->fId != k){
94  cout << "missmatch for cell " << k << "\t" << cell->fId << endl;
95  continue;
96  }
97  run->fSMT = cell->fSMT;
98  run->fBad = cell->fBad;
99  run->fLedM = cell->fLedM;
100  run->fLedR = cell->fLedR;
101  run->fMonM = cell->fMonM;
102  run->fMonR = cell->fMonR;
103  }
104  treeCells->Fill();
105  }
106  out->cd();
107  treeCells->Write();
108  out->Close();
109 }
Int_t fRunNo
Definition: anaTreeV3.C:34
Short_t fBad
Definition: anaTreeV3.C:35
Double32_t fSMT
Definition: createTree.C:35
Short_t fBad
Definition: createTree.C:29
Double32_t fMonR
Definition: anaTreeV3.C:31
virtual ~TCalRun()
Definition: rotateTree.C:27
UInt_t fFirstTime
Definition: createTree.C:64
Short_t fId
Definition: createTree.C:25
TCalRun()
Definition: rotateTree.C:26
TClonesArray fCells
Definition: createTree.C:70
Double32_t fLedR
Definition: anaTreeV3.C:29
Double32_t fMonM
Definition: createTree.C:32
TClonesArray fRuns
Definition: anaTreeV3.C:44
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
Double32_t fLedR
Definition: createTree.C:31
void rotateTree(const char *ifile="treefile.root", const char *ofile="treefile.root", Int_t referenceRun=-1)
Definition: rotateTree.C:48
Double32_t fSMT
Definition: anaTreeV3.C:32
unsigned long ULong_t
Definition: External.C:38
short Short_t
Definition: External.C:23
UInt_t fLastTime
Definition: createTree.C:65
Double32_t fMonM
Definition: anaTreeV3.C:30
Int_t fRunNo
Definition: createTree.C:62
virtual ~TCalCellInfo()
Definition: rotateTree.C:42
Double32_t fMonR
Definition: createTree.C:33
Double32_t fLedM
Definition: createTree.C:30
UInt_t fLength
Definition: anaTreeV3.C:33
Double32_t fLedM
Definition: anaTreeV3.C:28
Int_t fCellId
Definition: anaTreeV3.C:43