CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemCosmicRayQA.cxx
Go to the documentation of this file.
1// **************************************************************************/
2// authors: L. Lavezzi (univ. of Torino & INFN, Italy) - R. Farinelli (INFN Ferrara)
3//
4
5//include system lib
6#include <iostream>
7#include <fstream>
8#include <iomanip>
9#include <string>
10#include <cmath>
11
12// Include files
13#include "GaudiKernel/AlgFactory.h"
14#include "GaudiKernel/DataObject.h"
15#include "GaudiKernel/IEventProcessor.h"
16
17#include "GaudiKernel/Incident.h"
18#include "GaudiKernel/IIncidentSvc.h"
19#include "GaudiKernel/Memory.h"
20
21#include <csignal>
22
23//for save digit & cluster
24#include "GaudiKernel/ISvcLocator.h"
25#include "GaudiKernel/IDataProviderSvc.h"
26#include "GaudiKernel/Bootstrap.h"
27#include "GaudiKernel/RegistryEntry.h"
28#include "GaudiKernel/MsgStream.h"
29
33#include "Identifier/CgemID.h"
34
36#include "RawEvent/DigiEvent.h"
39#include "GaudiKernel/SmartDataPtr.h"
40
42
43#include "CLHEP/Vector/ThreeVector.h"
44
45#include "TMath.h"
46#include "TStyle.h"
47//using namespace std;
48
49CgemCosmicRayQA::CgemCosmicRayQA(const std::string& name, ISvcLocator* pSvcLocator):
50 Algorithm(name,pSvcLocator){
51
52 declareProperty("filename", filename);
53 declareProperty("align_flag", align_flag);
54 // time window
55 declareProperty("minDigiTime", minDigiTime=-8875);
56 declareProperty("maxDigiTime", maxDigiTime=-8562);
57 // selection
58 declareProperty("select_size", select_size=1);
59 // cuts
60 declareProperty("cut_chi2", cut_chi2=200);
61 declareProperty("cut_ene_L1_x", cut_ene_L1_x=10); // fC
62 declareProperty("cut_ene_L1_v", cut_ene_L1_v=10); // fC
63 declareProperty("cut_ene_L2_x", cut_ene_L2_x=10); // fC
64 declareProperty("cut_ene_L2_v", cut_ene_L2_v=10); // fC
65 declareProperty("cut_ene_L3_x", cut_ene_L2_x=10); // fC
66 declareProperty("cut_ene_L3_v", cut_ene_L2_v=10); // fC
67 declareProperty("cut_size_L1_x", cut_size_L1_x=1);
68 declareProperty("cut_size_L1_v", cut_size_L1_v=1);
69 declareProperty("cut_size_L2_x", cut_size_L2_x=1);
70 declareProperty("cut_size_L2_v", cut_size_L2_v=1);
71 declareProperty("cut_size_L3_x", cut_size_L2_x=1);
72 declareProperty("cut_size_L3_v", cut_size_L2_v=1);
73 declareProperty("cut_phi_min_L1", cut_phi_min_L1=0);
74 declareProperty("cut_phi_min_L2", cut_phi_min_L2=0);
75 declareProperty("cut_phi_min_L3", cut_phi_min_L3=0);
76 declareProperty("cut_phi_max_L1", cut_phi_max_L1=180);
77 declareProperty("cut_phi_max_L2", cut_phi_max_L2=180);
78 declareProperty("cut_phi_max_L3", cut_phi_max_L3=180);
79 declareProperty("cut_z_min_L1", cut_z_min_L1=-500);
80 declareProperty("cut_z_min_L2", cut_z_min_L2=-500);
81 declareProperty("cut_z_min_L3", cut_z_min_L3=-500);
82 declareProperty("cut_z_max_L1", cut_z_max_L1=500);
83 declareProperty("cut_z_max_L2", cut_z_max_L2=500);
84 declareProperty("cut_z_max_L3", cut_z_max_L3=500);
85 declareProperty("LUTfile", lutfile = "/bes3fs/cgemCosmic/data/DATA_L1L2L3/lut/cgem_lut_870.root");
86 declareProperty("output_path_tpc", output_path_tpc="plot/");
87 declareProperty("bool_plot_tpc", bool_plot_tpc=false);
88 declareProperty("NSIGMA_INSIDE", NSIGMA_INSIDE=10);
89}
90
92 // delete lutreader;
93}
94
95
96bool CgemCosmicRayQA::read_file(TString name) {
97 cout << "reading " << name << endl;
98 input = new TFile(name, "READ");
99 tree = (TTree*) input->Get("tree");
100
101 cout << "tree " << tree << endl;
102 // hit --------------------------------------------
103 tree->SetBranchAddress("event", &event);
104 tree->SetBranchAddress("nhit", &nhit);
105 // from geometry
106 tree->SetBranchAddress("hit_strip", &hit_strip);
107 tree->SetBranchAddress("hit_view", &hit_view);
108 tree->SetBranchAddress("hit_layer", &hit_layer);
109 tree->SetBranchAddress("hit_sheet", &hit_sheet);
110 tree->SetBranchAddress("hit_length", &hit_length);
111 // from LUT
112 tree->SetBranchAddress("hit_channel", &hit_channel);
113 tree->SetBranchAddress("hit_roc", &hit_roc);
114 tree->SetBranchAddress("hit_feb", &hit_feb);
115 tree->SetBranchAddress("hit_tiger", &hit_tiger);
116 tree->SetBranchAddress("hit_chip", &hit_chip);
117 // from signal
118 tree->SetBranchAddress("hit_t", &hit_t);
119 tree->SetBranchAddress("hit_q", &hit_q);
120 tree->SetBranchAddress("hit_quality", &hit_quality);
121 tree->SetBranchAddress("hit_selgooddigi", &hit_selgooddigi);
122 // µTPC debug
123 tree->SetBranchAddress("hit_x_tpc", &hit_x_tpc);
124 tree->SetBranchAddress("hit_z_tpc", &hit_z_tpc);
125 tree->SetBranchAddress("hit_ex_tpc", &hit_ex_tpc);
126 tree->SetBranchAddress("hit_ez_tpc", &hit_ez_tpc);
127 tree->SetBranchAddress("hit_deltax_tpc", &hit_deltax_tpc);
128 tree->SetBranchAddress("hit_deltaz_tpc", &hit_deltaz_tpc);
129 tree->SetBranchAddress("hit_order", &hit_order);
130
131
132 // cluster ----------------------------------------
133 tree->SetBranchAddress("ncluster", &ncluster);
134 // 1d
135 tree->SetBranchAddress("ncluster_1d", &ncluster_1d);
136 tree->SetBranchAddress("ncluster_1d_L1_S1_x", &ncluster_1d_L1_S1_x);
137 tree->SetBranchAddress("ncluster_1d_L2_S1_x", &ncluster_1d_L2_S1_x);
138 tree->SetBranchAddress("ncluster_1d_L2_S2_x", &ncluster_1d_L2_S2_x);
139 tree->SetBranchAddress("ncluster_1d_L3_S1_x", &ncluster_1d_L3_S1_x);
140 tree->SetBranchAddress("ncluster_1d_L3_S2_x", &ncluster_1d_L3_S2_x);
141 tree->SetBranchAddress("ncluster_1d_L1_S1_v", &ncluster_1d_L1_S1_v);
142 tree->SetBranchAddress("ncluster_1d_L2_S1_v", &ncluster_1d_L2_S1_v);
143 tree->SetBranchAddress("ncluster_1d_L2_S2_v", &ncluster_1d_L2_S2_v);
144 tree->SetBranchAddress("ncluster_1d_L3_S1_v", &ncluster_1d_L3_S1_v);
145 tree->SetBranchAddress("ncluster_1d_L3_S2_v", &ncluster_1d_L3_S2_v);
146 tree->SetBranchAddress("cluster_1d_ID", &cluster_1d_ID);
147 tree->SetBranchAddress("cluster_1d_t", &cluster_1d_t);
148 tree->SetBranchAddress("cluster_1d_q", &cluster_1d_q);
149 tree->SetBranchAddress("cluster_1d_r", &cluster_1d_r);
150 tree->SetBranchAddress("cluster_1d_v", &cluster_1d_v);
151 tree->SetBranchAddress("cluster_1d_v_cc", &cluster_1d_v_cc);
152 tree->SetBranchAddress("cluster_1d_v_tpc", &cluster_1d_v_tpc);
153 tree->SetBranchAddress("cluster_1d_phi", &cluster_1d_phi);
154 tree->SetBranchAddress("cluster_1d_phi_cc", &cluster_1d_phi_cc);
155 tree->SetBranchAddress("cluster_1d_phi_tpc", &cluster_1d_phi_tpc);
156 tree->SetBranchAddress("cluster_1d_layerid", &cluster_1d_layerid);
157 tree->SetBranchAddress("cluster_1d_sheetid", &cluster_1d_sheetid);
158 tree->SetBranchAddress("cluster_1d_view", &cluster_1d_view);
159 tree->SetBranchAddress("cluster_1d_strip1", &cluster_1d_strip1);
160 tree->SetBranchAddress("cluster_1d_strip2", &cluster_1d_strip2);
161 tree->SetBranchAddress("cluster_1d_size", &cluster_1d_size);
162 tree->SetBranchAddress("cluster_1d_slope_tpc", &cluster_1d_slope_tpc);
163 tree->SetBranchAddress("cluster_1d_inter_tpc", &cluster_1d_inter_tpc);
164 tree->SetBranchAddress("cluster_1d_hitindex", cluster_1d_hitindex);
165
166 // 2d
167 tree->SetBranchAddress("ncluster_2d", &ncluster_2d);
168 tree->SetBranchAddress("cluster_2d_t", &cluster_2d_t);
169 tree->SetBranchAddress("cluster_2d_q", &cluster_2d_q);
170 tree->SetBranchAddress("cluster_2d_r", &cluster_2d_r);
171 tree->SetBranchAddress("cluster_2d_z", &cluster_2d_z);
172 tree->SetBranchAddress("cluster_2d_z_cc", &cluster_2d_z_cc);
173 tree->SetBranchAddress("cluster_2d_z_tpc", &cluster_2d_z_tpc);
174 tree->SetBranchAddress("cluster_2d_phi", &cluster_2d_phi);
175 tree->SetBranchAddress("cluster_2d_phi_cc", &cluster_2d_phi_cc);
176 tree->SetBranchAddress("cluster_2d_phi_tpc", &cluster_2d_phi_tpc);
177 tree->SetBranchAddress("cluster_2d_layerid", &cluster_2d_layerid);
178 tree->SetBranchAddress("cluster_2d_sheetid", &cluster_2d_sheetid);
179 tree->SetBranchAddress("cluster_2d_view", &cluster_2d_view);
180 tree->SetBranchAddress("cluster_2d_idx", &cluster_2d_idx);
181 tree->SetBranchAddress("cluster_2d_idv", &cluster_2d_idv);
182 tree->SetBranchAddress("cluster_2d_highest", &cluster_2d_highest);
183
184 // track ------------------------------------------
185 // parameters
186 tree->SetBranchAddress("track_dr", &track_dr);
187 tree->SetBranchAddress("track_phi0", &track_phi0);
188 tree->SetBranchAddress("track_dz", &track_dz);
189 tree->SetBranchAddress("track_tanL", &track_tanL);
190 tree->SetBranchAddress("track_chi2", &track_chi2);
191 // clusters
192 tree->SetBranchAddress("track_nfitpoint", &track_nfitpoint);
193 tree->SetBranchAddress("track_clusterid", &track_clusterid);
194 tree->SetBranchAddress("track_layerid", &track_layerid);
195 tree->SetBranchAddress("track_sheetid", &track_sheetid);
196 // layer/sheet under test (if none these are -1)
197 tree->SetBranchAddress("track_test_layerid", &track_test_layerid);
198 tree->SetBranchAddress("track_test_sheetid", &track_test_sheetid);
199 // poca
200 tree->SetBranchAddress("track_xpoca_glo", &track_xpoca_glo);
201 tree->SetBranchAddress("track_ypoca_glo", &track_ypoca_glo);
202 tree->SetBranchAddress("track_zpoca_glo", &track_zpoca_glo);
203 // intersections
204 // L1
205 tree->SetBranchAddress("track_x1top_glo", &track_x1top_glo);
206 tree->SetBranchAddress("track_y1top_glo", &track_y1top_glo);
207 tree->SetBranchAddress("track_z1top_glo", &track_z1top_glo);
208 tree->SetBranchAddress("track_phi1top_loc", &track_phi1top_loc);
209 tree->SetBranchAddress("track_v1top_loc", &track_v1top_loc);
210 tree->SetBranchAddress("track_x1bot_glo", &track_x1bot_glo);
211 tree->SetBranchAddress("track_y1bot_glo", &track_y1bot_glo);
212 tree->SetBranchAddress("track_z1bot_glo", &track_z1bot_glo);
213 tree->SetBranchAddress("track_phi1bot_loc", &track_phi1bot_loc);
214 tree->SetBranchAddress("track_v1bot_loc", &track_v1bot_loc);
215 // L2
216 tree->SetBranchAddress("track_x2top_glo", &track_x2top_glo);
217 tree->SetBranchAddress("track_y2top_glo", &track_y2top_glo);
218 tree->SetBranchAddress("track_z2top_glo", &track_z2top_glo);
219 tree->SetBranchAddress("track_phi2top_loc", &track_phi2top_loc);
220 tree->SetBranchAddress("track_v2top_loc", &track_v2top_loc);
221 tree->SetBranchAddress("track_x2bot_glo", &track_x2bot_glo);
222 tree->SetBranchAddress("track_y2bot_glo", &track_y2bot_glo);
223 tree->SetBranchAddress("track_z2bot_glo", &track_z2bot_glo);
224 tree->SetBranchAddress("track_phi2bot_loc", &track_phi2bot_loc);
225 tree->SetBranchAddress("track_v2bot_loc", &track_v2bot_loc);
226 // L3
227 tree->SetBranchAddress("track_x3top_glo", &track_x3top_glo);
228 tree->SetBranchAddress("track_y3top_glo", &track_y3top_glo);
229 tree->SetBranchAddress("track_z3top_glo", &track_z3top_glo);
230 tree->SetBranchAddress("track_phi3top_loc", &track_phi3top_loc);
231 tree->SetBranchAddress("track_v3top_loc", &track_v3top_loc);
232 tree->SetBranchAddress("track_x3bot_glo", &track_x3bot_glo);
233 tree->SetBranchAddress("track_y3bot_glo", &track_y3bot_glo);
234 tree->SetBranchAddress("track_z3bot_glo", &track_z3bot_glo);
235 tree->SetBranchAddress("track_phi3bot_loc", &track_phi3bot_loc);
236 tree->SetBranchAddress("track_v3bot_loc", &track_v3bot_loc);
237
238
239 // Intersection angles
240 // L1
241 tree->SetBranchAddress("ang_xy_L1", &ang_xy_L1);
242 tree->SetBranchAddress("ang_yz_L1", &ang_yz_L1);
243 // L2
244 tree->SetBranchAddress("ang_xy_L2", &ang_xy_L2);
245 tree->SetBranchAddress("ang_yz_L2", &ang_yz_L2);
246 //L3
247 tree->SetBranchAddress("ang_xy_L3", &ang_xy_L3);
248 tree->SetBranchAddress("ang_yz_L3", &ang_yz_L3);
249
250
251 // ------------------------------------------------
252 return true;
253}
254
256
257 output = new TFile("histo.root", "RECREATE");
258}
259
260
262 cout << "define_hit_histo" << endl;
263
264 double hit_mintime = -10000;
265 double hit_maxtime = -8000;
266 double hit_maxcharge = 70;
267
268 TString dname = "hit_histo";
269 output->mkdir(dname, "histograms for all the hits");
270 output->cd(dname);
271
272 // nof hits
273 // x
274 h_nofhit_L1_S1_x = new TH1F("h_nofhit_L1_S1_x", "number of hits in L1, S1, x view", MAXNOFHITS, 0, MAXNOFHITS);
275 h_nofhit_L1_S2_x = new TH1F("h_nofhit_L1_S2_x", "number of hits in L1, S2, x view", MAXNOFHITS, 0, MAXNOFHITS);
276 h_nofhit_L2_S1_x = new TH1F("h_nofhit_L2_S1_x", "number of hits in L2, S1, x view", MAXNOFHITS, 0, MAXNOFHITS);
277 h_nofhit_L2_S2_x = new TH1F("h_nofhit_L2_S2_x", "number of hits in L2, S2, x view", MAXNOFHITS, 0, MAXNOFHITS);
278 h_nofhit_L3_S1_x = new TH1F("h_nofhit_L3_S1_x", "number of hits in L3, S1, x view", MAXNOFHITS, 0, MAXNOFHITS);
279 h_nofhit_L3_S2_x = new TH1F("h_nofhit_L3_S2_x", "number of hits in L3, S2, x view", MAXNOFHITS, 0, MAXNOFHITS);
280
281 // v
282 h_nofhit_L1_S1_v = new TH1F("h_nofhit_L1_S1_v", "number of hits in L1, S1, v view", MAXNOFHITS, 0, MAXNOFHITS);
283 h_nofhit_L2_S1_v = new TH1F("h_nofhit_L2_S1_v", "number of hits in L2, S1, v view", MAXNOFHITS, 0, MAXNOFHITS);
284 h_nofhit_L2_S2_v = new TH1F("h_nofhit_L2_S2_v", "number of hits in L2, S2, v view", MAXNOFHITS, 0, MAXNOFHITS);
285 h_nofhit_L3_S1_v = new TH1F("h_nofhit_L3_S1_v", "number of hits in L3, S1, v view", MAXNOFHITS, 0, MAXNOFHITS);
286 h_nofhit_L3_S2_v = new TH1F("h_nofhit_L3_S2_v", "number of hits in L3, S2, v view", MAXNOFHITS, 0, MAXNOFHITS);
287
288 // charge
289 // x
290 h_hit_charge_L1_S1_x = new TH1F("h_hit_charge_L1_S1_x", "hit charge (fC) in L1, S1, x view", hit_maxcharge, 0, hit_maxcharge);
291 h_hit_charge_L1_S2_x = new TH1F("h_hit_charge_L1_S2_x", "hit charge (fC) in L1, S2, x view", hit_maxcharge, 0, hit_maxcharge); //???????? perche qui c'è e negli altri no?
292 h_hit_charge_L2_S1_x = new TH1F("h_hit_charge_L2_S1_x", "hit charge (fC) in L2, S1, x view", hit_maxcharge, 0, hit_maxcharge);
293 h_hit_charge_L2_S2_x = new TH1F("h_hit_charge_L2_S2_x", "hit charge (fC) in L2, S2, x view", hit_maxcharge, 0, hit_maxcharge);
294 h_hit_charge_L3_S1_x = new TH1F("h_hit_charge_L3_S1_x", "hit charge (fC) in L3, S1, x view", hit_maxcharge, 0, hit_maxcharge);
295 h_hit_charge_L3_S2_x = new TH1F("h_hit_charge_L3_S2_x", "hit charge (fC) in L3, S2, x view", hit_maxcharge, 0, hit_maxcharge);
296
297 // v
298 h_hit_charge_L1_S1_v = new TH1F("h_hit_charge_L1_S1_v", "hit charge (fC) in L1, S1, v view", hit_maxcharge, 0, hit_maxcharge);
299 h_hit_charge_L2_S1_v = new TH1F("h_hit_charge_L2_S1_v", "hit charge (fC) in L2, S1, v view", hit_maxcharge, 0, hit_maxcharge);
300 h_hit_charge_L2_S2_v = new TH1F("h_hit_charge_L2_S2_v", "hit charge (fC) in L2, S2, v view", hit_maxcharge, 0, hit_maxcharge);
301 h_hit_charge_L3_S1_v = new TH1F("h_hit_charge_L3_S1_v", "hit charge (fC) in L3, S1, v view", hit_maxcharge, 0, hit_maxcharge);
302 h_hit_charge_L3_S2_v = new TH1F("h_hit_charge_L3_S2_v", "hit charge (fC) in L3, S2, v view", hit_maxcharge, 0, hit_maxcharge);
303
304 // time
305 // x
306 h_hit_time_L1_S1_x = new TH1F("h_hit_time_L1_S1_x", "hit time (ns) in L1, S1, x view", 500, hit_mintime, hit_maxtime);
307 h_hit_time_L1_S2_x = new TH1F("h_hit_time_L1_S2_x", "hit time (ns) in L1, S2, x view", 500, hit_mintime, hit_maxtime); //idem
308 h_hit_time_L2_S1_x = new TH1F("h_hit_time_L2_S1_x", "hit time (ns) in L2, S1, x view", 500, hit_mintime, hit_maxtime);
309 h_hit_time_L2_S2_x = new TH1F("h_hit_time_L2_S2_x", "hit time (ns) in L2, S2, x view", 500, hit_mintime, hit_maxtime);
310 h_hit_time_L3_S1_x = new TH1F("h_hit_time_L3_S1_x", "hit time (ns) in L3, S1, x view", 500, hit_mintime, hit_maxtime);
311 h_hit_time_L3_S2_x = new TH1F("h_hit_time_L3_S2_x", "hit time (ns) in L3, S2, x view", 500, hit_mintime, hit_maxtime);
312 // v
313 h_hit_time_L1_S1_v = new TH1F("h_hit_time_L1_S1_v", "hit time (ns) in L1, S1, v view", 500, hit_mintime, hit_maxtime);
314 h_hit_time_L2_S1_v = new TH1F("h_hit_time_L2_S1_v", "hit time (ns) in L2, S1, v view", 500, hit_mintime, hit_maxtime);
315 h_hit_time_L2_S2_v = new TH1F("h_hit_time_L2_S2_v", "hit time (ns) in L2, S2, v view", 500, hit_mintime, hit_maxtime);
316 h_hit_time_L3_S1_v = new TH1F("h_hit_time_L3_S1_v", "hit time (ns) in L3, S1, v view", 500, hit_mintime, hit_maxtime);
317 h_hit_time_L3_S2_v = new TH1F("h_hit_time_L3_S2_v", "hit time (ns) in L3, S2, v view", 500, hit_mintime, hit_maxtime);
318
319 // charge vs strip ID
320 // x
321 h_hit_charge_vs_strip_L1_S1_x = new TH2F("h_hit_charge_vs_strip_L1_S1_x", "hit charge (fC) vs stripID in L1, S1, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x, hit_maxcharge, 0, hit_maxcharge);
322 h_hit_charge_vs_strip_L1_S2_x = new TH2F("h_hit_charge_vs_strip_L1_S2_x", "hit charge (fC) vs stripID in L1, S2, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x, hit_maxcharge, 0, hit_maxcharge);
323 h_hit_charge_vs_strip_L2_S1_x = new TH2F("h_hit_charge_vs_strip_L2_S1_x", "hit charge (fC) vs stripID in L2, S1, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x, hit_maxcharge, 0, hit_maxcharge);
324 h_hit_charge_vs_strip_L2_S2_x = new TH2F("h_hit_charge_vs_strip_L2_S2_x", "hit charge (fC) vs stripID in L2, S2, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x, hit_maxcharge, 0, hit_maxcharge);
325 h_hit_charge_vs_strip_L3_S1_x = new TH2F("h_hit_charge_vs_strip_L3_S1_x", "hit charge (fC) vs stripID in L3, S1, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x, hit_maxcharge, 0, hit_maxcharge);
326 h_hit_charge_vs_strip_L3_S2_x = new TH2F("h_hit_charge_vs_strip_L3_S2_x", "hit charge (fC) vs stripID in L3, S2, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x, hit_maxcharge, 0, hit_maxcharge);
327 // v
328 h_hit_charge_vs_strip_L1_S1_v = new TH2F("h_hit_charge_vs_strip_L1_S1_v", "hit charge (fC) vs stripID in L1, S1, v view", MAXNOFSTRIP_L1_v, 0, MAXNOFSTRIP_L1_v, hit_maxcharge, 0, hit_maxcharge);
329 h_hit_charge_vs_strip_L2_S1_v = new TH2F("h_hit_charge_vs_strip_L2_S1_v", "hit charge (fC) vs stripID in L2, S1, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v, hit_maxcharge, 0, hit_maxcharge);
330 h_hit_charge_vs_strip_L2_S2_v = new TH2F("h_hit_charge_vs_strip_L2_S2_v", "hit charge (fC) vs stripID in L2, S2, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v, hit_maxcharge, 0, hit_maxcharge);
331 h_hit_charge_vs_strip_L3_S1_v = new TH2F("h_hit_charge_vs_strip_L3_S1_v", "hit charge (fC) vs stripID in L3, S1, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v, hit_maxcharge, 0, hit_maxcharge);
332 h_hit_charge_vs_strip_L3_S2_v = new TH2F("h_hit_charge_vs_strip_L3_S2_v", "hit charge (fC) vs stripID in L3, S2, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v, hit_maxcharge, 0, hit_maxcharge);
333
334 // time vs strip ID
335 // x
336 h_hit_time_vs_strip_L1_S1_x = new TH2F("h_hit_time_vs_strip_L1_S1_x", "hit time (ns) vs stripID in L1, S1, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x, 500, hit_mintime, hit_maxtime);
337 h_hit_time_vs_strip_L1_S2_x = new TH2F("h_hit_time_vs_strip_L1_S2_x", "hit time (ns) vs stripID in L1, S2, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x, 500, hit_mintime, hit_maxtime);
338 h_hit_time_vs_strip_L2_S1_x = new TH2F("h_hit_time_vs_strip_L2_S1_x", "hit time (ns) vs stripID in L2, S1, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x, 500, hit_mintime, hit_maxtime);
339 h_hit_time_vs_strip_L2_S2_x = new TH2F("h_hit_time_vs_strip_L2_S2_x", "hit time (ns) vs stripID in L2, S2, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x, 500, hit_mintime, hit_maxtime);
340 h_hit_time_vs_strip_L3_S1_x = new TH2F("h_hit_time_vs_strip_L3_S1_x", "hit time (ns) vs stripID in L3, S1, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x, 500, hit_mintime, hit_maxtime);
341 h_hit_time_vs_strip_L3_S2_x = new TH2F("h_hit_time_vs_strip_L3_S2_x", "hit time (ns) vs stripID in L3, S2, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x, 500, hit_mintime, hit_maxtime);
342 // v
343 h_hit_time_vs_strip_L1_S1_v = new TH2F("h_hit_time_vs_strip_L1_S1_v", "hit time (ns) vs stripID in L1, S1, v view", MAXNOFSTRIP_L1_v, 0, MAXNOFSTRIP_L1_v, 500, hit_mintime, hit_maxtime);
344 h_hit_time_vs_strip_L2_S1_v = new TH2F("h_hit_time_vs_strip_L2_S1_v", "hit time (ns) vs stripID in L2, S1, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v, 500, hit_mintime, hit_maxtime);
345 h_hit_time_vs_strip_L2_S2_v = new TH2F("h_hit_time_vs_strip_L2_S2_v", "hit time (ns) vs stripID in L2, S2, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v, 500, hit_mintime, hit_maxtime);
346 h_hit_time_vs_strip_L3_S1_v = new TH2F("h_hit_time_vs_strip_L3_S1_v", "hit time (ns) vs stripID in L3, S1, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v, 500, hit_mintime, hit_maxtime);
347 h_hit_time_vs_strip_L3_S2_v = new TH2F("h_hit_time_vs_strip_L3_S2_v", "hit time (ns) vs stripID in L3, S2, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v, 500, hit_mintime, hit_maxtime);
348
349 // charge vs time
350 // x
351 h_hit_charge_vs_time_L1_S1_x = new TH2F("h_hit_charge_vs_time_L1_S1_x", "hit charge (fC) vs time (ns) in L1, S1, x view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
352 h_hit_charge_vs_time_L1_S2_x = new TH2F("h_hit_charge_vs_time_L1_S2_x", "hit charge (fC) vs time (ns) in L1, S2, x view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
353 h_hit_charge_vs_time_L2_S1_x = new TH2F("h_hit_charge_vs_time_L2_S1_x", "hit charge (fC) vs time (ns) in L2, S1, x view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
354 h_hit_charge_vs_time_L2_S2_x = new TH2F("h_hit_charge_vs_time_L2_S2_x", "hit charge (fC) vs time (ns) in L2, S2, x view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
355 h_hit_charge_vs_time_L3_S1_x = new TH2F("h_hit_charge_vs_time_L3_S1_x", "hit charge (fC) vs time (ns) in L3, S1, x view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
356 h_hit_charge_vs_time_L3_S2_x = new TH2F("h_hit_charge_vs_time_L3_S2_x", "hit charge (fC) vs time (ns) in L3, S2, x view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
357 // v
358 h_hit_charge_vs_time_L1_S1_v = new TH2F("h_hit_charge_vs_time_L1_S1_v", "hit charge (fC) vs time (ns) in L1, S1, v view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
359 h_hit_charge_vs_time_L2_S1_v = new TH2F("h_hit_charge_vs_time_L2_S1_v", "hit charge (fC) vs time (ns) in L2, S1, v view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
360 h_hit_charge_vs_time_L2_S2_v = new TH2F("h_hit_charge_vs_time_L2_S2_v", "hit charge (fC) vs time (ns) in L2, S2, v view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
361 h_hit_charge_vs_time_L3_S1_v = new TH2F("h_hit_charge_vs_time_L3_S1_v", "hit charge (fC) vs time (ns) in L3, S1, v view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
362 h_hit_charge_vs_time_L3_S2_v = new TH2F("h_hit_charge_vs_time_L3_S2_v", "hit charge (fC) vs time (ns) in L3, S2, v view", 500, hit_mintime, hit_maxtime, hit_maxcharge, 0, hit_maxcharge);
363
364 // charge vs length
365 // v
366 h_hit_charge_vs_length_L1_S1_v = new TH2F("h_hit_charge_vs_length_L1_S1_v", "hit charge (fC) vs length (mm) in L1, S1, v view", 500, 0, MAXLENGTH_L1_v, hit_maxcharge, 0, hit_maxcharge);
367 h_hit_charge_vs_length_L2_S1_v = new TH2F("h_hit_charge_vs_length_L2_S1_v", "hit charge (fC) vs length (mm) in L2, S1, v view", 500, 0, MAXLENGTH_L2_v, hit_maxcharge, 0, hit_maxcharge);
368 h_hit_charge_vs_length_L2_S2_v = new TH2F("h_hit_charge_vs_length_L2_S2_v", "hit charge (fC) vs length (mm) in L2, S2, v view", 500, 0, MAXLENGTH_L2_v, hit_maxcharge, 0, hit_maxcharge);
369 h_hit_charge_vs_length_L3_S1_v = new TH2F("h_hit_charge_vs_length_L3_S1_v", "hit charge (fC) vs length (mm) in L3, S1, v view", 500, 0, MAXLENGTH_L2_v, hit_maxcharge, 0, hit_maxcharge);
370 h_hit_charge_vs_length_L3_S2_v = new TH2F("h_hit_charge_vs_length_L3_S2_v", "hit charge (fC) vs length (mm) in L3, S2, v view", 500, 0, MAXLENGTH_L2_v, hit_maxcharge, 0, hit_maxcharge);
371
372 output->cd();
373}
374
376 cout << "define_hit_in_time_histo" << endl;
377
378 double hit_mintime = -10000;
379 double hit_maxtime = -8000;
380 double hit_maxcharge = 70;
381
382 TString dname = "hit_in_time_histo";
383 output-> mkdir(dname, "histograms for the hits in time window");
384 output->cd(dname);
385
386 // charge in time
387 // x
388 h_hit_in_time_charge_L1_S1_x = new TH1F("h_hit_in_time_charge_L1_S1_x", "(in time) hit charge (fC) in L1, S1, x view", hit_maxcharge, 0, hit_maxcharge);
389 h_hit_in_time_charge_L1_S2_x = new TH1F("h_hit_in_time_charge_L1_S2_x", "(in time) hit charge (fC) in L1, S2, x view", hit_maxcharge, 0, hit_maxcharge);
390 h_hit_in_time_charge_L2_S1_x = new TH1F("h_hit_in_time_charge_L2_S1_x", "(in time) hit charge (fC) in L2, S1, x view", hit_maxcharge, 0, hit_maxcharge);
391 h_hit_in_time_charge_L2_S2_x = new TH1F("h_hit_in_time_charge_L2_S2_x", "(in time) hit charge (fC) in L2, S2, x view", hit_maxcharge, 0, hit_maxcharge);
392 h_hit_in_time_charge_L3_S1_x = new TH1F("h_hit_in_time_charge_L3_S1_x", "(in time) hit charge (fC) in L3, S1, x view", hit_maxcharge, 0, hit_maxcharge);
393 h_hit_in_time_charge_L3_S2_x = new TH1F("h_hit_in_time_charge_L3_S2_x", "(in time) hit charge (fC) in L3, S2, x view", hit_maxcharge, 0, hit_maxcharge);
394
395 // v
396 h_hit_in_time_charge_L1_S1_v = new TH1F("h_hit_in_time_charge_L1_S1_v", "(in time) hit charge (fC) in L1, S1, v view", hit_maxcharge, 0, hit_maxcharge);
397 h_hit_in_time_charge_L2_S1_v = new TH1F("h_hit_in_time_charge_L2_S1_v", "(in time) hit charge (fC) in L2, S1, v view", hit_maxcharge, 0, hit_maxcharge);
398 h_hit_in_time_charge_L2_S2_v = new TH1F("h_hit_in_time_charge_L2_S2_v", "(in time) hit charge (fC) in L2, S2, v view", hit_maxcharge, 0, hit_maxcharge);
399 h_hit_in_time_charge_L3_S1_v = new TH1F("h_hit_in_time_charge_L3_S1_v", "(in time) hit charge (fC) in L3, S1, v view", hit_maxcharge, 0, hit_maxcharge);
400 h_hit_in_time_charge_L3_S2_v = new TH1F("h_hit_in_time_charge_L3_S2_v", "(in time) hit charge (fC) in L3, S2, v view", hit_maxcharge, 0, hit_maxcharge);
401
402 // count on each strip
403 // x
404 h_hit_in_time_strip_L1_S1_x = new TH1F("h_hit_in_time_strip_L1_S1_x", "(in time) hit counts vs stripID in L1, S1, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x);
405 h_hit_in_time_strip_L1_S2_x = new TH1F("h_hit_in_time_strip_L1_S2_x", "(in time) hit counts vs stripID in L1, S2, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x);
406 h_hit_in_time_strip_L2_S1_x = new TH1F("h_hit_in_time_strip_L2_S1_x", "(in time) hit counts vs stripID in L2, S1, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x);
407 h_hit_in_time_strip_L2_S2_x = new TH1F("h_hit_in_time_strip_L2_S2_x", "(in time) hit counts vs stripID in L2, S2, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x);
408 h_hit_in_time_strip_L3_S1_x = new TH1F("h_hit_in_time_strip_L3_S1_x", "(in time) hit counts vs stripID in L3, S1, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x);
409 h_hit_in_time_strip_L3_S2_x = new TH1F("h_hit_in_time_strip_L3_S2_x", "(in time) hit counts vs stripID in L3, S2, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x);
410
411 // v
412 h_hit_in_time_strip_L1_S1_v = new TH1F("h_hit_in_time_strip_L1_S1_v", "(in time) hit counts vs stripID in L1, S1, v view", MAXNOFSTRIP_L1_v, 0, MAXNOFSTRIP_L1_v);
413 h_hit_in_time_strip_L2_S1_v = new TH1F("h_hit_in_time_strip_L2_S1_v", "(in time) hit counts vs stripID in L2, S1, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v);
414 h_hit_in_time_strip_L2_S2_v = new TH1F("h_hit_in_time_strip_L2_S2_v", "(in time) hit counts vs stripID in L2, S2, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v);
415 h_hit_in_time_strip_L3_S1_v = new TH1F("h_hit_in_time_strip_L3_S1_v", "(in time) hit counts vs stripID in L3, S1, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v);
416 h_hit_in_time_strip_L3_S2_v = new TH1F("h_hit_in_time_strip_L3_S2_v", "(in time) hit counts vs stripID in L3, S2, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v);
417
418 // charge vs strip ID
419 // x
420 h_hit_in_time_charge_vs_strip_L1_S1_x = new TH2F("h_hit_in_time_charge_vs_strip_L1_S1_x", "(in time) hit charge (fC) vs stripID in L1, S1, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x, hit_maxcharge, 0, hit_maxcharge);
421 h_hit_in_time_charge_vs_strip_L1_S2_x = new TH2F("h_hit_in_time_charge_vs_strip_L1_S2_x", "(in time) hit charge (fC) vs stripID in L1, S2, x view", MAXNOFSTRIP_L1_x, 0, MAXNOFSTRIP_L1_x, hit_maxcharge, 0, hit_maxcharge);
422 h_hit_in_time_charge_vs_strip_L2_S1_x = new TH2F("h_hit_in_time_charge_vs_strip_L2_S1_x", "(in time) hit charge (fC) vs stripID in L2, S1, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x, hit_maxcharge, 0, hit_maxcharge);
423 h_hit_in_time_charge_vs_strip_L2_S2_x = new TH2F("h_hit_in_time_charge_vs_strip_L2_S2_x", "(in time) hit charge (fC) vs stripID in L2, S2, x view", MAXNOFSTRIP_L2_x, 0, MAXNOFSTRIP_L2_x, hit_maxcharge, 0, hit_maxcharge);
424 h_hit_in_time_charge_vs_strip_L3_S1_x = new TH2F("h_hit_in_time_charge_vs_strip_L3_S1_x", "(in time) hit charge (fC) vs stripID in L3, S1, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x, hit_maxcharge,0, hit_maxcharge);
425 h_hit_in_time_charge_vs_strip_L3_S2_x = new TH2F("h_hit_in_time_charge_vs_strip_L3_S2_x", "(in time) hit charge (fC) vs stripID in L3, S2, x view", MAXNOFSTRIP_L3_x, 0, MAXNOFSTRIP_L3_x, hit_maxcharge,0, hit_maxcharge);
426
427 // v
428 h_hit_in_time_charge_vs_strip_L1_S1_v = new TH2F("h_hit_in_time_charge_vs_strip_L1_S1_v", "(in time) hit charge (fC) vs stripID in L1, S1, v view", MAXNOFSTRIP_L1_v, 0, MAXNOFSTRIP_L1_v, hit_maxcharge, 0, hit_maxcharge);
429 h_hit_in_time_charge_vs_strip_L2_S1_v = new TH2F("h_hit_in_time_charge_vs_strip_L2_S1_v", "(in time) hit charge (fC) vs stripID in L2, S1, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v, hit_maxcharge, 0, hit_maxcharge);
430 h_hit_in_time_charge_vs_strip_L2_S2_v = new TH2F("h_hit_in_time_charge_vs_strip_L2_S2_v", "(in time) hit charge (fC) vs stripID in L2, S2, v view", MAXNOFSTRIP_L2_v, 0, MAXNOFSTRIP_L2_v, hit_maxcharge, 0, hit_maxcharge);
431 h_hit_in_time_charge_vs_strip_L3_S1_v = new TH2F("h_hit_in_time_charge_vs_strip_L3_S1_v", "(in time) hit charge (fC) vs stripID in L3, S1, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v, hit_maxcharge, 0, hit_maxcharge);
432 h_hit_in_time_charge_vs_strip_L3_S2_v = new TH2F("h_hit_in_time_charge_vs_strip_L3_S2_v", "(in time) hit charge (fC) vs stripID in L3, S2, v view", MAXNOFSTRIP_L3_v, 0, MAXNOFSTRIP_L3_v, hit_maxcharge, 0, hit_maxcharge);
433
434 output->cd();
435
436}
437
439 cout << "define_cluster1d_histo" << endl;
440
441 double cluster1d_max_charge = 250;
442 double cluster1d_max_size = 40;
443
444 TString dname = "cluster1d_histo";
445 output-> mkdir(dname, "histograms of all cluster 1D");
446 output->cd(dname);
447
448 // nof cluster 1d
449 // x
450 h_nofcluster1d_L1_S1_x = new TH1F("h_nofcluster1d_L1_S1_x", "number of cluster1d in L1, S1, x view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
451 h_nofcluster1d_L1_S2_x = new TH1F("h_nofcluster1d_L1_S2_x", "number of cluster1d in L1, S2, x view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
452 h_nofcluster1d_L2_S1_x = new TH1F("h_nofcluster1d_L2_S1_x", "number of cluster1d in L2, S1, x view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
453 h_nofcluster1d_L2_S2_x = new TH1F("h_nofcluster1d_L2_S2_x", "number of cluster1d in L2, S2, x view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
454 h_nofcluster1d_L3_S1_x = new TH1F("h_nofcluster1d_L3_S1_x", "number of cluster1d in L3, S1, x view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
455 h_nofcluster1d_L3_S2_x = new TH1F("h_nofcluster1d_L3_S2_x", "number of cluster1d in L3, S2, x view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
456 // v
457 h_nofcluster1d_L1_S1_v = new TH1F("h_nofcluster1d_L1_S1_v", "number of cluster1d in L1, S1, v view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
458 h_nofcluster1d_L2_S1_v = new TH1F("h_nofcluster1d_L2_S1_v", "number of cluster1d in L2, S1, v view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
459 h_nofcluster1d_L2_S2_v = new TH1F("h_nofcluster1d_L2_S2_v", "number of cluster1d in L2, S2, v view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
460 h_nofcluster1d_L3_S1_v = new TH1F("h_nofcluster1d_L3_S1_v", "number of cluster1d in L3, S1, v view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
461 h_nofcluster1d_L3_S2_v = new TH1F("h_nofcluster1d_L3_S2_v", "number of cluster1d in L3, S2, v view", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
462
463 // cl. size
464 // x
465 h_cluster1d_size_L1_S1_x = new TH1F("h_cluster1d_size_L1_S1_x", "cluster1d size in L1, S1, x view", cluster1d_max_size, 0, cluster1d_max_size);
466 h_cluster1d_size_L1_S2_x = new TH1F("h_cluster1d_size_L1_S2_x", "cluster1d size in L1, S2, x view", cluster1d_max_size, 0, cluster1d_max_size);
467 h_cluster1d_size_L2_S1_x = new TH1F("h_cluster1d_size_L2_S1_x", "cluster1d size in L2, S1, x view", cluster1d_max_size, 0, cluster1d_max_size);
468 h_cluster1d_size_L2_S2_x = new TH1F("h_cluster1d_size_L2_S2_x", "cluster1d size in L2, S2, x view", cluster1d_max_size, 0, cluster1d_max_size);
469 h_cluster1d_size_L3_S1_x = new TH1F("h_cluster1d_size_L3_S1_x", "cluster1d size in L3, S1, x view", cluster1d_max_size, 0, cluster1d_max_size);
470 h_cluster1d_size_L3_S2_x = new TH1F("h_cluster1d_size_L3_S2_x", "cluster1d size in L3, S2, x view", cluster1d_max_size, 0, cluster1d_max_size);
471 // v
472 h_cluster1d_size_L1_S1_v = new TH1F("h_cluster1d_size_L1_S1_v", "cluster1d size in L1, S1, v view", cluster1d_max_size, 0, cluster1d_max_size);
473 h_cluster1d_size_L2_S1_v = new TH1F("h_cluster1d_size_L2_S1_v", "cluster1d size in L2, S1, v view", cluster1d_max_size, 0, cluster1d_max_size);
474 h_cluster1d_size_L2_S2_v = new TH1F("h_cluster1d_size_L2_S2_v", "cluster1d size in L2, S2, v view", cluster1d_max_size, 0, cluster1d_max_size);
475 h_cluster1d_size_L3_S1_v = new TH1F("h_cluster1d_size_L3_S1_v", "cluster1d size in L3, S1, v view", cluster1d_max_size, 0, cluster1d_max_size);
476 h_cluster1d_size_L3_S2_v = new TH1F("h_cluster1d_size_L3_S2_v", "cluster1d size in L3, S2, v view", cluster1d_max_size, 0, cluster1d_max_size);
477
478 // charge vs phi (x view)
479 h_cluster1d_charge_vs_phi_L1_S1_x = new TH2F("h_cluster1d_charge_vs_phi_L1_S1_x", "cluster1d charge (fC) vs phi (deg) in L1, S1, x view", 180, -180, 0, cluster1d_max_charge, 0, cluster1d_max_charge);
480 h_cluster1d_charge_vs_phi_L1_S2_x = new TH2F("h_cluster1d_charge_vs_phi_L1_S2_x", "cluster1d charge (fC) vs phi (deg) in L1, S2, x view", 180, 0, 180, cluster1d_max_charge, 0, cluster1d_max_charge);
481 h_cluster1d_charge_vs_phi_L2_S1_x = new TH2F("h_cluster1d_charge_vs_phi_L2_S1_x", "cluster1d charge (fC) vs phi (deg) in L2, S1, x view", 180, -180, 0, cluster1d_max_charge, 0, cluster1d_max_charge);
482 h_cluster1d_charge_vs_phi_L2_S2_x = new TH2F("h_cluster1d_charge_vs_phi_L2_S2_x", "cluster1d charge (fC) vs phi (deg) in L2, S2, x view", 180, 0, 180, cluster1d_max_charge, 0, cluster1d_max_charge);
483 h_cluster1d_charge_vs_phi_L3_S1_x = new TH2F("h_cluster1d_charge_vs_phi_L3_S1_x", "cluster1d charge (fC) vs phi (deg) in L3, S1, x view", 180, -180, 0, cluster1d_max_charge, 0, cluster1d_max_charge);
484 h_cluster1d_charge_vs_phi_L3_S2_x = new TH2F("h_cluster1d_charge_vs_phi_L3_S2_x", "cluster1d charge (fC) vs phi (deg) in L3, S2, x view", 180, 0, 180, cluster1d_max_charge, 0, cluster1d_max_charge);
485
486 // charge vs v (v view)
487 h_cluster1d_charge_vs_v_L1_S1_v = new TH2F("h_cluster1d_charge_vs_v_L1_S1_v", "cluster1d charge (fC) vs v (mm) in L1, S1, v view", 0.7*MAXNOFSTRIP_L1_v, 0, 0.7*MAXNOFSTRIP_L1_v, cluster1d_max_charge, 0, cluster1d_max_charge);
488 h_cluster1d_charge_vs_v_L2_S1_v = new TH2F("h_cluster1d_charge_vs_v_L2_S1_v", "cluster1d charge (fC) vs v (mm) in L2, S1, v view", 0.7*MAXNOFSTRIP_L2_v, 0, 0.7*MAXNOFSTRIP_L2_v, cluster1d_max_charge, 0, cluster1d_max_charge);
489 h_cluster1d_charge_vs_v_L2_S2_v = new TH2F("h_cluster1d_charge_vs_v_L2_S2_v", "cluster1d charge (fC) vs v (mm) in L2, S2, v view", 0.7*MAXNOFSTRIP_L2_v, 0, 0.7*MAXNOFSTRIP_L2_v, cluster1d_max_charge, 0, cluster1d_max_charge);
490 h_cluster1d_charge_vs_v_L3_S1_v = new TH2F("h_cluster1d_charge_vs_v_L3_S1_v", "cluster1d charge (fC) vs v (mm) in L3, S1, v view", 0.7*MAXNOFSTRIP_L3_v, 0, 0.7*MAXNOFSTRIP_L3_v, cluster1d_max_charge, 0, cluster1d_max_charge);
491 h_cluster1d_charge_vs_v_L3_S2_v = new TH2F("h_cluster1d_charge_vs_v_L3_S2_v", "cluster1d charge (fC) vs v (mm) in L3, S2, v view", 0.7*MAXNOFSTRIP_L3_v, 0, 0.7*MAXNOFSTRIP_L3_v, cluster1d_max_charge, 0, cluster1d_max_charge);
492
493 output->cd();
494
495}
496
498 cout << "define_cluster_selected_histo" << endl;
499
500 double cluster1d_max_charge = 250;
501 double cluster1d_max_size = 40;
502
503 TString dname = "cluster_selected_histo";
504 output->mkdir(dname, "histograms of cluster 1D and 2D from selected clusters");
505 output->cd(dname);
506
507 // charge of the selected clusters
508 h_cluster1d_charge_selected_L1_S1_x = new TH1F("h_cluster1d_charge_selected_L1_S1_x", "cluster1d charge (fC) in L1, S1, x view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
509 h_cluster1d_charge_selected_L1_S2_x = new TH1F("h_cluster1d_charge_selected_L1_S2_x", "cluster1d charge (fC) in L1, S2, x view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
510 h_cluster1d_charge_selected_L2_S1_x = new TH1F("h_cluster1d_charge_selected_L2_S1_x", "cluster1d charge (fC) in L2, S1, x view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
511 h_cluster1d_charge_selected_L2_S2_x = new TH1F("h_cluster1d_charge_selected_L2_S2_x", "cluster1d charge (fC) in L2, S2, x view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
512 h_cluster1d_charge_selected_L3_S1_x = new TH1F("h_cluster1d_charge_selected_L3_S1_x", "cluster1d charge (fC) in L3, S1, x view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
513 h_cluster1d_charge_selected_L3_S2_x = new TH1F("h_cluster1d_charge_selected_L3_S2_x", "cluster1d charge (fC) in L3, S2, x view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
514
515 h_cluster1d_charge_selected_L1_S1_v = new TH1F("h_cluster1d_charge_selected_L1_S1_v", "cluster1d charge (fC) in L1, S1, v view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
516 h_cluster1d_charge_selected_L1_S2_v = new TH1F("h_cluster1d_charge_selected_L1_S2_v", "cluster1d charge (fC) in L1, S2, v view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
517 h_cluster1d_charge_selected_L2_S1_v = new TH1F("h_cluster1d_charge_selected_L2_S1_v", "cluster1d charge (fC) in L2, S1, v view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
518 h_cluster1d_charge_selected_L2_S2_v = new TH1F("h_cluster1d_charge_selected_L2_S2_v", "cluster1d charge (fC) in L2, S2, v view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
519 h_cluster1d_charge_selected_L3_S1_v = new TH1F("h_cluster1d_charge_selected_L3_S1_v", "cluster1d charge (fC) in L3, S1, v view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
520 h_cluster1d_charge_selected_L3_S2_v = new TH1F("h_cluster1d_charge_selected_L3_S2_v", "cluster1d charge (fC) in L3, S2, v view (only selected clusters)", cluster1d_max_charge, 0, cluster1d_max_charge);
521
522 // cl. size
523 // x
524 h_cluster1d_size_selected_L1_S1_x = new TH1F("h_cluster1d_size_selected_L1_S1_x", "cluster1d size in L1, S1, x view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
525 h_cluster1d_size_selected_L1_S2_x = new TH1F("h_cluster1d_size_selected_L1_S2_x", "cluster1d size in L1, S2, x view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
526 h_cluster1d_size_selected_L2_S1_x = new TH1F("h_cluster1d_size_selected_L2_S1_x", "cluster1d size in L2, S1, x view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
527 h_cluster1d_size_selected_L2_S2_x = new TH1F("h_cluster1d_size_selected_L2_S2_x", "cluster1d size in L2, S2, x view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
528 h_cluster1d_size_selected_L3_S1_x = new TH1F("h_cluster1d_size_selected_L3_S1_x", "cluster1d size in L3, S1, x view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
529 h_cluster1d_size_selected_L3_S2_x = new TH1F("h_cluster1d_size_selected_L3_S2_x", "cluster1d size in L3, S2, x view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
530 // v
531 h_cluster1d_size_selected_L1_S1_v = new TH1F("h_cluster1d_size_selected_L1_S1_v", "cluster1d size in L1, S1, v view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
532 h_cluster1d_size_selected_L1_S2_v = new TH1F("h_cluster1d_size_selected_L1_S2_v", "cluster1d size in L1, S2, v view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
533 h_cluster1d_size_selected_L2_S1_v = new TH1F("h_cluster1d_size_selected_L2_S1_v", "cluster1d size in L2, S1, v view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
534 h_cluster1d_size_selected_L2_S2_v = new TH1F("h_cluster1d_size_selected_L2_S2_v", "cluster1d size in L2, S2, v view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
535 h_cluster1d_size_selected_L3_S1_v = new TH1F("h_cluster1d_size_selected_L3_S1_v", "cluster1d size in L3, S1, v view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
536 h_cluster1d_size_selected_L3_S2_v = new TH1F("h_cluster1d_size_selected_L3_S2_v", "cluster1d size in L3, S2, v view (only selected clusters)", cluster1d_max_size, 0, cluster1d_max_size);
537
538 double cluster2d_max_charge = 500;
539 double cluster2d_max_size = 40;
540
541 // charge of the selected clusters 2D
542 h_cluster2d_charge_selected_L1_S1 = new TH1F("h_cluster2d_charge_selected_L1_S1", "cluster2d charge (fC) in L1, S1 (only selected clusters)", cluster2d_max_charge, 0, cluster2d_max_charge);
543 h_cluster2d_charge_selected_L1_S2 = new TH1F("h_cluster2d_charge_selected_L1_S2", "cluster2d charge (fC) in L1, S2 (only selected clusters)", cluster2d_max_charge, 0, cluster2d_max_charge);
544 h_cluster2d_charge_selected_L2_S1 = new TH1F("h_cluster2d_charge_selected_L2_S1", "cluster2d charge (fC) in L2, S1 (only selected clusters)", cluster2d_max_charge, 0, cluster2d_max_charge);
545 h_cluster2d_charge_selected_L2_S2 = new TH1F("h_cluster2d_charge_selected_L2_S2", "cluster2d charge (fC) in L2, S2 (only selected clusters)", cluster2d_max_charge, 0, cluster2d_max_charge);
546 h_cluster2d_charge_selected_L3_S1 = new TH1F("h_cluster2d_charge_selected_L3_S1", "cluster2d charge (fC) in L3, S1 (only selected clusters)", cluster2d_max_charge, 0, cluster2d_max_charge);
547 h_cluster2d_charge_selected_L3_S2 = new TH1F("h_cluster2d_charge_selected_L3_S2", "cluster2d charge (fC) in L3, S2 (only selected clusters)", cluster2d_max_charge, 0, cluster2d_max_charge);
548
549 //MaxQhit cluster 1d
550 h_cl_hitmaxQ_charge_selected_L1_S1_x = new TH1F("h_cl_hitmaxQ_charge_selected_L1_S1_x", "cl hitmaxQ charge (fC) in L1, S1, x view (only selected clusters)", 0, 0, 60);
551 h_cl_hitmaxQ_charge_selected_L1_S2_x = new TH1F("h_cl_hitmaxQ_charge_selected_L1_S2_x", "cl hitmaxQ charge (fC) in L1, S2, x view (only selected clusters)", 0, 0, 60);
552 h_cl_hitmaxQ_charge_selected_L2_S1_x = new TH1F("h_cl_hitmaxQ_charge_selected_L2_S1_x", "cl hitmaxQ charge (fC) in L2, S1, x view (only selected clusters)", 0, 0, 60);
553 h_cl_hitmaxQ_charge_selected_L2_S2_x = new TH1F("h_cl_hitmaxQ_charge_selected_L2_S2_x", "cl hitmaxQ charge (fC) in L2, S2, x view (only selected clusters)", 0, 0, 60);
554 h_cl_hitmaxQ_charge_selected_L3_S1_x = new TH1F("h_cl_hitmaxQ_charge_selected_L3_S1_x", "cl hitmaxQ charge (fC) in L3, S1, x view (only selected clusters)", 0, 0, 60);
555 h_cl_hitmaxQ_charge_selected_L3_S2_x = new TH1F("h_cl_hitmaxQ_charge_selected_L3_S2_x", "cl hitmaxQ charge (fC) in L3, S2, x view (only selected clusters)", 0, 0, 60);
556 h_cl_hitmaxQ_charge_selected_L1_S1_v = new TH1F("h_cl_hitmaxQ_charge_selected_L1_S1_v", "cl hitmaxQ charge (fC) in L1, S1, v view (only selected clusters)", 0, 0, 60);
557 h_cl_hitmaxQ_charge_selected_L1_S2_v = new TH1F("h_cl_hitmaxQ_charge_selected_L1_S2_v", "cl hitmaxQ charge (fC) in L1, S2, v view (only selected clusters)", 0, 0, 60);
558 h_cl_hitmaxQ_charge_selected_L2_S1_v = new TH1F("h_cl_hitmaxQ_charge_selected_L2_S1_v", "cl hitmaxQ charge (fC) in L2, S1, v view (only selected clusters)", 0, 0, 60);
559 h_cl_hitmaxQ_charge_selected_L2_S2_v = new TH1F("h_cl_hitmaxQ_charge_selected_L2_S2_v", "cl hitmaxQ charge (fC) in L2, S2, v view (only selected clusters)", 0, 0, 60);
560 h_cl_hitmaxQ_charge_selected_L3_S1_v = new TH1F("h_cl_hitmaxQ_charge_selected_L3_S1_v", "cl hitmaxQ charge (fC) in L3, S1, v view (only selected clusters)", 0, 0, 60);
561 h_cl_hitmaxQ_charge_selected_L3_S2_v = new TH1F("h_cl_hitmaxQ_charge_selected_L3_S2_v", "cl hitmaxQ charge (fC) in L3, S2, v view (only selected clusters)", 0, 0, 60);
562
563
564 output->cd();
565
566}
567
569 cout << "define_cluster1d_from_fit_histo" << endl;
570
571 double cluster1d_max_charge = 250;
572 double cluster1d_max_size = 40;
573
574 TString dname = "cluster1d_from_fit_histo";
575 output->mkdir(dname, "histograms of cluster 1D from fitted tracks");
576 output->cd(dname);
577
578 // charge of the used clusters used in the fit
579 h_cluster1d_charge_fitted_L1_S1_x = new TH1F("h_cluster1d_charge_fitted_L1_S1_x", "cluster1d charge (fC) in L1, S1, x view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
580 h_cluster1d_charge_fitted_L1_S2_x = new TH1F("h_cluster1d_charge_fitted_L1_S2_x", "cluster1d charge (fC) in L1, S2, x view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
581 h_cluster1d_charge_fitted_L2_S1_x = new TH1F("h_cluster1d_charge_fitted_L2_S1_x", "cluster1d charge (fC) in L2, S1, x view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
582 h_cluster1d_charge_fitted_L2_S2_x = new TH1F("h_cluster1d_charge_fitted_L2_S2_x", "cluster1d charge (fC) in L2, S2, x view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
583 h_cluster1d_charge_fitted_L3_S1_x = new TH1F("h_cluster1d_charge_fitted_L3_S1_x", "cluster1d charge (fC) in L3, S1, x view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
584 h_cluster1d_charge_fitted_L3_S2_x = new TH1F("h_cluster1d_charge_fitted_L3_S2_x", "cluster1d charge (fC) in L3, S2, x view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
585
586 h_cluster1d_charge_fitted_L1_S1_v = new TH1F("h_cluster1d_charge_fitted_L1_S1_v", "cluster1d charge (fC) in L1, S1, v view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
587 h_cluster1d_charge_fitted_L1_S2_v = new TH1F("h_cluster1d_charge_fitted_L1_S2_v", "cluster1d charge (fC) in L1, S2, v view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
588 h_cluster1d_charge_fitted_L2_S1_v = new TH1F("h_cluster1d_charge_fitted_L2_S1_v", "cluster1d charge (fC) in L2, S1, v view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
589 h_cluster1d_charge_fitted_L2_S2_v = new TH1F("h_cluster1d_charge_fitted_L2_S2_v", "cluster1d charge (fC) in L2, S2, v view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
590 h_cluster1d_charge_fitted_L3_S1_v = new TH1F("h_cluster1d_charge_fitted_L3_S1_v", "cluster1d charge (fC) in L3, S1, v view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
591 h_cluster1d_charge_fitted_L3_S2_v = new TH1F("h_cluster1d_charge_fitted_L3_S2_v", "cluster1d charge (fC) in L3, S2, v view (only clusters in the fit)", cluster1d_max_charge, 0, cluster1d_max_charge);
592
593
594 output->cd();
595
596}
597
599 cout << "define_cluster2d_histo" << endl;
600
601 double cluster2d_max_charge = 500;
602 double cluster2d_max_size = 40;
603
604 TString dname = "cluster2d_histo";
605 output-> mkdir(dname, "histograms of all cluster 2D");
606 output->cd(dname);
607
608 // nof cluster 2d
609 h_nofcluster2d_L1_S1 = new TH1F("h_nofcluster2d_L1_S1", "number of cluster2d in L1, S1", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
610 h_nofcluster2d_L1_S2 = new TH1F("h_nofcluster2d_L1_S2", "number of cluster2d in L1, S2", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
611 h_nofcluster2d_L2_S1 = new TH1F("h_nofcluster2d_L2_S1", "number of cluster2d in L2, S1", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
612 h_nofcluster2d_L2_S2 = new TH1F("h_nofcluster2d_L2_S2", "number of cluster2d in L2, S2", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
613 h_nofcluster2d_L3_S1 = new TH1F("h_nofcluster2d_L3_S1", "number of cluster2d in L3, S1", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
614 h_nofcluster2d_L3_S2 = new TH1F("h_nofcluster2d_L3_S2", "number of cluster2d in L3, S2", MAXNOFCLUSTERS, 0, MAXNOFCLUSTERS);
615
616 // cl. size CHECK
617 // h_cluster2d_size_L1_S1 = new TH1F("h_cluster2d_size_L1_S1", "cluster2d size in L1, S1", 40, 0, 40);
618 // h_cluster2d_size_L1_S2 = new TH1F("h_cluster2d_size_L1_S2", "cluster2d size in L1, S2", 40, 0, 40);
619 // h_cluster2d_size_L2_S1 = new TH1F("h_cluster2d_size_L2_S1", "cluster2d size in L2, S1", 40, 0, 40);
620 // h_cluster2d_size_L2_S2 = new TH1F("h_cluster2d_size_L2_S2", "cluster2d size in L2, S2", 40, 0, 40);
621
622 // charge vs phi
623 h_cluster2d_charge_vs_phi_L1_S1 = new TH2F("h_cluster2d_charge_vs_phi_L1_S1", "cluster2d charge (fC) vs phi (deg) in L1, S1", 180, -180, 0, cluster2d_max_charge, 0, cluster2d_max_charge);
624 h_cluster2d_charge_vs_phi_L1_S2 = new TH2F("h_cluster2d_charge_vs_phi_L1_S2", "cluster2d charge (fC) vs phi (deg) in L1, S2", 180, 0, 180, cluster2d_max_charge, 0, cluster2d_max_charge);
625 h_cluster2d_charge_vs_phi_L2_S1 = new TH2F("h_cluster2d_charge_vs_phi_L2_S1", "cluster2d charge (fC) vs phi (deg) in L2, S1", 180, -180, 0, cluster2d_max_charge, 0, cluster2d_max_charge);
626 h_cluster2d_charge_vs_phi_L2_S2 = new TH2F("h_cluster2d_charge_vs_phi_L2_S2", "cluster2d charge (fC) vs phi (deg) in L2, S2", 180, 0, 180, cluster2d_max_charge, 0, cluster2d_max_charge);
627 h_cluster2d_charge_vs_phi_L3_S1 = new TH2F("h_cluster2d_charge_vs_phi_L3_S1", "cluster2d charge (fC) vs phi (deg) in L3, S1", 180, -180, 0, cluster2d_max_charge, 0, cluster2d_max_charge);
628 h_cluster2d_charge_vs_phi_L3_S2 = new TH2F("h_cluster2d_charge_vs_phi_L3_S2", "cluster2d charge (fC) vs phi (deg) in L3, S2", 180, 0, 180, cluster2d_max_charge, 0, cluster2d_max_charge);
629
630 // charge vs z
631 h_cluster2d_charge_vs_z_L1_S1 = new TH2F("h_cluster2d_charge_vs_z_L1_S1", "cluster2d charge (fC) vs z (mm) in L1, S1", MAXLENGTH_L1_x, -0.5*MAXLENGTH_L1_x-20, 0.5*MAXLENGTH_L1_x+20, cluster2d_max_charge, 0, cluster2d_max_charge);
632 h_cluster2d_charge_vs_z_L1_S2 = new TH2F("h_cluster2d_charge_vs_z_L1_S2", "cluster2d charge (fC) vs z (mm) in L1, S2", MAXLENGTH_L1_x, -0.5*MAXLENGTH_L1_x-20, 0.5*MAXLENGTH_L1_x+20, cluster2d_max_charge, 0, cluster2d_max_charge);
633 h_cluster2d_charge_vs_z_L2_S1 = new TH2F("h_cluster2d_charge_vs_z_L2_S1", "cluster2d charge (fC) vs z (mm) in L2, S1", MAXLENGTH_L2_x, -0.5*MAXLENGTH_L2_x-20, 0.5*MAXLENGTH_L2_x+20, cluster2d_max_charge, 0, cluster2d_max_charge);
634 h_cluster2d_charge_vs_z_L2_S2 = new TH2F("h_cluster2d_charge_vs_z_L2_S2", "cluster2d charge (fC) vs z (mm) in L2, S2", MAXLENGTH_L2_x, -0.5*MAXLENGTH_L2_x-20, 0.5*MAXLENGTH_L2_x+20, cluster2d_max_charge, 0, cluster2d_max_charge);
635 h_cluster2d_charge_vs_z_L3_S1 = new TH2F("h_cluster2d_charge_vs_z_L3_S1", "cluster2d charge (fC) vs z (mm) in L3, S1", MAXLENGTH_L3_x, -0.5*MAXLENGTH_L3_x-20, 0.5*MAXLENGTH_L3_x+20, cluster2d_max_charge, 0, cluster2d_max_charge);
636 h_cluster2d_charge_vs_z_L3_S2 = new TH2F("h_cluster2d_charge_vs_z_L3_S2", "cluster2d charge (fC) vs z (mm) in L3, S2", MAXLENGTH_L3_x, -0.5*MAXLENGTH_L3_x-20, 0.5*MAXLENGTH_L3_x+20, cluster2d_max_charge, 0, cluster2d_max_charge);
637
638 // z vs phi
639 h_cluster2d_z_vs_phi_L1_S1 = new TH2F("h_cluster2d_z_vs_phi_L1_S1", "cluster2d z (mm) vs phi (deg) in L1, S1", 180, -180, 0, MAXLENGTH_L1_x, -0.5*MAXLENGTH_L1_x-20, 0.5*MAXLENGTH_L1_x+20);
640 h_cluster2d_z_vs_phi_L1_S2 = new TH2F("h_cluster2d_z_vs_phi_L1_S2", "cluster2d z (mm) vs phi (deg) in L1, S2", 180, 0, 180, MAXLENGTH_L1_x, -0.5*MAXLENGTH_L1_x-20, 0.5*MAXLENGTH_L1_x+20);
641 h_cluster2d_z_vs_phi_L2_S1 = new TH2F("h_cluster2d_z_vs_phi_L2_S1", "cluster2d z (mm) vs phi (deg) in L2, S1", 180, -180, 0, MAXLENGTH_L2_x, -0.5*MAXLENGTH_L2_x-20, 0.5*MAXLENGTH_L2_x+20);
642 h_cluster2d_z_vs_phi_L2_S2 = new TH2F("h_cluster2d_z_vs_phi_L2_S2", "cluster2d z (mm) vs phi (deg) in L2, S2", 180, 0, 180, MAXLENGTH_L2_x, -0.5*MAXLENGTH_L2_x-20, 0.5*MAXLENGTH_L2_x+20);
643 h_cluster2d_z_vs_phi_L3_S1 = new TH2F("h_cluster2d_z_vs_phi_L3_S1", "cluster2d z (mm) vs phi (deg) in L3, S1", 180, -180, 0, MAXLENGTH_L3_x, -0.5*MAXLENGTH_L3_x-20, 0.5*MAXLENGTH_L3_x+20);
644 h_cluster2d_z_vs_phi_L3_S2 = new TH2F("h_cluster2d_z_vs_phi_L3_S2", "cluster2d z (mm) vs phi (deg) in L3, S2", 180, 0, 180, MAXLENGTH_L3_x, -0.5*MAXLENGTH_L3_x-20, 0.5*MAXLENGTH_L3_x+20);
645
646 output->cd();
647
648}
649
650
652
653 float xy_max = 200;
654 float z_max = MAX_Z;
655 float res_max = 5;
656 float cl_q_max = 500;
657 float cl_nhit_max = 20;
658
659 cout << "define_track_histo" << endl;
660
661 TString dname = "track_histo";
662 output-> mkdir(dname, "histograms of fitted tracks");
663 output->cd(dname);
664
665 // nof fitted tracks
666 h_noftrack = new TH1F("h_noftrack", "number of fitted tracks", MAXNOFTRACKS, 0, MAXNOFTRACKS);
667
668 // chi2 distro
669 h_track_chi2 = new TH1F("h_track_chi2", "fitted track chi2", 8000, 0, 8000);
670
671 // xpoca, ypoca, zpoca distro
672 h_track_xpoca = new TH1F("h_track_xpoca", "fitted track point of closest approach x (mm)", 100, -xy_max, xy_max);
673 h_track_ypoca = new TH1F("h_track_ypoca", "fitted track point of closest approach y (mm)", 100, -xy_max, xy_max);
674 h_track_zpoca = new TH1F("h_track_zpoca", "fitted track point of closest approach z (mm)", 100, -z_max, z_max);
675
676 // TEST PLANE
677 // residual in rphi
678 h_test_residual_rphi = new TH1F("h_test_residual_rphi", "test plane: residual in R * phi (mm)", 100, -res_max, res_max);
679 h_test_res_rphi_vs_chi2 = new TH2F("h_test_res_rphi_vs_chi2", "test plane: residual in R * phi (mm) vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
680
681 // TPC residual in rphi
682 h_test_residual_rphi_tpc = new TH1F("h_test_residual_rphi_tpc", "test plane: TPC residual in R * phi (mm)", 100, -res_max, res_max);
683 h_test_res_rphi_vs_chi2_tpc = new TH2F("h_test_res_rphi_vs_chi2_tpc", "test plane: TPC residual in R * phi (mm) vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
684
685 // residual in z
686 h_test_residual_z = new TH1F("h_test_residual_z", "test plane: residual in z (mm)", 100, -res_max, res_max);
687 h_test_res_z_vs_chi2 = new TH2F("h_test_res_z_vs_chi2", "test plane: residual in z (mm) vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
688
689 // TPC residual in z
690 h_test_residual_z_tpc = new TH1F("h_test_residual_z_tpc", "test plane: TPC residual in z (mm)", 100, -res_max, res_max);
691 h_test_res_z_vs_chi2_tpc = new TH2F("h_test_res_z_vs_chi2_tpc", "test plane: TPC residual in z (mm) vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
692
693 // TRACKER
694 // residual in phi
695 h_residual_rphi_L1_S1 = new TH1F("h_residual_rphi_L1_S1", "residual in R * phi (mm) on L1, S1", 100, -res_max, res_max);
696 h_residual_rphi_L1_S2 = new TH1F("h_residual_rphi_L1_S2", "residual in R * phi (mm) on L1, S2", 100, -res_max, res_max);
697 h_residual_rphi_L2_S1 = new TH1F("h_residual_rphi_L2_S1", "residual in R * phi (mm) on L2, S1", 100, -res_max, res_max);
698 h_residual_rphi_L2_S2 = new TH1F("h_residual_rphi_L2_S2", "residual in R * phi (mm) on L2, S2", 100, -res_max, res_max);
699 h_residual_rphi_L3_S1 = new TH1F("h_residual_rphi_L3_S1", "residual in R * phi (mm) on L3, S1", 100, -res_max, res_max);
700 h_residual_rphi_L3_S2 = new TH1F("h_residual_rphi_L3_S2", "residual in R * phi (mm) on L3, S2", 100, -res_max, res_max);
701
702 h_res_rphi_vs_chi2_L1_S1 = new TH2F("h_res_rphi_vs_chi2_L1_S1", "residual in R * phi (mm) on L1, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
703 h_res_rphi_vs_chi2_L1_S2 = new TH2F("h_res_rphi_vs_chi2_L1_S2", "residual in R * phi (mm) on L1, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
704 h_res_rphi_vs_chi2_L2_S1 = new TH2F("h_res_rphi_vs_chi2_L2_S1", "residual in R * phi (mm) on L2, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
705 h_res_rphi_vs_chi2_L2_S2 = new TH2F("h_res_rphi_vs_chi2_L2_S2", "residual in R * phi (mm) on L2, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
706 h_res_rphi_vs_chi2_L3_S1 = new TH2F("h_res_rphi_vs_chi2_L3_S1", "residual in R * phi (mm) on L3, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
707 h_res_rphi_vs_chi2_L3_S2 = new TH2F("h_res_rphi_vs_chi2_L3_S2", "residual in R * phi (mm) on L3, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
708
709 // TPC residual in phi
710 h_residual_rphi_L1_S1_tpc = new TH1F("h_residual_rphi_L1_S1_tpc", "TPC residual in R * phi (mm) on L1, S1", 100, -res_max, res_max);
711 h_residual_rphi_L1_S2_tpc = new TH1F("h_residual_rphi_L1_S2_tpc", "TPC residual in R * phi (mm) on L1, S2", 100, -res_max, res_max);
712 h_residual_rphi_L2_S1_tpc = new TH1F("h_residual_rphi_L2_S1_tpc", "TPC residual in R * phi (mm) on L2, S1", 100, -res_max, res_max);
713 h_residual_rphi_L2_S2_tpc = new TH1F("h_residual_rphi_L2_S2_tpc", "TPC residual in R * phi (mm) on L2, S2", 100, -res_max, res_max);
714 h_residual_rphi_L3_S1_tpc = new TH1F("h_residual_rphi_L3_S1_tpc", "TPC residual in R * phi (mm) on L3, S1", 100, -res_max, res_max);
715 h_residual_rphi_L3_S2_tpc = new TH1F("h_residual_rphi_L3_S2_tpc", "TPC residual in R * phi (mm) on L3, S2", 100, -res_max, res_max);
716
717 h_res_rphi_vs_chi2_L1_S1_tpc = new TH2F("h_res_rphi_vs_chi2_L1_S1_tpc", "TPC residual in R * phi (mm) on L1, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
718 h_res_rphi_vs_chi2_L1_S2_tpc = new TH2F("h_res_rphi_vs_chi2_L1_S2_tpc", "TPC residual in R * phi (mm) on L1, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
719 h_res_rphi_vs_chi2_L2_S1_tpc = new TH2F("h_res_rphi_vs_chi2_L2_S1_tpc", "TPC residual in R * phi (mm) on L2, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
720 h_res_rphi_vs_chi2_L2_S2_tpc = new TH2F("h_res_rphi_vs_chi2_L2_S2_tpc", "TPC residual in R * phi (mm) on L2, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
721 h_res_rphi_vs_chi2_L3_S1_tpc = new TH2F("h_res_rphi_vs_chi2_L3_S1_tpc", "TPC residual in R * phi (mm) on L3, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
722 h_res_rphi_vs_chi2_L3_S2_tpc = new TH2F("h_res_rphi_vs_chi2_L3_S2_tpc", "TPC residual in R * phi (mm) on L3, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
723
724 // residual in z
725 h_residual_z_L1_S1 = new TH1F("h_residual_z_L1_S1", "residual in z (mm) on L1, S1", 100, -res_max, res_max);
726 h_residual_z_L1_S2 = new TH1F("h_residual_z_L1_S2", "residual in z (mm) on L1, S2", 100, -res_max, res_max);
727 h_residual_z_L2_S1 = new TH1F("h_residual_z_L2_S1", "residual in z (mm) on L2, S1", 100, -res_max, res_max);
728 h_residual_z_L2_S2 = new TH1F("h_residual_z_L2_S2", "residual in z (mm) on L2, S2", 100, -res_max, res_max);
729 h_residual_z_L3_S1 = new TH1F("h_residual_z_L3_S1", "residual in z (mm) on L3, S1", 100, -res_max, res_max);
730 h_residual_z_L3_S2 = new TH1F("h_residual_z_L3_S2", "residual in z (mm) on L3, S2", 100, -res_max, res_max);
731
732 h_res_z_vs_chi2_L1_S1 = new TH2F("h_res_z_vs_chi2_L1_S1", "residual in z (mm) on L1, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
733 h_res_z_vs_chi2_L1_S2 = new TH2F("h_res_z_vs_chi2_L1_S2", "residual in z (mm) on L1, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
734 h_res_z_vs_chi2_L2_S1 = new TH2F("h_res_z_vs_chi2_L2_S1", "residual in z (mm) on L2, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
735 h_res_z_vs_chi2_L2_S2 = new TH2F("h_res_z_vs_chi2_L2_S2", "residual in z (mm) on L2, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
736 h_res_z_vs_chi2_L3_S1 = new TH2F("h_res_z_vs_chi2_L3_S1", "residual in z (mm) on L3, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
737 h_res_z_vs_chi2_L3_S2 = new TH2F("h_res_z_vs_chi2_L3_S2", "residual in z (mm) on L3, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
738
739 // TPC residual in z
740 h_residual_z_L1_S1_tpc = new TH1F("h_residual_z_L1_S1_tpc", "TPC residual in z (mm) on L1, S1", 100, -res_max, res_max);
741 h_residual_z_L1_S2_tpc = new TH1F("h_residual_z_L1_S2_tpc", "TPC residual in z (mm) on L1, S2", 100, -res_max, res_max);
742 h_residual_z_L2_S1_tpc = new TH1F("h_residual_z_L2_S1_tpc", "TPC residual in z (mm) on L2, S1", 100, -res_max, res_max);
743 h_residual_z_L2_S2_tpc = new TH1F("h_residual_z_L2_S2_tpc", "TPC residual in z (mm) on L2, S2", 100, -res_max, res_max);
744 h_residual_z_L3_S1_tpc = new TH1F("h_residual_z_L3_S1_tpc", "TPC residual in z (mm) on L3, S1", 100, -res_max, res_max);
745 h_residual_z_L3_S2_tpc = new TH1F("h_residual_z_L3_S2_tpc", "TPC residual in z (mm) on L3, S2", 100, -res_max, res_max);
746
747 h_res_z_vs_chi2_L1_S1_tpc = new TH2F("h_res_z_vs_chi2_L1_S1_tpc", "TPC residual in z (mm) on L1, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
748 h_res_z_vs_chi2_L1_S2_tpc = new TH2F("h_res_z_vs_chi2_L1_S2_tpc", "TPC residual in z (mm) on L1, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
749 h_res_z_vs_chi2_L2_S1_tpc = new TH2F("h_res_z_vs_chi2_L2_S1_tpc", "TPC residual in z (mm) on L2, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
750 h_res_z_vs_chi2_L2_S2_tpc = new TH2F("h_res_z_vs_chi2_L2_S2_tpc", "TPC residual in z (mm) on L2, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
751 h_res_z_vs_chi2_L3_S1_tpc = new TH2F("h_res_z_vs_chi2_L3_S1_tpc", "TPC residual in z (mm) on L3, S1 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
752 h_res_z_vs_chi2_L3_S2_tpc = new TH2F("h_res_z_vs_chi2_L3_S2_tpc", "TPC residual in z (mm) on L3, S2 vs chi2", 100, -res_max, res_max, 1000, 0, 1000);
753
754 // signal
755 h_signal_charge_2d = new TH1F("h_signal_charge_2d", "total charge of the signal (fC)", cl_q_max, 0, cl_q_max);
756 h_signal_charge_1d_x = new TH1F("h_signal_charge_1d_x", "charge x of the signal (fC)", cl_q_max, 0, cl_q_max);
757 h_signal_charge_1d_v = new TH1F("h_signal_charge_1d_v", "charge v of the signal (fC)", cl_q_max, 0, cl_q_max);
758 h_signal_size_1d_x = new TH1F("h_signal_size_1d_x", "cl.size x of the signal", cl_nhit_max, 0, cl_nhit_max);
759 h_signal_size_1d_v = new TH1F("h_signal_size_1d_v", "cl.size v of the signal", cl_nhit_max, 0, cl_nhit_max);
760
761 h_signal_charge_2d_chi2cut = new TH1F("h_signal_charge_2d_chi2cut", "total charge of the signal (fC) with a chi2 cut", cl_q_max, 0, cl_q_max);
762 h_signal_charge_1d_x_chi2cut = new TH1F("h_signal_charge_1d_x_chi2cut", "charge x of the signal (fC) with a chi2 cut", cl_q_max, 0, cl_q_max);
763 h_signal_charge_1d_v_chi2cut = new TH1F("h_signal_charge_1d_v_chi2cut", "charge v of the signal (fC) with a chi2 cut", cl_q_max, 0, cl_q_max);
764 h_signal_size_1d_x_chi2cut = new TH1F("h_signal_size_1d_x_chi2cut", "cl.size x of the signal with a chi2 cut", cl_nhit_max, 0, cl_nhit_max);
765 h_signal_size_1d_v_chi2cut = new TH1F("h_signal_size_1d_v_chi2cut", "cl.size v of the signal with a chi2 cut", cl_nhit_max, 0, cl_nhit_max);
766
767 // background
768 h_background_charge_2d = new TH1F("h_background_charge_2d", "total charge of the background (fC)", cl_q_max, 0, cl_q_max);
769 h_background_charge_1d_x = new TH1F("h_background_charge_1d_x", "charge x of the background (fC)", cl_q_max, 0, cl_q_max);
770 h_background_charge_1d_v = new TH1F("h_background_charge_1d_v", "charge v of the background (fC)", cl_q_max, 0, cl_q_max);
771 h_background_size_1d_x = new TH1F("h_background_size_1d_x", "cl.size x of the background", cl_nhit_max, 0, cl_nhit_max);
772 h_background_size_1d_v = new TH1F("h_background_size_1d_v", "cl.size v of the background", cl_nhit_max, 0, cl_nhit_max);
773
774 // efficiency vs phi
775 h_eff_vs_phi = new TH1F("h_eff_vs_phi", "Track efficiency vs phi (deg)", MAX_PHI_BIN, MIN_PHI, MAX_PHI);
776 h_eff_vs_phi_vs_chi2 = new TH2F("h_eff_vs_phi_vs_chi2", "Track efficiency vs phi (deg) vs chi2", MAX_PHI_BIN, MIN_PHI, MAX_PHI, CHI_BIN, CHI_MIN, CHI_MAX);
777 h_track_selection_vs_phi = new TH1F("h_track_selection_vs_phi", "Number of track selected vs phi (deg)", MAX_PHI_BIN, MIN_PHI, MAX_PHI);
778
779 // efficiency vs z
780 h_eff_vs_z = new TH1F("h_eff_vs_z", "Track efficiency vs z (mm)", MAX_Z_BIN, MIN_Z, MAX_Z);
781 h_eff_vs_z_vs_chi2 = new TH2F("h_eff_vs_z_vs_chi2", "Track efficiency vs z (mm) vs chi2", MAX_Z_BIN, MIN_Z, MAX_Z, CHI_BIN, CHI_MIN, CHI_MAX);
782 h_track_selection_vs_z = new TH1F("h_track_selection_vs_z", "Number of track selected vs z (mm)", MAX_Z_BIN, MIN_Z, MAX_Z);
783
784 // efficiency vs phi vs z
785 h_eff_vs_phi_vs_z = new TH2F("h_eff_vs_phi_vs_z", "Track efficiency vs phi (deg) vs z (mm)", MAX_PHI_BIN, MIN_PHI, MAX_PHI, MAX_Z_BIN, MIN_Z, MAX_Z);
786 h_track_selection_vs_phi_vs_z = new TH2F("h_track_selection_vs_phi_vs_z", "Number of track selected vs phi (deg) vs z (mm)", MAX_PHI_BIN, MIN_PHI, MAX_PHI, MAX_Z_BIN, MIN_Z, MAX_Z);
787
788 //efficiency 1D vs phi
789 h_eff_vs_phi_1d = new TH1F("h_eff_vs_phi_1d", "Track efficiency 1D vs phi (deg)", MAX_PHI_BIN, MIN_PHI, MAX_PHI);
790
791 //efficiency 1D vs v
792 h_eff_vs_v_1d = new TH1F("h_eff_vs_v_1d", "Track efficiency 1D vs v", MAX_V_BIN, MIN_V, MAX_V);
793
794 //efficiency 2x1D vs FEB
795 h_eff_vs_FEB = new TH1F("h_eff_vs_FEB", "Track efeficiency 2x1D vs FEB",80,0,80);
796
797 // cc resolution in rphi vs chi2
798 h_resolution_rphi_vs_chi2 = new TH1F("h_resolution_rphi_vs_chi2" , "test plane: cc resolution in R * phi (mm) vs chi2" , CHI_BIN, CHI_MIN, CHI_MAX);
799 h_resolution_rphi_tpc_vs_chi2 = new TH1F("h_resolution_rphi_tpc_vs_chi2", "test plane: tpc resolution in R * phi (mm) vs chi2", CHI_BIN, CHI_MIN, CHI_MAX);
800
801 h_resolution_z_vs_chi2 = new TH1F("h_resolution_z_vs_chi2" , "test plane: cc resolution in z (mm) vs chi2" , CHI_BIN, CHI_MIN, CHI_MAX);
802 h_resolution_z_tpc_vs_chi2 = new TH1F("h_resolution_z_tpc_vs_chi2", "test plane: tpc resolution in z (mm) vs chi2", CHI_BIN, CHI_MIN, CHI_MAX);
803
804 // Incident Angles
805
806 // L1 residual
807 h_test_residual_rphi_vs_angxy_L1_cc = new TH2F("h_test_residual_rphi_vs_angxy_L1_cc" , "test plane: CC residual in R * phi (mm) vs ang_{xy}_{L1}", 100, -5, 5, ANG_BIN, ANG_MIN, ANG_MAX);
808 h_test_residual_rphi_vs_angxy_L1_tpc = new TH2F("h_test_residual_rphi_vs_angxy_L1_tpc", "test plane: TPC residual in R * phi (mm) vs ang_{xy}_{L1}", 100, -5, 5, ANG_BIN, ANG_MIN, ANG_MAX);
809
810 // L2 residual
811 h_test_residual_rphi_vs_angxy_L2_cc = new TH2F("h_test_residual_rphi_vs_angxy_L2_cc" , "test plane: CC residual in R * phi (mm) vs ang_{xy}_{L2}", 100, -5, 5, ANG_BIN, ANG_MIN, ANG_MAX);
812 h_test_residual_rphi_vs_angxy_L2_tpc = new TH2F("h_test_residual_rphi_vs_angxy_L2_tpc", "test plane: TPC residual in R * phi (mm) vs ang_{xy}_{L2}", 100, -5, 5, ANG_BIN, ANG_MIN, ANG_MAX);
813
814 // L3 residual
815 h_test_residual_rphi_vs_angxy_L3_cc = new TH2F("h_test_residual_rphi_vs_angxy_L3_cc" , "test plane: CC residual in R * phi (mm) vs ang_{xy}_{L3}", 100, -5, 5, ANG_BIN, ANG_MIN, ANG_MAX);
816 h_test_residual_rphi_vs_angxy_L3_tpc = new TH2F("h_test_residual_rphi_vs_angxy_L3_tpc", "test plane: TPC residual in R * phi (mm) vs ang_{xy}_{L3}", 100, -5, 5, ANG_BIN, ANG_MIN, ANG_MAX);
817
818 // cc resolution
819 h_resolution_vs_ang_xy_L1 = new TH1F("h_resolution_vs_ang_xy_L1", "cc resolution in R * phi (mm) vs L1 ang_{xy}", ANG_BIN, ANG_MIN, ANG_MAX);
820 h_resolution_vs_ang_xy_L2 = new TH1F("h_resolution_vs_ang_xy_L2", "cc resolution in R * phi (mm) vs L2 ang_{xy}", ANG_BIN, ANG_MIN, ANG_MAX);
821 h_resolution_vs_ang_xy_L3 = new TH1F("h_resolution_vs_ang_xy_L3", "cc resolution in R * phi (mm) vs L3 ang_{xy}", ANG_BIN, ANG_MIN, ANG_MAX);
822
823 // tpc resolution
824 h_resolution_tpc_vs_ang_xy_L1 = new TH1F("h_resolution_tpc_vs_ang_xy_L1", "tpc resolution in R * phi (mm) vs L1 ang_{xy}", ANG_BIN, ANG_MIN, ANG_MAX);
825 h_resolution_tpc_vs_ang_xy_L2 = new TH1F("h_resolution_tpc_vs_ang_xy_L2", "tpc resolution in R * phi (mm) vs L2 ang_{xy}", ANG_BIN, ANG_MIN, ANG_MAX);
826 h_resolution_tpc_vs_ang_xy_L3 = new TH1F("h_resolution_tpc_vs_ang_xy_L3", "tpc resolution in R * phi (mm) vs L3 ang_{xy}", ANG_BIN, ANG_MIN, ANG_MAX);
827
828 //MAPS and tpc debug
829 int u_NbinX = 50;
830 int u_NbinY = 50;
831 int u_NbinZ = 50;
832 float u_minXY = -xy_max;
833 float u_maxXY = xy_max;
834 float u_minZ = -z_max;
835 float u_maxZ = z_max;
836 h_map_xy_event_trk = new TH2F("h_map_xy_event_trk" ,"event map xy" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
837 h_map_xz_event_trk = new TH2F("h_map_xz_event_trk" ,"event map xz" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
838 h_map_xy_2d = new TH2F("h_map_xy_2d" ,"event map xy cluster 2d",u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
839 h_map_xz_2d = new TH2F("h_map_xz_2d" ,"event map xz cluster 2d",u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
840 h_map_xy_1d_tpc = new TH2F("h_map_xy_1d_tpc" ,"event map xy cluster 1d",u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
841 h_map_xz_1d_tpc = new TH2F("h_map_xz_1d_tpc" ,"event map xz cluster 1d",u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
842 h_map_xy_tpc_eff = new TH2F("h_map_xy_tpc_eff" ,"eff map xy tpc" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
843 h_map_xz_tpc_eff = new TH2F("h_map_xz_tpc_eff" ,"eff map xz tpc" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
844 h_map_xy_tpc_fail = new TH2F("h_map_xy_tpc_fail" ,"fail map xy tpc" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
845 h_map_xz_tpc_fail = new TH2F("h_map_xz_tpc_fail" ,"fail map xz tpc" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
846 h_map_xy_cc_eff = new TH2F("h_map_xy_cc_eff" ,"eff map xy cc" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
847 h_map_xz_cc_eff = new TH2F("h_map_xz_cc_eff" ,"eff map xz cc" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
848 h_map_xy_cc_tpc_diff = new TH2F("h_map_xy_cc_tpc_diff" ,"diff cc tpc map xy" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
849 h_map_xz_cc_tpc_diff = new TH2F("h_map_xz_cc_tpc_diff" ,"diff cc tpc map xz" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
850 h_map_xy_cc_tpc_diff2= new TH2F("h_map_xy_cc_tpc_diff2","diff cc tpc map xy" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
851 h_map_xz_cc_tpc_diff2= new TH2F("h_map_xz_cc_tpc_diff2","diff cc tpc map xz" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
852 h_map_xy_q2d = new TH2F("h_map_xy_q2d" ,"charge cluster 2D xy" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
853 h_map_xz_q2d = new TH2F("h_map_xz_q2d" ,"charge cluster 2D xz" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
854 h_map_xy_dT = new TH2F("h_map_xy_dT" ,"delta Time hits xy" ,u_NbinX,u_minXY,u_maxXY,u_NbinY,u_minXY,u_maxXY);
855 h_map_xz_dT = new TH2F("h_map_xz_dT" ,"delta Time hits xz" ,u_NbinX,u_minXY,u_maxXY,u_NbinZ,u_minZ,u_maxZ);
856 h_ang_trk_meas = new TH2F("h_ang_trk_meas" ,"h_ang_trk_meas" ,180 ,-90 ,90 ,180 ,-90 ,90 );
857 h_ang_diff_vs_trk = new TH2F("h_ang_diff_vs_trk" ,"h_ang_diff_vs_trk" ,180 ,-90 ,90 ,180 ,-90 ,90 );
858 h_ang_diff = new TH1F("h_ang_diff" ,"h_ang_diff" ,180 ,-90 ,90);
859 h_ang_tpc =new TH1F("h_ang_tpc" ,"h_ang_tp" ,720 ,-360 ,360);
860
861 //tpc calibration and correction
862 for(int i=0;i<(int)maxclusize;i++){
863 for(int j=0;j<i;j++){
864 h_deltaX_order_size[j][i] = new TH1F(Form("deltaX_%i%i",j,i),Form("deltaX strip %i and size %i",j,i),100,-0.05,0.05);
865 h_deltaZ_order_size[j][i] = new TH1F(Form("deltaZ_%i%i",j,i),Form("deltaZ strip %i and size %i",j,i),100,-0.1,0.1);
866 }
867 f_deltaX[i] = new TF1(Form("f_deltaX_size_%i",i),"pol1");
868 f_deltaZ[i] = new TF1(Form("f_deltaZ_size_%i",i),"pol1");
869 }
870
871
872 output->cd();
873}
874
875
877 MsgStream log(msgSvc(), name());
878 log << MSG::INFO << "CgemCosmicRayQA initialize()" << endreq;
879 cout << "QA info" << endl;
880 cout << "filename " << filename << endl;
881 cout << "alignment flag " << align_flag << endl;
882 cout << "cut_chi2 " << cut_chi2 << endl;
883
884 // SmartIF<IProperty> propMgr( IID_IProperty, iface );
885 // SmartIF<IAppMgrUI> appMgr( IID_IAppMgrUI, iface );
886
887 // CgemGeomSvc
888 StatusCode sc;
889 sc = service("CgemGeomSvc", m_SvcCgem);
890 if(sc != StatusCode::SUCCESS) {
891 log << MSG::ERROR << "can not use CgemGeomSvc" << endreq;
892 return StatusCode::FAILURE;
893 }
894 middleplane = m_SvcCgem->getMidDriftPtr() ;
895 alignment = m_SvcCgem->getAlignPtr() ;
896
897 // cout << "ALLINEAMENTO L1 " << alignment->getDx(0) << " " << alignment->getDy(0) << " " << alignment->getDz(0) << endl;
898 // cout << "ALLINEAMENTO L2 " << alignment->getDx(1) << " " << alignment->getDy(1) << " " << alignment->getDz(1) << endl;
899
900 anode = m_SvcCgem->getReadoutPlane(0, 0);
901 anode_mid_gap_radius[0] = anode->getMidRAtGap();
902 anode = m_SvcCgem->getReadoutPlane(1, 0);
903 anode_mid_gap_radius[1] = anode->getMidRAtGap();
904 anode = m_SvcCgem->getReadoutPlane(2, 0);
905 anode_mid_gap_radius[2] = anode->getMidRAtGap();
906
907
908 cout << "CgemLineFit alignment " << align_flag << endl;
909 if(align_flag) {
910 for(int ilay=0; ilay<3; ilay++) {
911 cout << "LAYER " << ilay+1 << endl;
912 cout << "midplane radius " << middleplane->getR(ilay) << endl;
913 for(int ishe=0; ishe<2; ishe++) {
914 cout << "shift dx " << alignment->getDx(ilay,ishe) << " dy " << alignment->getDy(ilay,ishe) << " dz " << alignment->getDz(ilay,ishe) << endl;
915 cout << "rotation Rx " << alignment->getRx(ilay,ishe) << " Ry " << alignment->getRy(ilay,ishe) << " Rz " << alignment->getRz(ilay,ishe) << endl;
916 }
917 }
918 }
919
920 // LUT
921 // LUT
922 // cout << "CREATING LUT" << endl;
923 lutreader = new CgemLUTReader(lutfile);
924 lutreader->ReadLUT();
925 // lutreader->PrintMap(1,0,0);
926 // lutreader->PrintMap(1,1,0);
927
928 event=0;
930 // all
935 // selection
939
940 nchi2 = 0;
941 nstopped = 0;
942 nfittedtrack = 0;
943 nvalidtrack = 0;
944 ninside = 0;
945 ninside1Dx = 0;
946 ninside1Dz = 0;
947 noutside = 0;
948
949 test_l = 0;
950 test_ml = 0;
951 test_mh = 0;
952 test_h = 0;
953 test_p = 0;
954
955 test_layer_id_all = -1;
956 test_sheet_id_all = -1;
957
958 // For efficiency vs phi
959 for(int i = 0; i < MAX_PHI_BIN; i++) {
960 n_validtrack_phi_arr[i] = 0;
961 n_insidetrack_phi_arr[i] = 0;
962 n_validtrack_phi_1d_arr[i] = 0;
963 n_insidetrack_phi_1d_arr[i] = 0;
964 }
965
966 // For efficiency vs v
967 for(int i = 0; i < MAX_V_BIN; i++) {
968 n_validtrack_v_1d_arr[i] = 0;
969 n_insidetrack_v_1d_arr[i] = 0;
970 }
971
972 // For efficiency vs FEB
973 for(int i=0; i < 80; i++){
974 n_validtrack_feb_arr[i]=0;
975 n_insidetrack_feb_arr[i]=0;
976 }
977
978 // For efficiency vs z
979 for(int i = 0; i < MAX_Z_BIN; i++) {
980 n_validtrack_z_arr[i] = 0;
981 n_insidetrack_z_arr[i] = 0;
982 }
983
984 for(int i = 0; i < MAX_PHI_BIN; i++) {
985 for(int j = 0; j < MAX_Z_BIN; j++) {
986 n_validtrack_phi_z_mat[i][j] = 0;
987 n_insidetrack_phi_z_mat[i][j] = 0;
988 }
989 }
990
991 for(int j = 0; j < CHI_BIN; j++) {
992 for(int i = 0; i < MAX_PHI_BIN; i++) {
993 n_validtrack_phi_chi2_mat[j][i] = 0;
994 n_insidetrack_phi_chi2_mat[j][i] = 0;
995 }
996 for(int i = 0; i < MAX_Z_BIN; i++) {
997 n_validtrack_z_chi2_mat[j][i] = 0;
998 n_insidetrack_z_chi2_mat[j][i] = 0;
999 }
1000 }
1001
1002 int chi_dummy_var = 0;
1003 int j_dum = 0;
1004
1005 for(int i = 0; i < CHI_BIN; i++) {
1006
1007 chi_dummy_var = j_dum*j_dum + 1;
1008 if(i/3 == 1) chi_dummy_var = chi_dummy_var*10;
1009 if(i/3 == 2) chi_dummy_var = chi_dummy_var*100;
1010 if(i/3 == 3) chi_dummy_var = chi_dummy_var*1000;
1011
1012 chi2_cut_arr[i] = chi_dummy_var;
1013 if(j_dum < 2) j_dum++;
1014 else j_dum = 0;
1015 }
1016
1017 read_file(filename);
1018 cout << "entries " << tree->GetEntries() << endl;
1019 cout<<"End initialize"<<endl;
1020 return StatusCode::SUCCESS;
1021
1022}
1023
1025 MsgStream log(msgSvc(), name());
1026 if(event%1000==0) cout << "--------->CgemCosmicRayQA::execute " << event << endl;
1027
1028 /**
1029 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
1030 if (!eventHeader) {
1031 log << MSG::FATAL << "Could not find Event Header" << endreq;
1032 return StatusCode::FAILURE;
1033 }
1034 cout << "EVENTO " << eventHeader->eventNumber() << " RUN " << eventHeader->runNumber() << endl;
1035 **/
1036
1037
1038 //interface to event data service
1039 ISvcLocator* svcLocator = Gaudi::svcLocator();
1040 StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
1041 if (sc.isFailure())
1042 cout<<"Could not accesss EventDataSvc!"<<endl;
1043 // for(int ievt = 0; ievt < tree->GetEntries(); ievt++) {
1044 tree->GetEntry(event);
1045 // ..................................................................................................
1046 // loop on hits
1048 // ..................................................................................................
1049 // loop on hits in time window
1051 // ..................................................................................................
1052 // loop on cluster1d
1054 // ..................................................................................................
1055 // loop on cluster2d
1057 // ..................................................................................................
1058 // loop on cluster selected
1060 // ..................................................................................................
1061 // loop on track
1063 event++;
1064 if(event==tree->GetEntries()) return StatusCode::FAILURE; // CHECK HACK THIS
1065 return StatusCode::SUCCESS;
1066}
1067
1069 MsgStream log(msgSvc(),name());
1070 log << MSG::INFO << "CgemCosmicRayQA finalize()" << endreq;
1071 cout << "finalize" << endl;
1072
1073 // ..................................................................................................
1074 // analisys
1075 analyze();
1077 tpc_finalize();
1078
1079 output->cd();
1080 double efficiency2D = (double) ninside/nvalidtrack;
1081 double efficiency1Dx = (double) ninside1Dx/nvalidtrack;
1082 double efficiency1Dz = (double) ninside1Dz/nvalidtrack;
1083 double background = (double) noutside/nvalidtrack;
1084 int nentries = tree->GetEntries();
1085 int nof_fitted_track = nfittedtrack;
1086 double signal_charge_2d = h_signal_charge_2d->GetMean();
1087 double signal_charge_1d_x = h_signal_charge_1d_x->GetMean();
1088 double signal_charge_1d_v = h_signal_charge_1d_v->GetMean();
1089 double signal_size_1d_x = h_signal_size_1d_x->GetMean();
1090 double signal_size_1d_v = h_signal_size_1d_v->GetMean();
1091 double background_charge_2d = h_background_charge_2d->GetMean();
1092 double background_charge_1d_x = h_background_charge_1d_x->GetMean();
1093 double background_charge_1d_v = h_background_charge_1d_v->GetMean();
1094 double background_size_1d_x = h_background_size_1d_x->GetMean();
1095 double background_size_1d_v = h_background_size_1d_v->GetMean();
1096
1097 TTree *res_tree = new TTree("qa_results","QA results");
1098 res_tree->Branch("ntrigger", &nentries, "ntrigger/I");
1099 res_tree->Branch("ntrack_fitted", &nfittedtrack, "ntrack_fitted/I");
1100 res_tree->Branch("ntrack_not_passing_chi2_cut", &nchi2, "ntrack_not_passing_chi2_cut/I");
1101 res_tree->Branch("ntrack_not_passing_ene_cut", &nstopped, "ntrack_not_passing_ene_cut/I");
1102 res_tree->Branch("ntrack_valid", &nvalidtrack, "ntrack_valid/I");
1103 res_tree->Branch("efficiency2D", &efficiency2D, "efficiency2D/D");
1104 res_tree->Branch("efficiency1Dx", &efficiency1Dx, "efficiency1Dx/D");
1105 res_tree->Branch("efficiency1Dz", &efficiency1Dz, "efficiency1Dz/D");
1106 res_tree->Branch("background", &background,"background/D");
1107 res_tree->Branch("nentries_residual_rphi", &nentries_residual_rphi, "nentries_residual_rphi/I");
1108 res_tree->Branch("mean_residual_rphi", &mean_residual_rphi, "mean_residual_rphi/D");
1109 res_tree->Branch("sigma_residual_rphi", &sigma_residual_rphi, "sigma_residual_rphi/D");
1110 res_tree->Branch("nentries_residual_z", &nentries_residual_z, "nentries_residual_z/I");
1111 res_tree->Branch("mean_residual_z", &mean_residual_z, "mean_residual_z/D");
1112 res_tree->Branch("sigma_residual_z", &sigma_residual_z, "sigma_residual_z/D");
1113 res_tree->Branch("signal_charge_2d", &signal_charge_2d, "signal_charge_2d/D");
1114 res_tree->Branch("signal_charge_1d_x", &signal_charge_1d_x, "signal_charge_1d_x/D");
1115 res_tree->Branch("signal_charge_1d_v", &signal_charge_1d_v, "signal_charge_1d_v/D");
1116 res_tree->Branch("signal_size_1d_x", &signal_size_1d_x, "signal_size_1d_x/D");
1117 res_tree->Branch("signal_size_1d_v", &signal_size_1d_v, "signal_size_1d_v/D");
1118 res_tree->Branch("background_charge_2d", &background_charge_2d, "background_charge_2d/D");
1119 res_tree->Branch("background_charge_1d_x", &background_charge_1d_x, "background_charge_1d_x/D");
1120 res_tree->Branch("background_charge_1d_v", &background_charge_1d_v, "background_charge_1d_v/D");
1121 res_tree->Branch("background_size_1d_x", &background_size_1d_x, "background_size_1d_x/D");
1122 res_tree->Branch("background_size_1d_v", &background_size_1d_v, "background_size_1d_v/D");
1123
1124 res_tree->Fill();
1125 // res_tree->Write();
1126
1127 ofstream res_file;
1128 res_file.open("qa_results.txt");
1129 res_file<<"ntrigger : "<<nentries<<endl;
1130 res_file<<"ntrack_fitted : "<<nfittedtrack<<endl;
1131 res_file<<"ntrack_not_passing_chi2_cut : "<<nchi2<<endl;
1132 res_file<<"ntrack_not_passing_ene_cut : "<<nstopped<<endl;
1133 res_file<<"ntrack_valid : "<<nvalidtrack<<endl;
1134 res_file<<"efficiency2D : "<<efficiency2D<<endl;
1135 res_file<<"efficiency1Dx : "<<efficiency1Dx<<endl;
1136 res_file<<"efficiency1Dz : "<<efficiency1Dz<<endl;
1137 res_file<<"background : "<<background<<endl;
1138 res_file<<"nentries_residual_rphi : "<<nentries_residual_rphi<<endl;
1139 res_file<<"mean_residual_rphi : "<<mean_residual_rphi<<endl;
1140 res_file<<"sigma_residual_rphi : "<<sigma_residual_rphi<<endl;
1141 res_file<<"nentries_residual_z : "<<nentries_residual_z<<endl;
1142 res_file<<"mean_residual_z : "<<mean_residual_z<<endl;
1143 res_file<<"sigma_residual_z : "<<sigma_residual_z<<endl;
1144 res_file<<"signal_charge_2d : "<<signal_charge_2d<<endl;
1145 res_file<<"signal_charge_1d_x : "<<signal_charge_1d_x<<endl;
1146 res_file<<"signal_charge_1d_v : "<<signal_charge_1d_v<<endl;
1147 res_file<<"signal_size_1d_x : "<<signal_size_1d_x<<endl;
1148 res_file<<"signal_size_1d_v : "<<signal_size_1d_v<<endl;
1149 res_file<<"background_charge_2d : "<<background_charge_2d<<endl;
1150 res_file<<"background_charge_1d_x : "<<background_charge_1d_x<<endl;
1151 res_file<<"background_charge_1d_v : "<<background_charge_1d_v<<endl;
1152 res_file<<"background_size_1d_x : "<<background_size_1d_x<<endl;
1153 res_file<<"background_size_1d_v : "<<background_size_1d_v<<endl;
1154 res_file.close();
1155
1156 h_eff_vs_phi_vs_z->Draw("zcol2");
1157 output->Write();
1158 output->Close();
1159
1160
1161 return StatusCode::SUCCESS;
1162}
1163
1164
1166 // cout << "event " << event << " nhit " << nhit << endl;
1167 // ..................................................................................................
1168 // loop on hits
1169 int nhit_L1_S1_x = 0; int nhit_L1_S2_x = 0; int nhit_L2_S1_x = 0; int nhit_L2_S2_x = 0; int nhit_L3_S1_x = 0; int nhit_L3_S2_x = 0;
1170 int nhit_L1_S1_v = 0; int nhit_L2_S1_v = 0; int nhit_L2_S2_v = 0; int nhit_L3_S1_v = 0; int nhit_L3_S2_v = 0;
1171 for(int ihit = 0; ihit < nhit; ihit++) {
1172
1173 // L1
1174 if(hit_layer[ihit] == 0) { // ................................................. LAYER 1
1175
1176 if(hit_view[ihit] == 0) {
1177
1178 // x view
1179 if(hit_sheet[ihit] == 0) { // ................................... S1 (CHECK aggiungi ed usa phi)
1180 h_hit_charge_L1_S1_x->Fill(hit_q[ihit]);
1181 h_hit_time_L1_S1_x->Fill(hit_t[ihit]);
1182 h_hit_charge_vs_strip_L1_S1_x->Fill(hit_strip[ihit], hit_q[ihit]);
1183 h_hit_time_vs_strip_L1_S1_x->Fill(hit_strip[ihit], hit_t[ihit]);
1184 h_hit_charge_vs_time_L1_S1_x->Fill(hit_t[ihit], hit_q[ihit]);
1185 nhit_L1_S1_x++;
1186 }
1187 else { // ................................... S2
1188 h_hit_charge_L1_S2_x->Fill(hit_q[ihit]);
1189 h_hit_time_L1_S2_x->Fill(hit_t[ihit]);
1190 h_hit_charge_vs_strip_L1_S2_x->Fill(hit_strip[ihit], hit_q[ihit]);
1191 h_hit_time_vs_strip_L1_S2_x->Fill(hit_strip[ihit], hit_t[ihit]);
1192 h_hit_charge_vs_time_L1_S2_x->Fill(hit_t[ihit], hit_q[ihit]);
1193 nhit_L1_S2_x++;
1194 }
1195 }
1196 else {
1197
1198 // v view
1199 h_hit_charge_L1_S1_v->Fill(hit_q[ihit]);
1200 h_hit_time_L1_S1_v->Fill(hit_t[ihit]);
1201 h_hit_charge_vs_strip_L1_S1_v->Fill(hit_strip[ihit], hit_q[ihit]);
1202 h_hit_time_vs_strip_L1_S1_v->Fill(hit_strip[ihit], hit_t[ihit]);
1203 h_hit_charge_vs_time_L1_S1_v->Fill(hit_t[ihit], hit_q[ihit]);
1204 h_hit_charge_vs_length_L1_S1_v->Fill(hit_length[ihit], hit_q[ihit]);
1205 nhit_L1_S1_v++;
1206 }
1207 }
1208 else if(hit_layer[ihit] == 1) { // ................................................. LAYER 2
1209
1210 if(hit_view[ihit] == 0) {
1211
1212 // x view
1213 if(hit_sheet[ihit] == 0) { // ................................... S1
1214 h_hit_charge_L2_S1_x->Fill(hit_q[ihit]);
1215 h_hit_time_L2_S1_x->Fill(hit_t[ihit]);
1216 h_hit_charge_vs_strip_L2_S1_x->Fill(hit_strip[ihit], hit_q[ihit]);
1217 h_hit_time_vs_strip_L2_S1_x->Fill(hit_strip[ihit], hit_t[ihit]);
1218 h_hit_charge_vs_time_L2_S1_x->Fill(hit_t[ihit], hit_q[ihit]);
1219 nhit_L2_S1_x++;
1220 }
1221 else { // ................................... S2
1222 h_hit_charge_L2_S2_x->Fill(hit_q[ihit]);
1223 h_hit_time_L2_S2_x->Fill(hit_t[ihit]);
1224 h_hit_charge_vs_strip_L2_S2_x->Fill(hit_strip[ihit], hit_q[ihit]);
1225 h_hit_time_vs_strip_L2_S2_x->Fill(hit_strip[ihit], hit_t[ihit]);
1226 h_hit_charge_vs_time_L2_S2_x->Fill(hit_t[ihit], hit_q[ihit]);
1227 nhit_L2_S2_x++;
1228 }
1229 }
1230 else {
1231
1232 // v view
1233 if(hit_sheet[ihit] == 0) { // ................................... S1
1234 h_hit_charge_L2_S1_v->Fill(hit_q[ihit]);
1235 h_hit_time_L2_S1_v->Fill(hit_t[ihit]);
1236 h_hit_charge_vs_strip_L2_S1_v->Fill(hit_strip[ihit], hit_q[ihit]);
1237 h_hit_time_vs_strip_L2_S1_v->Fill(hit_strip[ihit], hit_t[ihit]);
1238 h_hit_charge_vs_time_L2_S1_v->Fill(hit_t[ihit], hit_q[ihit]);
1239 h_hit_charge_vs_length_L2_S1_v->Fill(hit_length[ihit], hit_q[ihit]);
1240 nhit_L2_S1_v++;
1241 }
1242 else { // ................................... S2
1243 h_hit_charge_L2_S2_v->Fill(hit_q[ihit]);
1244 h_hit_time_L2_S2_v->Fill(hit_t[ihit]);
1245 h_hit_charge_vs_strip_L2_S2_v->Fill(hit_strip[ihit], hit_q[ihit]);
1246 h_hit_time_vs_strip_L2_S2_v->Fill(hit_strip[ihit], hit_t[ihit]);
1247 h_hit_charge_vs_time_L2_S2_v->Fill(hit_t[ihit], hit_q[ihit]);
1248 h_hit_charge_vs_length_L2_S2_v->Fill(hit_length[ihit], hit_q[ihit]);
1249 nhit_L2_S2_v++;
1250 }
1251 }
1252 }
1253 else if(hit_layer[ihit] == 2) { // ................................................. LAYER 3
1254 if(hit_view[ihit] == 0) {
1255
1256 // x view
1257 if(hit_sheet[ihit] == 0) { // ................................... S1
1258 h_hit_charge_L3_S1_x->Fill(hit_q[ihit]);
1259 h_hit_time_L3_S1_x->Fill(hit_t[ihit]);
1260 h_hit_charge_vs_strip_L3_S1_x->Fill(hit_strip[ihit], hit_q[ihit]);
1261 h_hit_time_vs_strip_L3_S1_x->Fill(hit_strip[ihit], hit_t[ihit]);
1262 h_hit_charge_vs_time_L3_S1_x->Fill(hit_t[ihit], hit_q[ihit]);
1263 nhit_L3_S1_x++;
1264 }
1265 else { // ................................... S2
1266 h_hit_charge_L3_S2_x->Fill(hit_q[ihit]);
1267 h_hit_time_L3_S2_x->Fill(hit_t[ihit]);
1268 h_hit_charge_vs_strip_L3_S2_x->Fill(hit_strip[ihit], hit_q[ihit]);
1269 h_hit_time_vs_strip_L3_S2_x->Fill(hit_strip[ihit], hit_t[ihit]);
1270 h_hit_charge_vs_time_L3_S2_x->Fill(hit_t[ihit], hit_q[ihit]);
1271 nhit_L3_S2_x++;
1272 }
1273 }
1274 else {
1275
1276 // v view
1277 if(hit_sheet[ihit] == 0) { // ................................... S1
1278 h_hit_charge_L3_S1_v->Fill(hit_q[ihit]);
1279 h_hit_time_L3_S1_v->Fill(hit_t[ihit]);
1280 h_hit_charge_vs_strip_L3_S1_v->Fill(hit_strip[ihit], hit_q[ihit]);
1281 h_hit_time_vs_strip_L3_S1_v->Fill(hit_strip[ihit], hit_t[ihit]);
1282 h_hit_charge_vs_time_L3_S1_v->Fill(hit_t[ihit], hit_q[ihit]);
1283 h_hit_charge_vs_length_L3_S1_v->Fill(hit_length[ihit], hit_q[ihit]);
1284 nhit_L3_S1_v++;
1285 }
1286 else { // ................................... S2
1287 h_hit_charge_L3_S2_v->Fill(hit_q[ihit]);
1288 h_hit_time_L3_S2_v->Fill(hit_t[ihit]);
1289 h_hit_charge_vs_strip_L3_S2_v->Fill(hit_strip[ihit], hit_q[ihit]);
1290 h_hit_time_vs_strip_L3_S2_v->Fill(hit_strip[ihit], hit_t[ihit]);
1291 h_hit_charge_vs_time_L3_S2_v->Fill(hit_t[ihit], hit_q[ihit]);
1292 h_hit_charge_vs_length_L3_S2_v->Fill(hit_length[ihit], hit_q[ihit]);
1293 nhit_L3_S2_v++;
1294 }
1295 }
1296 }
1297 }
1298
1299 h_nofhit_L1_S1_x->Fill(nhit_L1_S1_x);
1300 h_nofhit_L1_S2_x->Fill(nhit_L1_S2_x);
1301 h_nofhit_L2_S1_x->Fill(nhit_L2_S1_x);
1302 h_nofhit_L2_S2_x->Fill(nhit_L2_S2_x);
1303 h_nofhit_L3_S1_x->Fill(nhit_L3_S1_x);
1304 h_nofhit_L3_S2_x->Fill(nhit_L3_S2_x);
1305 h_nofhit_L1_S1_v->Fill(nhit_L1_S1_v);
1306 h_nofhit_L2_S1_v->Fill(nhit_L2_S1_v);
1307 h_nofhit_L2_S2_v->Fill(nhit_L2_S2_v);
1308 h_nofhit_L3_S1_v->Fill(nhit_L3_S1_v);
1309 h_nofhit_L3_S2_v->Fill(nhit_L3_S2_v);
1310
1311}
1312
1314 // cout << "event " << event << " nhit " << nhit << endl;
1315 // ..................................................................................................
1316 // loop on hits
1317 int nhit_L1_S1_x = 0; int nhit_L1_S2_x = 0; int nhit_L2_S1_x = 0; int nhit_L2_S2_x = 0; int nhit_L3_S1_x = 0; int nhit_L3_S2_x = 0;
1318 int nhit_L1_S1_v = 0; int nhit_L2_S1_v = 0; int nhit_L2_S2_v = 0; int nhit_L3_S1_v = 0; int nhit_L3_S2_v = 0;
1319 for(int ihit = 0; ihit < nhit; ihit++) {
1320 // if hit outside time window -> continue
1321 if(hit_t[ihit] < minDigiTime || hit_t[ihit] > maxDigiTime) continue;
1322
1323 // L1
1324 if(hit_layer[ihit] == 0) { // ................................................. LAYER 1
1325
1326 if(hit_view[ihit] == 0) {
1327
1328 // x view
1329 if(hit_sheet[ihit] == 0) { // ................................... S1 (CHECK aggiungi ed usa phi)
1330 h_hit_in_time_charge_L1_S1_x->Fill(hit_q[ihit]);
1331 h_hit_in_time_strip_L1_S1_x->Fill(hit_strip[ihit]);
1332 h_hit_in_time_charge_vs_strip_L1_S1_x->Fill(hit_strip[ihit], hit_q[ihit]);
1333 }
1334 else { // ................................... S2
1335 h_hit_in_time_charge_L1_S2_x->Fill(hit_q[ihit]);
1336 h_hit_in_time_strip_L1_S2_x->Fill(hit_strip[ihit]);
1337 h_hit_in_time_charge_vs_strip_L1_S2_x->Fill(hit_strip[ihit], hit_q[ihit]);
1338 }
1339 }
1340 else {
1341
1342 // v view
1343
1344 h_hit_in_time_charge_L1_S1_v->Fill(hit_q[ihit]);
1345 h_hit_in_time_strip_L1_S1_v->Fill(hit_strip[ihit]);
1346 h_hit_in_time_charge_vs_strip_L1_S1_v->Fill(hit_strip[ihit], hit_q[ihit]);
1347 }
1348 }
1349 else if(hit_layer[ihit] == 1) { // ................................................. LAYER 2
1350
1351 if(hit_view[ihit] == 0) {
1352
1353 // x view
1354 if(hit_sheet[ihit] == 0) { // ................................... S1
1355 h_hit_in_time_charge_L2_S1_x->Fill(hit_q[ihit]);
1356 h_hit_in_time_strip_L2_S1_x->Fill(hit_strip[ihit]);
1357 h_hit_in_time_charge_vs_strip_L2_S1_x->Fill(hit_strip[ihit], hit_q[ihit]);
1358 }
1359 else { // ................................... S2
1360 h_hit_in_time_charge_L2_S2_x->Fill(hit_q[ihit]);
1361 h_hit_in_time_strip_L2_S2_x->Fill(hit_strip[ihit]);
1362 h_hit_in_time_charge_vs_strip_L2_S2_x->Fill(hit_strip[ihit], hit_q[ihit]);
1363 }
1364 }
1365 else {
1366
1367 // v view
1368 if(hit_sheet[ihit] == 0) { // ................................... S1
1369 h_hit_in_time_charge_L2_S1_v->Fill(hit_q[ihit]);
1370 h_hit_in_time_strip_L2_S1_v->Fill(hit_strip[ihit]);
1371 h_hit_in_time_charge_vs_strip_L2_S1_v->Fill(hit_strip[ihit], hit_q[ihit]);
1372 }
1373 else { // ................................... S2
1374 h_hit_in_time_charge_L2_S2_v->Fill(hit_q[ihit]);
1375 h_hit_in_time_strip_L2_S2_v->Fill(hit_strip[ihit]);
1376 h_hit_in_time_charge_vs_strip_L2_S2_v->Fill(hit_strip[ihit], hit_q[ihit]);
1377 }
1378 }
1379 }
1380 else if(hit_layer[ihit] == 2) { // ................................................. LAYER 3
1381 if(hit_view[ihit] == 0) {
1382 // x view
1383 if(hit_sheet[ihit] == 0) { // ................................... S1
1384 h_hit_in_time_charge_L3_S1_x->Fill(hit_q[ihit]);
1385 h_hit_in_time_strip_L3_S1_x->Fill(hit_strip[ihit]);
1386 h_hit_in_time_charge_vs_strip_L3_S1_x->Fill(hit_strip[ihit], hit_q[ihit]);
1387 }
1388 else { // ................................... S2
1389 h_hit_in_time_charge_L3_S2_x->Fill(hit_q[ihit]);
1390 h_hit_in_time_strip_L3_S2_x->Fill(hit_strip[ihit]);
1391 h_hit_in_time_charge_vs_strip_L3_S2_x->Fill(hit_strip[ihit], hit_q[ihit]);
1392 }
1393 }
1394 else {
1395 // v view
1396 if(hit_sheet[ihit] == 0) { // ................................... S1
1397 h_hit_in_time_charge_L3_S1_v->Fill(hit_q[ihit]);
1398 h_hit_in_time_strip_L3_S1_v->Fill(hit_strip[ihit]);
1399 h_hit_in_time_charge_vs_strip_L3_S1_v->Fill(hit_strip[ihit], hit_q[ihit]);
1400 }
1401 else { // ................................... S2
1402 h_hit_in_time_charge_L3_S2_v->Fill(hit_q[ihit]);
1403 h_hit_in_time_strip_L3_S2_v->Fill(hit_strip[ihit]);
1404 h_hit_in_time_charge_vs_strip_L3_S2_v->Fill(hit_strip[ihit], hit_q[ihit]);
1405 }
1406 }
1407 }
1408 }
1409}
1410
1412
1413 // loop on cluster 1d
1414 int counter=0;
1415 for(int iclu = 0; iclu < ncluster; iclu++) {
1416
1417 if(cluster_1d_view[iclu] == -1) continue;
1418 if(cluster_1d_view[iclu] != 0 && cluster_1d_view[iclu] != 1) cout << "ERROR " << cluster_1d_view[iclu] << endl;
1419 counter++;
1420 // L1
1421 if(cluster_1d_layerid[iclu] == 0) { // ................................................. LAYER 1
1422
1423 if(cluster_1d_view[iclu] == 0) {
1424
1425 // x view
1426 if(cluster_1d_phi[iclu] < 0) { // ................................... S1
1427 h_cluster1d_size_L1_S1_x->Fill(cluster_1d_size[iclu]);
1428 h_cluster1d_charge_vs_phi_L1_S1_x->Fill(TMath::RadToDeg()*cluster_1d_phi[iclu], cluster_1d_q[iclu]);
1429 }
1430 else { // ................................... S2
1431 h_cluster1d_size_L1_S2_x->Fill(cluster_1d_size[iclu]);
1432 h_cluster1d_charge_vs_phi_L1_S2_x->Fill(TMath::RadToDeg()*cluster_1d_phi[iclu], cluster_1d_q[iclu]);
1433 }
1434 }
1435 else {
1436 // v view
1437 h_cluster1d_size_L1_S1_v->Fill(cluster_1d_size[iclu]);
1438 h_cluster1d_charge_vs_v_L1_S1_v->Fill(cluster_1d_v[iclu], cluster_1d_q[iclu]);
1439 }
1440 }
1441 else if(cluster_1d_layerid[iclu] == 1) { // ................................................. LAYER 2
1442
1443 if(cluster_1d_view[iclu] == 0) {
1444
1445 // x view
1446 if(cluster_1d_sheetid[iclu] == 0) { // ................................... S1
1447 h_cluster1d_size_L2_S1_x->Fill(cluster_1d_size[iclu]);
1448 h_cluster1d_charge_vs_phi_L2_S1_x->Fill(TMath::RadToDeg()*cluster_1d_phi[iclu], cluster_1d_q[iclu]);
1449 }
1450 else { // ................................... S2
1451 h_cluster1d_size_L2_S2_x->Fill(cluster_1d_size[iclu]);
1452 h_cluster1d_charge_vs_phi_L2_S2_x->Fill(TMath::RadToDeg()*cluster_1d_phi[iclu], cluster_1d_q[iclu]);
1453 }
1454 }
1455 else {
1456
1457 // v view
1458 if(cluster_1d_sheetid[iclu] == 0) { // ................................... S1
1459 h_cluster1d_size_L2_S1_v->Fill(cluster_1d_size[iclu]);
1460 h_cluster1d_charge_vs_v_L2_S1_v->Fill(cluster_1d_v[iclu], cluster_1d_q[iclu]);
1461 }
1462 else { // ................................... S2
1463 h_cluster1d_size_L2_S2_v->Fill(cluster_1d_size[iclu]);
1464 h_cluster1d_charge_vs_v_L2_S2_v->Fill(cluster_1d_v[iclu], cluster_1d_q[iclu]);
1465 }
1466 }
1467 }
1468 else if(cluster_1d_layerid[iclu] == 2) { // ................................................. LAYER 3
1469
1470 if(cluster_1d_view[iclu] == 0) {
1471
1472 // x view
1473 if(cluster_1d_sheetid[iclu] == 0) { // ................................... S1
1474 h_cluster1d_size_L3_S1_x->Fill(cluster_1d_size[iclu]);
1475 h_cluster1d_charge_vs_phi_L3_S1_x->Fill(TMath::RadToDeg()*cluster_1d_phi[iclu], cluster_1d_q[iclu]);
1476 }
1477 else { // ................................... S2
1478 h_cluster1d_size_L3_S2_x->Fill(cluster_1d_size[iclu]);
1479 h_cluster1d_charge_vs_phi_L3_S2_x->Fill(TMath::RadToDeg()*cluster_1d_phi[iclu], cluster_1d_q[iclu]);
1480 }
1481 }
1482 else {
1483
1484 // v view
1485 if(cluster_1d_sheetid[iclu] == 0) { // ................................... S1
1486 h_cluster1d_size_L3_S1_v->Fill(cluster_1d_size[iclu]);
1487 h_cluster1d_charge_vs_v_L3_S1_v->Fill(cluster_1d_v[iclu], cluster_1d_q[iclu]);
1488 }
1489 else { // ................................... S2
1490 h_cluster1d_size_L3_S2_v->Fill(cluster_1d_size[iclu]);
1491 h_cluster1d_charge_vs_v_L3_S2_v->Fill(cluster_1d_v[iclu], cluster_1d_q[iclu]);
1492 }
1493 }
1494 }
1495
1496 }
1497
1498 h_nofcluster1d_L1_S1_x->Fill(ncluster_1d_L1_S1_x);
1499 // h_nofcluster1d_L1_S2_x->Fill(ncluster_1d_L1_S2_x); // CHECK
1500 h_nofcluster1d_L2_S1_x->Fill(ncluster_1d_L2_S1_x);
1501 h_nofcluster1d_L2_S2_x->Fill(ncluster_1d_L2_S2_x);
1502 h_nofcluster1d_L2_S1_x->Fill(ncluster_1d_L3_S1_x);
1503 h_nofcluster1d_L2_S2_x->Fill(ncluster_1d_L3_S2_x);
1504 h_nofcluster1d_L1_S1_v->Fill(ncluster_1d_L1_S1_v);
1505 h_nofcluster1d_L2_S1_v->Fill(ncluster_1d_L2_S1_v);
1506 h_nofcluster1d_L2_S2_v->Fill(ncluster_1d_L2_S2_v);
1507 h_nofcluster1d_L2_S1_v->Fill(ncluster_1d_L3_S1_v);
1508 h_nofcluster1d_L2_S2_v->Fill(ncluster_1d_L3_S2_v);
1509
1510 if(ncluster_1d != counter) cout << "ERROR in fill_cluster1d_histo: ncluster_1d " << ncluster_1d << ", counter " << counter <<endl;
1511
1512}
1513
1514/**
1515* SELECTION 1 - require all firing planes, i.e. at least one cluster 2d for each plane
1516* get cluster 2d with max charge on each plane
1517* SELECTION 2 - require all charges 1d above cuts
1518* SELECTION 3 - require cl.size 1d > 1 strip
1519**/
1521
1522 double tmp_charge_L1bot = 0;
1523 double tmp_charge_L1top = 0;
1524 double tmp_charge_L2bot = 0;
1525 double tmp_charge_L2top = 0;
1526 double tmp_charge_L3bot = 0;
1527 double tmp_charge_L3top = 0;
1528
1529 int tmp_cluster_L1bot = -1;
1530 int tmp_cluster_L1top = -1;
1531 int tmp_cluster_L2bot = -1;
1532 int tmp_cluster_L2top = -1;
1533 int tmp_cluster_L3bot = -1;
1534 int tmp_cluster_L3top = -1;
1535
1536 // loop on cluster 2d
1537 for(int iclu = 0; iclu < ncluster; iclu++) {
1538
1539 if(cluster_2d_view[iclu] == -1) continue;
1540 if(cluster_2d_view[iclu] != 2) cout << "ERROR in fill_cluster2d_histo " << cluster_2d_view[iclu] << endl;
1541
1542 if(cluster_2d_layerid[iclu] == 0) { // ................................................. LAYER 1
1543
1544 if(cluster_2d_phi[iclu] < 0) { // ................................... S1
1545 if(cluster_2d_q[iclu] > tmp_charge_L1bot) {
1546 tmp_charge_L1bot = cluster_2d_q[iclu];
1547 tmp_cluster_L1bot = iclu;
1548 }
1549 }
1550 else { // ................................... S2
1551 if(cluster_2d_q[iclu] > tmp_charge_L1top) {
1552 tmp_charge_L1top = cluster_2d_q[iclu];
1553 tmp_cluster_L1top = iclu;
1554 }
1555 }
1556 }
1557 else if(cluster_2d_layerid[iclu] == 1) { // ............................................ LAYER 2
1558
1559 if(cluster_2d_sheetid[iclu] == 0) { // ............................... S1
1560 if(cluster_2d_q[iclu] > tmp_charge_L2bot) {
1561 tmp_charge_L2bot = cluster_2d_q[iclu];
1562 tmp_cluster_L2bot = iclu;
1563 }
1564 }
1565 else { // ................................... S2
1566 if(cluster_2d_q[iclu] > tmp_charge_L2top) {
1567 tmp_charge_L2top = cluster_2d_q[iclu];
1568 tmp_cluster_L2top = iclu;
1569 }
1570 }
1571 }
1572 else if(cluster_2d_layerid[iclu] == 2) { // ............................................ LAYER 3
1573 if(cluster_2d_sheetid[iclu] == 0) { // ............................... S1
1574 if(cluster_2d_q[iclu] > tmp_charge_L3bot) {
1575 tmp_charge_L3bot = cluster_2d_q[iclu];
1576 tmp_cluster_L3bot = iclu;
1577 }
1578 }
1579 else { // ................................... S2
1580 if(cluster_2d_q[iclu] > tmp_charge_L3top) {
1581 tmp_charge_L3top = cluster_2d_q[iclu];
1582 tmp_cluster_L3top = iclu;
1583 }
1584 }
1585 }
1586 }
1587
1588 // SELECTION 1 - six firing
1589 if(tmp_cluster_L1bot == -1 || tmp_cluster_L1top == -1 || tmp_cluster_L2bot == -1 || tmp_cluster_L2top == -1 || tmp_cluster_L3bot == -1 || tmp_cluster_L3top == -1 ) return;
1590
1591 // check it is not using the same v strip on L1
1592 if(cluster_2d_idv[tmp_cluster_L1bot] == cluster_2d_idv[tmp_cluster_L1top]) return;
1593
1594 // SELECTION 2 - energy
1595 if(cluster_1d_q[cluster_2d_idx[tmp_cluster_L1bot]] < cut_ene_L1_x || cluster_1d_q[cluster_2d_idv[tmp_cluster_L1bot]] < cut_ene_L1_v ||
1596 cluster_1d_q[cluster_2d_idx[tmp_cluster_L1top]] < cut_ene_L1_x || cluster_1d_q[cluster_2d_idv[tmp_cluster_L1top]] < cut_ene_L1_v ||
1597 cluster_1d_q[cluster_2d_idx[tmp_cluster_L2bot]] < cut_ene_L2_x || cluster_1d_q[cluster_2d_idv[tmp_cluster_L2bot]] < cut_ene_L2_v ||
1598 cluster_1d_q[cluster_2d_idx[tmp_cluster_L2top]] < cut_ene_L2_x || cluster_1d_q[cluster_2d_idv[tmp_cluster_L2top]] < cut_ene_L2_v ||
1599 cluster_1d_q[cluster_2d_idx[tmp_cluster_L3bot]] < cut_ene_L3_x || cluster_1d_q[cluster_2d_idv[tmp_cluster_L3bot]] < cut_ene_L3_v ||
1600 cluster_1d_q[cluster_2d_idx[tmp_cluster_L3top]] < cut_ene_L3_x || cluster_1d_q[cluster_2d_idv[tmp_cluster_L3top]] < cut_ene_L3_v) return;
1601
1602 // SELECTION 3 - size
1603 if(cluster_1d_size[cluster_2d_idx[tmp_cluster_L1bot]] <= cut_size_L1_x || cluster_1d_size[cluster_2d_idv[tmp_cluster_L1bot]] <= cut_size_L1_v ||
1604 cluster_1d_size[cluster_2d_idx[tmp_cluster_L1top]] <= cut_size_L1_x || cluster_1d_size[cluster_2d_idv[tmp_cluster_L1top]] <= cut_size_L1_v ||
1605 cluster_1d_size[cluster_2d_idx[tmp_cluster_L2bot]] <= cut_size_L2_x || cluster_1d_size[cluster_2d_idv[tmp_cluster_L2bot]] <= cut_size_L2_v ||
1606 cluster_1d_size[cluster_2d_idx[tmp_cluster_L2top]] <= cut_size_L2_x || cluster_1d_size[cluster_2d_idv[tmp_cluster_L2top]] <= cut_size_L2_v ||
1607 cluster_1d_size[cluster_2d_idx[tmp_cluster_L3bot]] <= cut_size_L3_x || cluster_1d_size[cluster_2d_idv[tmp_cluster_L3bot]] <= cut_size_L2_v ||
1608 cluster_1d_size[cluster_2d_idx[tmp_cluster_L3top]] <= cut_size_L3_x || cluster_1d_size[cluster_2d_idv[tmp_cluster_L3top]] <= cut_size_L2_v ) return;
1609
1610 // fill charge 2d
1611 h_cluster2d_charge_selected_L1_S1->Fill(tmp_charge_L1bot);
1612 h_cluster2d_charge_selected_L1_S2->Fill(tmp_charge_L1top);
1613 h_cluster2d_charge_selected_L2_S1->Fill(tmp_charge_L2bot);
1614 h_cluster2d_charge_selected_L2_S2->Fill(tmp_charge_L2top);
1615 h_cluster2d_charge_selected_L3_S1->Fill(tmp_charge_L3bot);
1616 h_cluster2d_charge_selected_L3_S2->Fill(tmp_charge_L3top);
1617
1618 // fill charge 1d x
1619 h_cluster1d_charge_selected_L1_S1_x->Fill(cluster_1d_q[cluster_2d_idx[tmp_cluster_L1bot]]);
1620 h_cluster1d_charge_selected_L1_S2_x->Fill(cluster_1d_q[cluster_2d_idx[tmp_cluster_L1top]]);
1621 h_cluster1d_charge_selected_L2_S1_x->Fill(cluster_1d_q[cluster_2d_idx[tmp_cluster_L2bot]]);
1622 h_cluster1d_charge_selected_L2_S2_x->Fill(cluster_1d_q[cluster_2d_idx[tmp_cluster_L2top]]);
1623 h_cluster1d_charge_selected_L3_S1_x->Fill(cluster_1d_q[cluster_2d_idx[tmp_cluster_L3bot]]);
1624 h_cluster1d_charge_selected_L3_S2_x->Fill(cluster_1d_q[cluster_2d_idx[tmp_cluster_L3top]]);
1625
1626 // fill charge 1d v
1627 h_cluster1d_charge_selected_L1_S1_v->Fill(cluster_1d_q[cluster_2d_idv[tmp_cluster_L1bot]]);
1628 h_cluster1d_charge_selected_L1_S2_v->Fill(cluster_1d_q[cluster_2d_idv[tmp_cluster_L1top]]);
1629 h_cluster1d_charge_selected_L2_S1_v->Fill(cluster_1d_q[cluster_2d_idv[tmp_cluster_L2bot]]);
1630 h_cluster1d_charge_selected_L2_S2_v->Fill(cluster_1d_q[cluster_2d_idv[tmp_cluster_L2top]]);
1631 h_cluster1d_charge_selected_L3_S1_v->Fill(cluster_1d_q[cluster_2d_idv[tmp_cluster_L3bot]]);
1632 h_cluster1d_charge_selected_L3_S2_v->Fill(cluster_1d_q[cluster_2d_idv[tmp_cluster_L3top]]);
1633
1634 // fill size 1d x
1635 h_cluster1d_size_selected_L1_S1_x->Fill(cluster_1d_size[cluster_2d_idx[tmp_cluster_L1bot]]);
1636 h_cluster1d_size_selected_L1_S2_x->Fill(cluster_1d_size[cluster_2d_idx[tmp_cluster_L1top]]);
1637 h_cluster1d_size_selected_L2_S1_x->Fill(cluster_1d_size[cluster_2d_idx[tmp_cluster_L2bot]]);
1638 h_cluster1d_size_selected_L2_S2_x->Fill(cluster_1d_size[cluster_2d_idx[tmp_cluster_L2top]]);
1639 h_cluster1d_size_selected_L3_S1_x->Fill(cluster_1d_size[cluster_2d_idx[tmp_cluster_L3bot]]);
1640 h_cluster1d_size_selected_L3_S2_x->Fill(cluster_1d_size[cluster_2d_idx[tmp_cluster_L3top]]);
1641
1642 // fill size 1d v
1643 h_cluster1d_size_selected_L1_S1_v->Fill(cluster_1d_size[cluster_2d_idv[tmp_cluster_L1bot]]);
1644 h_cluster1d_size_selected_L1_S2_v->Fill(cluster_1d_size[cluster_2d_idv[tmp_cluster_L1top]]);
1645 h_cluster1d_size_selected_L2_S1_v->Fill(cluster_1d_size[cluster_2d_idv[tmp_cluster_L2bot]]);
1646 h_cluster1d_size_selected_L2_S2_v->Fill(cluster_1d_size[cluster_2d_idv[tmp_cluster_L2top]]);
1647 h_cluster1d_size_selected_L3_S1_v->Fill(cluster_1d_size[cluster_2d_idv[tmp_cluster_L3bot]]);
1648 h_cluster1d_size_selected_L3_S2_v->Fill(cluster_1d_size[cluster_2d_idv[tmp_cluster_L3top]]);
1649
1650 // fill QmaxQ hit in cluster
1651 float qmax=-999;
1652 for(int i=0;i<cluster_1d_size[cluster_2d_idv[tmp_cluster_L1bot]];i++){
1653 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L1bot]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L1bot]][i]];
1654 }
1655 h_cl_hitmaxQ_charge_selected_L1_S1_v->Fill(qmax);
1656 qmax=-999;
1657 for(int i=0;i<cluster_1d_size[cluster_2d_idv[tmp_cluster_L1top]];i++){
1658 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L1top]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L1top]][i]];
1659 }
1660 h_cl_hitmaxQ_charge_selected_L1_S2_v->Fill(qmax);
1661 qmax=-999;
1662 for(int i=0;i<cluster_1d_size[cluster_2d_idv[tmp_cluster_L2bot]];i++){
1663 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L2bot]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L2bot]][i]];
1664 }
1665 h_cl_hitmaxQ_charge_selected_L2_S1_v->Fill(qmax);
1666 qmax=-999;
1667 for(int i=0;i<cluster_1d_size[cluster_2d_idv[tmp_cluster_L2top]];i++){
1668 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L2top]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L2top]][i]];
1669 }
1670 h_cl_hitmaxQ_charge_selected_L2_S2_v->Fill(qmax);
1671 qmax=-999;
1672 for(int i=0;i<cluster_1d_size[cluster_2d_idv[tmp_cluster_L3bot]];i++){
1673 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L3bot]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L3bot]][i]];
1674 }
1675 h_cl_hitmaxQ_charge_selected_L3_S1_v->Fill(qmax);
1676 qmax=-999;
1677 for(int i=0;i<cluster_1d_size[cluster_2d_idv[tmp_cluster_L3top]];i++){
1678 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L3top]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idv[tmp_cluster_L3top]][i]];
1679 }
1680 h_cl_hitmaxQ_charge_selected_L3_S2_v->Fill(qmax);
1681 qmax=-999;
1682 for(int i=0;i<cluster_1d_size[cluster_2d_idx[tmp_cluster_L1bot]];i++){
1683 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L1bot]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L1bot]][i]];
1684 }
1685 h_cl_hitmaxQ_charge_selected_L1_S1_x->Fill(qmax);
1686 qmax=-999;
1687 for(int i=0;i<cluster_1d_size[cluster_2d_idx[tmp_cluster_L1top]];i++){
1688 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L1top]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L1top]][i]];
1689 }
1690 h_cl_hitmaxQ_charge_selected_L1_S2_x->Fill(qmax);
1691 qmax=-999;
1692 for(int i=0;i<cluster_1d_size[cluster_2d_idx[tmp_cluster_L2bot]];i++){
1693 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L2bot]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L2bot]][i]];
1694 }
1695 h_cl_hitmaxQ_charge_selected_L2_S1_x->Fill(qmax);
1696 qmax=-999;
1697 for(int i=0;i<cluster_1d_size[cluster_2d_idx[tmp_cluster_L2top]];i++){
1698 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L2top]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L2top]][i]];
1699 }
1700 h_cl_hitmaxQ_charge_selected_L2_S2_x->Fill(qmax);
1701 qmax=-999;
1702 for(int i=0;i<cluster_1d_size[cluster_2d_idx[tmp_cluster_L3bot]];i++){
1703 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L3bot]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L3bot]][i]];
1704 }
1705 h_cl_hitmaxQ_charge_selected_L3_S1_x->Fill(qmax);
1706 qmax=-999;
1707 for(int i=0;i<cluster_1d_size[cluster_2d_idx[tmp_cluster_L3top]];i++){
1708 if(qmax<hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L3top]][i]]) qmax=hit_q[cluster_1d_hitindex[cluster_2d_idx[tmp_cluster_L3top]][i]];
1709 }
1710 h_cl_hitmaxQ_charge_selected_L3_S2_x->Fill(qmax);
1711
1712
1713
1714}
1715
1717
1718 // loop on cluster 2d
1719 int ncluster_2d_L1_S1 = 0; int ncluster_2d_L1_S2 = 0; int ncluster_2d_L2_S1 = 0; int ncluster_2d_L2_S2 = 0;int ncluster_2d_L3_S1 = 0; int ncluster_2d_L3_S2 = 0;
1720 int counter=0;
1721 for(int iclu = 0; iclu < ncluster; iclu++) {
1722
1723 if(cluster_2d_view[iclu] == -1) continue;
1724 if(cluster_2d_view[iclu] != 2) cout << "ERROR in fill_cluster2d_histo " << cluster_2d_view[iclu] << endl;
1725 counter++;
1726 // L1
1727 if(cluster_2d_layerid[iclu] == 0) { // ................................................. LAYER 1
1728
1729 if(cluster_2d_phi[iclu] < 0) { // ................................... S1
1730 // h_cluster2d_size_L1_S1->Fill(cluster_2d_size[iclu]);
1731 h_cluster2d_charge_vs_phi_L1_S1->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_q[iclu]);
1732 h_cluster2d_charge_vs_z_L1_S1->Fill(cluster_2d_z[iclu], cluster_2d_q[iclu]);
1733 h_cluster2d_z_vs_phi_L1_S1->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_z[iclu]);
1734 ncluster_2d_L1_S1++;
1735 }
1736 else { // ................................... S2
1737 // h_cluster2d_size_L1_S2->Fill(cluster_2d_size[iclu]);
1738 h_cluster2d_charge_vs_phi_L1_S2->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_q[iclu]);
1739 h_cluster2d_charge_vs_z_L1_S2->Fill(cluster_2d_z[iclu], cluster_2d_q[iclu]);
1740 h_cluster2d_z_vs_phi_L1_S2->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_z[iclu]);
1741 ncluster_2d_L1_S2++;
1742 }
1743 }
1744 else if(cluster_2d_layerid[iclu] == 1) { // ................................................. LAYER 2
1745
1746 if(cluster_2d_sheetid[iclu] == 0) { // ................................... S1
1747 // h_cluster2d_size_L2_S1->Fill(cluster_2d_size[iclu]);
1748 h_cluster2d_charge_vs_phi_L2_S1->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_q[iclu]);
1749 h_cluster2d_charge_vs_z_L2_S1->Fill(cluster_2d_z[iclu], cluster_2d_q[iclu]);
1750 h_cluster2d_z_vs_phi_L2_S1->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_z[iclu]);
1751 ncluster_2d_L2_S1++;
1752 }
1753 else { // ................................... S2
1754 // h_cluster2d_size_L2_S2->Fill(cluster_2d_size[iclu]);
1755 h_cluster2d_charge_vs_phi_L2_S2->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_q[iclu]);
1756 h_cluster2d_charge_vs_z_L2_S2->Fill(cluster_2d_z[iclu], cluster_2d_q[iclu]);
1757 h_cluster2d_z_vs_phi_L2_S2->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_z[iclu]);
1758 ncluster_2d_L2_S2++;
1759 }
1760 }
1761 else if(cluster_2d_layerid[iclu] == 2) { // ................................................. LAYER 3
1762
1763 if(cluster_2d_sheetid[iclu] == 0) { // ................................... S1
1764 // h_cluster2d_size_L2_S1->Fill(cluster_2d_size[iclu]);
1765
1766 h_cluster2d_charge_vs_phi_L3_S1->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_q[iclu]);
1767 h_cluster2d_charge_vs_z_L3_S1->Fill(cluster_2d_z[iclu], cluster_2d_q[iclu]);
1768 h_cluster2d_z_vs_phi_L3_S1->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_z[iclu]);
1769 ncluster_2d_L3_S1++;
1770 }
1771 else { // ................................... S2
1772 // h_cluster2d_size_L2_S2->Fill(cluster_2d_size[iclu]);
1773 h_cluster2d_charge_vs_phi_L3_S2->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_q[iclu]);
1774 h_cluster2d_charge_vs_z_L3_S2->Fill(cluster_2d_z[iclu], cluster_2d_q[iclu]);
1775 h_cluster2d_z_vs_phi_L3_S2->Fill(TMath::RadToDeg()*cluster_2d_phi[iclu], cluster_2d_z[iclu]);
1776 ncluster_2d_L3_S2++;
1777 }
1778 }
1779
1780 }
1781
1782
1783 h_nofcluster2d_L1_S1->Fill(ncluster_2d_L1_S1);
1784 h_nofcluster2d_L1_S2->Fill(ncluster_2d_L1_S2); // CHECK
1785 h_nofcluster2d_L2_S1->Fill(ncluster_2d_L2_S1);
1786 h_nofcluster2d_L2_S2->Fill(ncluster_2d_L2_S2);
1787 h_nofcluster2d_L3_S1->Fill(ncluster_2d_L3_S1);
1788 h_nofcluster2d_L3_S2->Fill(ncluster_2d_L3_S2);
1789 if(ncluster_2d != counter) cout << "ERROR in fill_cluster2d_histo: ncluster_2d " << ncluster_2d << ", counter " << counter << endl;
1790}
1791
1793 // is fitted?
1794 if(track_chi2 == 9999) return;
1795 nfittedtrack++;
1796 h_track_chi2->Fill(track_chi2);
1797 bool isgood = apply_cuts(); // CHECK
1798 if(isgood == false) return;
1799 nvalidtrack++;
1800 h_track_xpoca->Fill(track_xpoca_glo);
1801 h_track_ypoca->Fill(track_ypoca_glo);
1802 h_track_zpoca->Fill(track_zpoca_glo);
1803 // -----------------------------
1804 for(int iclu = 0; iclu < track_nfitpoint; iclu++) {
1805 int ilay = track_layerid[iclu];
1806 int ishe = track_sheetid[iclu];
1807 int cluster2d_id = track_clusterid[iclu];
1808 int idx = cluster_2d_idx[cluster2d_id];
1809 int idv = cluster_2d_idv[cluster2d_id];
1810 //For debugging purporse untile track.root has bug
1811 /*
1812 if(iclu==0) { ilay = 0; ishe = 0; }
1813 if(iclu==1) { ilay = 0; ishe = 1; }
1814 if(iclu==2) { ilay = 1; ishe = 0; }
1815 if(iclu==3) { ilay = 1; ishe = 1; }
1816 if(iclu==4) { ilay = 2; ishe = 0; }
1817 if(iclu==5) { ilay = 2; ishe = 1; }
1818 */
1819 //
1820 if(ilay==0 && ishe==0) {
1821 h_cluster1d_charge_fitted_L1_S1_x->Fill(cluster_1d_q[idx]);
1822 h_cluster1d_charge_fitted_L1_S1_v->Fill(cluster_1d_q[idv]);
1823 }
1824 else if(ilay==0 && ishe==1) {
1825 h_cluster1d_charge_fitted_L1_S2_x->Fill(cluster_1d_q[idx]);
1826 h_cluster1d_charge_fitted_L1_S2_v->Fill(cluster_1d_q[idv]);
1827 }
1828 else if(ilay==1 && ishe==0) {
1829 h_cluster1d_charge_fitted_L2_S1_x->Fill(cluster_1d_q[idx]);
1830 h_cluster1d_charge_fitted_L2_S1_v->Fill(cluster_1d_q[idv]);
1831 }
1832 else if(ilay==1 && ishe==1) {
1833 h_cluster1d_charge_fitted_L2_S2_x->Fill(cluster_1d_q[idx]);
1834 h_cluster1d_charge_fitted_L2_S2_v->Fill(cluster_1d_q[idv]);
1835 }
1836 else if(ilay==2 && ishe==0) {
1837 h_cluster1d_charge_fitted_L3_S1_x->Fill(cluster_1d_q[idx]);
1838 h_cluster1d_charge_fitted_L3_S1_v->Fill(cluster_1d_q[idv]);
1839 }
1840 else if(ilay==2 && ishe==1) {
1841 h_cluster1d_charge_fitted_L3_S2_x->Fill(cluster_1d_q[idx]);
1842 h_cluster1d_charge_fitted_L3_S2_v->Fill(cluster_1d_q[idv]);
1843 }
1844 }
1845
1846 // fitted ..............................
1847 double fit_phi[MAXNOFLAYER][MAXNOFSHEET];
1848 double fit_z[MAXNOFLAYER][MAXNOFSHEET];
1849
1850 // phi
1851 fit_phi[0][0] = track_phi1bot_loc;
1852 fit_phi[0][1] = track_phi1top_loc;
1853 fit_phi[1][0] = track_phi2bot_loc;
1854 fit_phi[1][1] = track_phi2top_loc;
1855 fit_phi[2][0] = track_phi3bot_loc;
1856 fit_phi[2][1] = track_phi3top_loc;
1857
1858
1859 // z
1860 if(align_flag==true) {
1861
1862 HepPoint3D fit_L1_S1_glo(track_x1bot_glo, track_y1bot_glo, track_z1bot_glo);
1863 HepPoint3D fit_L1_S1_loc = alignment->point_transform(0, 0, fit_L1_S1_glo);
1864 HepPoint3D fit_L1_S2_glo(track_x1top_glo, track_y1top_glo, track_z1top_glo);
1865 HepPoint3D fit_L1_S2_loc = alignment->point_transform(0, 1, fit_L1_S2_glo);
1866
1867 HepPoint3D fit_L2_S1_glo(track_x2bot_glo, track_y2bot_glo, track_z2bot_glo);
1868 HepPoint3D fit_L2_S1_loc = alignment->point_transform(1, 0, fit_L2_S1_glo);
1869 HepPoint3D fit_L2_S2_glo(track_x2top_glo, track_y2top_glo, track_z2top_glo);
1870 HepPoint3D fit_L2_S2_loc = alignment->point_transform(1, 1, fit_L2_S2_glo);
1871
1872 HepPoint3D fit_L3_S1_glo(track_x3bot_glo, track_y2bot_glo, track_z3bot_glo);
1873 HepPoint3D fit_L3_S1_loc = alignment->point_transform(2, 0, fit_L3_S1_glo);
1874 HepPoint3D fit_L3_S2_glo(track_x3top_glo, track_y2top_glo, track_z3top_glo);
1875 HepPoint3D fit_L3_S2_loc = alignment->point_transform(2, 1, fit_L3_S2_glo);
1876
1877
1878 fit_z[0][0] = fit_L1_S1_loc.z();
1879 fit_z[0][1] = fit_L1_S2_loc.z();
1880 fit_z[1][0] = fit_L2_S1_loc.z();
1881 fit_z[1][1] = fit_L2_S2_loc.z();
1882 fit_z[2][0] = fit_L3_S1_loc.z();
1883 fit_z[2][1] = fit_L3_S2_loc.z();
1884
1885 }
1886 else {
1887
1888 fit_z[0][0] = track_z1bot_glo;
1889 fit_z[0][1] = track_z1top_glo;
1890 fit_z[1][0] = track_z2bot_glo;
1891 fit_z[1][1] = track_z2top_glo;
1892 fit_z[2][0] = track_z3bot_glo;
1893 fit_z[2][1] = track_z3top_glo;
1894
1895 }
1896 // ------------------------
1897
1898 // experimental ........................
1899 double exp_phi[MAXNOFLAYER][MAXNOFSHEET];
1900 double exp_z[MAXNOFLAYER][MAXNOFSHEET];
1901
1902 double exp_phi_tpc[MAXNOFLAYER][MAXNOFSHEET];
1903 double exp_z_tpc[MAXNOFLAYER][MAXNOFSHEET];
1904
1905 bool stop_here=false;
1906 // trackers
1907 for(int iclu = 0; iclu < track_nfitpoint; iclu++) {
1908 int exp_lay = track_layerid[iclu];
1909 int exp_she = track_sheetid[iclu];
1910
1911 //For debugging purporse untile track.root has bug
1912 /*
1913 if(iclu==0) { exp_lay = 0; exp_she = 0; }
1914 if(iclu==1) { exp_lay = 0; exp_she = 1; }
1915 if(iclu==2) { exp_lay = 1; exp_she = 0; }
1916 if(iclu==3) { exp_lay = 1; exp_she = 1; }
1917 if(iclu==4) { exp_lay = 2; exp_she = 0; }
1918 if(iclu==5) { exp_lay = 2; exp_she = 1; }
1919 */
1920 //
1921
1922 exp_phi[exp_lay][exp_she] = cluster_2d_phi[track_clusterid[iclu]];
1923 exp_z[exp_lay][exp_she] = cluster_2d_z[track_clusterid[iclu]];
1924
1925 exp_phi_tpc[exp_lay][exp_she] = cluster_2d_phi_tpc[track_clusterid[iclu]];
1926 exp_z_tpc[exp_lay][exp_she] = cluster_2d_z_tpc[track_clusterid[iclu]];
1927 }
1928
1929 // residuals
1930 for(int ilay=0; ilay<MAXNOFLAYER; ilay++) {
1931 for(int ishe=0; ishe<MAXNOFSHEET; ishe++) {
1932
1933 double residual_rphi = anode_mid_gap_radius[ilay] * (exp_phi[ilay][ishe] - fit_phi[ilay][ishe]);
1934 double residual_z = exp_z[ilay][ishe] - fit_z[ilay][ishe];
1935
1936 double residual_rphi_tpc = anode_mid_gap_radius[ilay] * (exp_phi_tpc[ilay][ishe] - fit_phi[ilay][ishe]);
1937 double residual_z_tpc = exp_z_tpc[ilay][ishe] - fit_z[ilay][ishe];
1938
1939 /*
1940 cout<<"lay she: "<<ilay<<" "<<ishe<<endl;
1941 cout<<"Phi Z exp: "<<exp_phi[ilay][ishe]<<" "<<exp_z[ilay][ishe]<<endl;
1942 cout<<"Phi Z fit: "<<fit_phi[ilay][ishe]<<" "<<fit_z[ilay][ishe]<<endl;
1943 cout<<"Res RPhi Z: "<<residual_rphi<<" "<<residual_z<<endl;
1944 cout<<"Rad: "<<anode_mid_gap_radius[ilay]<<endl;
1945 cout<<"dPhi: "<<exp_phi[ilay][ishe] - fit_phi[ilay][ishe]<<endl;
1946 cout<<"R*dPhi: "<<anode_mid_gap_radius[ilay] * (exp_phi[ilay][ishe] - fit_phi[ilay][ishe])<<endl;
1947 cout<<"dZ: "<<exp_z[ilay][ishe] - fit_z[ilay][ishe]<<endl;
1948 cout<<"---------"<<endl;
1949 cout<<endl;
1950 */
1951
1952 if(ilay==0 && ishe==0) {
1953 h_residual_rphi_L1_S1->Fill(residual_rphi);
1954 h_residual_z_L1_S1->Fill(residual_z);
1955
1956 h_res_rphi_vs_chi2_L1_S1->Fill(residual_rphi, track_chi2);
1957 h_res_z_vs_chi2_L1_S1->Fill(residual_z, track_chi2);
1958
1959 h_residual_rphi_L1_S1_tpc->Fill(residual_rphi_tpc);
1960 h_residual_z_L1_S1_tpc->Fill(residual_z_tpc);
1961
1962 h_res_rphi_vs_chi2_L1_S1_tpc->Fill(residual_rphi_tpc, track_chi2);
1963 h_res_z_vs_chi2_L1_S1_tpc->Fill(residual_z_tpc, track_chi2);
1964 }
1965 else if(ilay==0 && ishe==1) {
1966 h_residual_rphi_L1_S2->Fill(residual_rphi);
1967 h_residual_z_L1_S2->Fill(residual_z);
1968
1969 h_res_rphi_vs_chi2_L1_S2->Fill(residual_rphi, track_chi2);
1970 h_res_z_vs_chi2_L1_S2->Fill(residual_z, track_chi2);
1971
1972 h_residual_rphi_L1_S2_tpc->Fill(residual_rphi_tpc);
1973 h_residual_z_L1_S2_tpc->Fill(residual_z_tpc);
1974
1975 h_res_rphi_vs_chi2_L1_S2_tpc->Fill(residual_rphi_tpc, track_chi2);
1976 h_res_z_vs_chi2_L1_S2_tpc->Fill(residual_z_tpc, track_chi2);
1977 }
1978 else if(ilay==1 && ishe==0) {
1979 h_residual_rphi_L2_S1->Fill(residual_rphi);
1980 h_residual_z_L2_S1->Fill(residual_z);
1981
1982 h_res_rphi_vs_chi2_L2_S1->Fill(residual_rphi, track_chi2);
1983 h_res_z_vs_chi2_L2_S1->Fill(residual_z, track_chi2);
1984
1985 h_residual_rphi_L2_S1_tpc->Fill(residual_rphi_tpc);
1986 h_residual_z_L2_S1_tpc->Fill(residual_z_tpc);
1987
1988 h_res_rphi_vs_chi2_L2_S1_tpc->Fill(residual_rphi_tpc, track_chi2);
1989 h_res_z_vs_chi2_L2_S1_tpc->Fill(residual_z_tpc, track_chi2);
1990 }
1991 else if(ilay==1 && ishe==1) {
1992 h_residual_rphi_L2_S2->Fill(residual_rphi);
1993 h_residual_z_L2_S2->Fill(residual_z);
1994
1995 h_res_rphi_vs_chi2_L2_S2->Fill(residual_rphi, track_chi2);
1996 h_res_z_vs_chi2_L2_S2->Fill(residual_z, track_chi2);
1997
1998 h_residual_rphi_L2_S2_tpc->Fill(residual_rphi_tpc);
1999 h_residual_z_L2_S2_tpc->Fill(residual_z_tpc);
2000
2001 h_res_rphi_vs_chi2_L2_S2_tpc->Fill(residual_rphi_tpc, track_chi2);
2002 h_res_z_vs_chi2_L2_S2_tpc->Fill(residual_z_tpc, track_chi2);
2003 }
2004 else if(ilay==2 && ishe==0) {
2005 h_residual_rphi_L3_S1->Fill(residual_rphi);
2006 h_residual_z_L3_S1->Fill(residual_z);
2007
2008 h_res_rphi_vs_chi2_L3_S1->Fill(residual_rphi, track_chi2);
2009 h_res_z_vs_chi2_L3_S1->Fill(residual_z, track_chi2);
2010
2011 h_residual_rphi_L3_S1_tpc->Fill(residual_rphi_tpc);
2012 h_residual_z_L3_S1_tpc->Fill(residual_z_tpc);
2013
2014 h_res_rphi_vs_chi2_L3_S1_tpc->Fill(residual_rphi_tpc, track_chi2);
2015 h_res_z_vs_chi2_L3_S1_tpc->Fill(residual_z_tpc, track_chi2);
2016 }
2017 else if(ilay==2 && ishe==1) {
2018 h_residual_rphi_L3_S2->Fill(residual_rphi);
2019 h_residual_z_L3_S2->Fill(residual_z);
2020
2021 h_res_rphi_vs_chi2_L3_S2->Fill(residual_rphi, track_chi2);
2022 h_res_z_vs_chi2_L3_S2->Fill(residual_z, track_chi2);
2023
2024 h_residual_rphi_L3_S2_tpc->Fill(residual_rphi_tpc);
2025 h_residual_z_L3_S2_tpc->Fill(residual_z_tpc);
2026
2027 h_res_rphi_vs_chi2_L3_S2_tpc->Fill(residual_rphi_tpc, track_chi2);
2028 h_res_z_vs_chi2_L3_S2_tpc->Fill(residual_z_tpc, track_chi2);
2029 }
2030 }
2031 }
2032
2033
2034 //
2035
2036
2037
2038 // --------------------------- IF WE ARE TESTING --------------------
2039
2040
2041 // test plane
2042 int exp_lay = track_test_layerid;
2043 int exp_she = track_test_sheetid;
2044
2045 if(exp_lay != -1 && exp_she != -1) {
2046 int track_test_sheetid_checked = track_test_sheetid;
2047 if(track_test_layerid==0) track_test_sheetid_checked=0;
2048 anode = m_SvcCgem->getReadoutPlane(track_test_layerid, track_test_sheetid_checked);
2049 double fit_phi_test_layer = TMath::RadToDeg()*fit_phi[track_test_layerid][track_test_sheetid];
2050 double fit_z_test_layer = fit_z[track_test_layerid][track_test_sheetid];
2051 double fit_v_test_layer = anode->getVFromPhiZ(fit_phi[track_test_layerid][track_test_sheetid],fit_z_test_layer,true);
2052 int strip_phi = anode->getXStripID(fit_phi[track_test_layerid][track_test_sheetid]);
2053 int fit_feb_phi= lutreader->GetFEB(track_test_layerid,track_test_sheetid_checked,0,strip_phi);
2054 int fit_feb_v=lutreader->GetFEB(track_test_layerid,track_test_sheetid_checked,1,(int)fit_v_test_layer);
2055 if(track_chi2>cut_chi2) return;
2056
2057 //Good event vs Phi and/or vs Z
2058 if(track_chi2 <= cut_chi2) {
2059 //Phi 1D and 2D
2060 for(int jj = 0; jj < MAX_PHI_BIN; jj++) {
2061 if(fit_phi_test_layer >= MIN_PHI+(PHI_STEP*jj) && fit_phi_test_layer < MIN_PHI+(PHI_STEP*(jj+1))) {
2062 n_validtrack_phi_arr[jj]++;
2063 n_validtrack_phi_1d_arr[jj]++;
2064 }
2065 }
2066 //V 1D
2067 for(int jj = 0; jj < MAX_V_BIN; jj++) {
2068 if(fit_v_test_layer >= MIN_V+(V_STEP*jj) && fit_v_test_layer < MIN_V+(V_STEP*(jj+1))) {
2069 n_validtrack_v_1d_arr[jj]++;
2070 }
2071 }
2072 //Z 2D
2073 for(int jj = 0; jj < MAX_Z_BIN; jj++) {
2074 if(fit_z_test_layer >= MIN_Z+(Z_STEP*jj) && fit_z_test_layer < MIN_Z+(Z_STEP*(jj+1))) n_validtrack_z_arr[jj]++;
2075 }
2076 //Phi and Z 2D
2077 for(int ii = 0; ii < MAX_PHI_BIN; ii++) {
2078 for(int jj = 0; jj < MAX_Z_BIN; jj++) {
2079 if( (fit_phi_test_layer >= MIN_PHI+(PHI_STEP*ii) && fit_phi_test_layer < MIN_PHI+(PHI_STEP*(ii+1))) && (fit_z_test_layer >= MIN_Z+(Z_STEP*jj) && fit_z_test_layer < MIN_Z+(Z_STEP*(jj+1))) ) n_validtrack_phi_z_mat[ii][jj]++;
2080 }
2081 }
2082 //FEB 2x1D
2083 if(fit_feb_phi>=0 && fit_feb_phi<80) n_validtrack_feb_arr[fit_feb_phi]++;
2084 if(fit_feb_v>=0 && fit_feb_v<80 ) n_validtrack_feb_arr[fit_feb_v]++;
2085 }
2086
2087 //Find the good cluster in test plane
2088 int closest_cluster2d_id = find_closest_exp_cluster2d(fit_phi[exp_lay][exp_she], fit_z[exp_lay][exp_she]);
2089 int closest_cluster1dx_id = find_closest_exp_cluster1dx(fit_phi[exp_lay][exp_she]);
2090 int closest_cluster1dv_id = find_closest_exp_cluster1dv(fit_phi[exp_lay][exp_she], fit_z[exp_lay][exp_she]);
2091
2092 if(closest_cluster1dx_id != -1){
2093 double residual_rphi_1d = anode_mid_gap_radius[track_test_layerid] * (cluster_1d_phi_cc[closest_cluster1dx_id] - fit_phi[track_test_layerid][track_test_sheetid]);
2094 double exp_phi_1d_test_layer = TMath::RadToDeg()*cluster_1d_phi_cc[closest_cluster1dx_id];
2095 vector_test_phi_1d.push_back(exp_phi_1d_test_layer);
2096 vector_fit_phi_1d.push_back(TMath::RadToDeg()*fit_phi[track_test_layerid][track_test_sheetid]);
2097 vector_test_residual_rphi_1d.push_back(residual_rphi_1d);
2098 }
2099
2100 if(closest_cluster1dv_id != -1){
2101 double residual_v_1d = cluster_1d_v_cc[closest_cluster1dv_id] - fit_v_test_layer;
2102 double exp_v_1d_test_layer = cluster_1d_v_cc[closest_cluster1dx_id];
2103 vector_test_v_1d.push_back(exp_v_1d_test_layer);
2104 vector_fit_v_1d.push_back(fit_v_test_layer);
2105 vector_test_residual_v_1d.push_back(residual_v_1d);
2106 }
2107
2108
2109 if(closest_cluster2d_id == -1) return;
2110
2111 exp_phi[exp_lay][exp_she] = cluster_2d_phi[closest_cluster2d_id];
2112 exp_z[exp_lay][exp_she] = cluster_2d_z[closest_cluster2d_id];
2113
2114 exp_phi_tpc[exp_lay][exp_she] = cluster_2d_phi_tpc[closest_cluster2d_id];
2115 exp_z_tpc[exp_lay][exp_she] = cluster_2d_z_tpc[closest_cluster2d_id];
2116
2117 double residual_rphi = anode_mid_gap_radius[track_test_layerid] * (exp_phi[track_test_layerid][track_test_sheetid] - fit_phi[track_test_layerid][track_test_sheetid]);
2118 double residual_z = exp_z[track_test_layerid][track_test_sheetid] - fit_z[track_test_layerid][track_test_sheetid];
2119
2120 double exp_phi_test_layer = TMath::RadToDeg()*exp_phi[track_test_layerid][track_test_sheetid];
2121 vector_test_phi.push_back(exp_phi_test_layer);
2122 vector_fit_phi.push_back(TMath::RadToDeg()*fit_phi[track_test_layerid][track_test_sheetid]);
2123
2124 double exp_z_test_layer = exp_z[track_test_layerid][track_test_sheetid];
2125 vector_test_z.push_back(exp_z_test_layer);
2126 vector_fit_z.push_back(fit_z[track_test_layerid][track_test_sheetid]);
2127
2128 vector_chi2.push_back(track_chi2);
2129
2130 //Map chi2vsPhi and chi2vsZ --> this has to be fixed: exp->fit
2131 for(int chi_i = 0; chi_i < CHI_BIN; chi_i++) {
2132 for(int jj = 0; jj < MAX_PHI_BIN; jj++) {
2133 if(track_chi2 < chi2_cut_arr[chi_i] &&
2134 (exp_phi_test_layer >= MIN_PHI+(PHI_STEP*jj) && exp_phi_test_layer < MIN_PHI+(PHI_STEP*(jj+1))))
2135 n_validtrack_phi_chi2_mat[chi_i][jj]++;
2136 }
2137 for(int jj = 0; jj < MAX_Z_BIN; jj++) {
2138 if( track_chi2 < chi2_cut_arr[chi_i] &&
2139 (exp_z_test_layer >= MIN_Z+(Z_STEP*jj) && exp_z_test_layer < MIN_Z+(Z_STEP*(jj+1))))
2140 n_validtrack_z_chi2_mat[chi_i][jj]++;
2141 }
2142 }
2143
2144 //µTPC
2145 double residual_rphi_tpc = anode_mid_gap_radius[track_test_layerid] * (exp_phi_tpc[track_test_layerid][track_test_sheetid] - fit_phi[track_test_layerid][track_test_sheetid]);
2146 double residual_z_tpc = exp_z_tpc[track_test_layerid][track_test_sheetid] - fit_z[track_test_layerid][track_test_sheetid];
2147
2148 h_test_residual_rphi->Fill(residual_rphi);
2149 h_test_residual_z->Fill(residual_z);
2150
2151 h_test_res_rphi_vs_chi2->Fill(residual_rphi, track_chi2);
2152 h_test_res_z_vs_chi2->Fill(residual_z, track_chi2);
2153
2154 h_test_residual_rphi_tpc->Fill(residual_rphi_tpc);
2155 h_test_residual_z_tpc->Fill(residual_z_tpc);
2156
2157 h_test_res_rphi_vs_chi2_tpc->Fill(residual_rphi_tpc, track_chi2);
2158 h_test_res_z_vs_chi2_tpc->Fill(residual_z_tpc, track_chi2);
2159
2160 h_test_residual_rphi_vs_angxy_L1_cc ->Fill(residual_rphi , ang_xy_L1*TMath::RadToDeg());
2161 h_test_residual_rphi_vs_angxy_L1_tpc->Fill(residual_rphi_tpc, ang_xy_L1*TMath::RadToDeg());
2162 h_test_residual_rphi_vs_angxy_L2_cc ->Fill(residual_rphi , ang_xy_L2*TMath::RadToDeg());
2163 h_test_residual_rphi_vs_angxy_L2_tpc->Fill(residual_rphi_tpc, ang_xy_L2*TMath::RadToDeg());
2164 h_test_residual_rphi_vs_angxy_L3_cc ->Fill(residual_rphi , ang_xy_L3*TMath::RadToDeg());
2165 h_test_residual_rphi_vs_angxy_L3_tpc->Fill(residual_rphi_tpc, ang_xy_L3*TMath::RadToDeg());
2166
2167
2168 // save info for analysis
2169 double q = cluster_2d_q[closest_cluster2d_id];
2170 // 1d components
2171 int idx = cluster_2d_idx[closest_cluster2d_id];
2172 int idv = cluster_2d_idv[closest_cluster2d_id];
2173 double qx = cluster_1d_q[idx];
2174 double qv = cluster_1d_q[idv];
2175 double sizex = cluster_1d_size[idx];
2176 double sizev = cluster_1d_size[idv];
2177
2178 vector_test_residual_rphi.push_back(residual_rphi);
2179 vector_test_residual_z.push_back(residual_z);
2180 vector_test_charge.push_back(q);
2181 vector_test_charge_x.push_back(qx);
2182 vector_test_charge_v.push_back(qv);
2183 vector_test_size_x.push_back(sizex);
2184 vector_test_size_v.push_back(sizev);
2185
2186 vector_test_clusterid.push_back(closest_cluster2d_id);
2187 vector_test_idx.push_back(idx);
2188 vector_test_idv.push_back(idv);
2189
2190 // µtpc debug
2191 bool istpc=plot_debug_tpc(closest_cluster2d_id);
2192 if(istpc) calibration_tpc(closest_cluster2d_id);
2193
2194 }
2195}
2196
2198 bool microsectorL3 = true;
2199 bool gridsL3 = false;
2200
2201
2202 if(track_chi2 > cut_chi2) {
2203 nchi2++;
2204 return false;
2205 }
2206 //init trackers
2207 // fitted
2208 double fit_phi[MAXNOFLAYER][MAXNOFSHEET];
2209 double fit_z[MAXNOFLAYER][MAXNOFSHEET];
2210 //experimental
2211 double exp_phi[MAXNOFLAYER][MAXNOFSHEET];
2212 double exp_z[MAXNOFLAYER][MAXNOFSHEET];
2213 // phi
2214 fit_phi[0][0] = track_phi1bot_loc;
2215 fit_phi[0][1] = track_phi1top_loc;
2216 fit_phi[1][0] = track_phi2bot_loc;
2217 fit_phi[1][1] = track_phi2top_loc;
2218 fit_phi[2][0] = track_phi3bot_loc;
2219 fit_phi[2][1] = track_phi3top_loc;
2220 //z
2221 if(align_flag==true) {
2222 HepPoint3D fit_L1_S1_glo(track_x1bot_glo, track_y1bot_glo, track_z1bot_glo);
2223 HepPoint3D fit_L1_S1_loc = alignment->point_transform(0, 0, fit_L1_S1_glo);
2224 HepPoint3D fit_L1_S2_glo(track_x1top_glo, track_y1top_glo, track_z1top_glo);
2225 HepPoint3D fit_L1_S2_loc = alignment->point_transform(0, 1, fit_L1_S2_glo);
2226
2227 HepPoint3D fit_L2_S1_glo(track_x2bot_glo, track_y2bot_glo, track_z2bot_glo);
2228 HepPoint3D fit_L2_S1_loc = alignment->point_transform(1, 0, fit_L2_S1_glo);
2229 HepPoint3D fit_L2_S2_glo(track_x2top_glo, track_y2top_glo, track_z2top_glo);
2230 HepPoint3D fit_L2_S2_loc = alignment->point_transform(1, 1, fit_L2_S2_glo);
2231
2232 HepPoint3D fit_L3_S1_glo(track_x3bot_glo, track_y2bot_glo, track_z3bot_glo);
2233 HepPoint3D fit_L3_S1_loc = alignment->point_transform(2, 0, fit_L3_S1_glo);
2234 HepPoint3D fit_L3_S2_glo(track_x3top_glo, track_y2top_glo, track_z3top_glo);
2235 HepPoint3D fit_L3_S2_loc = alignment->point_transform(2, 1, fit_L3_S2_glo);
2236
2237 fit_z[0][0] = fit_L1_S1_loc.z();
2238 fit_z[0][1] = fit_L1_S2_loc.z();
2239 fit_z[1][0] = fit_L2_S1_loc.z();
2240 fit_z[1][1] = fit_L2_S2_loc.z();
2241 fit_z[2][0] = fit_L3_S1_loc.z();
2242 fit_z[2][1] = fit_L3_S2_loc.z();
2243 }
2244 else {
2245 fit_z[0][0] = track_z1bot_glo;
2246 fit_z[0][1] = track_z1top_glo;
2247 fit_z[1][0] = track_z2bot_glo;
2248 fit_z[1][1] = track_z2top_glo;
2249 fit_z[2][0] = track_z3bot_glo;
2250 fit_z[2][1] = track_z3top_glo;
2251 }
2252
2253
2254 // ------------------------------
2255 // trackers selection
2256 bool stop_here=false;
2257 for(int iclu = 0; iclu < track_nfitpoint; iclu++) {
2258 int exp_lay = track_layerid[iclu];
2259 int exp_she = track_sheetid[iclu];
2260
2261 int idx = cluster_2d_idx[track_clusterid[iclu]];
2262 int idv = cluster_2d_idv[track_clusterid[iclu]];
2263 double qx = cluster_1d_q[idx];
2264 double qv = cluster_1d_q[idv];
2265
2266 int nx = cluster_1d_size[idx];
2267 int nv = cluster_1d_size[idv];
2268
2269 //charge selection
2270 if(exp_lay==0 && qx < cut_ene_L1_x) stop_here=true;
2271 if(exp_lay==0 && qv < cut_ene_L1_v) stop_here=true;
2272 if(exp_lay==1 && qx < cut_ene_L2_x) stop_here=true;
2273 if(exp_lay==1 && qv < cut_ene_L2_v) stop_here=true;
2274 if(exp_lay==2 && qx < cut_ene_L3_x) stop_here=true;
2275 if(exp_lay==2 && qv < cut_ene_L3_v) stop_here=true;
2276
2277 //size selection
2278 if(exp_lay==0 && nx < cut_size_L1_x) stop_here=true;
2279 if(exp_lay==0 && nv < cut_size_L1_v) stop_here=true;
2280 if(exp_lay==1 && nx < cut_size_L2_x) stop_here=true;
2281 if(exp_lay==1 && nv < cut_size_L2_v) stop_here=true;
2282 if(exp_lay==2 && nx < cut_size_L3_x) stop_here=true;
2283 if(exp_lay==2 && nv < cut_size_L3_v) stop_here=true;
2284
2285 //position selection
2286 exp_phi[exp_lay][exp_she] = cluster_2d_phi[track_clusterid[iclu]];
2287 exp_z[exp_lay][exp_she] = cluster_2d_z[track_clusterid[iclu]];
2288
2289 fit_phi[exp_lay][exp_she]*=TMath::RadToDeg();
2290 exp_phi[exp_lay][exp_she]*=TMath::RadToDeg();
2291
2292 if(exp_lay==0 && exp_she==0){
2293 if(fit_phi[exp_lay][exp_she] < -cut_phi_max_L1 || fit_phi[exp_lay][exp_she] > -cut_phi_min_L1) stop_here=true;
2294 if(fit_z[exp_lay][exp_she] < cut_z_min_L1 || fit_z[exp_lay][exp_she] > cut_z_max_L1) stop_here=true;
2295 }
2296 if(exp_lay==1 && exp_she==0){
2297 if(fit_phi[exp_lay][exp_she] < -cut_phi_max_L2 || fit_phi[exp_lay][exp_she] > -cut_phi_min_L2) stop_here=true;
2298 if(fit_z[exp_lay][exp_she] < cut_z_min_L2 || fit_z[exp_lay][exp_she] > cut_z_max_L2) stop_here=true;
2299 }
2300 if(exp_lay==2 && exp_she==0){
2301 if(fit_phi[exp_lay][exp_she] < -cut_phi_max_L3 || fit_phi[exp_lay][exp_she] > -cut_phi_min_L3) stop_here=true;
2302 if(fit_z[exp_lay][exp_she] < cut_z_min_L3 || fit_z[exp_lay][exp_she] > cut_z_max_L3) stop_here=true;
2303 if(gridsL3){
2304 if(fit_z[exp_lay][exp_she] > -441.875 && fit_z[exp_lay][exp_she] < -439.875 ) stop_here=true; //grid
2305 if(fit_z[exp_lay][exp_she] > -343.938 && fit_z[exp_lay][exp_she] < -341.938 ) stop_here=true;
2306 if(fit_z[exp_lay][exp_she] > -246 &&fit_z[exp_lay][exp_she] <-244 ) stop_here=true;
2307 if(fit_z[exp_lay][exp_she] > -148.062 && fit_z[exp_lay][exp_she] < -146.062 ) stop_here=true;
2308 if(fit_z[exp_lay][exp_she] > -50.125 &&fit_z[exp_lay][exp_she] < -48.125 ) stop_here=true;
2309 if(fit_z[exp_lay][exp_she] > 47.8125 &&fit_z[exp_lay][exp_she] < 49.8125 ) stop_here=true;
2310 if(fit_z[exp_lay][exp_she] > 145.75 &&fit_z[exp_lay][exp_she] <147.75 ) stop_here=true;
2311 if(fit_z[exp_lay][exp_she] > 243.688 &&fit_z[exp_lay][exp_she] < 245.688 ) stop_here=true;
2312 if(fit_z[exp_lay][exp_she] > 341.625 &&fit_z[exp_lay][exp_she] < 343.625 ) stop_here=true;
2313 if(fit_z[exp_lay][exp_she] > 439.562 &&fit_z[exp_lay][exp_she] < 441.562 ) stop_here=true;
2314 }
2315 }
2316 if(exp_lay==0 && exp_she==1){
2317 if(fit_phi[exp_lay][exp_she] < cut_phi_min_L1 || fit_phi[exp_lay][exp_she] > cut_phi_max_L1) stop_here=true;
2318 if(fit_z[exp_lay][exp_she] < cut_z_min_L1 || fit_z[exp_lay][exp_she] > cut_z_max_L1) stop_here=true;
2319 }
2320 if(exp_lay==1 && exp_she==1){
2321 if(fit_phi[exp_lay][exp_she] < cut_phi_min_L2 || fit_phi[exp_lay][exp_she] > cut_phi_max_L2) stop_here=true;
2322 if(fit_z[exp_lay][exp_she] < cut_z_min_L2 || fit_z[exp_lay][exp_she] > cut_z_max_L2) stop_here=true;
2323 }
2324 if(exp_lay==2 && exp_she==1){
2325 if(fit_phi[exp_lay][exp_she] < cut_phi_min_L3 || fit_phi[exp_lay][exp_she] > cut_phi_max_L3) stop_here=true;
2326 if(fit_z[exp_lay][exp_she] < cut_z_min_L3 || fit_z[exp_lay][exp_she] > cut_z_max_L3) stop_here=true;
2327 if(microsectorL3){
2328 if(fit_phi[exp_lay][exp_she] > 93 && fit_phi[exp_lay][exp_she] < 97) stop_here=true; //microsector disconnected
2329 }
2330 if(gridsL3){
2331 if(fit_z[exp_lay][exp_she] > -441.875 && fit_z[exp_lay][exp_she] < -439.875 ) stop_here=true; //grids
2332 if(fit_z[exp_lay][exp_she] > -343.938 && fit_z[exp_lay][exp_she] < -341.938 ) stop_here=true;
2333 if(fit_z[exp_lay][exp_she] > -246 &&fit_z[exp_lay][exp_she] <-244 ) stop_here=true;
2334 if(fit_z[exp_lay][exp_she] > -148.062 && fit_z[exp_lay][exp_she] < -146.062 ) stop_here=true;
2335 if(fit_z[exp_lay][exp_she] > -50.125 &&fit_z[exp_lay][exp_she] < -48.125 ) stop_here=true;
2336 if(fit_z[exp_lay][exp_she] > 47.8125 &&fit_z[exp_lay][exp_she] < 49.8125 ) stop_here=true;
2337 if(fit_z[exp_lay][exp_she] > 145.75 &&fit_z[exp_lay][exp_she] <147.75 ) stop_here=true;
2338 if(fit_z[exp_lay][exp_she] > 243.688 &&fit_z[exp_lay][exp_she] < 245.688 ) stop_here=true;
2339 if(fit_z[exp_lay][exp_she] > 341.625 &&fit_z[exp_lay][exp_she] < 343.625 ) stop_here=true;
2340 if(fit_z[exp_lay][exp_she] > 439.562 &&fit_z[exp_lay][exp_she] < 441.562 ) stop_here=true;
2341 }
2342 }
2343 }
2344
2345
2346 //expected test detector
2347 int exp_lay = track_test_layerid;
2348 int exp_she = track_test_sheetid;
2349 if(exp_lay != -1 && exp_she != -1) {
2350 fit_phi[exp_lay][exp_she]*=TMath::RadToDeg();
2351 if(exp_lay==0 && exp_she==0){
2352 if(fit_phi[exp_lay][exp_she] < -cut_phi_max_L1 || fit_phi[exp_lay][exp_she] > -cut_phi_min_L1) stop_here=true;
2353 if(fit_z[exp_lay][exp_she] < cut_z_min_L1 || fit_z[exp_lay][exp_she] > cut_z_max_L1) stop_here=true;
2354 }
2355 if(exp_lay==1 && exp_she==0){
2356 if(fit_phi[exp_lay][exp_she] < -cut_phi_max_L2 || fit_phi[exp_lay][exp_she] > -cut_phi_min_L2) stop_here=true;
2357 if(fit_z[exp_lay][exp_she] < cut_z_min_L2 || fit_z[exp_lay][exp_she] > cut_z_max_L2) stop_here=true;
2358 }
2359 if(exp_lay==2 && exp_she==0){
2360 if(fit_phi[exp_lay][exp_she] < -cut_phi_max_L3 || fit_phi[exp_lay][exp_she] > -cut_phi_min_L3) stop_here=true;
2361 if(fit_z[exp_lay][exp_she] < cut_z_min_L3 || fit_z[exp_lay][exp_she] > cut_z_max_L3) stop_here=true;
2362 if(gridsL3){
2363 if(fit_z[exp_lay][exp_she] > -441.875 && fit_z[exp_lay][exp_she] < -439.875 ) stop_here=true; //grids
2364 if(fit_z[exp_lay][exp_she] > -343.938 && fit_z[exp_lay][exp_she] < -341.938 ) stop_here=true;
2365 if(fit_z[exp_lay][exp_she] > -246 &&fit_z[exp_lay][exp_she] <-244 ) stop_here=true;
2366 if(fit_z[exp_lay][exp_she] > -148.062 && fit_z[exp_lay][exp_she] < -146.062 ) stop_here=true;
2367 if(fit_z[exp_lay][exp_she] > -50.125 &&fit_z[exp_lay][exp_she] < -48.125 ) stop_here=true;
2368 if(fit_z[exp_lay][exp_she] > 47.8125 &&fit_z[exp_lay][exp_she] < 49.8125 ) stop_here=true;
2369 if(fit_z[exp_lay][exp_she] > 145.75 &&fit_z[exp_lay][exp_she] <147.75 ) stop_here=true;
2370 if(fit_z[exp_lay][exp_she] > 243.688 &&fit_z[exp_lay][exp_she] < 245.688 ) stop_here=true;
2371 if(fit_z[exp_lay][exp_she] > 341.625 &&fit_z[exp_lay][exp_she] < 343.625 ) stop_here=true;
2372 if(fit_z[exp_lay][exp_she] > 439.562 &&fit_z[exp_lay][exp_she] < 441.562 ) stop_here=true;
2373 }
2374 }
2375 if(exp_lay==0 && exp_she==1){
2376 if(fit_phi[exp_lay][exp_she] < cut_phi_min_L1 || fit_phi[exp_lay][exp_she] > cut_phi_max_L1) stop_here=true;
2377 if(fit_z[exp_lay][exp_she] < cut_z_min_L1 || fit_z[exp_lay][exp_she] > cut_z_max_L1) stop_here=true;
2378 }
2379 if(exp_lay==1 && exp_she==1){
2380 if(fit_phi[exp_lay][exp_she] < cut_phi_min_L2 || fit_phi[exp_lay][exp_she] > cut_phi_max_L2) stop_here=true;
2381 if(fit_z[exp_lay][exp_she] < cut_z_min_L2 || fit_z[exp_lay][exp_she] > cut_z_max_L2) stop_here=true;
2382 }
2383 if(exp_lay==2 && exp_she==1){
2384 if(fit_phi[exp_lay][exp_she] < cut_phi_min_L3 || fit_phi[exp_lay][exp_she] > cut_phi_max_L3) stop_here=true;
2385 if(fit_z[exp_lay][exp_she] < cut_z_min_L3 || fit_z[exp_lay][exp_she] > cut_z_max_L3) stop_here=true;
2386 if(microsectorL3){
2387 if(fit_phi[exp_lay][exp_she] > 93 && fit_phi[exp_lay][exp_she] < 97) stop_here=true; //disconnected micro
2388 }
2389 if(gridsL3){
2390 if(fit_z[exp_lay][exp_she] > -441.875 && fit_z[exp_lay][exp_she] < -439.875 ) stop_here=true; //grids
2391 if(fit_z[exp_lay][exp_she] > -343.938 && fit_z[exp_lay][exp_she] < -341.938 ) stop_here=true;
2392 if(fit_z[exp_lay][exp_she] > -246 &&fit_z[exp_lay][exp_she] <-244 ) stop_here=true;
2393 if(fit_z[exp_lay][exp_she] > -148.062 && fit_z[exp_lay][exp_she] < -146.062 ) stop_here=true;
2394 if(fit_z[exp_lay][exp_she] > -50.125 &&fit_z[exp_lay][exp_she] < -48.125 ) stop_here=true;
2395 if(fit_z[exp_lay][exp_she] > 47.8125 &&fit_z[exp_lay][exp_she] < 49.8125 ) stop_here=true;
2396 if(fit_z[exp_lay][exp_she] > 145.75 &&fit_z[exp_lay][exp_she] <147.75 ) stop_here=true;
2397 if(fit_z[exp_lay][exp_she] > 243.688 &&fit_z[exp_lay][exp_she] < 245.688 ) stop_here=true;
2398 if(fit_z[exp_lay][exp_she] > 341.625 &&fit_z[exp_lay][exp_she] < 343.625 ) stop_here=true;
2399 if(fit_z[exp_lay][exp_she] > 439.562 &&fit_z[exp_lay][exp_she] < 441.562 ) stop_here=true;
2400 }
2401 }
2402 }
2403
2404
2405
2406 if(stop_here==true) {
2407 nstopped++;
2408 return false;
2409 }
2410 return true;
2411
2412}
2413// ------------------- ANALYSIS --------------------
2415 // hnoftrack->Fill(ntrack);
2416
2417
2418 int track_test_sheetid_checked = test_sheet_id_all;
2419 if(test_layer_id_all==0) track_test_sheetid_checked=0;
2420 //anode = m_SvcCgem->getReadoutPlane(test_layer_id_all, 0);
2421 anode = m_SvcCgem->getReadoutPlane(test_layer_id_all, track_test_sheetid_checked);
2422
2423
2424
2425 nentries_residual_rphi = h_test_residual_rphi->GetEntries();
2426 nentries_residual_z = h_test_residual_z->GetEntries();
2427
2428 //*
2429 //analysis 1D
2430 float mean_residual_rphi_1d=0;
2431 float mean_residual_v_1d=0;
2432 float sigma_residual_rphi_1d=0;
2433 float sigma_residual_v_1d=0;
2434 for(int i=0;i<vector_test_residual_rphi_1d.size();i++) mean_residual_rphi_1d+=vector_test_residual_rphi_1d.at(i);
2435 mean_residual_rphi_1d/=vector_test_residual_rphi_1d.size();
2436 for(int i=0;i<vector_test_residual_v_1d.size();i++) mean_residual_v_1d+=vector_test_residual_v_1d.at(i);
2437 mean_residual_v_1d/=vector_test_residual_v_1d.size();
2438 for(int i=0;i<vector_test_residual_rphi_1d.size();i++) sigma_residual_rphi_1d+=pow(vector_test_residual_rphi_1d.at(i)-mean_residual_rphi_1d,2);
2439 sigma_residual_rphi_1d=sqrt(sigma_residual_rphi_1d/vector_test_residual_rphi_1d.size());
2440 for(int i=0;i<vector_test_residual_v_1d.size();i++) sigma_residual_v_1d+=pow(vector_test_residual_v_1d.at(i)-mean_residual_v_1d,2);
2441 sigma_residual_v_1d=sqrt(sigma_residual_v_1d/vector_test_residual_v_1d.size());
2442
2443 ofstream res_file2;
2444 res_file2.open("oneDres.txt");
2445 res_file2<<"eff 1dX mean : "<<mean_residual_rphi_1d<<endl;
2446 res_file2<<"eff 1dX sigma : "<<sigma_residual_rphi_1d<<endl;
2447 res_file2<<"eff 1dV mean : "<<mean_residual_v_1d<<endl;
2448 res_file2<<"eff 1dV sigma : "<<sigma_residual_v_1d<<endl;
2449
2450 TCanvas *ccc = new TCanvas("ccc","ccc",800,600);
2451 ccc->cd();
2452 TStyle *ggStyle = new TStyle();
2453 ggStyle->SetOptFit(1111);
2454 TH1F *h_res_1dX = new TH1F("h_res_1dX","h_res_1dX",100,-5,5);
2455 for(int i=0;i<vector_test_residual_rphi_1d.size();i++) h_res_1dX->Fill(vector_test_residual_rphi_1d.at(i));
2456 TF1 *f_res_1dX = new TF1("f_res_1dX","gaus");
2457 if(h_res_1dX->GetEntries()>10) {
2458 h_res_1dX->Fit(f_res_1dX,"WQ");
2459 mean_residual_rphi_1d=f_res_1dX->GetParameter(1);
2460 sigma_residual_rphi_1d=f_res_1dX->GetParameter(2);
2461 ccc->Print("res_X.pdf");
2462 }
2463 TH1F *h_res_1dV = new TH1F("h_res_1dV","h_res_1dV",100,-50,50);
2464 for(int i=0;i<vector_test_residual_v_1d.size();i++) h_res_1dV->Fill(vector_test_residual_v_1d.at(i));
2465 TF1 *f_res_1dV = new TF1("f_res_1dV","gaus");
2466 if(h_res_1dV->GetEntries()>10){
2467 h_res_1dV->Fit(f_res_1dV,"WQ");
2468 mean_residual_v_1d=f_res_1dV->GetParameter(1);
2469 sigma_residual_v_1d=f_res_1dV->GetParameter(2);
2470 ccc->Print("res_V.pdf");
2471 }
2472 res_file2<<"FIT"<<endl;
2473 res_file2<<"eff 1dX mean : "<<mean_residual_rphi_1d<<endl;
2474 res_file2<<"eff 1dX sigma : "<<sigma_residual_rphi_1d<<endl;
2475 res_file2<<"eff 1dV mean : "<<mean_residual_v_1d<<endl;
2476 res_file2<<"eff 1dV sigma : "<<sigma_residual_v_1d<<endl;
2477
2478 res_file2.close();
2479
2480
2481 //*
2482 //analysis 2D
2483
2484 // fit R * phi residual
2485 if(nentries_residual_rphi > 10) {
2486 TF1* f1 = new TF1("f1", "gaus", -5, 5);
2487 f1->SetParameters(1, 0, 1);
2488 h_test_residual_rphi->Fit("f1", "WRNQ");
2489 double param1[3];
2490 f1->GetParameters(&param1[0]);
2491 mean_residual_rphi = param1[1];
2492 sigma_residual_rphi = param1[2];
2493 delete f1;
2494 }
2495
2496 // fit z residual
2497 if(nentries_residual_z > 10) {
2498 TF1 *f2 = new TF1("f2", "gaus", -5, 5);
2499 f2->SetParameters(1, 0, 1);
2500 h_test_residual_z->Fit("f2", "WRNQ");
2501 double param2[3];
2502 f2->GetParameters(&param2[0]);
2503 mean_residual_z = param2[1];
2504 sigma_residual_z = param2[2];
2505 delete f2;
2506 }
2507
2508 // fit residual vs chi2
2509 TF1* f3 = new TF1("f3", "gaus", -5, 5); TF1* f4 = new TF1("f4", "gaus", -5, 5);
2510 TF1* f5 = new TF1("f5", "gaus", -5, 5); TF1* f6 = new TF1("f6", "gaus", -5, 5);
2511 TF1* f7 = new TF1("f7", "gaus", -5, 5); TF1* f8 = new TF1("f8", "gaus", -5, 5);
2512
2513
2514 TH1D *h1_dummy = new TH1D("h1_dummy", "h1_dummy", 100, -5, 5); TH1D *h2_dummy = new TH1D("h2_dummy", "h2_dummy", 100, -5, 5);
2515 TH1D *h3_dummy = new TH1D("h3_dummy", "h3_dummy", 100, -5, 5); TH1D *h4_dummy = new TH1D("h4_dummy", "h4_dummy", 100, -5, 5);
2516 TH1D *h5_dummy = new TH1D("h5_dummy", "h5_dummy", 100, -5, 5); TH1D *h6_dummy = new TH1D("h6_dummy", "h6_dummy", 100, -5, 5);
2517
2518
2519 int i_bin = 0;
2520 int j_dumbin = 0;
2521
2522 double param3[3]; double param4[3];
2523 double param5[3]; double param6[3];
2524 double param7[3]; double param8[3];
2525
2526 for(int i_chi = 0; i_chi < CHI_BIN; i_chi++) {
2527 f3->SetParameters(1, 0, 1); f4->SetParameters(1, 0, 1);
2528 f5->SetParameters(1, 0, 1); f6->SetParameters(1, 0, 1);
2529
2530 i_bin = j_dumbin*j_dumbin + 1;
2531 if(i_chi/3 == 1) i_bin = i_bin*10 ;
2532 if(i_chi/3 == 2) i_bin = i_bin*100 ;
2533 if(i_chi/3 == 3) i_bin = i_bin*1000;
2534
2535 if(j_dumbin < 2) j_dumbin++;
2536 else j_dumbin = 0;
2537
2538 h1_dummy = h_test_res_rphi_vs_chi2->ProjectionX("h1_dummy", 1, i_bin);
2539 h2_dummy = h_test_res_z_vs_chi2 ->ProjectionX("h2_dummy", 1, i_bin);
2540
2541 h3_dummy = h_test_res_rphi_vs_chi2_tpc->ProjectionX("h3_dummy", 1, i_bin);
2542 h4_dummy = h_test_res_z_vs_chi2_tpc ->ProjectionX("h4_dummy", 1, i_bin);
2543
2544 if(h1_dummy->GetEntries() > 10) {
2545 h1_dummy->Fit("f3", "WRNQ");
2546 f3->GetParameters(&param3[0]);
2547 h_resolution_rphi_vs_chi2->SetBinContent(i_chi+1, param3[2]);
2548 }
2549 else h_resolution_rphi_vs_chi2->SetBinContent(i_chi+1, -1);
2550
2551 if(h2_dummy->GetEntries() > 10) {
2552 h2_dummy->Fit("f4", "WRNQ");
2553 f4->GetParameters(&param4[0]);
2554 h_resolution_z_vs_chi2 ->SetBinContent(i_chi+1, param4[2]);
2555 }
2556 else h_resolution_z_vs_chi2 ->SetBinContent(i_chi+1, -1);
2557
2558 if(h3_dummy->GetEntries() > 10) {
2559 h3_dummy->Fit("f5", "WRNQ");
2560 f5->GetParameters(&param5[0]);
2561 h_resolution_rphi_tpc_vs_chi2->SetBinContent(i_chi+1, param5[2]);
2562 }
2563 else h_resolution_rphi_tpc_vs_chi2->SetBinContent(i_chi+1, -1);
2564
2565 if(h4_dummy->GetEntries() > 10) {
2566 h4_dummy->Fit("f6", "WRNQ");
2567 f6->GetParameters(&param6[0]);
2568 h_resolution_z_tpc_vs_chi2 ->SetBinContent(i_chi+1, param6[2]);
2569 }
2570 else h_resolution_z_tpc_vs_chi2 ->SetBinContent(i_chi+1, -1);
2571
2572 h1_dummy->Reset(); h2_dummy->Reset();
2573 h3_dummy->Reset(); h4_dummy->Reset();
2574 }
2575
2576 for(int i_clean = 0; i_clean < 3; i_clean++) {
2577 param3[i_clean] = 0; param4[i_clean] = 0;
2578 param5[i_clean] = 0; param6[i_clean] = 0;
2579 param7[i_clean] = 0; param8[i_clean] = 0;
2580 }
2581 h1_dummy->Reset(); h2_dummy->Reset();
2582 h3_dummy->Reset(); h4_dummy->Reset();
2583 h5_dummy->Reset(); h6_dummy->Reset();
2584
2585 // fit residual vs ang_xy
2586 for(int i_ang = 0; i_ang < ANG_BIN; i_ang++) {
2587
2588 f3->SetParameters(1, 0, 1); f4->SetParameters(1, 0, 1);
2589 f5->SetParameters(1, 0, 1); f6->SetParameters(1, 0, 1);
2590
2591 h1_dummy = h_test_residual_rphi_vs_angxy_L1_cc->ProjectionX("h1_dummy", i_ang+1, i_ang+1);
2592 h2_dummy = h_test_residual_rphi_vs_angxy_L2_cc->ProjectionX("h2_dummy", i_ang+1, i_ang+1);
2593 h5_dummy = h_test_residual_rphi_vs_angxy_L3_cc->ProjectionX("h5_dummy", i_ang+1, i_ang+1);
2594
2595 h3_dummy = h_test_residual_rphi_vs_angxy_L1_tpc->ProjectionX("h3_dummy", i_ang+1, i_ang+1);
2596 h4_dummy = h_test_residual_rphi_vs_angxy_L2_tpc->ProjectionX("h4_dummy", i_ang+1, i_ang+1);
2597 h6_dummy = h_test_residual_rphi_vs_angxy_L3_tpc->ProjectionX("h6_dummy", i_ang+1, i_ang+1);
2598
2599
2600 if(h1_dummy->GetEntries() > 10) {
2601 h1_dummy->Fit("f3", "WRNQ");
2602 h1_dummy->Fit("f3", "WRNQ","",-2*f3->GetParameter(2),2*f3->GetParameter(2));
2603 f3->GetParameters(&param3[0]);
2604 h_resolution_vs_ang_xy_L1->SetBinContent(i_ang+1, param3[2]);
2605 }
2606 else h_resolution_vs_ang_xy_L1->SetBinContent(i_ang+1, -1);
2607
2608 if(h2_dummy->GetEntries() > 10) {
2609 h2_dummy->Fit("f4", "WRNQ");
2610 h2_dummy->Fit("f4", "WRNQ","",-2*f4->GetParameter(2),2*f4->GetParameter(2));
2611 f4->GetParameters(&param4[0]);
2612 h_resolution_vs_ang_xy_L2->SetBinContent(i_ang+1, param4[2]);
2613 }
2614 else h_resolution_vs_ang_xy_L2->SetBinContent(i_ang+1, -1);
2615
2616 if(h5_dummy->GetEntries() > 10) {
2617 h5_dummy->Fit("f7", "WRNQ");
2618 h5_dummy->Fit("f7", "WRNQ","",-2*f7->GetParameter(2),2*f7->GetParameter(2));
2619 f7->GetParameters(&param7[0]);
2620 h_resolution_vs_ang_xy_L3->SetBinContent(i_ang+1, param7[2]);
2621 }
2622 else h_resolution_vs_ang_xy_L3->SetBinContent(i_ang+1, -1);
2623
2624 if(h3_dummy->GetEntries() > 10) {
2625 h3_dummy->Fit("f5", "WRNQ");
2626 h3_dummy->Fit("f5", "WRNQ","",-2*f5->GetParameter(2),2*f5->GetParameter(2));
2627 f5->GetParameters(&param5[0]);
2628 h_resolution_tpc_vs_ang_xy_L1->SetBinContent(i_ang+1, param5[2]);
2629 }
2630 else h_resolution_tpc_vs_ang_xy_L1->SetBinContent(i_ang+1, -1);
2631
2632 if(h4_dummy->GetEntries() > 10) {
2633 h4_dummy->Fit("f6", "WRNQ");
2634 h4_dummy->Fit("f6", "WRNQ","",-2*f6->GetParameter(2),2*f6->GetParameter(2));
2635 f6->GetParameters(&param6[0]);
2636 h_resolution_tpc_vs_ang_xy_L2->SetBinContent(i_ang+1, param6[2]);
2637 }
2638 else h_resolution_tpc_vs_ang_xy_L2->SetBinContent(i_ang+1, -1);
2639
2640 if(h6_dummy->GetEntries() > 10) {
2641 h6_dummy->Fit("f8", "WRNQ");
2642 h6_dummy->Fit("f8", "WRNQ","",-2*f8->GetParameter(2),2*f8->GetParameter(2));
2643 f8->GetParameters(&param8[0]);
2644 h_resolution_tpc_vs_ang_xy_L3->SetBinContent(i_ang+1, param8[2]);
2645 }
2646 else h_resolution_tpc_vs_ang_xy_L3->SetBinContent(i_ang+1, -1);
2647
2648 h1_dummy->Reset(); h2_dummy->Reset();
2649 h3_dummy->Reset(); h4_dummy->Reset();
2650 h5_dummy->Reset(); h6_dummy->Reset();
2651
2652 }
2653 delete f3; delete f4;
2654 delete f5; delete f6;
2655 delete f7; delete f8;
2656
2657 delete h1_dummy; delete h2_dummy;
2658 delete h3_dummy; delete h4_dummy;
2659 delete h5_dummy; delete h6_dummy;
2660
2661 // inside and outside n-sigma on test plane
2662 int const nsigma_inside = NSIGMA_INSIDE; // CHECK cout to ttree
2663 int const nsigma_outside = NSIGMA_INSIDE+5; // CHECK cout to ttree
2664
2665
2666 //cluster 1d
2667 for(int ivec=0; ivec < vector_test_phi_1d.size(); ivec++) {
2668 double phi_fit = vector_fit_phi_1d.at(ivec);
2669 int strip_phi = anode->getXStripID(phi_fit*TMath::DegToRad());
2670 int feb_fit = lutreader->GetFEB(test_layer_id_all,track_test_sheetid_checked,0,strip_phi);
2671 double residual_rphi_1d = vector_test_residual_rphi_1d.at(ivec);
2672 if(residual_rphi_1d > mean_residual_rphi_1d - nsigma_inside * sigma_residual_rphi_1d && residual_rphi_1d < mean_residual_rphi_1d + nsigma_inside * sigma_residual_rphi_1d){
2673 for(int jj = 0; jj < MAX_PHI_BIN; jj++) {
2674 if(phi_fit >= MIN_PHI+(PHI_STEP*jj) && phi_fit < MIN_PHI+(PHI_STEP*(jj+1))) n_insidetrack_phi_1d_arr[jj]++;
2675 }
2676 if(feb_fit>=0 && feb_fit<80) n_insidetrack_feb_arr[feb_fit]++;
2677 }
2678 }
2679 for(int ivec=0; ivec < vector_test_v_1d.size(); ivec++) {
2680 double v_fit = vector_fit_v_1d.at(ivec);
2681 int strip_v = v_fit;
2682 int feb_fit= lutreader->GetFEB(test_layer_id_all,track_test_sheetid_checked,1,strip_v);
2683 double residual_v_1d = vector_test_residual_v_1d.at(ivec);
2684 if(residual_v_1d > mean_residual_v_1d - nsigma_inside * sigma_residual_v_1d && residual_v_1d < mean_residual_v_1d + nsigma_inside * sigma_residual_v_1d){
2685 for(int jj = 0; jj < MAX_V_BIN; jj++) {
2686 if(v_fit >= MIN_V+(V_STEP*jj) && v_fit < MIN_V+(V_STEP*(jj+1))) {
2687 n_insidetrack_v_1d_arr[jj]++;
2688 }
2689 }
2690 if(feb_fit>=0 && feb_fit<80) n_insidetrack_feb_arr[feb_fit]++;
2691 }
2692 }
2693
2694
2695 //cluster 2d
2696 for(int ivec=0; ivec < vector_test_charge.size(); ivec++) {
2697
2698 double residual_rphi = vector_test_residual_rphi.at(ivec);
2699 double residual_z = vector_test_residual_z.at(ivec);
2700
2701 double q = vector_test_charge.at(ivec);
2702 double qx = vector_test_charge_x.at(ivec);
2703 double qv = vector_test_charge_v.at(ivec);
2704 double sizex = vector_test_size_x.at(ivec);
2705 double sizev = vector_test_size_v.at(ivec);
2706 double phi_t = vector_test_phi.at(ivec);
2707 double z_t = vector_test_z.at(ivec);
2708 double phi_fit = vector_fit_phi.at(ivec);
2709 double z_fit = vector_fit_z.at(ivec);
2710
2711 double t_chi2 = vector_chi2.at(ivec);
2712
2713 int clusterid = vector_test_clusterid.at(ivec);
2714 int idx = vector_test_idx.at(ivec);
2715 int idv = vector_test_idv.at(ivec);
2716
2717 // signal 1D
2718 if(residual_rphi > mean_residual_rphi - nsigma_inside * sigma_residual_rphi && residual_rphi < mean_residual_rphi + nsigma_inside * sigma_residual_rphi){
2719 ninside1Dx++;
2720 }
2721 if(residual_z > mean_residual_z - nsigma_inside * sigma_residual_z && residual_z < mean_residual_z + nsigma_inside * sigma_residual_z){
2722 ninside1Dz++;
2723 }
2724
2725 // signal 2D within N sigma
2726 if((residual_rphi > mean_residual_rphi - nsigma_inside * sigma_residual_rphi && residual_rphi < mean_residual_rphi + nsigma_inside * sigma_residual_rphi)
2727 && (residual_z > mean_residual_z - nsigma_inside * sigma_residual_z && residual_z < mean_residual_z + nsigma_inside * sigma_residual_z)) {
2728
2729 h_signal_charge_2d->Fill(q);
2730 h_signal_charge_1d_x->Fill(qx);
2731 h_signal_charge_1d_v->Fill(qv);
2732 h_signal_size_1d_x->Fill(sizex);
2733 h_signal_size_1d_v->Fill(sizev);
2734
2735 if(t_chi2 <= cut_chi2) {
2736 h_signal_charge_2d_chi2cut->Fill(q);
2737 h_signal_charge_1d_x_chi2cut->Fill(qx);
2738 h_signal_charge_1d_v_chi2cut->Fill(qv);
2739 h_signal_size_1d_x_chi2cut->Fill(sizex);
2740 h_signal_size_1d_v_chi2cut->Fill(sizev);
2741
2742 double phi_fit2 = phi_t - residual_rphi/anode_mid_gap_radius[test_layer_id_all];
2743 double z_fit2 = z_t - residual_z;
2744
2745 //Efficienct numerator
2746 for(int jj = 0; jj < MAX_PHI_BIN; jj++) {
2747 if(phi_fit >= MIN_PHI+(PHI_STEP*jj) && phi_fit < MIN_PHI+(PHI_STEP*(jj+1))) n_insidetrack_phi_arr[jj]++;
2748 }
2749 for(int jj = 0; jj < MAX_Z_BIN; jj++) {
2750 if(z_fit >= MIN_Z+(Z_STEP*jj) && z_fit < MIN_Z+(Z_STEP*(jj+1))) n_insidetrack_z_arr[jj]++;
2751 }
2752
2753 for(int ii = 0; ii < MAX_PHI_BIN; ii++) {
2754 for(int jj = 0; jj < MAX_Z_BIN; jj++) {
2755 if((phi_fit >= MIN_PHI+(PHI_STEP*ii) && phi_fit < MIN_PHI+(PHI_STEP*(ii+1))) && (z_fit >= MIN_Z+(Z_STEP*jj) && z_fit < MIN_Z+(Z_STEP*(jj+1)))) {
2756 n_insidetrack_phi_z_mat[ii][jj]++;
2757 }
2758 }
2759 }
2760
2761 }
2762
2763 for(int chi_i = 0; chi_i < CHI_BIN; chi_i++) {
2764 for(int jj = 0; jj < MAX_PHI_BIN; jj++) {
2765 if(t_chi2 < chi2_cut_arr[chi_i] && (phi_t >= MIN_PHI+(PHI_STEP*jj) && phi_t < MIN_PHI+(PHI_STEP*(jj+1)))) n_insidetrack_phi_chi2_mat[chi_i][jj]++;
2766 }
2767 for(int jj = 0; jj < MAX_Z_BIN; jj++) {
2768 if(t_chi2 < chi2_cut_arr[chi_i] && (z_t >= MIN_Z+(Z_STEP*jj) && z_t < MIN_Z+(Z_STEP*(jj+1)))) n_insidetrack_z_chi2_mat[chi_i][jj]++;
2769 }
2770 }
2771
2772 ninside++;
2773 }
2774
2775 // outside
2776 if((residual_rphi < mean_residual_rphi - nsigma_outside * sigma_residual_rphi || residual_rphi > mean_residual_rphi + nsigma_outside * sigma_residual_rphi)
2777 && (residual_z < mean_residual_z - nsigma_outside * sigma_residual_z || residual_z > mean_residual_z + nsigma_outside * sigma_residual_z)) {
2778
2779 h_background_charge_2d->Fill(q);
2780 h_background_charge_1d_x->Fill(qx);
2781 h_background_charge_1d_v->Fill(qv);
2782 h_background_size_1d_x->Fill(sizex);
2783 h_background_size_1d_v->Fill(sizev);
2784
2785 noutside++;
2786 }
2787 }
2788
2789
2790 //MAPS vs phi and Z
2791
2792 for(int i_bin_phi = 0; i_bin_phi < MAX_PHI_BIN; i_bin_phi++) {
2793 h_track_selection_vs_phi->SetBinContent(i_bin_phi+1, n_validtrack_phi_arr[i_bin_phi]);
2794 //2D Phi
2795 if(n_validtrack_phi_arr[i_bin_phi] != 0 && n_validtrack_phi_arr[i_bin_phi] > MIN_ENTRIES) {
2796 float eff = ((double)n_insidetrack_phi_arr[i_bin_phi])/((double)n_validtrack_phi_arr[i_bin_phi]);
2797 float deff = sqrt(eff*(1-eff)/((double)n_validtrack_phi_arr[i_bin_phi]));
2798 h_eff_vs_phi->SetBinContent(i_bin_phi+1, eff);
2799 h_eff_vs_phi->SetBinError(i_bin_phi+1, deff);
2800 }
2801 else {
2802 h_eff_vs_phi->SetBinContent(i_bin_phi+1, 0);
2803 }
2804 //1D Phi
2805 if(n_validtrack_phi_1d_arr[i_bin_phi] != 0 && n_validtrack_phi_1d_arr[i_bin_phi] > MIN_ENTRIES) {
2806 float eff_1d = ((double)n_insidetrack_phi_1d_arr[i_bin_phi])/((double)n_validtrack_phi_1d_arr[i_bin_phi]);
2807 float deff_1d = sqrt(eff_1d*(1-eff_1d)/((double)n_validtrack_phi_1d_arr[i_bin_phi]));
2808 h_eff_vs_phi_1d->SetBinContent(i_bin_phi+1, eff_1d);
2809 h_eff_vs_phi_1d->SetBinError(i_bin_phi+1, deff_1d);
2810 }
2811 else {
2812 h_eff_vs_phi_1d->SetBinContent(i_bin_phi+1, 0);
2813 }
2814 }
2815
2816 for(int i_bin_v = 0; i_bin_v < MAX_V_BIN; i_bin_v++) {
2817 //1D V
2818 if(n_validtrack_v_1d_arr[i_bin_v] != 0 && n_validtrack_v_1d_arr[i_bin_v] > MIN_ENTRIES) {
2819 float eff_1d = ((double)n_insidetrack_v_1d_arr[i_bin_v])/((double)n_validtrack_v_1d_arr[i_bin_v]);
2820 float deff_1d = sqrt(eff_1d*(1-eff_1d)/((double)n_validtrack_v_1d_arr[i_bin_v]));
2821 h_eff_vs_v_1d->SetBinContent(i_bin_v+1, eff_1d);
2822 h_eff_vs_v_1d->SetBinError(i_bin_v+1, deff_1d);
2823 }
2824 else {
2825 h_eff_vs_v_1d->SetBinContent(i_bin_v+1, 0);
2826 }
2827 }
2828
2829 for(int i_bin_feb = 0; i_bin_feb < 80; i_bin_feb++) {
2830 //2x1D FEB
2831 if(n_validtrack_feb_arr[i_bin_feb] != 0 && n_validtrack_feb_arr[i_bin_feb] > MIN_ENTRIES) {
2832 float eff_1d = ((double)n_insidetrack_feb_arr[i_bin_feb])/((double)n_validtrack_feb_arr[i_bin_feb]);
2833 float deff_1d = sqrt(eff_1d*(1-eff_1d)/((double)n_validtrack_feb_arr[i_bin_feb]));
2834 h_eff_vs_FEB->SetBinContent(i_bin_feb+1, eff_1d);
2835 h_eff_vs_FEB->SetBinError(i_bin_feb+1, deff_1d);
2836 }
2837 else {
2838 h_eff_vs_FEB->SetBinContent(i_bin_feb+1, 0);
2839 }
2840 }
2841
2842 //2D Z
2843 for(int i_bin_z = 0; i_bin_z < MAX_Z_BIN; i_bin_z++) {
2844 h_track_selection_vs_z->SetBinContent(i_bin_z+1, n_validtrack_z_arr[i_bin_z]);
2845 if(n_validtrack_z_arr[i_bin_z] != 0 && n_validtrack_z_arr[i_bin_z] > MIN_ENTRIES) {
2846 float eff = ((double)n_insidetrack_z_arr[i_bin_z])/((double)n_validtrack_z_arr[i_bin_z]);
2847 float deff = sqrt(eff*(1-eff)/((double)n_validtrack_z_arr[i_bin_z]));
2848 h_eff_vs_z->SetBinContent(i_bin_z+1, eff);
2849 h_eff_vs_z->SetBinError(i_bin_z+1, deff);
2850 }
2851 else h_eff_vs_z->SetBinContent(i_bin_z+1, 0);
2852 }
2853 //2D Phi and Z
2854 for(int i_bin_phi = 0; i_bin_phi < MAX_PHI_BIN; i_bin_phi++) {
2855 for(int i_bin_z = 0; i_bin_z < MAX_Z_BIN; i_bin_z++) {
2856 h_track_selection_vs_phi_vs_z->SetBinContent(i_bin_phi+1, i_bin_z+1, n_validtrack_phi_z_mat[i_bin_phi][i_bin_z]);
2857 if(n_validtrack_phi_z_mat[i_bin_phi][i_bin_z] != 0 && n_validtrack_phi_z_mat[i_bin_phi][i_bin_z] > MIN_ENTRIES) h_eff_vs_phi_vs_z->SetBinContent(i_bin_phi+1, i_bin_z+1, ((double)n_insidetrack_phi_z_mat[i_bin_phi][i_bin_z])/((double)n_validtrack_phi_z_mat[i_bin_phi][i_bin_z]));
2858 else h_eff_vs_phi_vs_z->SetBinContent(i_bin_phi+1, i_bin_z+1, 0);
2859 }
2860 }
2861 //2D chi2 | chi2 and Phi | chi2 and Z
2862 for(int i_bin_chi = 0; i_bin_chi < CHI_BIN; i_bin_chi++) {
2863 for(int i_bin_phi = 0; i_bin_phi < MAX_PHI_BIN; i_bin_phi++) {
2864 if(n_validtrack_phi_chi2_mat[i_bin_chi][i_bin_phi] != 0 && n_validtrack_phi_chi2_mat[i_bin_chi][i_bin_phi] > MIN_ENTRIES) h_eff_vs_phi_vs_chi2->SetBinContent(i_bin_phi+1, i_bin_chi+1, ((double)n_insidetrack_phi_chi2_mat[i_bin_chi][i_bin_phi])/((double)n_validtrack_phi_chi2_mat[i_bin_chi][i_bin_phi]));
2865 else h_eff_vs_phi_vs_chi2->SetBinContent(i_bin_phi+1, i_bin_chi+1, 0);
2866 }
2867 for(int i_bin_z = 0; i_bin_z < MAX_Z_BIN; i_bin_z++) {
2868 if(n_validtrack_z_chi2_mat[i_bin_chi][i_bin_z] != 0 && n_validtrack_z_chi2_mat[i_bin_chi][i_bin_z] > MIN_ENTRIES) h_eff_vs_z_vs_chi2->SetBinContent(i_bin_z+1, i_bin_chi+1, ((double)n_insidetrack_z_chi2_mat[i_bin_chi][i_bin_z])/((double)n_validtrack_z_chi2_mat[i_bin_chi][i_bin_z]));
2869 else h_eff_vs_z_vs_chi2->SetBinContent(i_bin_z+1, i_bin_chi+1, 0);
2870 }
2871 }
2872
2873}
2874
2875
2877
2878 // ---------------------------------------
2879 // reset range
2880 int lastbin = h_nofhit_L1_S1_x->FindLastBinAbove(0);
2881 h_nofhit_L1_S1_x->GetXaxis()->SetRangeUser(0, lastbin);
2882 lastbin = h_nofhit_L1_S2_x->FindLastBinAbove(0);
2883 h_nofhit_L1_S2_x->GetXaxis()->SetRangeUser(0, lastbin);
2884 lastbin = h_nofhit_L2_S1_x->FindLastBinAbove(0);
2885 h_nofhit_L2_S1_x->GetXaxis()->SetRangeUser(0, lastbin);
2886 lastbin = h_nofhit_L2_S2_x->FindLastBinAbove(0);
2887 h_nofhit_L2_S2_x->GetXaxis()->SetRangeUser(0, lastbin);
2888 lastbin = h_nofhit_L3_S1_x->FindLastBinAbove(0);
2889 h_nofhit_L3_S1_x->GetXaxis()->SetRangeUser(0, lastbin);
2890 lastbin = h_nofhit_L3_S2_x->FindLastBinAbove(0);
2891 h_nofhit_L3_S2_x->GetXaxis()->SetRangeUser(0, lastbin);
2892
2893 lastbin = h_nofhit_L1_S1_v->FindLastBinAbove(0);
2894 h_nofhit_L1_S1_v->GetXaxis()->SetRangeUser(0, lastbin);
2895 lastbin = h_nofhit_L2_S1_v->FindLastBinAbove(0);
2896 h_nofhit_L2_S1_v->GetXaxis()->SetRangeUser(0, lastbin);
2897 lastbin = h_nofhit_L2_S2_v->FindLastBinAbove(0);
2898 h_nofhit_L2_S2_v->GetXaxis()->SetRangeUser(0, lastbin);
2899 lastbin = h_nofhit_L3_S1_v->FindLastBinAbove(0);
2900 h_nofhit_L3_S1_v->GetXaxis()->SetRangeUser(0, lastbin);
2901 lastbin = h_nofhit_L3_S2_v->FindLastBinAbove(0);
2902 h_nofhit_L3_S2_v->GetXaxis()->SetRangeUser(0, lastbin);
2903
2904 lastbin = h_nofcluster1d_L1_S1_x->FindLastBinAbove(0);
2905 h_nofcluster1d_L1_S1_x->GetXaxis()->SetRangeUser(0, lastbin);
2906 lastbin = h_nofcluster1d_L1_S2_x->FindLastBinAbove(0);
2907 h_nofcluster1d_L1_S2_x->GetXaxis()->SetRangeUser(0, lastbin);
2908 lastbin = h_nofcluster1d_L2_S1_x->FindLastBinAbove(0);
2909 h_nofcluster1d_L2_S1_x->GetXaxis()->SetRangeUser(0, lastbin);
2910 lastbin = h_nofcluster1d_L2_S2_x->FindLastBinAbove(0);
2911 h_nofcluster1d_L2_S2_x->GetXaxis()->SetRangeUser(0, lastbin);
2912 lastbin = h_nofcluster1d_L3_S1_x->FindLastBinAbove(0);
2913 h_nofcluster1d_L3_S1_x->GetXaxis()->SetRangeUser(0, lastbin);
2914 lastbin = h_nofcluster1d_L3_S2_x->FindLastBinAbove(0);
2915 h_nofcluster1d_L3_S2_x->GetXaxis()->SetRangeUser(0, lastbin);
2916
2917 lastbin = h_nofcluster1d_L1_S1_v->FindLastBinAbove(0);
2918 h_nofcluster1d_L1_S1_v->GetXaxis()->SetRangeUser(0, lastbin);
2919 lastbin = h_nofcluster1d_L2_S1_v->FindLastBinAbove(0);
2920 h_nofcluster1d_L2_S1_v->GetXaxis()->SetRangeUser(0, lastbin);
2921 lastbin = h_nofcluster1d_L2_S2_v->FindLastBinAbove(0);
2922 h_nofcluster1d_L2_S2_v->GetXaxis()->SetRangeUser(0, lastbin);
2923 lastbin = h_nofcluster1d_L3_S1_v->FindLastBinAbove(0);
2924 h_nofcluster1d_L3_S1_v->GetXaxis()->SetRangeUser(0, lastbin);
2925 lastbin = h_nofcluster1d_L3_S2_v->FindLastBinAbove(0);
2926 h_nofcluster1d_L3_S2_v->GetXaxis()->SetRangeUser(0, lastbin);
2927 /*
2928 h_map_xy_event_trk->GetXaxis()->SetTitle("X pos [mm]");
2929 h_map_xy_event_trk->GetYaxis()->SetTitle("Y pos [mm]");
2930 h_map_xz_event_trk->GetXaxis()->SetTitle("X pos [mm]");
2931 h_map_xz_event_trk->GetYaxis()->SetTitle("Z pos [mm]");
2932
2933 h_map_xy_tpc_eff->GetXaxis()->SetTitle("X pos [mm]");
2934 h_map_xy_tpc_eff->GetYaxis()->SetTitle("Y pos [mm]");
2935 h_map_xz_tpc_eff->GetXaxis()->SetTitle("X pos [mm]");
2936 h_map_xz_tpc_eff->GetYaxis()->SetTitle("Z pos [mm]");
2937
2938 h_map_xy_cc_tpc_diff->GetXaxis()->SetTitle("X pos [mm]");
2939 h_map_xy_cc_tpc_diff->GetYaxis()->SetTitle("Y pos [mm]");
2940 h_map_xz_cc_tpc_diff->GetXaxis()->SetTitle("X pos [mm]");
2941 h_map_xz_cc_tpc_diff->GetYaxis()->SetTitle("Z pos [mm]");
2942
2943 h_map_xy_cc_tpc_diff2->GetXaxis()->SetTitle("X pos [mm]");
2944 h_map_xy_cc_tpc_diff2->GetYaxis()->SetTitle("Y pos [mm]");
2945 h_map_xz_cc_tpc_diff2->GetXaxis()->SetTitle("X pos [mm]");
2946 h_map_xz_cc_tpc_diff2->GetYaxis()->SetTitle("Z pos [mm]");
2947
2948 for(int ii=1;ii<=h_map_xy_event_trk->GetNbinsX();ii++){
2949 for(int jj=1;jj<=h_map_xy_event_trk->GetNbinsY();jj++){
2950 int Nxy = h_map_xy_tpc_eff ->GetBinContent(ii,jj);
2951 int NXY = h_map_xy_cc_eff ->GetBinContent(ii,jj);
2952 int FXY = h_map_xy_tpc_fail ->GetBinContent(ii,jj);
2953 int Dxy = h_map_xy_event_trk ->GetBinContent(ii,jj);
2954 float DDxy = h_map_xy_cc_tpc_diff->GetBinContent(ii,jj);
2955 float Exy = (float)Nxy/Dxy;
2956 float EXY = (float)NXY/Dxy;
2957 float FFXY= (float)FXY/Dxy;
2958 float DDxy_norm = (float)DDxy/Dxy;
2959 if(Nxy && Dxy) h_map_xy_tpc_eff ->SetBinContent(ii,jj,Exy);
2960 if(NXY && Dxy) h_map_xy_cc_eff ->SetBinContent(ii,jj,EXY);
2961 if(FXY && Dxy) h_map_xy_tpc_fail ->SetBinContent(ii,jj,FFXY);
2962 if(DDxy && Dxy && DDxy_norm) h_map_xy_cc_tpc_diff->SetBinContent(ii,jj,DDxy_norm);
2963 //else h_map_xy_cc_tpc_diff->SetBinContent(ii,jj,0);
2964 //cout<<ii<<" "<<jj<<" "<<DDxy<<" "<<Dxy<<" "<<DDxy_norm<<" "<<(DDxy && Dxy)<<endl;
2965 if(abs(h_map_xy_cc_tpc_diff->GetBinContent(ii,jj))>0.01) h_map_xy_cc_tpc_diff2->Fill(ii,jj,h_map_xy_cc_tpc_diff->GetBinContent(ii,jj));
2966
2967 int Nxz = h_map_xz_tpc_eff ->GetBinContent(ii,jj);
2968 int NXZ = h_map_xz_cc_eff ->GetBinContent(ii,jj);
2969 int FXZ = h_map_xz_tpc_fail ->GetBinContent(ii,jj);
2970 int Dxz = h_map_xz_event_trk ->GetBinContent(ii,jj);
2971 float DDxz = h_map_xz_cc_tpc_diff->GetBinContent(ii,jj);
2972 float Exz = (float)Nxz/Dxz;
2973 float EXZ = (float)NXZ/Dxz;
2974 float FFXZ= (float)FXZ/Dxz;
2975 float DDxz_norm =(float)DDxz/Dxz;
2976 if(Nxz && Dxz) h_map_xz_tpc_eff ->SetBinContent(ii,jj,Exz);
2977 if(NXZ && Dxz) h_map_xz_cc_eff ->SetBinContent(ii,jj,EXZ);
2978 if(FXZ && Dxz) h_map_xz_tpc_fail ->SetBinContent(ii,jj,FFXZ);
2979 if(DDxz && Dxz && DDxz_norm) h_map_xz_cc_tpc_diff->SetBinContent(ii,jj,DDxz_norm);
2980 //else h_map_xz_cc_tpc_diff->SetBinContent(ii,jj,0);
2981 //cout<<ii<<" "<<jj<<" "<<DDxz<<" "<<Dxz<<" "<<DDxz_norm<<" "<<(DDxz && Dxz)<<endl;
2982 if(abs(h_map_xz_cc_tpc_diff->GetBinContent(ii,jj))>0.01) h_map_xz_cc_tpc_diff2->Fill(ii,jj,h_map_xz_cc_tpc_diff->GetBinContent(ii,jj));
2983 }
2984 }
2985 */
2986}
2987
2989
2990 int thisclusterid = -1;
2991 double thisdistance = 1000;
2992 for(int iclu = 0; iclu < ncluster; iclu++) {
2993
2994 if(cluster_2d_view[iclu] == -1) continue;
2995 if(cluster_2d_view[iclu] != 2) cout << "ERROR in find_closest_exp_cluster2d " << cluster_2d_view[iclu] << endl;
2996 if(cluster_2d_layerid[iclu] != track_test_layerid) continue;
2997 if(cluster_2d_sheetid[iclu] != track_test_sheetid) continue;
2998
2999 double closest_phi = cluster_2d_phi[iclu];
3000 double closest_z = cluster_2d_z[iclu];
3001
3002 double distance_rphi = fabs(closest_phi - fphi) *anode_mid_gap_radius[track_test_layerid];
3003 double distance_z = fabs(closest_z - fz);
3004 double distance = sqrt(distance_rphi*distance_rphi + distance_z*distance_z);
3005
3006 if(distance < thisdistance) {
3007 thisdistance = distance;
3008 thisclusterid = iclu;
3009 }
3010 }
3011
3012 return thisclusterid;
3013}
3014
3015
3017
3018 int thisclusterid = -1;
3019 double thisdistance = 1000;
3020 for(int iclu = 0; iclu < ncluster; iclu++) {
3021 int track_test_sheetid_checked = track_test_sheetid;
3022 if(track_test_layerid==0) track_test_sheetid_checked=0;
3023 if(cluster_1d_view[iclu] == -1 || cluster_1d_view[iclu] == 1) continue;
3024 if(cluster_1d_view[iclu] != 0) cout << "ERROR in find_closest_exp_cluster1dx " << cluster_1d_view[iclu] << endl;
3025 if(cluster_1d_layerid[iclu] != track_test_layerid) continue;
3026 if(cluster_1d_sheetid[iclu] != track_test_sheetid_checked) continue;
3027
3028 double closest_phi = cluster_1d_phi[iclu];
3029
3030 double distance_rphi = fabs(closest_phi - fphi) *anode_mid_gap_radius[track_test_layerid];
3031 double distance = distance_rphi;
3032
3033 if(distance < thisdistance) {
3034 thisdistance = distance;
3035 thisclusterid = iclu;
3036 }
3037 }
3038
3039 //cout<<"find_closest_exp_cluster1dx: "<<thisclusterid<<" "<<fphi<<" "<<thisdistance<<endl;
3040
3041 return thisclusterid;
3042}
3043
3044
3046
3047 int thisclusterid = -1;
3048 double thisdistance = 1000;
3049 int track_test_sheetid_checked = track_test_sheetid;
3050 if(track_test_layerid==0) track_test_sheetid_checked=0;
3051 anode = m_SvcCgem->getReadoutPlane(track_test_layerid, track_test_sheetid_checked);
3052 double fv = anode->getVFromPhiZ(fphi,fz);
3053 for(int iclu = 0; iclu < ncluster; iclu++) {
3054 if(cluster_1d_view[iclu] == -1 || cluster_1d_view[iclu] == 0) continue;
3055 if(cluster_1d_view[iclu] != 1) cout << "ERROR in find_closest_exp_cluster1dv " << cluster_1d_view[iclu] << endl;
3056 if(cluster_1d_layerid[iclu] != track_test_layerid) continue;
3057 if(cluster_1d_sheetid[iclu] != track_test_sheetid_checked) continue;
3058
3059 double closest_v = cluster_1d_v[iclu];
3060
3061 double distance_v = fabs(closest_v - fv);
3062 double distance = distance_v;
3063
3064 //cout<<"iclu: "<<iclu<<" v: "<<closest_v<<" res. "<<distance<<endl;
3065
3066 if(distance < thisdistance) {
3067 thisdistance = distance;
3068 thisclusterid = iclu;
3069 }
3070 }
3071
3072 //cout<<"find_closest_exp_cluster1dv: "<<thisclusterid<<" "<<fv<<" "<<thisdistance<<endl;
3073
3074 return thisclusterid;
3075}
3076
3077
3078
3080
3081 int cluster2d_id = ID2D;
3082 int idx = cluster_2d_idx[cluster2d_id];
3083 int idv = cluster_2d_idv[cluster2d_id];
3084
3085 int layer = cluster_1d_layerid[idx];
3086 int sheet = cluster_1d_sheetid[idx];
3087 int view = cluster_1d_view[idx];
3088
3089 double hit_x_tpc_good[100];
3090 double hit_z_tpc_good[100];
3091 double hit_ex_tpc_good[100];
3092 double hit_ez_tpc_good[100];
3093 int nhit_good=0;
3094
3095 //Fill
3096 double x_min = +9999;
3097 double x_max = -9999;
3098 for(int IDS=0; IDS<nhit; IDS++){
3099 if(hit_strip[IDS]>=cluster_1d_strip1[idx] && hit_strip[IDS]<=cluster_1d_strip2[idx] && hit_layer[IDS]==layer && hit_sheet[IDS]==sheet && hit_view[IDS]==view){
3100 hit_x_tpc_good[nhit_good] = anode_mid_gap_radius[0]*cos(hit_x_tpc[IDS]);
3101 hit_z_tpc_good[nhit_good] = hit_z_tpc[IDS];
3102 hit_ex_tpc_good[nhit_good] = hit_ex_tpc[IDS];
3103 hit_ez_tpc_good[nhit_good] = hit_ez_tpc[IDS];
3104 if(x_min>hit_x_tpc_good[nhit_good]) x_min = hit_x_tpc_good[nhit_good];
3105 if(x_max<hit_x_tpc_good[nhit_good]) x_max = hit_x_tpc_good[nhit_good];
3106 nhit_good++;
3107 }
3108 }
3109 double track_phi,track_x,track_y,track_z,radius, angle_xy;
3110 if(test_layer_id_all==-1) test_layer_id_all= track_test_layerid;
3111 if(test_sheet_id_all==-1) test_sheet_id_all= track_test_sheetid;
3112 //define Layer L1BOT
3113 if(track_test_layerid == 0 && track_test_sheetid == 0){
3114 track_phi = track_phi1bot_loc;
3115 track_x = track_x1bot_glo;
3116 track_y = track_y1bot_glo;
3117 track_z = track_z1bot_glo;
3118 radius = anode_mid_gap_radius[0];
3119 angle_xy = ang_xy_L1;
3120 }
3121 //define Layer L1TOP
3122 if(track_test_layerid == 0 && track_test_sheetid == 1){
3123 track_phi = track_phi1top_loc;
3124 track_x = track_x1top_glo;
3125 track_y = track_y1top_glo;
3126 track_z = track_z1top_glo;
3127 radius = anode_mid_gap_radius[0];
3128 angle_xy = ang_xy_L1;
3129 }
3130 //define Layer L2BOT
3131 if(track_test_layerid == 1 && track_test_sheetid == 0){
3132 track_phi = track_phi2bot_loc;
3133 track_x = track_x2bot_glo;
3134 track_y = track_y2bot_glo;
3135 track_z = track_z2bot_glo;
3136 radius = anode_mid_gap_radius[1];
3137 angle_xy = ang_xy_L2;
3138 }
3139 //define Layer L2TOP
3140 if(track_test_layerid == 1 && track_test_sheetid == 1){
3141 track_phi = track_phi2top_loc;
3142 track_x = track_x2top_glo;
3143 track_y = track_y2top_glo;
3144 track_z = track_z2top_glo;
3145 radius = anode_mid_gap_radius[1];
3146 angle_xy = ang_xy_L2;
3147 }
3148 //define Layer L3BOT
3149 if(track_test_layerid == 2 && track_test_sheetid == 0){
3150 track_phi = track_phi3bot_loc;
3151 track_x = track_x3bot_glo;
3152 track_y = track_y3bot_glo;
3153 track_z = track_z3bot_glo;
3154 radius = anode_mid_gap_radius[2];
3155 angle_xy = ang_xy_L3;
3156 }
3157 //define Layer L3TOP
3158 if(track_test_layerid == 2 && track_test_sheetid == 1){
3159 track_phi = track_phi3top_loc;
3160 track_x = track_x3top_glo;
3161 track_y = track_y3top_glo;
3162 track_z = track_z3top_glo;
3163 radius = anode_mid_gap_radius[2];
3164 angle_xy = ang_xy_L3;
3165 }
3166
3167 double phi_trk = track_phi;
3168 double x_trk = radius*(cos(phi_trk));
3169 double m_trk = tan((0.5*TMath::Pi()-angle_xy));
3170 if(track_x1bot_glo<0) m_trk*=-1;
3171 double delta = 5;
3172 double x0 = x_trk - delta;
3173 double y0 = 2.5 - delta*m_trk;
3174 double x1 = x_trk + delta;
3175 double y1 = 2.5 + delta*m_trk;
3176 double x_tpc = radius*cos(cluster_1d_phi_tpc[idx]);
3177 double x_cc = radius*cos(cluster_1d_phi_cc[idx]);
3178 double y_tpc = radius*sin(cluster_1d_phi_tpc[idx]);
3179 if(cluster_1d_phi_tpc[idx]==9999) x_tpc=9999;
3180
3181 double x_2d = radius*cos(cluster_2d_phi[ID2D]);
3182 double y_2d = radius*sin(cluster_2d_phi[ID2D]);
3183 double z_2d = cluster_2d_z[ID2D];
3184 double q_2d = cluster_2d_q[ID2D];
3185
3186 //HepPoint3D fit_L1_S1_glo(track_x1bot_glo, track_y1bot_glo, track_z1bot_glo);
3187 //HepPoint3D fit_L1_S1_loc = alignment->point_transform(0, 0, fit_L1_S1_glo);
3188 //HepPoint3D fit_L1_S2_glo(track_x1top_glo, track_y1top_glo, track_z1top_glo);
3189 //HepPoint3D fit_L1_S2_loc = alignment->point_transform(0, 1, fit_L1_S2_glo);
3190
3191
3192 //Fill TH2
3193 double res_cut = 5;
3194 bool fire_tpc = abs(x_tpc-x_trk)<res_cut;
3195 bool fire_cc = abs( x_cc-x_trk)<res_cut;
3196 float diff = (x_cc-x_tpc);
3197 h_map_xy_event_trk ->Fill(track_x, track_y);
3198 h_map_xz_event_trk ->Fill(track_x, track_z);
3199 h_map_xy_2d ->Fill(x_2d , y_2d);
3200 h_map_xz_2d ->Fill(x_2d , z_2d);
3201 if(x_tpc!=9999) h_map_xy_1d_tpc ->Fill(x_tpc , y_tpc);
3202 if(x_tpc!=9999) h_map_xz_1d_tpc ->Fill(x_tpc , z_2d);
3203 if(x_tpc!=9999) h_map_xy_tpc_eff ->Fill(track_x, track_y, fire_tpc);
3204 if(x_tpc!=9999) h_map_xz_tpc_eff ->Fill(track_x, track_z, fire_tpc);
3205 if(x_tpc==9999) h_map_xy_tpc_fail ->Fill(track_x, track_y);
3206 if(x_tpc==9999) h_map_xz_tpc_fail ->Fill(track_x, track_z);
3207 h_map_xy_cc_eff ->Fill(track_x, track_y, fire_cc);
3208 h_map_xz_cc_eff ->Fill(track_x, track_z, fire_cc);
3209 if(x_tpc!=9999) h_map_xy_cc_tpc_diff->Fill(track_x, track_y, diff);
3210 if(x_tpc!=9999) h_map_xz_cc_tpc_diff->Fill(track_x, track_z, diff);
3211 if(fire_cc){
3212 h_map_xy_q2d ->Fill(track_x, track_y, q_2d);
3213 h_map_xz_q2d ->Fill(track_x, track_z, q_2d);
3214 int nbinX = h_map_xy_dT->GetNbinsX();
3215 int nbinY = h_map_xy_dT->GetNbinsY();
3216 int nbinZ = h_map_xz_dT->GetNbinsY();
3217 float rangeX = h_map_xy_dT->GetXaxis()->GetBinCenter(h_map_xy_dT->GetXaxis()->GetLast())-h_map_xy_dT->GetXaxis()->GetBinCenter(1)+h_map_xy_dT->GetXaxis()->GetBinWidth(1);
3218 float rangeY = h_map_xy_dT->GetYaxis()->GetBinCenter(h_map_xy_dT->GetYaxis()->GetLast())-h_map_xy_dT->GetYaxis()->GetBinCenter(1)+h_map_xy_dT->GetYaxis()->GetBinWidth(1);
3219 float rangeZ = h_map_xz_dT->GetYaxis()->GetBinCenter(h_map_xz_dT->GetYaxis()->GetLast())-h_map_xz_dT->GetYaxis()->GetBinCenter(1)+h_map_xz_dT->GetYaxis()->GetBinWidth(1);
3220 float x0 = h_map_xy_dT->GetXaxis()->GetBinCenter(1)+0.5*h_map_xy_dT->GetXaxis()->GetBinWidth(1);
3221 float y0 = h_map_xy_dT->GetYaxis()->GetBinCenter(1)+0.5*h_map_xy_dT->GetYaxis()->GetBinWidth(1);
3222 float z0 = h_map_xz_dT->GetYaxis()->GetBinCenter(1)+0.5*h_map_xz_dT->GetYaxis()->GetBinWidth(1);
3223 int xbin = (track_x-x0)/rangeX*nbinX;
3224 int ybin = (track_y-y0)/rangeY*nbinY;
3225 int zbin = (track_z-z0)/rangeZ*nbinZ;
3226 float time = 0;
3227 for(int IDS=0; IDS<nhit; IDS++){
3228 if(hit_strip[IDS]>=cluster_1d_strip1[idx] && hit_strip[IDS]<=cluster_1d_strip2[idx] && hit_layer[IDS]==layer && hit_sheet[IDS]==sheet && hit_view[IDS]==view){
3229 time = hit_t[IDS];
3230 vector_time_xy[xbin][ybin].push_back(time);
3231 vector_time_xz[xbin][zbin].push_back(time);
3232 }
3233 }
3234 for(int IDS=0; IDS<nhit; IDS++){
3235 if(hit_strip[IDS]>=cluster_1d_strip1[idv] && hit_strip[IDS]<=cluster_1d_strip2[idv] && hit_layer[IDS]==layer && hit_sheet[IDS]==sheet && hit_view[IDS]==view){
3236 time = hit_t[IDS];
3237 vector_time_xy[xbin][ybin].push_back(time);
3238 vector_time_xz[xbin][zbin].push_back(time);
3239 }
3240 }
3241 }
3242
3243 //
3244 //double ang_trk = (0.5*TMath::Pi()-angle_xy)*TMath::RadToDeg();
3245 //if(track_x>0) ang_trk*=-1;
3246 //double ang_tpc = atan(cluster_1d_a_tpc[idx])*TMath::RadToDeg();
3247 //if(x_tpc!=9999) h_ang_trk_meas ->Fill(ang_trk,ang_tpc);
3248
3249 //Correction
3250 //h_deltaX_order_size
3251
3252
3253
3254
3255 //if(event < 5000 && false){
3256 // cout<<"------------------"<<endl;
3257 // cout<<"x_2d: "<<x_2d<<" \t x_1d_cc: "<<x_cc<<" \t x_1d_tpc: "<<x_tpc<<" \t x_trk: "<<x_trk<<endl;
3258 // if(x_tpc==9999 || 1){
3259 // cout<<"event: "<<event<<" \t phi: "<<cluster_1d_phi_tpc[idx]<<" \t nHit_good: "<<nhit_good<<endl;
3260 // for(int hh=0;hh<nhit_good;hh++) cout<<hit_x_tpc_good[hh]<<" "<<hit_z_tpc_good[hh]<<endl;
3261 // }
3262 //}
3263 //if(event < 1000) cout<<diff<<" "<<(anode_mid_gap_radius[0]*(cos(cluster_1d_phi_cc[idx])))<<" "<<(anode_mid_gap_radius[0]*(cos(cluster_1d_phi_tpc[idx])))<<endl;
3264 //Plot TPC events on .png
3265 if(true){
3266 TCanvas *c1 = new TCanvas("c1","c1",800,600);
3267 if(cluster_1d_phi_tpc[idx]!=9999 && nhit_good>1){
3268 TGraphErrors *g = new TGraphErrors(nhit_good,hit_x_tpc_good,hit_z_tpc_good,hit_ex_tpc_good,hit_ez_tpc_good);
3269 g->SetMarkerStyle(20);
3270 g->SetMarkerSize(1.0);
3271 g->SetMarkerColor(2);
3272 g->Draw("AP");
3273 g->GetYaxis()->SetRangeUser(-2,7);
3274 TAxis *axis = g->GetXaxis();
3275 axis->SetLimits((x_min-1),(x_max+1));
3276 TF1 *tpc_fit = new TF1("tpc_fit","pol1");
3277 g->Fit("tpc_fit","Q");
3278 TLine *line_x_tpc = new TLine(x_tpc,-2,x_tpc,7);
3279 line_x_tpc->SetLineColor(2);
3280 line_x_tpc->Draw("same");
3281 TLine *line_x_fit = new TLine(x_trk,-2,x_trk,7);
3282 line_x_fit->SetLineColor(6);
3283 line_x_fit->Draw("same");
3284 TLine *line_trk = new TLine(x0,y0,x1,y1);
3285 line_trk->SetLineColor(6);
3286 line_trk->SetLineStyle(2);
3287 line_trk->Draw("same");
3288 TLine *line_mid = new TLine(-1000,2.5,1000,2.5);
3289 line_mid->SetLineColor(4);
3290 line_mid->SetLineStyle(2);
3291 line_mid->Draw("same");
3292 TLine *line_up = new TLine(-1000,5,1000,5);
3293 line_up->SetLineColor(4);
3294 line_up->SetLineStyle(2);
3295 line_up->Draw("same");
3296 TLine *line_dw = new TLine(-1000,0,1000,0);
3297 line_dw->SetLineColor(4);
3298 line_dw->SetLineStyle(2);
3299 line_dw->Draw("same");
3300
3301 double ang_trk = -(angle_xy)*TMath::RadToDeg();
3302 if(track_x>0) ang_trk*=-1;
3303 //double ang_tpc = (0.5*TMath::Pi()-atan(tpc_fit->GetParameter(1)))*TMath::RadToDeg();
3304 //h_ang_tpc->Fill(ang_tpc);
3305 //if(ang_tpc>90) ang_tpc= -(180-ang_tpc);
3306 double ang_tpc = atan(tpc_fit->GetParameter(1))*TMath::RadToDeg();
3307 if(ang_tpc>0) ang_tpc = (90-ang_tpc);
3308 else ang_tpc = -(90+ang_tpc);
3309 h_ang_tpc->Fill(ang_tpc);
3310 //if(x_tpc!=9999 && abs(ang_tpc)>5 && abs(x_tpc-x_trk)<res_cut){
3311 if(x_tpc!=9999 && abs(ang_tpc)>5 && abs(x_tpc-x_trk)<res_cut && ang_tpc<0){
3312 h_ang_trk_meas ->Fill(ang_trk,ang_tpc);
3313 h_ang_diff_vs_trk ->Fill(ang_trk,ang_trk-ang_tpc);
3314 h_ang_diff ->Fill(ang_trk-ang_tpc);
3315 }
3316
3317 //cout<<event<<" "<<ang_trk<<" "<<ang_tpc<<endl;
3318
3319 int deg5 = (int)(ang_xy_L1*TMath::RadToDeg()/5)*5;
3320 if(track_x>0) deg5*=-1;
3321 TString name_plot;
3322 //if(abs(x_tpc-x_trk)<res_cut) name_plot=Form("/IN_clus_tpc_%i.png" ,event);
3323 //else name_plot=Form("/OUT_clus_tpc_%i.png",event);
3324 if(abs(x_tpc-x_trk)<res_cut) name_plot=Form("/Angle_%i_IN_clus_tpc_%i.png" ,deg5,event);
3325 else name_plot=Form("/Angle_%i_OUT_clus_tpc_%i.png",deg5,event);
3326 name_plot = output_path_tpc+name_plot;
3327 if(bool_plot_tpc) c1->SaveAs(name_plot);
3328 delete g;
3329 delete axis;
3330 delete tpc_fit;
3331 delete line_x_tpc;
3332 delete line_x_fit;
3333 delete line_trk;
3334 delete line_mid;
3335 delete line_up;
3336 delete line_dw;
3337 }
3338 delete c1;
3339 }
3340 bool efficient_tpc = abs(x_tpc-x_trk)<res_cut;
3341 return efficient_tpc;
3342}
3343
3345 int cluster2d_id = ID2D;
3346 int idx = cluster_2d_idx[cluster2d_id];
3347 int idv = cluster_2d_idv[cluster2d_id];
3348
3349 int layer = cluster_1d_layerid[idx];
3350 int sheet = cluster_1d_sheetid[idx];
3351 int view = cluster_1d_view[idx];
3352 int size = cluster_1d_size[idx];
3353
3354 double hit_x_tpc_good[100];
3355 double hit_z_tpc_good[100];
3356 double hit_ex_tpc_good[100];
3357 double hit_ez_tpc_good[100];
3358 int nhit_good=0;
3359 double track_phi,track_x,track_y,track_z,radius, angle_xy;
3360 //define Layer L1BOT
3361 if(track_test_layerid == 0 && track_test_sheetid == 0){
3362 track_x = track_x1bot_glo;
3363 angle_xy = ang_xy_L1;
3364 }
3365 //define Layer L1TOP
3366 if(track_test_layerid == 0 && track_test_sheetid == 1){
3367 track_x = track_x1top_glo;
3368 angle_xy = ang_xy_L1;
3369 }
3370 //define Layer L2BOT
3371 if(track_test_layerid == 1 && track_test_sheetid == 0){
3372 track_x = track_x2bot_glo;
3373 angle_xy = ang_xy_L2;
3374 }
3375 //define Layer L2TOP
3376 if(track_test_layerid == 1 && track_test_sheetid == 1){
3377 track_x = track_x2top_glo;
3378 angle_xy = ang_xy_L2;
3379 }
3380 //define Layer L3BOT
3381 if(track_test_layerid == 2 && track_test_sheetid == 0){
3382 track_x = track_x3bot_glo;
3383 angle_xy = ang_xy_L3;
3384 }
3385 //define Layer L3TOP
3386 if(track_test_layerid == 2 && track_test_sheetid == 1){
3387 track_x = track_x3top_glo;
3388 angle_xy = ang_xy_L3;
3389 }
3390
3391 //cout<<"layer: "<<layer<<" view: "<<view<<" sheet: "<<sheet<<endl;
3392
3393 double ang_trk = -(angle_xy)*TMath::RadToDeg();
3394 if(track_x>0) ang_trk*=-1;
3395
3396 //Fill
3397 double x_min = +9999;
3398 double x_max = -9999;
3399 for(int IDS=0; IDS<nhit; IDS++){
3400 if(hit_strip[IDS]>=cluster_1d_strip1[idx] && hit_strip[IDS]<=cluster_1d_strip2[idx] && hit_layer[IDS]==layer && hit_sheet[IDS]==sheet && hit_view[IDS]==view){
3401 if(size>=maxclusize) continue;
3402 if(ang_trk<0) continue; // select only this angle ↗
3403 //if(ang_trk>0) continue;
3404 if(hit_order[IDS]<0) continue;
3405 if(hit_view[IDS]==0 && hit_ex_tpc[IDS]<1 && hit_ex_tpc[IDS]!=0 && abs(hit_deltaz_tpc[IDS])>0.001){
3406 //cout<<"order: "<<hit_order[IDS]<<" \t size: "<<size<<" \t deltaX: "<<hit_deltax_tpc[IDS]<<endl;
3407 h_deltaX_order_size[hit_order[IDS]][size]->Fill(hit_deltax_tpc[IDS]);
3408 h_deltaZ_order_size[hit_order[IDS]][size]->Fill(hit_deltax_tpc[IDS]);
3409 }
3410 }
3411 }
3412 return;
3413}
3414
3416
3417 //plot info
3418 h_map_xy_event_trk->GetXaxis()->SetTitle("X pos [mm]");
3419 h_map_xy_event_trk->GetYaxis()->SetTitle("Y pos [mm]");
3420 h_map_xz_event_trk->GetXaxis()->SetTitle("X pos [mm]");
3421 h_map_xz_event_trk->GetYaxis()->SetTitle("Z pos [mm]");
3422
3423 h_map_xy_tpc_eff->GetXaxis()->SetTitle("X pos [mm]");
3424 h_map_xy_tpc_eff->GetYaxis()->SetTitle("Y pos [mm]");
3425 h_map_xz_tpc_eff->GetXaxis()->SetTitle("X pos [mm]");
3426 h_map_xz_tpc_eff->GetYaxis()->SetTitle("Z pos [mm]");
3427
3428 h_map_xy_cc_tpc_diff->GetXaxis()->SetTitle("X pos [mm]");
3429 h_map_xy_cc_tpc_diff->GetYaxis()->SetTitle("Y pos [mm]");
3430 h_map_xz_cc_tpc_diff->GetXaxis()->SetTitle("X pos [mm]");
3431 h_map_xz_cc_tpc_diff->GetYaxis()->SetTitle("Z pos [mm]");
3432
3433 h_map_xy_cc_tpc_diff2->GetXaxis()->SetTitle("X pos [mm]");
3434 h_map_xy_cc_tpc_diff2->GetYaxis()->SetTitle("Y pos [mm]");
3435 h_map_xz_cc_tpc_diff2->GetXaxis()->SetTitle("X pos [mm]");
3436 h_map_xz_cc_tpc_diff2->GetYaxis()->SetTitle("Z pos [mm]");
3437
3438 //MAPS and efficiency
3439 for(int ii=1;ii<=h_map_xy_event_trk->GetNbinsX();ii++){
3440 for(int jj=1;jj<=h_map_xy_event_trk->GetNbinsY();jj++){
3441 //XY
3442 int Nxy = h_map_xy_tpc_eff ->GetBinContent(ii,jj);
3443 int NXY = h_map_xy_cc_eff ->GetBinContent(ii,jj);
3444 int FXY = h_map_xy_tpc_fail ->GetBinContent(ii,jj);
3445 int Dxy = h_map_xy_event_trk ->GetBinContent(ii,jj);
3446 float DDxy = h_map_xy_cc_tpc_diff->GetBinContent(ii,jj);
3447 float Qxy = h_map_xy_q2d ->GetBinContent(ii,jj);
3448 float Exy = (float)Nxy/Dxy;
3449 float EXY = (float)NXY/Dxy;
3450 float FFXY = (float)FXY/Dxy;
3451 float DDxy_norm = (float)DDxy/Dxy;
3452 float QXY = 0;
3453 if(NXY) QXY= (float)Qxy/NXY;
3454 //** Efficiency
3455 if(Nxy && Dxy) h_map_xy_tpc_eff ->SetBinContent(ii,jj,Exy);
3456 if(NXY && Dxy) h_map_xy_cc_eff ->SetBinContent(ii,jj,EXY);
3457 if(FXY && Dxy) h_map_xy_tpc_fail ->SetBinContent(ii,jj,FFXY);
3458 //** µTPC debug
3459 if(DDxy && Dxy && DDxy_norm)
3460 h_map_xy_cc_tpc_diff->SetBinContent(ii,jj,DDxy_norm);
3461 if(abs(h_map_xy_cc_tpc_diff->GetBinContent(ii,jj))>0.01)
3462 h_map_xy_cc_tpc_diff2->Fill(ii,jj,h_map_xy_cc_tpc_diff->GetBinContent(ii,jj));
3463 //** Charge
3464 if(NXY && QXY) h_map_xy_q2d ->SetBinContent(ii,jj,QXY);
3465 //** Time
3466 if(vector_time_xy[ii][jj].size()){
3467 TH1F *h_timemap_XY = new TH1F(Form("h_timemap_XY_%i_%i",ii,jj),"h_timemap_XY",96,-9400,-8800);
3468 for(int iv=0;iv<vector_time_xy[ii][jj].size();iv++){
3469 h_timemap_XY->Fill(vector_time_xy[ii][jj].at(iv));
3470 }
3471 if(h_timemap_XY->GetMaximum()<10) continue;
3472 float baseline_time_xy = 0;
3473 for(int ibin=1;ibin<6;ibin++) baseline_time_xy+=h_timemap_XY->GetBinContent(ibin);
3474 baseline_time_xy/=5;
3475 float maximum_time_xy = h_timemap_XY->GetMaximum()-baseline_time_xy;
3476 float rising_time_xy = 0;
3477 for(int ibin=h_timemap_XY->GetMaximumBin();ibin>1;ibin--){
3478 if(h_timemap_XY->GetBinContent(ibin)-baseline_time_xy < 0.3*maximum_time_xy) {
3479 rising_time_xy = h_timemap_XY->GetBinCenter(ibin);
3480 break;
3481 }
3482 }
3483 float falling_time_xy = 0;
3484 for(int ibin=h_timemap_XY->GetMaximumBin();ibin<200;ibin++){
3485 if(h_timemap_XY->GetBinContent(ibin)-baseline_time_xy < 0.3*maximum_time_xy) {
3486 falling_time_xy = h_timemap_XY->GetBinCenter(ibin);
3487 break;
3488 }
3489 }
3490 float delta_time_xy = falling_time_xy-rising_time_xy;
3491 h_map_xy_dT->SetBinContent(ii,jj,delta_time_xy);
3492 }
3493 //XZ
3494 int Nxz = h_map_xz_tpc_eff ->GetBinContent(ii,jj);
3495 int NXZ = h_map_xz_cc_eff ->GetBinContent(ii,jj);
3496 int FXZ = h_map_xz_tpc_fail ->GetBinContent(ii,jj);
3497 int Dxz = h_map_xz_event_trk ->GetBinContent(ii,jj);
3498 float DDxz = h_map_xz_cc_tpc_diff->GetBinContent(ii,jj);
3499 float Qxz = h_map_xz_q2d ->GetBinContent(ii,jj);
3500 float Exz = (float)Nxz/Dxz;
3501 float EXZ = (float)NXZ/Dxz;
3502 float FFXZ= (float)FXZ/Dxz;
3503 float DDxz_norm =(float)DDxz/Dxz;
3504 float QXZ = 0;
3505 if(NXZ) QXZ= (float)Qxz/NXZ;
3506 //** Efficiency
3507 if(Nxz && Dxz) h_map_xz_tpc_eff ->SetBinContent(ii,jj,Exz);
3508 if(NXZ && Dxz) h_map_xz_cc_eff ->SetBinContent(ii,jj,EXZ);
3509 if(FXZ && Dxz) h_map_xz_tpc_fail ->SetBinContent(ii,jj,FFXZ);
3510 //** µTPC debug
3511 if(DDxz && Dxz && DDxz_norm) h_map_xz_cc_tpc_diff->SetBinContent(ii,jj,DDxz_norm);
3512 if(abs(h_map_xz_cc_tpc_diff->GetBinContent(ii,jj))>0.01) h_map_xz_cc_tpc_diff2->Fill(ii,jj,h_map_xz_cc_tpc_diff->GetBinContent(ii,jj));
3513 //** Charge
3514 if(NXZ && QXZ) h_map_xz_q2d ->SetBinContent(ii,jj,QXZ);
3515 //** Time
3516 if(vector_time_xz[ii][jj].size()){
3517 TH1F *h_timemap_XZ = new TH1F(Form("h_timemap_XZ_%i_%i",ii,jj),"h_timemap_XZ",96,-9400,-8800);
3518 for(int iv=0;iv<vector_time_xz[ii][jj].size();iv++){
3519 h_timemap_XZ->Fill(vector_time_xz[ii][jj].at(iv));
3520 }
3521 if(h_timemap_XZ->GetMaximum()<10) continue;
3522 float baseline_time_xz = 0;
3523 //cout<<ii<<" "<<jj<<endl;
3524 //for(int ibin=1;ibin<96;ibin++) cout<<h_timemap_XZ->GetBinContent(ibin)<<" ";
3525 //cout<<endl;
3526 for(int ibin=1;ibin<6;ibin++) baseline_time_xz+=h_timemap_XZ->GetBinContent(ibin);
3527 baseline_time_xz/=5;
3528 float maximum_time_xz = h_timemap_XZ->GetMaximum()-baseline_time_xz;
3529 //cout<<"max bin: "<<h_timemap_XZ->GetMaximumBin()<<endl;
3530 //cout<<"base: "<<baseline_time_xz<<endl;
3531 //cout<<"max - base: "<<maximum_time_xz<<endl;
3532
3533 float rising_time_xz = 0;
3534 for(int ibin=h_timemap_XZ->GetMaximumBin();ibin>1;ibin--){
3535 //cout<<"rise: "<<ibin<<" "<<h_timemap_XZ->GetBinContent(ibin)<<" "<<h_timemap_XZ->GetBinContent(ibin)-baseline_time_xz<<" "<<0.3*maximum_time_xz<<endl;
3536 if(h_timemap_XZ->GetBinContent(ibin)-baseline_time_xz < 0.3*maximum_time_xz) {
3537 //cout<<"RISE"<<endl;
3538 rising_time_xz = h_timemap_XZ->GetBinCenter(ibin);
3539 break;
3540 }
3541 }
3542 float falling_time_xz = 0;
3543 for(int ibin=h_timemap_XZ->GetMaximumBin();ibin<200;ibin++){
3544 //cout<<"fall: "<<ibin<<" "<<h_timemap_XZ->GetBinContent(ibin)<<" "<<h_timemap_XZ->GetBinContent(ibin)-baseline_time_xz<<" "<<0.3*maximum_time_xz<<endl;
3545 if(h_timemap_XZ->GetBinContent(ibin)-baseline_time_xz < 0.3*maximum_time_xz) {
3546 //cout<<"FALL"<<endl;
3547 falling_time_xz = h_timemap_XZ->GetBinCenter(ibin);
3548 break;
3549 }
3550 }
3551 float delta_time_xz = falling_time_xz-rising_time_xz;
3552 //cout<<"rise: "<<rising_time_xz<<" fall: "<<falling_time_xz<<" delta: "<<delta_time_xz<<endl;
3553 h_map_xz_dT->SetBinContent(ii,jj,delta_time_xz);
3554
3555 }
3556 }
3557 }
3558
3559 //correction
3560 //output->cd("track_histo");
3561 output-> mkdir("tpc_histo", "histograms of fitted tracks");
3562 output->cd("tpc_histo");
3563 int size_init = 3;
3564 for(int i=size_init;i<(int)maxclusize;i++){
3565 cout<<"Size: "<<i<<endl;
3566 for(int j=0;j<i;j++){
3567 x_order[j]=j;
3568 y_deltaX[j] =h_deltaX_order_size[j][i]->GetMean();
3569 ey_deltaX[j]=h_deltaX_order_size[j][i]->GetMeanError();
3570 y_deltaZ[j] =h_deltaZ_order_size[j][i]->GetMean();
3571 ey_deltaZ[j]=h_deltaZ_order_size[j][i]->GetMeanError();
3572 }
3573 deltaX_order_L1[i] = new TGraphErrors(i,x_order,y_deltaX,0,ey_deltaX);
3574 deltaX_order_L1[i]->Draw("AP");
3575 deltaX_order_L1[i]->Fit(f_deltaX[i],"Q","",0.5,maxclusize);
3576 //deltaX_order_L1[i]->Fit(f_deltaX[i],"Q","",0.,i-1.5);
3577 deltaX_order_L1[i]->Write(Form("deltaX_order_L1_size_%i",i));
3578 deltaZ_order_L1[i] = new TGraphErrors(i,x_order,y_deltaZ,0,ey_deltaZ);
3579 deltaZ_order_L1[i]->Draw("AP");
3580 deltaZ_order_L1[i]->Fit(f_deltaZ[i],"Q","",0.5,maxclusize);
3581 //deltaZ_order_L1[i]->Fit(f_deltaZ[i],"Q","",0.,i-1.5);
3582 deltaZ_order_L1[i]->Write(Form("deltaZ_order_L1_size_%i",i));
3583
3584 y_deltaX_par0 [i-size_init] = f_deltaX[i]->GetParameter(0);
3585 ey_deltaX_par0[i-size_init] = f_deltaX[i]->GetParError(0);
3586 y_deltaX_par1 [i-size_init] = f_deltaX[i]->GetParameter(1);
3587 ey_deltaX_par1[i-size_init] = f_deltaX[i]->GetParError(1);
3588 y_deltaZ_par0 [i-size_init] = f_deltaZ[i]->GetParameter(0);
3589 ey_deltaZ_par0[i-size_init] = f_deltaZ[i]->GetParError(0);
3590 y_deltaZ_par1 [i-size_init] = f_deltaZ[i]->GetParameter(1);
3591 ey_deltaZ_par1[i-size_init] = f_deltaZ[i]->GetParError(1);
3592 xx_order [i-size_init] = i;
3593
3594 cout<<"f(0): "<<f_deltaX[i]->GetParameter(0)<<" y0: "<<y_deltaX[0]<<" diff: "<<f_deltaX[i]->GetParameter(0)-y_deltaX[0]<<endl;
3595 //cout<<"f(0): "<<f_deltaX[i]->GetParameter(0)<<" y0: "<<y_deltaX[0]<<" diff: "<<f_deltaX[i]->GetParameter(0)-y_deltaX[i-1]<<endl;
3596 y_shift0[i-size_init] =f_deltaX[i]->GetParameter(0)-y_deltaX[0];
3597 //y_shift0[i-size_init] =f_deltaX[i]->GetParameter(0)-y_deltaX[i-1];
3598 ey_shift0[i-size_init]=f_deltaX[i]->GetParError(0);
3599
3600 }
3601
3602 for(int i=size_init;i<(int)maxclusize;i++){
3603 x_order[i]=i;
3604 }
3605 deltaX_par0 = new TGraphErrors(maxclusize-size_init,xx_order,y_deltaX_par0,0,ey_deltaX_par0);
3606 deltaX_par0->Fit("pol1");
3607 deltaX_par1 = new TGraphErrors(maxclusize-size_init,xx_order,y_deltaX_par1,0,ey_deltaX_par1);
3608 deltaX_par1->Fit("pol1");
3609 deltaZ_par0 = new TGraphErrors(maxclusize-size_init,xx_order,y_deltaZ_par0,0,ey_deltaZ_par0);
3610 deltaZ_par1 = new TGraphErrors(maxclusize-size_init,xx_order,y_deltaZ_par1,0,ey_deltaZ_par1);
3611 shift0 = new TGraphErrors(maxclusize-size_init,xx_order,y_shift0,0,ey_shift0);
3612 shift0->Fit("pol1");
3613
3614 deltaX_par0->Write("deltaX_par0");
3615 deltaX_par1->Write("deltaX_par1");
3616 deltaZ_par0->Write("deltaZ_par0");
3617 deltaZ_par1->Write("deltaZ_par1");
3618 shift0->Write("shift0");
3619
3620
3621 return;
3622}
double tan(const BesAngle a)
Definition BesAngle.h:216
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
#define MAX_Z
#define MAXLENGTH_L2_x
#define MAXNOFSHEET
#define CHI_BIN
#define MAX_V
#define MAX_PHI
#define MAXNOFSTRIP_L2_v
#define V_STEP
#define MAXNOFTRACKS
#define MAXNOFSTRIP_L3_v
#define MAXNOFSTRIP_L1_x
#define Z_STEP
#define MAX_V_BIN
#define MAXNOFCLUSTERS
#define MIN_V
#define MAX_PHI_BIN
#define CHI_MAX
#define MAXNOFSTRIP_L3_x
#define ANG_MAX
#define MAXNOFSTRIP_L1_v
#define MIN_Z
#define maxclusize
#define MAXLENGTH_L3_x
#define MIN_ENTRIES
#define MAX_Z_BIN
#define MAXLENGTH_L1_x
#define MAXNOFHITS
#define MIN_PHI
#define MAXLENGTH_L2_v
#define ANG_MIN
#define PHI_STEP
#define MAXNOFLAYER
#define MAXNOFSTRIP_L2_x
#define CHI_MIN
#define ANG_BIN
#define MAXLENGTH_L1_v
TCanvas * c1
************Class m_alfQCDMZ INTEGER m_KFfin INTEGER m_IVfin INTEGER m_ibox *COMMON c_DZface $ alphaQED at(Q^2=MZ^2) DIZET $ m_alfQCDMZ
TFile * f1
Double_t time
Int_t nentries
double abs(const EvtComplex &c)
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition KKsem.h:33
IMessageSvc * msgSvc()
CgemCosmicRayQA(const std::string &name, ISvcLocator *pSvcLocator)
void calibration_tpc(int id_2D)
void define_cluster_selected_histo()
bool plot_debug_tpc(int id_2D)
int find_closest_exp_cluster1dx(double fphi)
int find_closest_exp_cluster2d(double fphi, double fz)
StatusCode initialize()
void define_cluster1d_from_fit_histo()
int find_closest_exp_cluster1dv(double fphi, double fz)
bool read_file(TString name)
double getDx(int layer_vir)
double getRx(int layer_vir)
double getRy(int layer_vir)
double getRz(int layer_vir)
double getDz(int layer_vir)
HepPoint3D point_transform(int layer_vir, HepPoint3D pos)
double getDy(int layer_vir)
double getVFromPhiZ(double phi, double z, bool checkRange=true) const
int getXStripID(double phi) const
int GetFEB(int ilayer, int isheet, int iview, int istrip)
double getR(int layer)
virtual CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const =0
virtual CgemGeoAlign * getAlignPtr() const =0
virtual CgemMidDriftPlane * getMidDriftPtr() const =0