COLZ.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////
2 // //
3 // Simple COLZ plot using Draw (and basic 1D and 2D plots) //
4 // Because cool 3D COLZ do not work using fill + profCOLZ //
5 // GRRRrrr! //
6 // //
7 // Created by: Diana Patricia Mendez //
8 // 03 March 2016 //
9 ////////////////////////////////////////////////////////////////
10 
11 #include <iostream>
12 #include <TFile.h>
13 #include <TPad.h>
14 #include <TProfile.h>
15 #include <TProfile2D.h>
16 #include <TH1F.h>
17 #include <TH1.h>
18 #include <TH2.h>
19 #include <TH2F.h>
20 #include <TH1D.h>
21 #include <TH2D.h>
22 #include <TH3D.h>
23 #include <TF1.h>
24 #include <TROOT.h>
25 #include <TFile.h>
26 #include <TTree.h>
27 #include <TSystem.h>
28 #include "TChain.h"
29 
30 // ND specifications
31 #define ND_Planes 214
32 #define ND_Cells 344044
33 #define ND_XMin -191
34 #define ND_XMax 192
35 #define ND_YMin -187
36 #define ND_YMax 194
37 #define ND_Z 1587
38 #define ND_ZActive 1270
39 
40 // FD specifications
41 #define FD_Planes 896
42 #define FD_Cells 20192
43 #define FD_XMin -758
44 #define FD_XMax 765
45 #define FD_YMin -749
46 #define FD_YMax 765
47 #define FD_Z 5962
48 #define FD_ZActive 1270
49 
50 // canvas size
51 #define c1_x 700
52 #define c1_y 500
53 
54 #define c2_x 1000
55 #define c2_y 500
56 
57 
58 
59 int main(){
60 
61 
62  gROOT->ForceStyle();
63 
64  TFile* fOut = new TFile("mc.root", "RECREATE");
65 
66  std::cout << "Loading files..." << std::endl;
67  TChain* tInChain = new TChain("muondedxana/fTree");
68 
69  tInChain->Add("mc/*.root");
70 
71  TH1D *hPECellPlaneX;
72  TH1D *hPECellPlaneY;
73  TH1D *hPECorrCellPlaneX;
74  TH1D *hPECorrCellPlaneY;
75  TH1D *hTrueCellPlaneX;
76  TH1D *hTrueCellPlaneY;
77 
78  tInChain ->Draw("PE/path:cell:plane >> hPECellPlaneX(214/2,0,214,96,0,96)","view==0 && (x>100 && x<200)","profcolz");
79  tInChain ->Draw("PE/path:cell:plane >> hPECellPlaneY(214/2,0,214,96,0,96)","view==1 && (x>100 && x<200)","profcolz");
80  tInChain ->Draw("PECorr/path:cell:plane >> hPECorrCellPlaneX(214/2,0,214,96,0,96)","view==0 && (x>100 && x<200)","profcolz");
81  tInChain ->Draw("PECorr/path:cell:plane >> hPECorrCellPlaneY(214/2,0,214,96,0,96)","view==1 && (x>100 && x<200)","profcolz");
82  tInChain ->Draw("trueE/path:cell:plane >> hTrueCellPlaneX(214/2,0,214,96,0,96)","view==0 && (x>100 && x<200)","profcolz");
83  tInChain ->Draw("trueE/path:cell:plane >> hTrueCellPlaneY(214/2,0,214,96,0,96)","view==1 && (x>100 && x<200)","profcolz");
84 
85  hPECellPlaneX -> SetTitle("");
86  hPECellPlaneY -> SetTitle("");
87  hPECorrCellPlaneX -> SetTitle("");
88  hPECorrCellPlaneY -> SetTitle("");
89  hTrueCellPlaneX -> SetTitle("");
90  hTrueCellPlaneY -> SetTitle("");
91 
92 
93  double PE, PECorr, path, w, cell, plane, x, trueE;
94  int hitId, view, totalPlanes;
95 
96  std::cout << "Setting branches" << std::endl;
97  tInChain->SetBranchAddress("PE", &PE);
98  tInChain->SetBranchAddress("PECorr", &PECorr);
99  tInChain->SetBranchAddress("path", &path);
100  tInChain->SetBranchAddress("w", &w);
101  tInChain->SetBranchAddress("cell", &cell);
102  tInChain->SetBranchAddress("plane", &plane);
103  tInChain->SetBranchAddress("view", &view);
104  tInChain->SetBranchAddress("x", &x);
105  tInChain->SetBranchAddress("trueE", &trueE);
106 
107 
108  unsigned int nEntries = tInChain->GetEntries();
109 
110  std::cout << "Defining histograms" << std::endl;
111  TH2D* hPEWX = new TH2D("hPEWX","hPEWX",40,-200,200,50,0,100);
112  TH2D* hPEWY = new TH2D("hPEWY","hPEWY",40,-200,200,50,0,100);
113  TH2D* hPECorrWX = new TH2D("hPECorrWX","hPECorrWX",40,-200,200,50,0,100);
114  TH2D* hPECorrWY = new TH2D("hPECorrWY","hPECorrWY",40,-200,200,50,0,100);
115  TH2D* hTrueWX = new TH2D("hTrueWX","hTrueWX",40,-200,200,100,0,10);
116  TH2D* hTrueWY = new TH2D("hTrueWY","hTrueWY",40,-200,200,100,0,10);
117  TH1D* hWX = new TH1D("hWX","hWX",40,-200,200);
118  TH1D* hWY = new TH1D("hWY","hWY",40,-200,200);
119 
120 
121 
122  TH3D* hPECorrCellPlaneX_test = new TH3D("hPECorrCellPlaneX_test","hPECorrCellPlaneX_test",214/2,0,214,96,0,96,100,0,100);
123  TH3D* hPECorrCellPlaneY_test = new TH3D("hPECorrCellPlaneY_test","hPECorrCellPlaneY_test",214/2,0,214,96,0,96,100,0,100);
124 
125 
126 
127  std::cout << "Filling histograms" << std::endl;
128  for(unsigned int i=0; i<nEntries; i++){
129  tInChain->GetEntry(i);
130 
131  if(x>100 && x<200){
132 
133  if(view==0){
134  hPEWX ->Fill(w,PE/path);
135  hPECorrWX ->Fill(w,PECorr/path);
136  hTrueWX ->Fill(w,trueE/path);
137  hWX ->Fill(w);
138 
139  hPECorrCellPlaneX_test->Fill(plane,cell,PECorr/path);
140 
141  }
142  else if(view==1){
143  hPEWY ->Fill(w,PE/path);
144  hPECorrWY ->Fill(w,PECorr/path);
145  hTrueWY ->Fill(w,trueE/path);
146  hWY ->Fill(w);
147 
148  hPECorrCellPlaneY_test->Fill(plane,cell,PECorr/path);
149 
150  }
151 
152  } // loop over tricells
153 
154  } // loop over entries
155 
156  hPEWX ->SetTitle("");
157  hPEWY ->SetTitle("");
158  hPECorrWX ->SetTitle("");
159  hPECorrWY ->SetTitle("");
160  hTrueWX ->SetTitle("");
161  hTrueWY ->SetTitle("");
162  hWX ->SetTitle("");
163  hWY ->SetTitle("");
164 
165  hPECorrCellPlaneX_test->SetTitle("");
166  hPECorrCellPlaneY_test->SetTitle("");
167 
168 
169  fOut->Write();
170  fOut->Close();
171 
172 }
173 
174 int COLZ(){
175  return main();
176 }
177 
178 
179 
int COLZ()
Definition: COLZ.cxx:174
gargamelle SetTitle("Gargamelle #nu_{e} CC data")
int main()
Definition: COLZ.cxx:59
OStream cout
Definition: OStream.cxx:6
const std::string path
Definition: plot_BEN.C:43
Float_t w
Definition: plot.C:20