BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnTOF1Detector.cxx
Go to the documentation of this file.
1#include "BmnTOF1Detector.h"
2
3#include <iomanip>
4
6
7BmnTOF1Detector::BmnTOF1Detector(Int_t tofId, Int_t NPlane, Int_t fill_hist = 0, Int_t Verbose = 0)
8{
9 // cout << "BmnTOF1Detector::BmnTOF1Detector tofId = " << tofId << "; NPlane = " << NPlane << endl;
10 fTofId = (DetectorId)tofId;
11 fVerbose = Verbose;
12 memset(fKilled, 0, sizeof(fKilled));
13 memset(fCorrLR, 0, sizeof(fCorrLR));
15 fKillSide = -1;
16 fNEvents = 0;
17 // KillStrip(0);
18 // KillStrip(47);
19 fFillHist = fill_hist;
20 fNPlane = NPlane;
22 fStripLength = 30; // cm
23 fSignalVelosity = 0.06; // 0.06 ns/cm
24 if (fNPlane >= 41) {
25 fStripLength = 56;
26 fSignalVelosity = 0.0585;
27 }
28 fMaxDelta = (fStripLength * 0.5 + 3.0) * fSignalVelosity; // + 20 mm on the strip edge
30
31 for (Int_t i = 0; i < fNStrMax; i++) {
33 gSlew[i] = NULL;
34 funT0[i] = NULL;
35 funRPC[i] = NULL;
36 }
37
38 if (fTofId == kTOF1)
39 fName = Form("TOF400_Plane_%d", NPlane);
40 if (fTofId == kTOF701)
41 fName = Form("TOF700_Plane_%d", NPlane);
42 TString Name;
43
44 if (fFillHist > 0) {
45 fHistListStat = new TList();
46 fHistListStat->SetName(Form("st_%s", fName.Data()));
47 fHistListdt = new TList();
48 fHistListdt->SetName(Form("dt_%s", fName.Data()));
49
50 Name.Clear();
51 Name = Form("Hist_HitByCh_%s", fName.Data());
52 hHitByCh = new TH1I(Name, Name, fNStrMax + 1, -0.5, fNStrMax + 0.5);
53 hHitByCh->SetDirectory(0);
55
56 Name.Clear();
57 Name = Form("Hist_HitPerEv_%s", fName.Data());
58 hHitPerEv = new TH1I(Name, Name, fNStrMax + 1, -0.5, fNStrMax + 0.5);
59 hHitPerEv->SetDirectory(0);
61
62 Name.Clear();
63 Name = Form("Hist_HitLR_%s", fName.Data());
64 hHitLR = new TH2I(Name, Name, fNStrMax, 0, fNStrMax, fNStrMax, 0, fNStrMax);
65 hHitLR->SetDirectory(0);
67
68 Name.Clear();
69 Name = Form("Hist_XY_%s", fName.Data());
70 hXY = new TH2I(Name, Name, 400, -250, 250, 120, -75, 75);
71 hXY->SetDirectory(0);
72 fHistListStat->Add(hXY);
73
74 hDy_near = new TH1S(Form("hDy_near_%s", fName.Data()), Form("hDy_near_%s", fName.Data()), 400, -20, 20);
75 hDy_near->SetDirectory(0);
76
78 new TH1S(Form("hDtime_near_%s", fName.Data()), Form("hDtime_near_%s", fName.Data()), 400, -10, 10);
79 hDtime_near->SetDirectory(0);
80
82 new TH1S(Form("hDWidth_near_%s", fName.Data()), Form("hDWidth_near_%s", fName.Data()), 256, -28., 28.);
83 hDWidth_near->SetDirectory(0);
84
85 hTempDtimeDy_near = new TH2S(Form("hTempDtimeDy_near_%s", fName.Data()),
86 Form("hTempDtimeDy_near_%s", fName.Data()), 400, -10, 10, 200, -10, 10);
87 hTempDtimeDy_near->SetDirectory(0);
88
89 hDy_acros = new TH1S(Form("hDy_acros_%s", fName.Data()), Form("hDy_acros_%s", fName.Data()), 400, -20, 20);
90 hDy_acros->SetDirectory(0);
91
93 new TH1S(Form("hDtime_acros_%s", fName.Data()), Form("hDtime_acros_%s", fName.Data()), 400, -10, 10);
94 hDtime_acros->SetDirectory(0);
95
97 new TH1S(Form("hDWidth_acros_%s", fName.Data()), Form("hDWidth_acros_%s", fName.Data()), 256, -28., 28.);
98 hDWidth_acros->SetDirectory(0);
99
100 hTempDtimeDy_acros = new TH2S(Form("hTempDtimeDy_acros_%s", fName.Data()),
101 Form("hTempDtimeDy_acros_%s", fName.Data()), 400, -10, 10, 200, -10, 10);
102 hTempDtimeDy_acros->SetDirectory(0);
103
112
113 if (fFillHist > 1) {
114 for (Int_t i = 0; i < fNStrMax + 1; i++) {
116 new TH2S(Form("dt_vs_WidthDet_str_%d_%s", i, fName.Data()),
117 Form("dt_vs_WidthDet_str_%d_%s", i, fName.Data()), 1024, 0, 50, 1024, -12, 12);
118 hdT_vs_WidthDet[i]->SetDirectory(0);
120 }
121 for (Int_t i = 0; i < fNStrMax + 1; i++) {
123 new TH2S(Form("dt_vs_WidthT0_str_%d_%s", i, fName.Data()),
124 Form("dt_vs_WidthT0_str_%d_%s", i, fName.Data()), 1024, 0, 50, 1024, -12, 12);
125 hdT_vs_WidthT0[i]->SetDirectory(0);
127 }
128 for (Int_t i = 0; i < fNStrMax + 1; i++) {
129 hdT[i] = new TH1I(Form("dt_str_%d_%s", i, fName.Data()), Form("dt_str_%d_%s", i, fName.Data()), 1024,
130 -12, 12);
131 hdT[i]->SetDirectory(0);
132 fHistListdt->Add(hdT[i]);
133 }
134 }
135
136 } else {
137
138 fHistListStat = NULL;
139 fHistListdt = NULL;
140
141 hHitByCh = NULL;
142 hHitPerEv = NULL;
143 hHitLR = NULL;
144 hXY = NULL;
145
146 hDy_near = NULL;
147 hDtime_near = NULL;
148 hDWidth_near = NULL;
149 hTempDtimeDy_near = NULL;
150 hDy_acros = NULL;
151 hDtime_acros = NULL;
152 hDWidth_acros = NULL;
153 hTempDtimeDy_acros = NULL;
154
155 for (Int_t i = 0; i < fNStrMax + 1; i++) {
156 hdT_vs_WidthDet[i] = NULL;
157 hdT_vs_WidthT0[i] = NULL;
158 hdT[i] = NULL;
159 }
160 }
161 Clear();
162}
163
164//----------------------------------------------------------------------------------------
165
167{
168 memset(fTimeL, 0, sizeof(fTimeL));
169 memset(fTimeR, 0, sizeof(fTimeR));
170 memset(fTimeLtemp, 0, sizeof(fTimeLtemp));
171 memset(fTimeRtemp, 0, sizeof(fTimeRtemp));
172 memset(fTime, 0, sizeof(fTime));
173 memset(fWidthL, 0, sizeof(fWidthL));
174 memset(fWidthR, 0, sizeof(fWidthR));
175 memset(fWidthLtemp, 0, sizeof(fWidthLtemp));
176 memset(fWidthRtemp, 0, sizeof(fWidthRtemp));
177 memset(fWidth, 0, sizeof(fWidth));
178 memset(fFlagHit, 0, sizeof(fFlagHit));
179 memset(fTof, 0, sizeof(fTof));
180 memset(fDigitL, 0, sizeof(fDigitL));
181 memset(fDigitR, 0, sizeof(fDigitR));
182 memset(fHit, 0, sizeof(fHit));
183 memset(fIndexL, 0, sizeof(fIndexL));
184 memset(fIndexR, 0, sizeof(fIndexR));
185 fHit_Per_Ev = 0;
186
187 vHitsL.clear();
188 vHitsL.reserve(fNStrMax);
189 vHitsL.resize(fNStrMax);
190
191 vHitsR.clear();
192 vHitsR.reserve(fNStrMax);
193 vHitsR.resize(fNStrMax);
194
195 for (Int_t i = 0; i < fNStrMax; i++) {
196 fCrossPoint[i].SetXYZ(0., 0., 0.);
197 fIndexLtemp[i] = -1;
198 fIndexRtemp[i] = -1;
199 }
200}
201
202//----------------------------------------------------------------------------------------
203
205{
206 fStrip = TofDigit->GetStrip();
207
209 return kFALSE;
210
211 if (fVerbose > 3)
212 cout << endl
213 << " Plane = " << TofDigit->GetPlane() << "; Strip " << TofDigit->GetStrip() << "; Side "
214 << TofDigit->GetSide() << "; Time " << TofDigit->GetTime() << "; Amp " << TofDigit->GetAmplitude() << endl;
215
216 if (TofDigit->GetSide() == 0 && fKillSide != 0)
217 fTimeLtemp[fStrip] = TofDigit->GetTime() - 2. * fCorrLR[fStrip];
218 else if (TofDigit->GetSide() == 1 && fKillSide != 1)
219 fTimeLtemp[fStrip] = TofDigit->GetTime();
220 else
221 return kFALSE;
222
223 if (fVerbose > 3)
224 cout << "Setting Shift: strip # " << fStrip << " shift val " << fCorrLR[fStrip] << "; shifted timeL "
225 << fTimeLtemp[fStrip] << "\n";
226
227 fWidthLtemp[fStrip] = TofDigit->GetAmplitude();
228
229 fIndexLtemp[fStrip] = ind;
230
231 std::vector<Double_t> tempVector;
232 tempVector.reserve(3);
233 tempVector.push_back(fTimeLtemp[fStrip]);
234 tempVector.push_back(fWidthLtemp[fStrip]);
235 tempVector.push_back(ind);
236
237 if (TofDigit->GetSide() == 0) {
238 vHitsL.at(fStrip).push_back(tempVector);
239 fDigitL[fStrip]++;
240
241 if (fKillSide == 1)
242 vHitsR.at(fStrip).push_back(tempVector);
243
244 return kTRUE;
245 } else {
246 vHitsR.at(fStrip).push_back(tempVector);
247 fDigitR[fStrip]++;
248
249 if (fKillSide == 0)
250 vHitsL.at(fStrip).push_back(tempVector);
251
252 return kTRUE;
253 }
254
255 return kFALSE;
256}
257
258//----------------------------------------------------------------------------------------
259
261{
262 fKilled[NumberOfStrip] = kTRUE;
263}
264
265//----------------------------------------------------------------------------------------
266
268{
269 fKillSide = NumberOfSide;
270}
271
272//----------------------------------------------------------------------------------------
273
275 TClonesArray* TofHit,
276 TClonesArray* TofCont = nullptr,
277 int printnow = 0)
278{
279 fT0 = T0;
280 if (fT0 == nullptr)
281 fT0 = new BmnTrigDigit(-1, 0, 20, -1);
282
283 fNEvents++;
284
285 if (printnow != 0)
286 cout << endl << " Plane " << fNPlane << endl;
287 for (Int_t i = 0; i < fNStr; i++) {
288 if (vHitsL[i].empty() || vHitsR[i].empty())
289 continue;
290 if (printnow != 0)
291 cout << " Strip " << i << endl;
292
293 for (Int_t iL = 0; iL < (int)vHitsL.at(i).size(); iL++)
294 for (Int_t iR = 0; iR < (int)vHitsR.at(i).size(); iR++) {
295
296 fTimeL[i] = vHitsL.at(i).at(iL).at(0);
297 fTimeR[i] = vHitsR.at(i).at(iR).at(0);
298
299 fWidthL[i] = vHitsL.at(i).at(iL).at(1);
300 fWidthR[i] = vHitsR.at(i).at(iR).at(1);
301
302 fIndexL[i] = vHitsL.at(i).at(iL).at(2);
303 fIndexR[i] = vHitsR.at(i).at(iR).at(2);
304
305 if (printnow != 0) {
306 cout << "iL = " << iL << ": time = " << fTimeL[i] << "; amp = " << fWidthL[i]
307 << "; ind = " << fIndexL[i] << endl;
308 cout << "iR = " << iR << ": time = " << fTimeR[i] << "; amp = " << fWidthR[i]
309 << "; ind = " << fIndexR[i] << endl;
310 }
311
312 fWidth[i] = 0;
313 fTime[i] = -1000;
314 fTof[i] = -1000;
315
316 if (!GetCrossPoint(i, fTimeL[i], fTimeR[i]))
317 continue;
318
319 fWidth[i] = fWidthL[i] + fWidthR[i];
320 fTime[i] = (fTimeL[i] + fTimeR[i]) * 0.5;
321 fTof[i] = CalculateDt(i);
322
323 fHit_Per_Ev++;
324
325 if (fVerbose > 2 || printnow != 0)
326 printf("Hit on Plane#%d Strip#%d\n\tTime = %.3f; (X,Y,Z) = %.3f, %.3f, %.3f\n", fNPlane, i,
327 fTof[i], fCrossPoint[i].X(), fCrossPoint[i].Y(), fCrossPoint[i].Z());
328
329 if (fFillHist > 0) {
330 if (i > 2 && fTof[i - 1] != -1000) {
331 hDy_near->Fill(fCrossPoint[i].Y() - fCrossPoint[i - 1].Y());
332 hDtime_near->Fill(fTof[i] - fTof[i - 1]);
333 hDWidth_near->Fill(fWidth[i] - fWidth[i - 1]);
334 hTempDtimeDy_near->Fill(fTof[i] - fTof[i - 1], fCrossPoint[i].Y() - fCrossPoint[i - 1].Y());
335 }
336 if (i > 3 && fTof[i - 1] != -1000) {
337 hDy_acros->Fill(fCrossPoint[i].Y() - fCrossPoint[i - 2].Y());
338 hDtime_acros->Fill(fTof[i] - fTof[i - 2]);
339 hDWidth_acros->Fill(fWidth[i] - fWidth[i - 2]);
340 hTempDtimeDy_acros->Fill(fTof[i] - fTof[i - 2], fCrossPoint[i].Y() - fCrossPoint[i - 2].Y());
341 }
342
343 if (fFillHist > 1) {
344 hdT_vs_WidthDet[i]->Fill(fWidth[i], fTof[i]);
345 hdT_vs_WidthT0[i]->Fill(fT0->GetAmp(), fTof[i]);
346 hdT[i]->Fill(fTof[i]);
347 hdT_vs_WidthDet[fNStr]->Fill(fWidth[i], fTof[i]);
348 hdT_vs_WidthT0[fNStr]->Fill(fT0->GetAmp(), fTof[i]);
349 hdT[fNStr]->Fill(fTof[i]);
350 }
351 }
352 if (TofHit != nullptr) {
353 // cout << " Fill BmnTofHit" << endl;
354 AddHit(i, TofHit);
355 }
356 if (TofCont != nullptr) {
357 // cout << " Fill BmnTOF1Conteiner" << endl;
358 AddConteiner(i, TofCont);
359 }
360 } // end loop over Left/Right sides of the strip
361 } // end loop over strips for (Int_t i = 0; i < fNStrMax; i++)
362
363 if (printnow != 0)
364 getchar();
365 if (fFillHist > 0)
366 FillHist();
367
368 if (fVerbose > 2)
369 printf("Total number of hits on Plane#%d is %d\n\n", fNPlane, fHit_Per_Ev);
370 return fHit_Per_Ev;
371}
372
373//------------------------------------------------------------------------------------------------------------------------
374
376{
377
378 fVectorTemp.SetXYZ(0.5, 0.36, 1.); // error for point dx = 0.5 cm; dy = 1.25/SQRT(12) = 0.36 cm; dz = 1(?)cm
379 Int_t UID = BmnTOF1Point::GetVolumeUID(0, fNPlane + 1, Str + 1); // strip [0,47] -> [1, 48]
380
381 BmnTofHit* pHit = new ((*TofHit)[TofHit->GetEntriesFast()])
382 BmnTofHit(UID, fCrossPoint[Str], fVectorTemp, FormIndex(fIndexL[Str], fIndexR[Str]));
383
384 pHit->SetModule(fNPlane);
385 pHit->SetStation(Str);
386 pHit->SetTimeStamp(fTof[Str]);
387 pHit->AddLink(FairLink(0x1, -1));
388 pHit->AddLink(FairLink(0x2, -1));
389 pHit->AddLink(FairLink(0x4, UID));
390 pHit->SetUpperClusterIndex(fIndexL[Str]);
391 pHit->SetLowerClusterIndex(fIndexR[Str]);
392 pHit->SetDetId(fTofId);
393
394 // cout << "Add hit to Array# " << TofHit->GetEntriesFast() << " : fNPlane = " << fNPlane << "; Str = " << Str
395 // << "; iR = " << fIndexL[Str] << "; iR = " << fIndexR[Str] << "; pointIndex";
396}
397
398//------------------------------------------------------------------------------------------------------------------------
399
401{
402
403 new ((*TofHit)[TofHit->GetEntriesFast()])
404 BmnTOF1Conteiner(fNPlane, Str, fTimeL[Str], fTimeR[Str], fTime[Str], fWidthL[Str], fWidthR[Str], fWidth[Str],
405 fCrossPoint[Str].x(), fCrossPoint[Str].y(), fCrossPoint[Str].z(), fT0->GetTime(),
406 fT0->GetAmp(), fTof[Str], fIndexL[Str], fIndexR[Str]);
407}
408
409//----------------------------------------------------------------------------------------
410
412{
413 hHitPerEv->Fill(fHit_Per_Ev);
414 for (Int_t i = 0; i < fNStr; i++)
415 for (Int_t j = 0; j < fNStr; j++) {
416 if (fWidthL[i] != 0 && fWidthR[j] != 0) {
417 hHitLR->Fill(i, j);
418 if (i == j) {
419 hHitByCh->Fill(i);
420 hXY->Fill(fCrossPoint[i].x(), fCrossPoint[i].y());
421 }
422 }
423 }
424}
425
426//----------------------------------------------------------------------------------------
427
429{
430
431 Double_t dt = 0;
432 Double_t T0Amp;
433 dt = fTime[Str] - fT0->GetTime() + fCommonTimeShift;
434 if (fVerbose > 3)
435 printf("Calculate dt\n raw dt = %.3f\n", dt);
436 T0Amp = fT0->GetAmp();
437
438 /*dt = dt - (1.947 - 0.5363 * T0Amp
439 + 0.03428 * T0Amp * T0Amp
440 - 0.0005853 * T0Amp * T0Amp * T0Amp);// RUN6 */
441
442 if (funT0[Str] != NULL)
443 dt = dt - funT0[Str]->Eval(T0Amp);
444 if (fVerbose > 3)
445 printf("After T0 corr dt = %.3f\t", dt);
446
447 if (gSlew[Str] != NULL) {
448 dt = dt - gSlew[Str]->Eval(fWidth[Str]);
449 if (fVerbose > 3)
450 printf("After RPC corr dt = %.3f\t", dt);
451 }
452
453 if (funRPC[Str] != NULL) {
454 dt = dt - funRPC[Str]->Eval(fWidth[Str]);
455 if (fVerbose > 3)
456 printf("After RPC corr dt = %.3f\t", dt);
457 }
458
459 dt = dt + fCorrTimeShift[Str]; // CorrTimeShift is ToF for Gamma
460 if (fVerbose > 3)
461 printf("After Shift on Proton mass dt = %.3f\n", dt);
462
463 // cout << dt << endl;
464 return dt;
465}
466
467//----------------------------------------------------------------------------------------
468
470{
471 if (fFillHist > 0) {
472 if (n == 0)
473 return fHistListStat;
474 } else
475 return NULL;
476
477 return NULL;
478}
479
480//----------------------------------------------------------------------------------------
481
483{
484 return fName;
485}
486
487//----------------------------------------------------------------------------------------
488
490{
491 // cout << "BmnTOF1Detector::SetCorrLR" << endl;
492 char line[256];
493 Int_t Pl, St;
494 Double_t CorrFit, CorrMean;
495 ifstream f_corr;
496 TString dir = Form("%s%s%s", getenv("VMCWORKDIR"), "/input/", NameFile.Data());
497 // cout << "Open file " << dir << endl;
498 f_corr.open(dir);
499 f_corr.getline(line, 256);
500 f_corr.getline(line, 256);
501 if (f_corr.is_open() == kTRUE) {
502 while (!f_corr.eof()) {
503 if (fTofId == kTOF1)
504 f_corr >> Pl >> St >> CorrFit >> CorrMean;
505 if (fTofId == kTOF701)
506 f_corr >> Pl >> St >> CorrMean;
507 if (Pl == fNPlane) {
508 fCorrLR[St] = CorrMean;
509 // If diff between my shift and old shift is greater than the actual cable, throw
510 // strip out
511 // if (TMath::Abs(Temp - fCorrLR[St]) > 2.) fCorrLR[St] = -11.9766;
512 // cout << Pl << " " << St << " " << fCorrLR[St] << " " << CorrMean << "\n";
513 }
514 }
515 } else {
516 cout << "File " << NameFile.Data() << " for LR correction is not found" << endl;
517 cout << "Check " << dir.Data() << " folder for file" << endl;
518 return kFALSE;
519 }
520 f_corr.close();
521 return kTRUE;
522}
523//----------------------------------------------------------------------------------------
524
526{
527 TString PathToFile = Form("%s%s%s", getenv("VMCWORKDIR"), "/input/", NameFile.Data());
528 TString name, dirname;
529 TDirectory* Dir;
530 TFile* f_corr = new TFile(PathToFile.Data(), "READ");
531 if (f_corr->IsOpen()) {
532 dirname = Form("Plane_%d", fNPlane);
533 f_corr->cd(dirname.Data());
534 Dir = f_corr->CurrentDirectory();
535 for (Int_t i = 0; i < fNStr; i++) {
536 name = Form("T0_TA_Plane%d_Str%d", fNPlane, i);
537 funT0[i] = (TF1*)Dir->Get(name.Data());
538 if (funT0[i] == NULL && fVerbose >= 1)
539 printf("funT0[%d] is NULL\n", i);
540 name = Form("Rpc_TA_Plane%d_Str%d", fNPlane, i);
541 gSlew[i] = (TGraphErrors*)Dir->Get(name.Data());
542 if (gSlew[i] == NULL && fVerbose >= 1)
543 printf("gSlew[%d] is NULL\n", i);
544 }
545 } else {
546 cout << "File " << NameFile.Data() << " for Slewing correction is not found" << endl;
547 cout << "Check " << PathToFile.Data() << " folder for file" << endl;
548 return kFALSE;
549 }
550 return kTRUE;
551}
552
553//----------------------------------------------------------------------------------------
554
556{
557 char line[256];
558 Int_t Pl, St;
559 Double_t Temp;
560 ifstream f_corr;
561 TString dir = Form("%s%s%s", getenv("VMCWORKDIR"), "/input/", NameFile.Data());
562 f_corr.open(dir);
563 f_corr.getline(line, 256);
564 // cout << line << endl;
565
566 f_corr.getline(line, 256);
567 // cout << line << endl;
568 fCommonTimeShift = atof(line);
569 // cout << fCommonTimeShift << endl;
570
571 f_corr.getline(line, 256);
572 // cout << line << endl;
573
574 // char ccc = getchar();
575 // if (ccc == 'q') return kFALSE;
576
577 if (f_corr.is_open() == kTRUE) {
578 while (!f_corr.eof()) {
579 f_corr >> Pl >> St >> Temp;
580 if (Pl == fNPlane) {
581 fCorrTimeShift[St] = Temp;
582 // cout << Pl << " " << St << " " << fCorrTimeShift[St] << "\n";
583 }
584 }
585 } else {
586 cout << "File " << NameFile.Data() << " for TimeShift correction is not found" << endl;
587 cout << "Check " << dir.Data() << " folder for file" << endl;
588 return kFALSE;
589 }
590 f_corr.close();
591 return kTRUE;
592}
593
594//----------------------------------------------------------------------------------------
595
597{
598
599 fVectorTemp.SetXYZ(0., 0., 0.);
600
601 double dtt = (tL - tR) * 0.5;
602 double dL = dtt / fSignalVelosityStr[NStrip];
603 // cout << "fSignalVelosityStr[NStrip] = " << fSignalVelosityStr[NStrip] << endl;
604 // cout << "dl = " << dL << endl;
605
606 if (TMath::Abs(dtt) > fMaxDelta)
607 return kFALSE;
608
609 // cout << "accept this hit" << endl;
610 // should be checked
611 fVectorTemp(0) = dL * TMath::Cos(fStripAngle[NStrip].X());
612 fVectorTemp(1) = dL * TMath::Cos(fStripAngle[NStrip].Y());
613 fVectorTemp(2) = dL * TMath::Cos(fStripAngle[NStrip].Z());
614
615 fCrossPoint[NStrip].SetXYZ(0., 0., 0.);
616 fCrossPoint[NStrip] = fCentrStrip[NStrip] + fVectorTemp;
617
618 return kTRUE;
619 // cout << "Z = " << fCrossPoint[NStrip].Z() << endl;
620 // return kTRUE;
621}
622//----------------------------------------------------------------------------------------
623
625{
626
627 // get gGeoManager from ROOT file
628 TString PathToFile = Form("%s%s%s", getenv("VMCWORKDIR"), "/macro/run/geometry_run/", NameFile.Data());
629 TFile* geoFile = new TFile(PathToFile, "READ");
630 if (!geoFile->IsOpen()) {
631 cout << "Error: could not open ROOT file with geometry: " + NameFile << endl;
632 return kFALSE;
633 }
634 TList* keyList = geoFile->GetListOfKeys();
635 TIter next(keyList);
636 TKey* key = (TKey*)next();
637 TString className(key->GetClassName());
638 if (className.BeginsWith("TGeoManager"))
639 key->ReadObj();
640 else {
641 cout << "Error: TGeoManager isn't top element in geometry file " + NameFile << endl;
642 return kFALSE;
643 }
644
645 BmnTof1GeoUtils* pGeoUtils = new BmnTof1GeoUtils();
646 if (fTofId == kTOF1)
647 pGeoUtils->ParseTGeoManager(false, NULL, true);
648 else if (fTofId == kTOF701)
649 pGeoUtils->ParseTGeoManager701(false, NULL, true);
650 else
651 return kFALSE;
652
653 SetGeo(pGeoUtils);
654
655 geoFile->Close();
656 pGeoUtils->~BmnTof1GeoUtils();
657 return kTRUE;
658}
659
660//----------------------------------------------------------------------------------------
661
663{
664 Int_t UID;
665 TVector3 x(1, 0, 0);
666 TVector3 y(0, 1, 0);
667 TVector3 z(0, 0, 1);
668 for (Int_t i = 0; i < fNStrMax; i++) {
669 UID = BmnTOF1Point::GetVolumeUID(0, fNPlane + 1, i + 1); // strip [0,47] -> [1, 48]
670 // cout << "Plane = " << fNPlane << "; Strip = " << i << "; UID = " << UID << endl;
671 const LStrip1* pStrip = pGeoUtils->FindStrip(UID);
672 if (pStrip == NULL) {
673 fNStr = i;
674 break;
675 }
676 if (fTofId == kTOF701)
677 SetStripLength(pStrip->GetLength());
678 fCentrStrip[i] = pStrip->center;
679
680 if (fTofId == kTOF1)
681 fVectorTemp = (pStrip->C + pStrip->D) * 0.5 - (pStrip->A + pStrip->B) * 0.5;
682 else if (fTofId == kTOF701)
683 fVectorTemp = (pStrip->B + pStrip->C) * 0.5 - (pStrip->A + pStrip->D) * 0.5;
684 else
685 return kFALSE;
686
687 fStripAngle[i](0) = fVectorTemp.Angle(x);
688 fStripAngle[i](1) = fVectorTemp.Angle(y);
689 fStripAngle[i](2) = fVectorTemp.Angle(z);
690
691 // printf("Plane%d, Strip%d\t A=%.3f\t B=%.3f\t C=%.3f\n", fNPlane, i, fStripAngle[i](0), fStripAngle[i](1),
692 // fStripAngle[i](2));
693
694 // if (fNPlane >= 5) fCentrStrip[i].SetX(fCentrStrip[i].X()+5.5); // for field run only
695 // else fCentrStrip[i].SetX(fCentrStrip[i].X()+2.5);
696 }
697 return kTRUE;
698}
699
700//----------------------------------------------------------------------------------------
701
703{
704
705 if (Str < 0 || Str > fNStr)
706 return kFALSE;
707 if (NULL != XYZ)
708 XYZ->SetXYZ(fCrossPoint[Str].x(), fCrossPoint[Str].y(), fCrossPoint[Str].z());
709 if (NULL != ToF)
710 *ToF = fTof[Str];
711
712 return kTRUE;
713}
714
715//----------------------------------------------------------------------------------------
716
718{
719
720 // if (fTof[Str] == 0) return kFALSE;
721 if (NULL == LMinusRTime)
722 return kFALSE;
723 *LMinusRTime = (fTimeL[Str] - fTimeR[Str]) * 0.5;
724 return kTRUE;
725}
726
727//----------------------------------------------------------------------------------------
728
730{
731 return fWidth[Str];
732}
733
734//----------------------------------------------------------------------------------------
735
737{
738 return fWidthL[Str];
739}
740
741//----------------------------------------------------------------------------------------
742
744{
745 return fWidthR[Str];
746}
747
748//----------------------------------------------------------------------------------------
749
751{
752 return fTime[Str];
753}
754
755//----------------------------------------------------------------------------------------
756
758{
759
760 if (fFillHist > 0) {
761 TFile* fileout = new TFile(NameFile.Data(), "UPDATE");
762 // Int_t ResWrite;
763 TDirectory* Dir;
764 TString Name;
765 Name = Form("%s", fName.Data());
766 Dir = fileout->mkdir(Name.Data());
767 Dir->cd();
768 // Dir->pwd();
769
770 TDirectory* DirStat;
771 DirStat = Dir->mkdir("Statistic");
772 DirStat->cd();
773 // DirStat->pwd();
774 // ResWrite = 0;
775 /*ResWrite = */ fHistListStat->Write();
776 // cout << "Res write = " << ResWrite << endl;
777
778 TDirectory* DirdT;
779 DirdT = Dir->mkdir("dt");
780 DirdT->cd();
781 // DirStat->pwd();
782 // ResWrite = 0;
783 /*ResWrite = */ fHistListdt->Write();
784 // cout << "Res write = " << ResWrite << endl;
785
786 fileout->Close(); //*/
787 return kTRUE; //*/
788
789 } else
790 return kFALSE;
791}
792
793//----------------------------------------------------------------------------------------
794
796{
797 if (IndL > fHalfMaxInt || IndR > fHalfMaxInt)
798 return -1;
799 Int_t Index = 0;
800 Index = (IndL << 16) + IndR;
801 return Index;
802}
803
804//----------------------------------------------------------------------------------------
805
806Bool_t BmnTOF1Detector::SetSpeedOfSignal(TString NameFile) // Should be used after BmnTOF1Detector::SetGeo
807{
808 char line[256];
809 Int_t Pl, St;
810 Double_t Temp;
811 ifstream f_corr;
812 TString dir = Form("%s%s%s", getenv("VMCWORKDIR"), "/input/", NameFile.Data());
813 f_corr.open(dir);
814 f_corr.getline(line, 256);
815 // cout << line << endl;
816
817 if (f_corr.is_open() == kTRUE) {
818 while (!f_corr.eof()) {
819 f_corr >> Pl >> St >> Temp;
820 if (Pl == fNPlane && St == fNStr) {
821 fSignalVelosity = Temp;
822 fMaxDelta = (fStripLength * 0.5 + 3.0) * fSignalVelosity;
823 // cout << Pl << " " << St << "fStripLength = " << fStripLength << "; Speed = " << fSignalVelosity
824 // << " MaxDelta = " << fMaxDelta << "\n";
825 }
826 if (Pl == fNPlane && St < fNStr) {
827 fSignalVelosityStr[St] = Temp;
828 }
829 }
830 } else {
831 cout << "File " << NameFile.Data() << " for TimeShift correction is not found" << endl;
832 cout << "Check " << dir.Data() << " folder for file" << endl;
833 return kFALSE;
834 }
835 f_corr.close();
836 return kTRUE;
837}
838
839//----------------------------------------------------------------------------------------
void memset(T *dest, T i, size_t num)
Copy to memory block [@dest, @dest+@num] num number of times the value of i of type @T with size @typ...
Definition L1Grid.h:27
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
char * Form(const char *fmt,...)
@ kTOF1
@ kTOF701
void SetModule(Int_t mod)
Definition BmnHit.h:53
void SetUpperClusterIndex(Int_t idx)
Definition BmnHit.h:64
void SetDetId(DetectorId det)
Definition BmnHit.h:51
void SetStation(Short_t st)
Definition BmnHit.h:52
void SetLowerClusterIndex(Int_t idx)
Definition BmnHit.h:65
Short_t fIndexL[fNStrMax]
Double_t fSignalVelosity
Double_t fCorrTimeShift[fNStrMax]
Int_t fDigitR[fNStrMax]
TH2S * hdT_vs_WidthT0[fNStrMax+1]
Double_t fTof[fNStrMax]
Int_t FormIndex(Int_t IndL, Int_t IndR)
Bool_t GetXYZTime(Int_t Str, TVector3 *XYZ, Double_t *ToF)
static const Int_t fHalfMaxInt
void SetStripLength(Double_t l)
Double_t fTimeLtemp[fNStrMax]
Double_t fWidthL[fNStrMax]
Bool_t SetGeoFile(TString NameFile)
TVector3 fCentrStrip[fNStrMax]
Bool_t SetCorrLR(TString NameFile)
Bool_t fKilled[fNStrMax]
Double_t fTimeR[fNStrMax]
void KillSide(Int_t NumberOfSide)
TVector3 fStripAngle[fNStrMax]
Double_t GetWidth(Int_t Str)
std::vector< std::vector< std::vector< Double_t > > > vHitsL
Short_t fIndexR[fNStrMax]
Int_t fDigitL[fNStrMax]
Int_t FindHitsNew(BmnTrigDigit *T0, TClonesArray *TofHit, TClonesArray *TofCont, int printnaw)
Bool_t GetLRTime(Int_t Str, Double_t *LMinusRTime)
BmnTrigDigit * fT0
Double_t fTimeL[fNStrMax]
TH1I * hdT[fNStrMax+1]
TF1 * funT0[fNStrMax]
Bool_t SetCorrTimeShift(TString NameFile)
static const Int_t fNStrMax
Double_t GetWidthR(Int_t Str)
TF1 * funRPC[fNStrMax]
Double_t fWidthRtemp[fNStrMax]
Double_t fWidthR[fNStrMax]
void KillStrip(Int_t NumberOfStrip)
Double_t fWidth[fNStrMax]
TH2S * hdT_vs_WidthDet[fNStrMax+1]
Bool_t SetDigitNew(BmnTof1Digit *TofDigit, Int_t ind=-1)
Double_t GetTime(Int_t Str)
Bool_t fFlagHit[fNStrMax]
Double_t fTime[fNStrMax]
Double_t fSignalVelosityStr[fNStrMax]
Double_t GetWidthL(Int_t Str)
Int_t fHit[fNStrMax]
TVector3 fCrossPoint[fNStrMax]
Bool_t SetGeo(BmnTof1GeoUtils *pGeoUtils)
Bool_t GetCrossPoint(Int_t NStrip, Double_t tL, Double_t tR)
Short_t fIndexRtemp[fNStrMax]
Double_t fCorrLR[fNStrMax]
Double_t CalculateDt(Int_t Str)
void AddConteiner(Int_t Str, TClonesArray *TofHit)
Bool_t SetSpeedOfSignal(TString NameFile)
Double_t fTimeRtemp[fNStrMax]
Double_t fCommonTimeShift
TList * GetList(Int_t n)
std::vector< std::vector< std::vector< Double_t > > > vHitsR
void AddHit(Int_t Str, TClonesArray *TofHit)
Bool_t SetCorrSlewing(TString NameFile)
Double_t fWidthLtemp[fNStrMax]
Short_t fIndexLtemp[fNStrMax]
Bool_t SaveHistToFile(TString NameFile)
TGraphErrors * gSlew[fNStrMax]
Int_t GetVolumeUID() const
Short_t GetPlane() const
Short_t GetSide() const
Short_t GetStrip() const
Float_t GetTime() const
Float_t GetAmplitude() const
const LStrip1 * FindStrip(Int_t UID)
Int_t ParseTGeoManager701(bool useMCinput, bool forced=false, Int_t verbose=0)
Int_t ParseTGeoManager(bool useMCinput, bool forced=false, Int_t verbose=0)
Double_t GetLength() const
TVector3 center
Bool_t cd() override
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
TList * GetListOfKeys() const override
virtual TObject * Get(const char *namecycle)
virtual Bool_t cd()
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
static std::atomic< TDirectory * > & CurrentDirectory()
virtual Bool_t IsOpen() const
void Close(Option_t *option="") override
Int_t GetEntriesFast() const
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void SetXYZ(Double_t x, Double_t y, Double_t z)
*brief user defined string literal for JSON values *sa std::size_t n
Definition json.hpp:20362
Double_t Cos(Double_t)
Double_t Abs(Double_t d)