BmnRoot
Loading...
Searching...
No Matches
BmnSlewingTOF700.cxx
Go to the documentation of this file.
1#include "BmnSlewingTOF700.h"
2
3#include <BmnMath.h>
4#include <arpa/inet.h> /* For ntohl for Big Endian LAND. */
5#include <sys/stat.h>
6
7using namespace std;
8
10{
11 fRunId = 0;
12 fPeriodId = 0;
13 fEventId = 0;
14 fNevents = 0;
15 fMaxEvent = 0;
16 fLengthRawFile = 0;
17 fCurentPositionRawFile = 0;
18 eventHeaderDAQ = NULL;
19 eventHeader = NULL;
20 fTime_ns = 0;
21 fTime_s = 0;
22 fT0Time = 0.0;
23 fRawTree = NULL;
24 fRootFileIn = NULL;
25 fRootFileOut = NULL;
26 fRawFileIn = NULL;
27 sync = NULL;
28 tdc = NULL;
29 tqdc_tdc = NULL;
30 tqdc_adc = NULL;
31 hrb = NULL;
32 adc32 = NULL;
33 adc128 = NULL;
34 adc = NULL;
35 msc = NULL;
36 fRootFileName = "";
37 fRawFileName = "";
38 fTrigPlaceMapFileName = "";
39 fTrigChannelMapFileName = "";
40 fTof700MapFileName = "";
41 fTof700GeomFileName = "";
42 fDat = 0;
43 fTrigMapper = NULL;
44 fTof700Mapper = NULL;
45 fDataQueue = NULL;
46 fTimeStart_s = 0;
47 fTimeStart_ns = 0;
48 syncCounter = 0;
49 fBmnSetup = kBMNSETUP;
50 fT0Serial = 0;
51}
52
53BmnSlewingTOF700::BmnSlewingTOF700(TString file, ULong_t nEvents, ULong_t period)
54{
55
56 isRawRootInputFile = kFALSE;
57
59
60 eventHeaderDAQ = NULL;
61 eventHeader = NULL;
62 fTime_ns = 0;
63 fTime_s = 0;
64 fT0Time = 0.0;
65 fRawTree = NULL;
66 fRootFileIn = NULL;
67 fRootFileOut = NULL;
68 fRawFileIn = NULL;
69 sync = NULL;
70 hrb = NULL;
71 tdc = NULL;
72 tqdc_tdc = NULL;
73 tqdc_adc = NULL;
74 adc32 = NULL;
75 adc128 = NULL;
76 adc = NULL;
77 msc = NULL;
78 fRawFileName = file;
79 fEventId = 0;
80 fNevents = 0;
81 fMaxEvent = nEvents;
82 fPeriodId = period;
83
84 if (fRawFileName != "") {
85 fRunId = GetRunIdFromFile(fRawFileName);
86 TString subName = GetSubNameAfterRunId(file, fRunId);
87 printf("RunId %d got from the %s file\n", fRunId, isRawRootInputFile ? "RawRoot" : "RawData");
88 TString DigiFileName = Form("bmn_run%d_digi%s.root", fRunId, subName.Data());
89 if (fRootFileName.Length()) {
90
91 } else {
92 Int_t lastSlash = DigiFileName.Last('/');
93 TString digiPath = (lastSlash == TString::kNPOS) ? "" : TString(DigiFileName(0, lastSlash + 1));
94 fRootFileName = Form("%sbmn_run%d_raw%s.root", digiPath.Data(), fRunId, subName.Data());
95 }
96 }
97
98 // fRunId = GetRunIdFromFile(fRawFileName);
99 // fRootFileName = Form("bmn_run%04d_raw.root", fRunId);
100 // fRootFileName = Form("bmn_run%04d_raw.root", (fRunId=6847));
101 fTrigPlaceMapFileName = "";
102 fTrigChannelMapFileName = "";
103 fTof700MapFileName = file;
104 fTof700GeomFileName = "";
105 fDat = 0;
106 fTrigMapper = NULL;
107 fTof700Mapper = NULL;
108 fDataQueue = NULL;
109 fTimeStart_s = 0;
110 fTimeStart_ns = 0;
111 syncCounter = 0;
112 fBmnSetup = kBMNSETUP;
113 fT0Serial = 0;
114 // InitMaps();
115}
116
118
119/*
120BmnStatus BmnSlewingTOF700::FillTimeShiftsMap() {
121 if (fT0Serial == 0) return kBMNERROR;
122 Long64_t t0time = 0;
123 for (Int_t i = 0; i < sync->GetEntriesFast(); ++i) {
124 BmnSyncDigit* syncDig = (BmnSyncDigit*) sync->At(i);
125 if (syncDig->GetSerial() == fT0Serial) {
126 t0time = syncDig->GetTime_ns() + syncDig->GetTime_sec() * 1000000000LL;
127 break;
128 }
129 }
130 for (Int_t i = 0; i < sync->GetEntriesFast(); ++i) {
131 BmnSyncDigit* syncDig = (BmnSyncDigit*) sync->At(i);
132 Long64_t syncTime = (t0time == 0.0) ? 0 : syncDig->GetTime_ns() + syncDig->GetTime_sec() * 1000000000LL;
133 fTimeShifts.insert(pair<UInt_t, Long64_t>(syncDig->GetSerial(), syncTime - t0time));
134 }
135
136 return kBMNSUCCESS;
137}
138*/
139
140BmnStatus BmnSlewingTOF700::FillTimeShiftsMap()
141{
142 if (fT0Serial == 0)
143 return kBMNERROR;
144 Long64_t t0time = 0;
145 for (Int_t i = 0; i < sync->GetEntriesFast(); ++i) {
146 BmnSyncDigit* syncDig = (BmnSyncDigit*)sync->At(i);
147 if (syncDig->GetSerial() == fT0Serial) {
148 t0time = syncDig->GetTime_ns() + syncDig->GetTime_sec() * 1000000000LL;
149 fTime_s = syncDig->GetTime_sec();
150 fTime_ns = syncDig->GetTime_ns();
151 // printf("serial %08X sync: %s\n", syncDig->GetSerial(), TTimeStamp(time_t(fTime_s), fTime_ns).AsString());
152 if (fRunStartTime == TimeZero) {
153 fRunStartTime = TTimeStamp(time_t(fTime_s), fTime_ns);
154 }
155 // printf("T0 sync: %s \n", TTimeStamp(time_t(fTime_s), fTime_ns).AsString());
156 break;
157 }
158 }
159 for (Int_t i = 0; i < sync->GetEntriesFast(); ++i) {
160 BmnSyncDigit* syncDig = (BmnSyncDigit*)sync->At(i);
161 Long64_t syncTime = (t0time == 0.0) ? 0 : syncDig->GetTime_ns() + syncDig->GetTime_sec() * 1000000000LL;
162 fTimeShifts.insert(pair<UInt_t, Long64_t>(syncDig->GetSerial(), syncTime - t0time));
163 }
164 return kBMNSUCCESS;
165}
166
167BmnStatus BmnSlewingTOF700::FillTimeShiftsMapNoDB(UInt_t t0serial)
168{
169
170 Long64_t t0time = -1;
171 // printf(" sync size %d, t0serial 0x%0x\n", sync->GetEntriesFast(), t0serial);
172 for (Int_t i = 0; i < sync->GetEntriesFast(); ++i) {
173 BmnSyncDigit* syncDig = (BmnSyncDigit*)sync->At(i);
174 // printf(" have 0x%0x requred 0x%0x\n", syncDig->GetSerial(), t0serial);
175 if (syncDig->GetSerial() == t0serial) {
176 t0time = syncDig->GetTime_ns() + syncDig->GetTime_sec() * 1000000000LL;
177 break;
178 }
179 }
180
181 if (t0time == -1) {
182 // cerr << "No T0 digit found in tree" << endl;
183 return kBMNERROR;
184 }
185
186 for (Int_t i = 0; i < sync->GetEntriesFast(); ++i) {
187 BmnSyncDigit* syncDig = (BmnSyncDigit*)sync->At(i);
188 Long64_t syncTime = syncDig->GetTime_ns() + syncDig->GetTime_sec() * 1000000000LL;
189 fTimeShifts.insert(pair<UInt_t, Long64_t>(syncDig->GetSerial(), syncTime - t0time));
190 }
191
192 return kBMNSUCCESS;
193}
194
196{
197
198 fDigiTree = new TTree("bmndata", "bmn_digit");
199 eventHeader = new TClonesArray("BmnEventHeader");
200 fDigiTree->Branch("BmnEventHeader", &eventHeader);
201
202 fRootFileIn = new TFile(fRootFileName, "READ");
203 if (fRootFileIn->IsOpen() == false) {
204 printf("\n!!!!\ncannot open file %s \nSlewingTOF700 are stopped\n!!!!\n", fRootFileName.Data());
205 return kBMNERROR;
206 } else {
207 printf("\nInput root file: %s;\n", fRootFileName.Data());
208 }
209 fRawTree = (TTree*)fRootFileIn->Get("BMN_RAW");
210 tdc = new TClonesArray("BmnTDCDigit");
211 tqdc_adc = new TClonesArray("BmnTQDCADCDigit");
212 tqdc_tdc = new TClonesArray("BmnTDCDigit");
213 sync = new TClonesArray("BmnSyncDigit");
214 eventHeaderDAQ = new TClonesArray("BmnEventHeader");
215 hrb = new TClonesArray("BmnHRBDigit");
216 adc32 = new TClonesArray("BmnADCDigit");
217 adc128 = new TClonesArray("BmnADCDigit");
218 adc = new TClonesArray("BmnADCDigit");
219 fRawTree->SetBranchAddress("TDC", &tdc);
220 fRawTree->SetBranchAddress("SYNC", &sync);
221 fRawTree->SetBranchAddress("TQDC_ADC", &tqdc_adc);
222 fRawTree->SetBranchAddress("TQDC_TDC", &tqdc_tdc);
223 fRawTree->SetBranchAddress("SYNC", &sync);
224 fRawTree->SetBranchAddress("EventHeader", &eventHeaderDAQ);
225 fRawTree->SetBranchAddress("HRB", &hrb);
226 fRawTree->SetBranchAddress("ADC32", &adc32);
227 fRawTree->SetBranchAddress("ADC128", &adc128);
228 fRawTree->SetBranchAddress("ADC", &adc);
229
230 fNevents = (fMaxEvent > (ULong_t)fRawTree->GetEntries() || fMaxEvent == 0) ? fRawTree->GetEntries() : fMaxEvent;
231
232 fTrigMapper = new BmnTrigRaw2Digit(fTrigPlaceMapFileName, fTrigChannelMapFileName, fDigiTree);
233 if (fT0Serial == 0) {
234 fT0Serial = fTrigMapper->GetT0Serial();
235 printf("T0 serial 0x%X got from trig mapping\n", fT0Serial);
236 }
237
238 fTrigMapper->SetSetup(fBmnSetup);
239
240 TString PeriodSetupExt = Form("%d%s.txt", fPeriodId, ((fBmnSetup == kBMNSETUP) ? "" : "_SRC"));
241
242 fTof700Mapper = new BmnTof2Raw2DigitNew(
243 fTof700MapFileName, fRootFileName, 0, 0, TString("TOF700_geometry_run") + PeriodSetupExt);
244 // fTof700Mapper->print();
245
246 return kBMNSUCCESS;
247}
248
250{
251
252 fTof700Mapper->readSlewingLimits();
253
254 fTof700Mapper->BookSlewing();
255
256 for (UInt_t iEv = 0; iEv < fNevents; ++iEv) {
257 if (iEv % 5000 == 0)
258 cout << "Slewing T0 event #" << iEv << endl;
259
260 fTrigMapper->ClearArrays();
261
262 fTimeShifts.clear();
263
264 fRawTree->GetEntry(iEv);
265
266 FillTimeShiftsMap();
267
268 // if (FillTimeShiftsMapNoDB(0x6EA9711) == kBMNERROR) {
269 // cout << "No TimeShiftMap created" << endl;
270 // continue;
271
272 //}
273
274 if (fTrigMapper) {
275 fTrigMapper->FillEvent(tdc, fTimeShifts);
276 fTrigMapper->FillEvent(tqdc_tdc, tqdc_adc, fTimeShifts);
277 }
278 fT0Time = 0.;
279 GetT0Info(fT0Time, fT0Width);
280 if (fT0Time == 0.)
281 continue;
282
283 fTof700Mapper->fillSlewingT0(tdc, &fTimeShifts, fT0Time, fT0Width);
284 }
285 cout << "Slewing T0 event #" << fNevents << endl;
286
287 for (UInt_t iEv = 0; iEv < fNevents; ++iEv) {
288 if (iEv % 5000 == 0)
289 cout << "Slewing RPC event #" << iEv << endl;
290
291 fTrigMapper->ClearArrays();
292
293 fTimeShifts.clear();
294
295 fRawTree->GetEntry(iEv);
296
297 FillTimeShiftsMap();
298
299 // if (FillTimeShiftsMapNoDB(0x6EA9711) == kBMNERROR) {
300 // cout << "No TimeShiftMap created" << endl;
301 // continue;
302 // }
303
304 if (fTrigMapper) {
305 fTrigMapper->FillEvent(tdc, fTimeShifts);
306 fTrigMapper->FillEvent(tqdc_tdc, tqdc_adc, fTimeShifts);
307 }
308 fT0Time = 0.;
309 GetT0Info(fT0Time, fT0Width);
310 if (fT0Time == 0.)
311 continue;
312
313 fTof700Mapper->fillSlewing(tdc, &fTimeShifts, fT0Time, fT0Width);
314 }
315 cout << "Slewing RPC event #" << fNevents << endl;
316
317 fTof700Mapper->FitSlewing();
318
319 for (UInt_t iEv = 0; iEv < fNevents; ++iEv) {
320 if (iEv % 5000 == 0)
321 cout << "Equalization RPC strips event #" << iEv << endl;
322
323 fTrigMapper->ClearArrays();
324
325 fTimeShifts.clear();
326
327 fRawTree->GetEntry(iEv);
328
329 FillTimeShiftsMap();
330
331 // if (FillTimeShiftsMapNoDB(0x6EA9711) == kBMNERROR) {
332 // cout << "No TimeShiftMap created" << endl;
333 // continue;
334 // }
335
336 if (fTrigMapper) {
337 fTrigMapper->FillEvent(tdc, fTimeShifts);
338 fTrigMapper->FillEvent(tqdc_tdc, tqdc_adc, fTimeShifts);
339 }
340 fT0Time = 0.;
341 GetT0Info(fT0Time, fT0Width);
342 if (fT0Time == 0.)
343 continue;
344
345 fTof700Mapper->fillEqualization(tdc, &fTimeShifts, fT0Time, fT0Width);
346 }
347 cout << "Equalization RPC strips event #" << fNevents << endl;
348
349 fTof700Mapper->Equalization();
350
351 // fRootFileIn->Close();
352
353 // delete trigMapper;
354 // delete tof700Mapper;
355
356 return kBMNSUCCESS;
357}
358
360{
361
362 for (UInt_t iEv = 0; iEv < fNevents; ++iEv) {
363 if (iEv % 5000 == 0)
364 cout << "Preparation stage event #" << iEv << endl;
365
366 fTrigMapper->ClearArrays();
367
368 fTimeShifts.clear();
369
370 fRawTree->GetEntry(iEv);
371
372 FillTimeShiftsMap();
373
374 // if (FillTimeShiftsMapNoDB(0x6EA9711) == kBMNERROR) {
375 // cout << "No TimeShiftMap created" << endl;
376 // continue;
377 // }
378
379 if (fTrigMapper) {
380 fTrigMapper->FillEvent(tdc, fTimeShifts);
381 fTrigMapper->FillEvent(tqdc_tdc, tqdc_adc, fTimeShifts);
382 }
383 fT0Time = 0.;
384 GetT0Info(fT0Time, fT0Width);
385 // printf(" T0 = %f TW = %f\n", fT0Time, fT0Width);
386 if (fT0Time == 0.)
387 continue;
388 // printf(" T0 = %f TW = %f\n", fT0Time, fT0Width);
389
390 fTof700Mapper->fillPreparation(tdc, &fTimeShifts, fT0Time, fT0Width);
391 }
392
393 fTof700Mapper->Equalization0();
394 fTof700Mapper->writeSlewingLimits();
395
396 // fRootFileIn->Close();
397
398 // delete trigMapper;
399 // delete tof700Mapper;
400
401 return kBMNSUCCESS;
402}
403
404/*
405Int_t BmnSlewingTOF700::GetRunIdFromFile(TString name) {
406 Int_t runId = -1;
407 FILE * file = fopen(name.Data(), "rb");
408 if (file == NULL) {
409 printf("File %s is not open!!!\n", name.Data());
410 return -1;
411 }
412 UInt_t word;
413 while (fread(&word, kWORDSIZE1, 1, file)) {
414 if (word == kRUNNUMBERSYNC1) {
415 fread(&word, kWORDSIZE1, 1, file); //skip word
416 fread(&runId, kWORDSIZE1, 1, file);
417 return runId;
418 }
419 }
420 fclose(file);
421 if (runId <= 0) {
422 Int_t run = 0;
423 //sscanf(&(((char *)name.Data())[strlen(name.Data())-9]), "%d", &run);
424 run = ((TString) name(name.Length() - 9, name.Length() - 5)).Atoi();
425 return run;
426 } else return runId;
427}
428
429BmnStatus BmnSlewingTOF700::GetT0Info(Double_t& t0time, Double_t &t0width) {
430 vector<TClonesArray*>* trigArr = fTrigMapper->GetTrigArrays();
431 BmnTrigDigit* dig = 0;
432 for (auto ar : *trigArr) {
433 if (fPeriodId > 6) {
434 if (strcmp(ar->GetName(), "BC2")) continue;
435 } else {
436 if (strcmp(ar->GetName(), "T0")) continue;
437 }
438 for (int i = 0; i < ar->GetEntriesFast(); i++) {
439 dig = (BmnTrigDigit*) ar->At(i);
440 if (fPeriodId > 6) {
441 if (dig->GetMod() == 0) {
442 t0time = dig->GetTime();
443 t0width = dig->GetAmp();
444 // printf(" t0 %f t0w %f n %d\n", t0time, t0width, ar->GetEntriesFast());
445 return kBMNSUCCESS;
446 }
447 } else {
448 t0time = dig->GetTime();
449 t0width = dig->GetAmp();
450 return kBMNSUCCESS;
451 }
452 }
453 }
454 return kBMNERROR;
455}
456*/
457
458Int_t BmnSlewingTOF700::GetRunIdFromFile(TString name)
459{
460 Int_t runId = -1;
461 TPRegexp re(".+\\.root");
462 if (re.MatchB(name)) {
463 printf("Name is %s\n", name.Data());
464 fRootFileIn = new TFile(name, "READ");
465 if (fRootFileIn->IsOpen()) {
466 BmnEventHeader* tempHdr = nullptr;
467 TTree* RawTree = (TTree*)fRootFileIn->Get("BMN_RAW");
468 if (RawTree) {
469 RawTree->SetBranchAddress("BmnEventHeader.", &tempHdr);
470 if (RawTree->GetEntriesFast()) {
471 RawTree->GetEntry(0);
472 runId = tempHdr->GetRunId();
473 fRootFileName = name;
474 }
475 delete RawTree;
476 }
477 fRootFileIn->Close();
478 }
479 delete fRootFileIn;
480 }
481 if (runId > 0) {
482 isRawRootInputFile = true;
483 return runId;
484 }
485
486 FILE* file = fopen(name.Data(), "rb");
487 if (file == nullptr) {
488 printf("File %s is not open!!!\n", name.Data());
489 return -1;
490 }
491 UInt_t word;
492 Int_t cntr = 0;
493 while (fread(&word, kWORDSIZE, 1, file)) {
494 // printf("%X\n", word);
495 if (cntr == 20) {
496 printf("After checking %d words in input file run number not found!\n", cntr);
497 printf("Let's get run number from file name\n");
498 break;
499 }
500 if (word == RECORD_RUN_NUMBER) {
501 if (fread(&word, kWORDSIZE, 1, file) != 1)
502 break; // skip word
503 if (fread(&runId, kWORDSIZE, 1, file) != 1)
504 break;
505 return runId;
506 }
507 cntr++;
508 }
509 fclose(file);
510 if (runId <= 0) {
511 // Int_t run = 0;
512 // sscanf(&(((char *)name.Data())[strlen(name.Data())-9]), "%d", &run);
513 TPRegexp(".*\\w+_\\w+_\\w+_(\\d+)[^/]*\\.data").Substitute(name, "$1");
514
515 // cout << name << endl;
516
517 return name.Atoi();
518
519 } else
520 return runId;
521}
522BmnStatus BmnSlewingTOF700::GetT0Info(Double_t& t0time, Double_t& t0width)
523{
524 vector<TClonesArray*>* trigArr = fTrigMapper->GetTrigArrays();
525 BmnTrigDigit* dig = 0;
526 for (auto ar : *trigArr) {
527 if ((fPeriodId == 8) && (fBmnSetup == kSRCSETUP)) { // temporary crutches
528 if ((fRunId >= 986) && (fRunId <= 1086)) {
529 if ((strcmp(ar->GetName(), "BC2_1_A")))
530 continue;
531 } else {
532 if ((strcmp(ar->GetName(), "T0_1_A")))
533 continue;
534 }
535 } else {
536 if (fPeriodId > 6) {
537 if (fPeriodId == 8) {
538 if (strcmp(ar->GetName(), "BC2AT"))
539 continue;
540 } else {
541 if (strcmp(ar->GetName(), "BC2"))
542 continue;
543 }
544 } else {
545 if (strcmp(ar->GetName(), "T0"))
546 continue;
547 }
548 }
549 for (int i = 0; i < ar->GetEntriesFast(); i++) {
550 dig = (BmnTrigDigit*)ar->At(i);
551 if (dig->GetMod() == 0) {
552 t0time = dig->GetTime();
553 t0width = dig->GetAmp();
554 // printf(" t0 %f t0w %f n %d\n", t0time, t0width, ar->GetEntriesFast());
555 return kBMNSUCCESS;
556 }
557 }
558 }
559 return kBMNERROR;
560}
561
563{
564 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1972, 1, 1, 0, 0, 9), 10));
565 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1972, 7, 1, 0, 0, 10), 11));
566 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1973, 1, 1, 0, 0, 11), 12));
567 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1974, 1, 1, 0, 0, 12), 13));
568 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1975, 1, 1, 0, 0, 13), 14));
569 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1976, 1, 1, 0, 0, 14), 15));
570 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1977, 1, 1, 0, 0, 15), 16));
571 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1978, 1, 1, 0, 0, 16), 17));
572 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1979, 1, 1, 0, 0, 17), 18));
573 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1980, 1, 1, 0, 0, 18), 19));
574 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1981, 7, 1, 0, 0, 19), 20));
575 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1982, 7, 1, 0, 0, 20), 21));
576 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1983, 7, 1, 0, 0, 21), 22));
577 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1985, 7, 1, 0, 0, 22), 23));
578 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1988, 1, 1, 0, 0, 23), 24));
579 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1990, 1, 1, 0, 0, 24), 25));
580 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1991, 1, 1, 0, 0, 25), 26));
581 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1992, 7, 1, 0, 0, 26), 27));
582 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1993, 7, 1, 0, 0, 27), 28));
583 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1994, 7, 1, 0, 0, 28), 29));
584 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1996, 1, 1, 0, 0, 29), 30));
585 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1997, 7, 1, 0, 0, 30), 31));
586 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(1999, 1, 1, 0, 0, 31), 32));
587 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2006, 1, 1, 0, 0, 32), 33));
588 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2009, 1, 1, 0, 0, 33), 34));
589 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2012, 7, 1, 0, 0, 34), 35));
590 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2015, 7, 1, 0, 0, 35), 36));
591 leaps.insert(pair<TTimeStamp, Int_t>(TTimeStamp(2017, 1, 1, 0, 0, 36), 37));
592 utc_valid = TTimeStamp(2023, 6, 1, 0, 0, 1);
593 return kBMNSUCCESS;
594}
595
597{
598 if (t < leaps.begin()->first) {
599 // if (fVerbose == 0) // verbosity as defined in BmnDataToRoot
600 printf("Wrong time!\n");
601 return 0;
602 }
603 if (t > utc_valid)
604 printf(ANSI_COLOR_RED "Warning! Leap seconds table expired!\n" ANSI_COLOR_RESET);
605 Int_t shift = 0;
606 auto it = leaps.lower_bound(t);
607 if ((it == leaps.end()))
608 it--;
609 else if (it->first > t)
610 it--;
611 shift = it->second;
612 return shift;
613}
614
615TString BmnSlewingTOF700::GetSubNameAfterRunId(TString name, Int_t RunID)
616{
617 TString ID = TString::Itoa(RunID, 10);
618 TRegexp reg1 = ID;
619 TRegexp reg2 = (".data");
620 Int_t index1 = name.Index(reg1) + ID.Length();
621 Int_t index2 = name.Index(reg2);
622 TSubString str = name(index1, index2 - index1);
623
624 return str;
625}
int i
Definition P4_F32vec4.h:22
BmnStatus
Definition BmnEnums.h:24
@ kBMNERROR
Definition BmnEnums.h:26
@ kBMNSUCCESS
Definition BmnEnums.h:25
@ kSRCSETUP
Definition BmnEnums.h:91
@ kBMNSETUP
Definition BmnEnums.h:90
#define ANSI_COLOR_RED
Definition BmnMath.h:16
#define ANSI_COLOR_RESET
Definition BmnMath.h:18
const uint32_t RECORD_RUN_NUMBER
Definition RawTypes.h:14
const size_t kWORDSIZE
Definition RawTypes.h:18
BmnStatus SlewingTOF700Init()
Int_t GetUTCShift(TTimeStamp t)
BmnStatus PreparationTOF700()
UInt_t GetSerial() const
Long64_t GetTime_sec() const
Long64_t GetTime_ns() const
void fillSlewing(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
void fillEqualization(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
void fillSlewingT0(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
void fillPreparation(TClonesArray *data, unordered_map< UInt_t, Long64_t > *ts, Double_t t0, Double_t t0width)
Double_t GetAmp() const
Double_t GetTime() const
Short_t GetMod() const
vector< TClonesArray * > * GetTrigArrays()
void SetSetup(BmnSetup stp)
BmnStatus FillEvent(TClonesArray *tdc, unordered_map< UInt_t, Long64_t > &tsMap)
name
Definition setup.py:7
STL namespace.