BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
ToF400DigitAnalysis_period5.c
Go to the documentation of this file.
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7#include "TCanvas.h"
8#include "TChain.h"
9#include "TDirectory.h"
10#include "TFile.h"
11#include "TH1.h"
12#include "TH1F.h"
13#include "TH1S.h"
14#include "TH2F.h"
15#include "TH2S.h"
16#include "TList.h"
17#include "TPad.h"
18
19#include <TMath.h>
20#include <fstream>
21#include <iostream>
22#include <stdio.h>
23// #include "BmnEventHeader.h"
24
25const UInt_t kNST = 48;
26const Double_t kTimeBin = 24. / 1024.;
29Double_t CorrPlane7Coeff_It1[5][4] = {{12.24, -3.919, 0.2624, -0.005153},
30 {-122.9, 14.84, -0.6158, 0.008724},
31 {-12.34, 0.482, 0., 0.},
32 {-12.28, 0.479, 0., 0.},
33 {-13.14, 0.5034, 0., 0.}};
34Double_t CorrT0Coeff_It1[4][4] = {{-5.486, 1.087, -0.07936, 0.00208},
35 {10.77, -2.635, 0.1984, -0.004631},
36 {-2.163, 0.1362, 0., 0.},
37 {200, 0, 0, 0}};
40
41struct ToF400Detector
42{
51};
52
53struct T0Detector
54{
58};
59
60void ToF400DigitAnalysis_period5(TString file = "", Int_t nEvForRead = 0, Int_t Periud = 5)
61{
62 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
63 bmnloadlibs(); // load BmnRoot libraries
64
65 /*if (Run < 796) {
66 CatTimeBC2Low = 250.;
67 CatTimeBC2High = 450.;
68 } else {
69 CatTimeBC2Low = 390.;
70 CatTimeBC2High = 590.;
71 }//*/
72
73 TChain* eveTree = new TChain("cbmsim");
74 TString inName;
75 inName = file;
76 cout << "Open file " << inName << endl << endl;
77 eveTree->Add(inName);
78
79 TClonesArray* ToF400Digits;
80 eveTree->SetBranchAddress("TOF400", &ToF400Digits);
81
82 TClonesArray* BC2Digits;
83 eveTree->SetBranchAddress("T0", &BC2Digits);
84
85 TClonesArray* EventHeader;
86 eveTree->SetBranchAddress("EventHeader", &EventHeader);
87
88 Long64_t nEvents = eveTree->GetEntries();
89 if (nEvForRead == 0)
90 nEvForRead = nEvents;
91 cout << "Will be readed " << nEvForRead << " events from " << nEvents << endl;
92
93 //------variables----------------------------------------------------------------------
94 char hid[50];
95 Int_t Point;
96 ofstream f_call, f_dt;
97 TF1* f_gaus = new TF1("f_gaus", "gaus", -20, 40);
98
99 ToF400Detector Plane2;
100 ToF400Detector Plane7;
101 T0Detector T0;
102 CleanTof(&Plane2);
103 CleanTof(&Plane7);
104 CleanBC2(&T0);
105
106 TList* ListStat = new TList();
107 TList* ListAmpTofPlane2 = new TList();
108 TList* ListTimeTofPlane2 = new TList();
109 TList* ListLRTofPlane2 = new TList();
110 TList* ListAmpTofPlane7 = new TList();
111 TList* ListTimeTofPlane7 = new TList();
112 TList* ListLRTofPlane7 = new TList();
113 TList* ListLRCorrTofPlane7 = new TList();
114 TList* ListLRvsAmpLTofPlane7 = new TList();
115 TList* ListLRvsAmpRTofPlane7 = new TList();
116 TList* ListAnalysis = new TList();
117 TString name, name2;
118
119 TH1I* hAmpTofPlane2[kNST + 1];
120 TH1I* hTimeTofPlane2[kNST + 1];
121 TH1I* hLevtMinusRightPlane2[kNST + 1];
122 for (Int_t i = 0; i < kNST + 1; i++) {
123 name = Form("hAmpTofPlane2_%d", i);
124 hAmpTofPlane2[i] = new TH1I(name, name, 1024, 0, 50.);
125 ListAmpTofPlane2->Add(hAmpTofPlane2[i]);
126 name = Form("hTimeTofPlane2_%d", i);
127 hTimeTofPlane2[i] = new TH1I(name, name, 1000, 0, 1000.);
128 ListTimeTofPlane2->Add(hTimeTofPlane2[i]);
129 name = Form("hLevtMinusRightPlane2_%d", i);
130 hLevtMinusRightPlane2[i] = new TH1I(name, name, 1024, -12., 12.);
131 ListLRTofPlane2->Add(hLevtMinusRightPlane2[i]);
132 }
133 TH2I* hAmpLRPlane2 = new TH2I("hAmpLRPlane2", "hAmpLRPlane2", 1024, 0., 50., 1024, 0., 50.);
134 ListAmpTofPlane2->Add(hAmpLRPlane2);
135
136 TH1I* hAmpTofPlane7[kNST + 1];
137 TH1I* hTimeTofPlane7[kNST + 1];
138 TH1I* hLeftMinusRightPlane7[kNST + 1];
139 TH2S* hLeftRightVsAmpLPlane7[kNST + 1];
140 TH2S* hLeftRightVsAmpRPlane7[kNST + 1];
141 TH2S* hLeftRightCorelationRPlane7[kNST + 1];
142 for (Int_t i = 0; i < kNST + 1; i++) {
143 name = Form("hAmpTofPlane7_%d", i);
144 hAmpTofPlane7[i] = new TH1I(name, name, 1024, 0, 50.);
145 ListAmpTofPlane7->Add(hAmpTofPlane7[i]);
146 name = Form("hTimeTofPlane7_%d", i);
147 hTimeTofPlane7[i] = new TH1I(name, name, 1000, 0, 1000.);
148 ListTimeTofPlane7->Add(hTimeTofPlane7[i]);
149 name = Form("hLeftRightCorelationRPlane7_%d", i);
150 hLeftRightCorelationRPlane7[i] = new TH2S(name, name, 1024, 0., 50., 1024, 0., 50.);
151 ListLRCorrTofPlane7->Add(hLeftRightCorelationRPlane7[i]);
152 name = Form("hLeftMinusRightPlane7_%d", i);
153 hLeftMinusRightPlane7[i] = new TH1I(name, name, 1024, -12., 12.);
154 ListLRTofPlane7->Add(hLeftMinusRightPlane7[i]);
155 name = Form("hLeftRightVsAmpLPlane7_%d", i);
156 hLeftRightVsAmpLPlane7[i] = new TH2S(name, name, 1024, 0., 50., 1024, -12., 12.);
157 ListLRvsAmpLTofPlane7->Add(hLeftRightVsAmpLPlane7[i]);
158 name = Form("hLeftRightVsAmpRPlane7_%d", i);
159 hLeftRightVsAmpRPlane7[i] = new TH2S(name, name, 1024, 0., 50., 1024, -12., 12.);
160 ListLRvsAmpRTofPlane7->Add(hLeftRightVsAmpRPlane7[i]);
161 }
162 TH2I* hAmpLRPlane7 = new TH2I("hAmpLRPlane7", "hAmpLRPlane7", 1024, 0., 50., 1024, 0., 50.);
163 ListAmpTofPlane7->Add(hAmpLRPlane7);
164
165 TH1I* hHitStripsPerEvPlane2 = new TH1I("hHitStripsPerEvPlane2", "Hit Strips Per Ev on Plane#2", kNST, 0, kNST);
166 ListStat->Add(hHitStripsPerEvPlane2);
167 TH1I* hHitStripsPerEvPlane7 = new TH1I("hHitStripsPerEvPlane7", "Hit Strips Per Ev on Plane#7", kNST, 0, kNST);
168 ListStat->Add(hHitStripsPerEvPlane7);
169 TH2I* hLefRightCorelation_Plane2 =
170 new TH2I("hLefRightCorelation_Plane2", " Lef-Right Corelation Plane#2", kNST, 0, kNST, kNST, 0, kNST);
171 ListStat->Add(hLefRightCorelation_Plane2);
172 TH2I* hLefRightCorelation_Plane7 =
173 new TH2I("hLefRightCorelation_Plane7", " Lef-Right Corelation Plane#7", kNST, 0, kNST, kNST, 0, kNST);
174 ListStat->Add(hLefRightCorelation_Plane7);
175 TH2I* hPlane2Plane7Correlation =
176 new TH2I("hPlane2Plane7Correlation", " Plane2-Plane7 Correlation", kNST, 0, kNST, kNST, 0, kNST);
177 ListStat->Add(hPlane2Plane7Correlation);
178 TH1S* hNoize = new TH1S("hNoize", "hNoize", 500, 0, 50);
179 hNoize->GetXaxis()->SetTitle("MHz");
180 ListStat->Add(hNoize);
181 Int_t NEvStrip47 = 0;
182 TH1I* hNEvStrip47 = new TH1I("hNEvStrip47", "hNEvStrip47", 20, 0, 20);
183 ListStat->Add(hNEvStrip47);
184
185 TList* ListT0 = new TList();
186 TH1I* hHitT0PerEv = new TH1I("hHitT0PerEv", "Hit T0 Per Ev", 10, 0, 10);
187 ListT0->Add(hHitT0PerEv);
188 TH1I* hAmpT0 = new TH1I("hAmpT0", "Amp T0", 1024, 0, 50);
189 ListT0->Add(hAmpT0);
190 TH1I* hTimeT0 = new TH1I("hTimeT0", "Time T0", 1000, 0, 1000);
191 ListT0->Add(hTimeT0);
192
193 TH1I* hdt[kNST + 1];
194
195 for (Int_t i = 0; i < kNST + 1; i++) {
196 name = Form("hdt_%d", i);
197 name2 = Form("dt T0 - ToF400_Plane7_str_%d", i);
198 hdt[i] = new TH1I(name, name2, 1024 + 512, -18., 18.);
199 hdt[i]->SetLineWidth(3);
200 ListAnalysis->Add(hdt[i]);
201 }
202
203 TH2I* hdt_vs_AmpT0[kNST + 1];
204 for (Int_t i = 0; i < kNST + 1; i++) {
205 name = Form("hdt_vs_AmpT0_%d", i);
206 name2 = Form("dt T0 - ToF400_Plane7_str_%d vs AMP_T0", i);
207 hdt_vs_AmpT0[i] = new TH2I(name, name2, 1024, 0, 50, 1024 + 512, -24, 48);
208 ListAnalysis->Add(hdt_vs_AmpT0[i]);
209 }
210
211 TH2I* hdt_vs_AmpToF[kNST + 1];
212 for (Int_t i = 0; i < kNST + 1; i++) {
213 name = Form("hdt_vs_AmpToF_%d", i);
214 name2 = Form("dt T0 - ToF400_Plane7_str_%d vs AMP_TOF400", i);
215 hdt_vs_AmpToF[i] = new TH2I(name, name2, 1024, 0, 50, 1024 + 512, -24, 48);
216 ListAnalysis->Add(hdt_vs_AmpToF[i]);
217 }
218
219 TH2F* h_StripHit = new TH2F("h_StripHit", "h_StripHit", kNST, 0, kNST, 2, 0, 2);
220 TH1I* h_StripHitSum = new TH1I("h_StripHitSum", "h_StripHitSum", kNST, 0, kNST);
221 TH1F* h_StripAmp = new TH1F("h_StripAmp", "h_StripAmp", kNST, 0, kNST);
222 h_StripAmp->GetYaxis()->SetLabelSize(0.07);
223 h_StripAmp->SetLineWidth(2);
224 h_StripAmp->SetLineColor(46);
225 TH1F* h_StripTime = new TH1F("h_StripTime", "h_StripTime", kNST, 0, kNST);
226 h_StripTime->GetYaxis()->SetLabelSize(0.07);
227 h_StripTime->GetYaxis()->SetRangeUser(-1., 1.);
228 h_StripTime->SetLineWidth(2);
229 h_StripTime->SetLineColor(46);
230 TH1F* h_StripAmpL = new TH1F("h_StripAmpL", "h_StripAmpL", kNST, 0, kNST);
231 h_StripAmpL->GetYaxis()->SetLabelSize(0.07);
232 h_StripAmpL->SetLineWidth(2);
233 h_StripAmpL->SetLineColor(2);
234 TH1F* h_StripTimeL = new TH1F("h_StripTimeL", "h_StripTimeL", kNST, 0, kNST);
235 h_StripTimeL->GetYaxis()->SetLabelSize(0.07);
236 h_StripTimeL->GetYaxis()->SetRangeUser(300, 450);
237 h_StripTimeL->SetLineWidth(2);
238 h_StripTimeL->SetLineColor(2);
239 TH1F* h_StripAmpR = new TH1F("h_StripAmpR", "h_StripAmpR", kNST, 0, kNST);
240 h_StripAmpR->GetYaxis()->SetLabelSize(0.07);
241 h_StripAmpR->SetLineWidth(2);
242 h_StripAmpR->SetLineColor(9);
243 TH1F* h_StripTimeR = new TH1F("h_StripTimeR", "h_StripTimeR", kNST, 0, kNST);
244 h_StripTimeR->GetYaxis()->SetLabelSize(0.07);
245 h_StripTimeR->GetYaxis()->SetRangeUser(300, 450);
246 h_StripTimeR->SetLineWidth(2);
247 h_StripTimeR->SetLineColor(9);
248 TH1F* h_StripLeftMinusRight = new TH1F("h_StripLeftMinusRight", "h_StripLeftMinusRight", kNST, 0, kNST);
249 h_StripLeftMinusRight->GetYaxis()->SetLabelSize(0.07);
250 h_StripLeftMinusRight->GetYaxis()->SetRangeUser(-2.5, 2.5);
251 h_StripLeftMinusRight->SetLineWidth(2);
252 h_StripLeftMinusRight->SetLineColor(9);
253 TH2F* h_StripLeftMinusRight_vs_Time =
254 new TH2F("h_StripLeftMinusRight_vs_Time", "h_StripLeftMinusRight_vs_Time", 512, -5., 5., 2048, 250., 450.);
255 h_StripLeftMinusRight_vs_Time->GetYaxis()->SetLabelSize(0.07);
256 h_StripLeftMinusRight_vs_Time->GetXaxis()->SetLabelSize(0.07);
257 h_StripLeftMinusRight_vs_Time->SetMarkerStyle(8);
258
259 TH2F* h_XYTime = new TH2F("h_XYTime", "h_XYTime", kNST, 0, kNST, 64, -16, 16.);
260 h_XYTime->GetYaxis()->SetLabelSize(0.07);
261 h_XYTime->GetXaxis()->SetLabelSize(0.07);
262 // h_XYTime->SetMarkerStyle(8);
263
264 //--------Data Analysis-----------------------------------------------------------------
265
266 TCanvas* c_1 = new TCanvas("c1", "c1", 20, 20, 1500, 750);
267 TPad* Pad_StripHit = new TPad("Pad_StripHit", "Pad_StripHit", 0.01, 0.51, 0.49, 0.99, 21);
268 TPad* Pad_StripHitSum = new TPad("Pad_StripHitSum", "Pad_StripHitSum", 0.01, 0.01, 0.49, 0.49, 21);
269 TPad* Pad_StripAmp = new TPad("Pad_StripAmp", "Pad_StripAmp", 0.51, 0.51, 0.99, 0.99, 21);
270 TPad* Pad_StripTime = new TPad("Pad_StripTime", "Pad_StripTime", 0.51, 0.01, 0.99, 0.49, 21);
271
272 Pad_StripHit->Draw();
273 Pad_StripHitSum->Draw();
274 Pad_StripAmp->Draw();
275 Pad_StripAmp->SetGridy();
276 Pad_StripTime->Draw();
277 Pad_StripTime->SetGridy();
278
279 TString NameDTFile = file;
280 Point = NameDTFile.First('.');
281 NameDTFile.Replace(Point, 15, "_dt.dat");
282 cout << "Write call to " << NameDTFile.Data() << endl;
283 f_dt.open(NameDTFile.Data());
284
285 for (Int_t iEv = 0; iEv < nEvForRead; iEv++) {
286 if (iEv % 50000 == 0)
287 cout << "EVENT: " << iEv << endl;
288 eveTree->GetEntry(iEv);
289 CleanTof(&Plane2);
290 CleanTof(&Plane7);
291 CleanBC2(&T0);
292 h_StripHit->Reset();
293 h_StripAmp->Reset();
294 h_StripTime->Reset();
295 h_StripAmpL->Reset();
296 h_StripTimeL->Reset();
297 h_StripAmpR->Reset();
298 h_StripTimeR->Reset();
299 h_StripLeftMinusRight->Reset();
300 h_StripLeftMinusRight_vs_Time->Reset();
301 h_XYTime->Reset();
302 NEvStrip47 = 0;
303 for (Int_t iDig = 0; iDig < ToF400Digits->GetEntriesFast(); ++iDig) {
304 BmnTof1Digit* digTof = (BmnTof1Digit*)ToF400Digits->At(iDig);
305 if (digTof->GetPlane() == 2) {
306 Int_t strip = digTof->GetStrip();
307 Int_t plane = digTof->GetPlane();
308 // cout << "Plane = " << digTof->GetPlane() << " Ev# " << iEv << endl;
309 if (digTof->GetSide() == 0 && Plane2.sStrHit[strip] == kFALSE) {
310 Plane2.sAmpL[strip] = digTof->GetAmplitude();
311 Plane2.sTimeL[strip] = digTof->GetTime();
312 // h_StripHit->SetBinContent(strip + 1, digTof->GetSide() + 1, digTof->GetAmplitude());
313 }
314 if (digTof->GetSide() == 1 && Plane2.sStrHit[strip] == kFALSE) {
315 Plane2.sAmpR[strip] = digTof->GetAmplitude();
316 Plane2.sTimeR[strip] = digTof->GetTime();
317 // h_StripHit->SetBinContent(strip + 1, digTof->GetSide() + 1, digTof->GetAmplitude());
318 }
319
320 if ((Plane2.sTimeR[strip] != 0 && Plane2.sTimeL[strip] != 0 && strip != 47
321 && TMath::Abs((Plane2.sTimeL[strip] - Plane2.sTimeR[strip]) * 0.5) <= 2.
322 && TMath::Abs((Plane2.sAmpL[strip] - Plane2.sAmpR[strip]) * 0.5) <= 1.5
323 && Plane2.sStrHit[strip] == kFALSE)) //
324 Plane2.sStrHit[strip] = kTRUE; //*/
325 }
326
327 if (digTof->GetPlane() == 7) {
328 Int_t strip = digTof->GetStrip();
329 Int_t plane = digTof->GetPlane();
330 // cout << "Plane = " << digTof->GetPlane() << " Ev# " << iEv << endl;
331 if (digTof->GetSide() == 0 && Plane7.sStrHit[strip] == kFALSE) {
332 // if (digTof->GetTime() > 300. && digTof->GetTime() < 430.) {
333 Plane7.sAmpL[strip] = digTof->GetAmplitude();
334
335 if (strip == 0) {
336 NEvStrip47++;
337 if (Plane7.sTimeL[strip] != 0)
338 hNoize->Fill(1000. / (digTof->GetTime() - Plane7.sTimeL[strip]));
339 }
340
341 Plane7.sTimeL[strip] = digTof->GetTime();
342 h_StripHit->SetBinContent(strip + 1, digTof->GetSide() + 1, digTof->GetAmplitude());
343 // if (strip == 22) cout << "L ";
344 }
345 if (digTof->GetSide() == 1 && Plane7.sStrHit[strip] == kFALSE) {
346 // if (digTof->GetTime() > 300. && digTof->GetTime() < 430.) {
347 Plane7.sAmpR[strip] = digTof->GetAmplitude();
348 Plane7.sTimeR[strip] = digTof->GetTime();
349 h_StripHit->SetBinContent(strip + 1, digTof->GetSide() + 1, digTof->GetAmplitude());
350 // if (strip == 22) cout << "R ";
351 }
352
353 if ((Plane7.sTimeR[strip] != 0 && Plane7.sTimeL[strip] != 0 && strip != 47
354 && TMath::Abs((Plane7.sTimeL[strip] - Plane7.sTimeR[strip]) * 0.5) <= 2.
355 && TMath::Abs((Plane7.sAmpL[strip] - Plane7.sAmpR[strip]) * 0.5) <= 1.5
356 && Plane7.sStrHit[strip] == kFALSE)) //
357 Plane7.sStrHit[strip] = kTRUE; //*/
358 }
359 }
360 hNEvStrip47->Fill(NEvStrip47);
361
362 for (Int_t i = 0; i < kNST; i++) {
363 if (Plane2.sStrHit[i] == kFALSE || i == 0 || i == 47) {
364 Plane2.sAmpL[i] = 0;
365 Plane2.sAmpR[i] = 0;
366 Plane2.sTimeL[i] = 0;
367 Plane2.sTimeR[i] = 0;
368 Plane2.sStrHit[i] = kFALSE;
369 }
370 if (Plane7.sStrHit[i] == kFALSE || i == 0 || i == 47) {
371 Plane7.sAmpL[i] = 0;
372 Plane7.sAmpR[i] = 0;
373 Plane7.sTimeL[i] = 0;
374 Plane7.sTimeR[i] = 0;
375 Plane7.sStrHit[i] = kFALSE;
376 }
377 }
378
379 for (Int_t iDig = 0; iDig < BC2Digits->GetEntriesFast(); ++iDig) {
380 BmnTrigDigit* digBC2 = (BmnTrigDigit*)BC2Digits->At(iDig);
381 // if (digBC2->GetAmp() > 6.15 && digBC2->GetAmp() < 17.14)
382 {
383 T0.sNHits++;
384 if (T0.sAmp == 0) {
385 T0.sAmp = digBC2->GetAmp();
386 T0.sTime = digBC2->GetTime();
387 hAmpT0->Fill(T0.sAmp);
388 hTimeT0->Fill(T0.sTime);
389 }
390 }
391 }
392 hHitT0PerEv->Fill(T0.sNHits);
393
394 for (Int_t i = 0; i < kNST; i++)
395 for (Int_t j = 0; j < kNST; j++) {
396 if (Plane2.sAmpL[i] != 0 && Plane2.sAmpR[j] != 0)
397 hLefRightCorelation_Plane2->Fill(i, j);
398 if (Plane7.sAmpL[i] != 0 && Plane7.sAmpR[j] != 0)
399 hLefRightCorelation_Plane7->Fill(i, j);
400 }
401
402 for (Int_t i = 0; i < kNST; i++) {
403 if (Plane2.sAmpL[i] != 0 && Plane2.sAmpR[i] != 0) {
404 Plane2.sAmp[i] = Plane2.sAmpL[i] + Plane2.sAmpR[i];
405 Plane2.sTime[i] = (Plane2.sTimeL[i] + Plane2.sTimeR[i]) * 0.5;
406 Plane2.sNHits++;
407 h_StripHitSum->Fill(i);
408 hAmpTofPlane2[i]->Fill(Plane2.sAmp[i]);
409 hTimeTofPlane2[i]->Fill(Plane2.sTime[i]);
410 hLevtMinusRightPlane2[i]->Fill((Plane2.sTimeL[i] - Plane2.sTimeR[i]) * 0.5);
411 hAmpTofPlane2[kNST]->Fill(Plane2.sAmp[i]);
412 hTimeTofPlane2[kNST]->Fill(Plane2.sTime[i]);
413 hLevtMinusRightPlane2[kNST]->Fill((Plane2.sTimeL[i] - Plane2.sTimeR[i]) * 0.5);
414 hAmpLRPlane2->Fill(Plane2.sAmpL[i], Plane2.sAmpR[i]);
415
416 /* h_StripAmp->Fill(i + 0.5, Plane2.sAmp[i]);
417 h_StripTime->Fill(i + 0.5, Plane2.sTime[i]);
418 h_StripAmpL->Fill(i + 0.5, Plane2.sAmpL[i]);
419 h_StripTimeL->Fill(i + 0.5, Plane2.sTimeL[i]);
420 h_StripAmpR->Fill(i + 0.5, Plane2.sAmpR[i]);
421 h_StripTimeR->Fill(i + 0.5, Plane2.sTimeR[i]);
422 h_StripLeftMinusRight->Fill(i + 0.5, Plane2.sTimeL[i] - Plane2.sTimeR[i]);
423 h_StripLeftMinusRight_vs_Time->Fill(Plane2.sTimeL[i] - Plane2.sTimeR[i], Plane2.sTime[i],
424 Plane2.sAmp[i]);
425 //*/
426 }
427 // if (Plane7.sAmpL[i] != 0 && Plane7.sAmpR[i] != 0) {
428 if (Plane7.sStrHit[i] != 0) {
429 Plane7.sAmp[i] = Plane7.sAmpL[i] + Plane7.sAmpR[i];
430 Plane7.sTime[i] = (Plane7.sTimeL[i] + Plane7.sTimeR[i]) / 2.;
431 Plane7.sNHits++;
432 h_StripHitSum->Fill(i);
433 hAmpTofPlane7[i]->Fill(Plane7.sAmp[i]);
434 hTimeTofPlane7[i]->Fill(Plane7.sTime[i]);
435 hLeftMinusRightPlane7[i]->Fill((Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5);
436 hAmpTofPlane7[kNST]->Fill(Plane7.sAmp[i]);
437 hTimeTofPlane7[kNST]->Fill(Plane7.sTime[i]);
438 hLeftMinusRightPlane7[kNST]->Fill((Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5);
439 hAmpLRPlane7->Fill(Plane7.sAmpL[i], Plane7.sAmpR[i]);
440
441 hLeftRightCorelationRPlane7[i]->Fill(Plane7.sAmpL[i], Plane7.sAmpR[i]);
442 hLeftRightCorelationRPlane7[kNST]->Fill(Plane7.sAmpL[i], Plane7.sAmpR[i]);
443
444 hLeftRightVsAmpLPlane7[i]->Fill(Plane7.sAmpL[i], (Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5);
445 hLeftRightVsAmpLPlane7[kNST]->Fill(Plane7.sAmpL[i], (Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5);
446
447 hLeftRightVsAmpRPlane7[i]->Fill(Plane7.sAmpR[i], (Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5);
448 hLeftRightVsAmpRPlane7[kNST]->Fill(Plane7.sAmpR[i], (Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5);
449
450 /* h_StripAmp->Fill(i + 0.5, Plane7.sAmp[i]);
451 h_StripTime->Fill(i + 0.5, CalculateDt(&Plane7, &T0, i));
452 h_StripAmpL->Fill(i + 0.5, Plane7.sAmpL[i]);
453 h_StripTimeL->Fill(i + 0.5, Plane7.sTimeL[i]);
454 h_StripAmpR->Fill(i + 0.5, Plane7.sAmpR[i]);
455 h_StripTimeR->Fill(i + 0.5, Plane7.sTimeR[i]);
456 h_StripLeftMinusRight->Fill(i + 0.5, (Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5);
457 //h_StripLeftMinusRight_vs_Time->Fill((Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5,
458 Plane7.sTime[i], Plane7.sAmp[i]); h_XYTime->Fill(i, ((Plane7.sTimeL[i] - Plane7.sTimeR[i]) * 0.5 /
459 0.06));
460
461 //*/
462 }
463 }
464 hHitStripsPerEvPlane2->Fill(Plane2.sNHits);
465 hHitStripsPerEvPlane7->Fill(Plane7.sNHits);
466
467 if (Plane2.sNHits == 1 && Plane2.sAmp[5] != 0 && T0.sNHits == 1) {
468 HitPlane2T0++;
469 if (Plane7.sNHits != 0)
470 EffPlane7++;
471 }
472 if (Plane7.sNHits == 1 && Plane7.sAmp[42] != 0 && T0.sNHits == 1) {
473 HitPlane7T0++;
474 if (Plane2.sNHits != 0)
475 EffPlane2++;
476 }
477 if (Plane2.sNHits != 0 && Plane7.sNHits != 0 && T0.sNHits == 1) {
478 Int_t MaxStrPlane2 = TMath::LocMax(kNST, Plane2.sAmp);
479 Int_t MaxStrPlane7 = TMath::LocMax(kNST, Plane7.sAmp);
480 hPlane2Plane7Correlation->Fill(MaxStrPlane2, MaxStrPlane7);
481 }
482
483 Double_t dt = -100.;
484 Int_t MaxStr = -1;
485 if (Plane7.sNHits == 1 && T0.sNHits == 1 && T0.sAmp >= 17.9 && T0.sAmp < 19.63) {
486 MaxStr = TMath::LocMax(kNST, Plane7.sAmp);
487 // dt = Plane7->sTime[MaxStr] - T0->sTime;
488 dt = CalculateDt(&Plane7, &T0, MaxStr);
489 hdt[MaxStr]->Fill(dt);
490 hdt_vs_AmpT0[MaxStr]->Fill(T0.sAmp, dt);
491 hdt_vs_AmpToF[MaxStr]->Fill(Plane7.sAmpL[MaxStr], dt);
492 hdt[kNST]->Fill(dt);
493 hdt_vs_AmpT0[kNST]->Fill(T0.sAmp, dt);
494 hdt_vs_AmpToF[kNST]->Fill(Plane7.sAmpL[MaxStr], dt);
495 }
496 Int_t iEvDig = EventHeader->GetEntriesFast();
497 if (iEvDig != 1)
498 cout << "iEvDig == " << iEvDig << endl;
499 BmnEventHeader* digEvent = (BmnEventHeader*)EventHeader->At(0);
500 f_dt << (digEvent->GetEventId()) << "\t" << MaxStr << "\t" << dt << endl;
501
502 /* if (Plane7.sNHits != 0) {
503 // if (Plane7.sNHits > 2) {
504 cout << "Event# " << digEvent->GetEventId() << endl;
505 Int_t MaxStr = TMath::LocMax(kNST, Plane7.sTime);
506 //h_StripTime->GetYaxis()->SetRangeUser(-15., +15.);
507 //h_StripTime->GetYaxis()->SetRangeUser(Plane7.sTime[MaxStr] - 15., Plane7.sTime[MaxStr] + 5.);
508 // cout << "event # " << iEv;
509 Pad_StripHit->cd();
510 h_StripHit->Draw("COLZ");
511 Pad_StripHitSum->cd();
512 //h_StripHitSum->Draw ();
513 h_StripLeftMinusRight->Draw();
514 Pad_StripAmp->cd();
515 //h_StripLeftMinusRight_vs_Time->Draw();
516 h_XYTime->Draw("COLZ");
517 //h_StripAmp->Draw ("");
518 // h_StripAmpL->Draw("SAME");
519 // h_StripAmpR->Draw("SAME");
520
521 Pad_StripTime->cd();
522 h_StripTime->Draw("");
523 // h_StripTimeL->Draw("SAME");
524 // h_StripTimeR->Draw("SAME");
525 c_1->Update();
526 getchar();
527 }//*/
528 }
529
530 f_dt.close();
531
532 TString NameCallFile = file;
533 Point = NameCallFile.First('.');
534 NameCallFile.Replace(Point, 15, "_call.dat");
535 cout << "Write call to " << NameCallFile.Data() << endl;
536 f_call.open(NameCallFile.Data());
537 // TProfile * pr_Hist_dt_FFD_SRPC200_vs_WSRPC[3];
538 // TProfile * pr_Hist_dt_FFD_SRPC400_vs_WSRPC[3];
539 for (i = 0; i < kNST + 1; i++) {
540
541 hAmpTofPlane7[i]->Fit(f_gaus, "QW", "QW",
542 hAmpTofPlane7[i]->GetMaximumBin() * hAmpTofPlane7[i]->GetXaxis()->GetBinWidth(1) - 0.5,
543 hAmpTofPlane7[i]->GetMaximumBin() * hAmpTofPlane7[i]->GetXaxis()->GetBinWidth(1) + 0.8);
544 sprintf(hid, "Plane7 Strip %d\t mean %f\t integral %.0f", i, f_gaus->GetParameter(1),
545 hAmpTofPlane7[i]->GetEntries());
546 f_call << hid << endl;
547 }
548 if (HitPlane7T0 != 0 && HitPlane2T0 != 0) {
549 f_call << "Efficiency Plane2 = " << EffPlane2 << "/" << HitPlane7T0 << "=" << EffPlane2 * 100. / HitPlane7T0
550 << " %" << endl;
551 cout << "Efficiency Plane2 = " << EffPlane2 << "/" << HitPlane7T0 << "=" << EffPlane2 * 100. / HitPlane7T0
552 << " %" << endl;
553 f_call << "Efficiency Plane7 = " << EffPlane7 << "/" << HitPlane2T0 << "=" << EffPlane7 * 100. / HitPlane2T0
554 << " %" << endl;
555 cout << "Efficiency Plane7 = " << EffPlane7 << "/" << HitPlane2T0 << "=" << EffPlane7 * 100. / HitPlane2T0
556 << " %" << endl;
557 }
558 f_call << "Strip\t Mean\t Sigma" << endl;
559 for (i = 0; i < kNST + 1; i++) {
560 f_gaus->SetParameter(1, 0.);
561 f_gaus->SetParameter(2, 0.1);
562 hdt[i]->Fit(f_gaus, "QW", "QW", -1, 1);
563 f_call << i << "\t" << f_gaus->GetParameter(1) << "\t" << f_gaus->GetParameter(2) * 1000. << endl;
564 cout << "Strip " << i << "\tMean " << f_gaus->GetParameter(1) << "\tSigma" << f_gaus->GetParameter(2) * 1000.
565 << endl;
566 }
567 f_call.close();
568
569 TString outName = file;
570 Point = outName.First('.');
571 outName.Replace(Point, 15, "_TofAn.root");
572 TFile* fileout = new TFile(outName.Data(), "RECREATE");
573
574 TDirectory* Dir;
575 Dir = fileout->mkdir("ToF");
576 Dir->cd();
577
578 TDirectory* DirPlane2;
579 DirPlane2 = Dir->mkdir("Plane2");
580 DirPlane2->cd();
581 ListTimeTofPlane2->Write();
582 ListAmpTofPlane2->Write();
583 ListLRTofPlane2->Write();
584
585 TDirectory* DirPlane7;
586 TDirectory* DirLRPlane7;
587 DirPlane7 = Dir->mkdir("Plane7");
588 DirLRPlane7 = DirPlane7->mkdir("LRCorelation");
589 DirPlane7->cd();
590 ListTimeTofPlane7->Write();
591 ListAmpTofPlane7->Write();
592 DirLRPlane7->cd();
593 ListLRCorrTofPlane7->Write();
594 ListLRTofPlane7->Write();
595 ListLRvsAmpLTofPlane7->Write();
596 ListLRvsAmpRTofPlane7->Write();
597
598 TDirectory* DirT0;
599 DirT0 = fileout->mkdir("T0");
600 DirT0->cd();
601 ListT0->Write();
602
603 TDirectory* DirAnalysis;
604 DirAnalysis = fileout->mkdir("Analysis");
605 DirAnalysis->cd();
606 ListAnalysis->Write();
607
608 fileout->cd();
609 ListStat->Write();
610 fileout->Close();
611
612} // end of macros
613
614//----Additional functions ----------------------------------------------------------------
615
617{
618 for (Int_t st = 0; st < kNST; st++) {
619 Det->sAmpL[st] = 0.;
620 Det->sAmpR[st] = 0.;
621 Det->sAmp[st] = 0.;
622 Det->sTimeL[st] = 0.;
623 Det->sTimeR[st] = 0.;
624 Det->sTime[st] = 0.;
625 Det->sStrHit[st] = kFALSE;
626 }
627 Det->sNHits = 0;
628}
629
631{
632 Det->sTime = 0;
633 Det->sAmp = 0;
634 Det->sNHits = 0;
635}
636
638{
639
640 if (Str == -1)
641 Str = TMath::LocMax(kNST, Plane7->sAmp);
642 Double_t dt = Det->sTime[Str] - T0->sTime;
643 // cout << " dt = " << dt << endl;
644 /* if (Det->sAmp[Str] < 20.46) CorrPlane7_It1 = 0;
645 else if (Det->sAmp[Str] >= 20.46 && Det->sAmp[Str] < 27.25) CorrPlane7_It1 = 1;
646 else if (Det->sAmp[Str] >= 27.25 && Det->sAmp[Str] < 34.81) CorrPlane7_It1 = 2;
647 else if (Det->sAmp[Str] >= 34.81 && Det->sAmp[Str] < 37.11) CorrPlane7_It1 = 3;
648 else if (Det->sAmp[Str] >= 37.11) CorrPlane7_It1 = 4;
649 dt = dt - (CorrPlane7Coeff_It1[CorrPlane7_It1][0] + CorrPlane7Coeff_It1[CorrPlane7_It1][1] * Det->sAmp[Str] +
650 CorrPlane7Coeff_It1[CorrPlane7_It1][2] * Det->sAmp[Str] * Det->sAmp[Str] +
651 CorrPlane7Coeff_It1[CorrPlane7_It1][3] * Det->sAmp[Str] * Det->sAmp[Str] * Det->sAmp[Str]); //*/
652
653 /* if (T0->sAmp >= 6.15 && T0->sAmp < 12.3) CorrT0_It1 = 0; //deutron
654 else if (T0->sAmp >= 12.3 && T0->sAmp < 17.14) CorrT0_It1 = 1; //deutron
655 else if (T0->sAmp >= 17.9 && T0->sAmp < 19.63) CorrT0_It1 = 2; //C6+
656 else CorrT0_It1 = 3; //skip
657 dt = dt - (CorrT0Coeff_It1[CorrT0_It1][0] + CorrT0Coeff_It1[CorrT0_It1][1] * T0->sAmp +
658 CorrT0Coeff_It1[CorrT0_It1][2] * T0->sAmp * T0->sAmp +
659 CorrT0Coeff_It1[CorrT0_It1][3] * T0->sAmp * T0->sAmp * T0->sAmp); //*/
660 return dt;
661}
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
unsigned int UInt_t
constexpr Bool_t kFALSE
double Double_t
long long Long64_t
constexpr Bool_t kTRUE
#define gROOT
char * Form(const char *fmt,...)
UInt_t GetEventId()
Get the event ID for this event.
Short_t GetPlane() const
Short_t GetSide() const
Short_t GetStrip() const
Float_t GetTime() const
Float_t GetAmplitude() const
Double_t GetAmp() const
Double_t GetTime() const
virtual void SetLabelSize(Float_t size=0.04)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
Long64_t GetEntries() const override
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
Bool_t cd() override
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
virtual Bool_t cd()
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
virtual Double_t GetParameter(const TString &name) const
virtual void SetParameter(const TString &name, Double_t value)
void Close(Option_t *option="") override
void Reset(Option_t *option="") override
TAxis * GetXaxis()
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
TAxis * GetYaxis()
virtual Int_t Fill(const char *name, Double_t w)
virtual Double_t GetEntries() const
void Reset(Option_t *option="") override
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
void SetBinContent(Int_t bin, Double_t content) override
void Add(TObject *obj) override
virtual void SetTitle(const char *title="")
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
void SetGridy(Int_t value=1) override
void Draw(Option_t *option="") override
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Ssiz_t First(char c) const
const char * Data() const
Double_t CatTimeBC2Low
Double_t CorrPlane7Coeff_It1[5][4]
const UInt_t kNST
const Double_t kTimeBin
Double_t CatTimeBC2High
Double_t CorrT0Coeff_It1[4][4]
Int_t CorrPlane7_It1
Bool_t FlagDigit[10][kNST]
void CleanBC2(T0Detector *Det)
void ToF400DigitAnalysis_period5(TString file="", Int_t nEvForRead=0, Int_t Periud=5)
void CleanTof(ToF400Detector *Det)
Double_t CalculateDt(ToF400Detector *Det, T0Detector *T0, Int_t Str=-1)
Iterator LocMax(Iterator first, Iterator last)
Double_t Abs(Double_t d)