AliPhysics  754e963 (754e963)
anaTree.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 <TDatime.h>
6 #include <TFile.h>
7 #include <TGraphErrors.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 <TProfile2D.h>
16 #include <TSystem.h>
17 #include "createTree.C"
18 #endif
19 
20 void anaTree(const char *ifile="treefile.root", const char *ofile="outhist.root")
21 {
22  AliEMCALGeometry *g=AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM");
23  const Int_t kSM=g->GetNumberOfSuperModules();
24  const Int_t kNcells=g->GetNCells();
25  const Int_t gain = 1;
26 
27  TCalInfo *info = 0;
28  TFile *in = TFile::Open(ifile,"read");
29  TTree *tt = (TTree*)in->Get("tcal");
30  tt->SetBranchAddress("event",&info);
31  tt->Branch("event", &info, 32000, 99);
32 
33  TProfile *gLedVsT[20];
34  TProfile *gRatVsT[20];
35  for (Int_t i=0;i<20;++i) {
36  gLedVsT[i] = new TProfile("","Led info;T;",1000,10,50);
37  gLedVsT[i]->SetMarkerStyle(20);
38  gLedVsT[i]->SetMarkerSize(1.2);
39  gLedVsT[i]->SetMarkerColor(1);
40  gLedVsT[i]->SetLineColor(1);
41  gLedVsT[i]->SetLineWidth(3);
42  gLedVsT[i]->SetName(Form("ledsm%d",i));
43  gRatVsT[i] = new TProfile("","Led/LedMon;T",1000,10,50);
44  gRatVsT[i]->SetMarkerStyle(20);
45  gRatVsT[i]->SetMarkerSize(1.2);
46  gRatVsT[i]->SetMarkerColor(1);
47  gRatVsT[i]->SetLineColor(1);
48  gRatVsT[i]->SetLineWidth(3);
49  gRatVsT[i]->SetName(Form("ledovermonsm%d",i));
50  }
51 
52  TProfile *gLedCellVsT[kNcells+1];
53  TProfile *gRatCellVsT[kNcells+1];
54 
55  for (Int_t j=0;j<kNcells+1;++j) {
56  gLedCellVsT[j] = new TProfile("",Form("Led info cell ID%i ;T;",j),1000,10,50);
57  gLedCellVsT[j]->SetMarkerStyle(20);
58  gLedCellVsT[j]->SetMarkerSize(1.2);
59  gLedCellVsT[j]->SetMarkerColor(1);
60  gLedCellVsT[j]->SetLineColor(1);
61  gLedCellVsT[j]->SetLineWidth(3);
62  gLedCellVsT[j]->SetName(Form("ledCell%d",j));
63  gRatCellVsT[j] = new TProfile("",Form("Led/LedMon cell ID%i ;T;",j),1000,10,50);
64  gRatCellVsT[j]->SetMarkerStyle(20);
65  gRatCellVsT[j]->SetMarkerSize(1.2);
66  gRatCellVsT[j]->SetMarkerColor(1);
67  gRatCellVsT[j]->SetLineColor(1);
68  gRatCellVsT[j]->SetLineWidth(3);
69  gRatCellVsT[j]->SetName(Form("ledovermonCell%d",j));
70  }
71 
72 
73  Int_t Nev=tt->GetEntries();
74  for (Int_t i=0;i<Nev;++i) {
75  tt->GetEvent(i);
76  cout << info->fRunNo << endl;
77  TClonesArray &cells = info->fCells;
78  for (Int_t j=0;j<cells.GetEntries();++j) {
79  TCalCell *cell = static_cast<TCalCell*>(cells.At(j));
80  Int_t cellID = cell->fId;
81  Int_t sm = cell->fSM;
82  Double_t ledM = cell->fLedM;
83  Double_t ledR = cell->fLedR;
84  Double_t monM = cell->fMonM;
85  Double_t monR = cell->fMonR;
86  Double_t locT = cell->fLocT;
87  Double_t smT = cell->fSMT;
88 
89  Double_t T = smT; // use local or SM T, change here
90  if ((T<5)||(T>45))
91  continue;
92  if ((ledM<=0)||(ledR<=0))
93  continue;
94  Double_t w = ledR;
95  TProfile *h = gLedVsT[sm];
96  h->Fill(T,ledM,w);
97  gLedCellVsT[cellID]->Fill(locT,ledM,w);
98  if ((monM<=0)||(monR<=0))
99  continue;
100  Double_t w2=TMath::Sqrt(ledR*ledR+monM*monM);
101  TProfile *h2 = gRatVsT[sm];
102  h2->Fill(T,ledM/monM,w2);
103  gRatCellVsT[cellID]->Fill(locT,ledM/monM,w2);
104  }
105  }
106 
107  TFile *out = TFile::Open(ofile,"recreate");
108  if (!out)
109  out = TFile::Open("dummyfile.root","update");
110  for (Int_t i=0;i<20;++i) {
111  gLedVsT[i]->Write();
112  gRatVsT[i]->Write();
113  }
114  for (Int_t j=0;j<kNcells+1;++j) {
115  if (gLedCellVsT[j]->GetEntries() > 0)
116  gLedCellVsT[j]->Write();
117  if (gRatCellVsT[j]->GetEntries() > 0)
118  gRatCellVsT[j]->Write();
119  }
120 
121 }
double Double_t
Definition: External.C:58
Double32_t fSMT
Definition: createTree.C:34
Short_t fId
Definition: createTree.C:25
TClonesArray fCells
Definition: createTree.C:52
void anaTree(const char *ifile="treefile.root", const char *ofile="outhist.root")
Definition: anaTree.C:20
Double32_t fMonM
Definition: createTree.C:31
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
int Int_t
Definition: External.C:63
Short_t fSM
Definition: createTree.C:26
Double32_t fLedR
Definition: createTree.C:30
Double32_t fLocT
Definition: createTree.C:33
Int_t fRunNo
Definition: createTree.C:42
Double32_t fMonR
Definition: createTree.C:32
Double32_t fLedM
Definition: createTree.C:29