BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnFillDstTask.cxx
Go to the documentation of this file.
1/********************************************************************************
2 * BmnFillDstTask.cxx *
3 * BM@N Fill DST Task class implementation *
4 * Add necessary data and event header to the DST file after reconstruction *
5 *******************************************************************************/
6
7#define ANSI_COLOR_RED "\x1b[91m"
8#define ANSI_COLOR_BLUE "\x1b[94m"
9#define ANSI_COLOR_RESET "\x1b[0m"
10
11#include "BmnFillDstTask.h"
12
13#include "BmnFieldConst.h"
14#include "BmnFieldMap.h"
15#include "BmnTrigDigit.h"
16#include "ExtractZ2.h"
17#include "FairBaseParSet.h"
18#include "FairGeoParSet.h"
19#include "FairLogger.h"
20#include "FairRunAna.h"
21#include "FairRuntimeDb.h"
22#include "TGeoManager.h"
23#include "TObjString.h"
24#include "TROOT.h"
25#include "TSystem.h"
26#include "UniRun.h"
27#include "function_set.h"
28
29#include <TStopwatch.h>
30#include <fstream>
31#include <iostream>
32using namespace std;
33
34static Double_t workTime = 0.0;
35
36// ---- Default constructor -------------------------------------------
38 : BmnTask("BmnFillDstTask")
39 , isExpData(-1)
40 , fPeriodNumber(-1)
41 , fRunNumber(-1)
42 , fMCEventHeader(nullptr)
43 , fMCTracks(nullptr)
44 , fMCInfoDst(nullptr)
45 , fEventHeader(nullptr)
46 , fDstHeader(nullptr)
47 , fRunHeader(nullptr)
48 , fNStartEvent(0)
49 , fNEvents(-1)
50 , fIEvent(0)
51 , fPrimaryVertex(nullptr)
52 , fGlobalTracks(nullptr)
53 , fZCalib1(1)
54 , fZCalib2(0)
55 , fBC1Calib(0)
56 , fBC2Calib(0)
58 , fT0(nullptr)
59 , fBC1(nullptr)
60 , fBC2(nullptr)
61 , fBC3(nullptr)
62 , fBC4(nullptr)
63{
64 LOG(debug) << "Defaul Constructor of BmnFillDstTask";
65}
66
67// ---- Constructor with start event and event number to be processed, and autodefinition whether experimental data are
68// used -------
70 : BmnTask("BmnFillDstTask")
71 , isExpData(-1)
72 , fPeriodNumber(-1)
73 , fRunNumber(-1)
74 , fMCEventHeader(nullptr)
75 , fMCTracks(nullptr)
76 , fMCInfoDst(nullptr)
77 , fEventHeader(nullptr)
78 , fDstHeader(nullptr)
79 , fRunHeader(nullptr)
80 , fNStartEvent(nStartEvent)
81 , fNEvents(nEvents)
82 , fIEvent(0)
83 , fPrimaryVertex(nullptr)
84 , fGlobalTracks(nullptr)
85 , fZCalib1(1)
86 , fZCalib2(0)
87 , fBC1Calib(0)
88 , fBC2Calib(0)
90 , fT0(nullptr)
91 , fBC1(nullptr)
92 , fBC2(nullptr)
93 , fBC3(nullptr)
94 , fBC4(nullptr)
95{
96 LOG(debug) << "Constructor of BmnFillDstTask";
97}
98
99// Constructor with start event and event number to be processed, experimental data flag, period and run numbers
101 Long64_t nEvents,
102 Bool_t isExp,
103 Int_t period_number,
104 Int_t run_number)
105 : BmnTask("BmnFillDstTask")
106 , fPeriodNumber(period_number)
107 , fRunNumber(run_number)
108 , fMCEventHeader(nullptr)
109 , fMCTracks(nullptr)
110 , fMCInfoDst(nullptr)
111 , fEventHeader(nullptr)
112 , fDstHeader(nullptr)
113 , fRunHeader(nullptr)
114 , fNStartEvent(nStartEvent)
115 , fNEvents(nEvents)
116 , fIEvent(0)
117 , fPrimaryVertex(nullptr)
118 , fGlobalTracks(nullptr)
119 , fZCalib1(1)
120 , fZCalib2(0)
121 , fBC1Calib(0)
122 , fBC2Calib(0)
124 , fT0(nullptr)
125 , fBC1(nullptr)
126 , fBC2(nullptr)
127 , fBC3(nullptr)
128 , fBC4(nullptr)
129{
130 LOG(debug) << "Constructor of BmnFillDstTask";
131 if (isExp)
132 isExpData = 1;
133 else
134 isExpData = 0;
135}
136
137// ---- Destructor ----------------------------------------------------
139{
140 LOG(debug) << "Destructor of BmnFillDstTask";
141 if (fMCInfoDst)
142 delete fMCInfoDst;
143 if (fRunHeader)
144 delete fRunHeader;
145}
146
147// Set headers with autodefinition whether experimental or simulation data are used
149{
150 FairRootManager* ioman = FairRootManager::Instance();
151
152 isExpData = 1;
153 // Get a pointer to the input Event Header
154 TObject* pObj = ioman->GetObject("BmnEventHeader.");
155 if (!pObj) {
156 // if no input Event Header was found, searching for "MCEventHeader."
157 fMCEventHeader = (FairMCEventHeader*)ioman->GetObject("MCEventHeader.");
158 if (!fMCEventHeader)
159 return false;
160 isExpData = 0;
161 } else {
162 if (pObj->InheritsFrom(FairMCEventHeader::Class())) {
164 isExpData = 0;
165 } else
167 }
168
169 return true;
170}
171
172// ---- Initialization of task at the beginning ------------------------
174{
175 LOG(debug) << "Initialization of BmnFillDstTask";
176
177 fRunHeader = new DstRunHeader();
178
179 // Get a handle from the IO manager
180 FairRootManager* ioman = FairRootManager::Instance();
181 if (!ioman) {
182 LOG(error) << "Init: FairRootManager is not instantiated! BmnFillDstTask task will be deactivated";
183 SetActive(kFALSE);
184 return kERROR;
185 }
186
187 if (isExpData == -1) {
188 if (!autoSetHeaders()) {
189 LOG(error) << "No input Event Header (BmnEventHeader. or MCEventHeader.) found! BmnFillDstTask task will "
190 "be deactivated";
191 return kERROR;
192 }
193 } else {
194 if (isExpData == 0)
195 fMCEventHeader = (FairMCEventHeader*)ioman->GetObject("MCEventHeader.");
196 else
197 fEventHeader = (BmnEventHeader*)ioman->GetObject("BmnEventHeader.");
198 }
199
201
202 // Get input branches
203 if (isExpData == 1) {
204 fT0 = (TClonesArray*)ioman->GetObject("BC2");
205 fBC1 = (TClonesArray*)ioman->GetObject("TQDC_BC1");
206 fBC2 = (TClonesArray*)ioman->GetObject("TQDC_BC2");
207 fBC3 = (TClonesArray*)ioman->GetObject("TQDC_BC3");
208 fBC4 = (TClonesArray*)ioman->GetObject("TQDC_BC4");
209 }
210 // Get a pointer to the output DST Event Header
211 fDstHeader = (DstEventHeader*)ioman->GetObject("DstEventHeader.");
212 if (!fDstHeader) {
213 LOG(error) << "No DstEventHeader prepared for the output DST file! BmnFillDstTask task will be deactivated";
214 return kERROR;
215 }
216
217 if (ioman->CheckMaxEventNo(fNEvents) < fNEvents)
218 fNEvents = ioman->CheckMaxEventNo(fNEvents);
219
220 // Fill Run Header with the magnetic field and geometry to simply use in physics analyses
221 FairField* fField = FairRunAna::Instance()->GetField();
222 if (fField != nullptr) {
223 fRunHeader->SetFieldType(fField->GetType());
224 if (fField->GetType() == 0) {
225 BmnFieldConst* fFieldConst = reinterpret_cast<BmnFieldConst*>(fField);
226 fRunHeader->SetFieldScale(-1);
227 fRunHeader->SetFieldName(TString::Format(
228 "%f:%f:%f:%f:%f:%f:%f:%f:%f", fFieldConst->GetXmin(), fFieldConst->GetXmax(), fFieldConst->GetYmin(),
229 fFieldConst->GetYmax(), fFieldConst->GetZmin(), fFieldConst->GetZmax(), fFieldConst->GetBx(),
230 fFieldConst->GetBy(), fFieldConst->GetBz()));
231 } else {
232 BmnFieldMap* fFieldMap = reinterpret_cast<BmnFieldMap*>(fField);
233 fRunHeader->SetFieldScale(fFieldMap->GetScale());
234 fRunHeader->SetFieldName(fFieldMap->GetName());
235 }
236 }
237
238 // Fill Run Header for the experimental data from the Condition Database
239 if (fRunNumber > 0) {
241
242 // Save gGeoManager in the container (this call creates the container if it does not exist)
243 FairGeoParSet* geopar = dynamic_cast<FairGeoParSet*>(FairRuntimeDb::instance()->getContainer("FairGeoParSet"));
244 if (geopar) {
245 geopar->SetGeometry(gGeoManager);
246 geopar->setChanged();
247 // geopar->setInputVersion(version, index);
248 }
249
251 if (pCurrentRun != 0) {
252 fRunHeader->SetPeriodRun(fPeriodNumber, fRunNumber);
253 TDatime start_date = pCurrentRun->GetStartDatetime();
254 TTimeStamp tsStartTime(start_date.GetYear(), start_date.GetMonth(), start_date.GetDay(),
255 start_date.GetHour(), start_date.GetMinute(), start_date.GetSecond());
256 fRunHeader->SetStartTime(tsStartTime);
257 TDatime* end_date = pCurrentRun->GetEndDatetime();
258 if (end_date != NULL) {
259
260 // TTimeStamp tsEndTime((time_t) pCurrentRun->GetEndDatetime()->Convert(), 0);
261
262 TTimeStamp tsEndTime(end_date->GetYear(), end_date->GetMonth(), end_date->GetDay(), end_date->GetHour(),
263 end_date->GetMinute(), end_date->GetSecond());
264 fRunHeader->SetFinishTime(tsEndTime);
265 }
266 delete end_date;
267 TString beam = pCurrentRun->GetBeamParticle();
268 fRunHeader->SetBeam(beam);
269 beam.ToLower();
270 map<TString, stParticleInfo>::iterator it = mapParticleInfo.find(beam);
271 if (it != mapParticleInfo.end()) {
272 fRunHeader->SetBeamA(it->second.A);
273 fRunHeader->SetBeamZ(it->second.Z);
274 } else
275 LOG(warn) << "BmnFillDstTask::Init(): unknown beam '" << beam
276 << "', A and Z are not written to the run header";
277 double* energy = pCurrentRun->GetEnergy();
278 if (energy != NULL) {
279 fRunHeader->SetBeamEnergy(*energy);
280 delete energy;
281 }
282
283 TString target = pCurrentRun->GetTargetParticle();
284 fRunHeader->SetTarget(target);
285 if (target != "") {
286 target.ToLower();
287 // cut a comment after the target name, e.g. "CsI (2%)"
288 Ssiz_t comment_pos = target.Index('(');
289 if (comment_pos != kNPOS)
290 target.Remove(comment_pos);
291 target = target.Strip(TString::kBoth);
292 it = mapParticleInfo.find(target);
293 if (it != mapParticleInfo.end()) {
294 fRunHeader->SetTargetA(it->second.A);
295 fRunHeader->SetTargetZ(it->second.Z);
296 } else
297 LOG(warn) << "BmnFillDstTask::Init(): unknown target '" << target
298 << "', A and Z are not written to the run header";
299 }
300 } // if (pCurrentRun != 0)
301 delete pCurrentRun;
302 } else {
303 // FIll Run Header from the Database for MC data
304 if (fPeriodNumber > 0)
305 fRunHeader->SetPeriodRun(fPeriodNumber, 0); // set period number (run_number = 0 for MC data)
306
308
309 // get beam, target and energy of the simulated data from the FairBaseParSet container of the simulation file:
310 // the beam energy is kept in the beam momentum field, the beam and target names - in the container description
311 // as 'beam;target' (they are written by run_sim_bmn.C)
312 FairBaseParSet* pBasePar =
313 dynamic_cast<FairBaseParSet*>(FairRuntimeDb::instance()->getContainer("FairBaseParSet"));
314 if (pBasePar) {
315 fRunHeader->SetBeamEnergy(pBasePar->GetBeamMom());
316
317 TString beam = "", target = "";
318 TObjArray* particles = TString(pBasePar->getDescription()).Tokenize(";");
319 if (particles->GetEntriesFast() > 0)
320 beam = ((TObjString*)particles->At(0))->GetString();
321 if (particles->GetEntriesFast() > 1)
322 target = ((TObjString*)particles->At(1))->GetString();
323 delete particles;
324
325 fRunHeader->SetBeam(beam);
326 fRunHeader->SetTarget(target);
327
328 beam.ToLower();
329 map<TString, stParticleInfo>::iterator it = mapParticleInfo.find(beam);
330 if (it != mapParticleInfo.end()) {
331 fRunHeader->SetBeamA(it->second.A);
332 fRunHeader->SetBeamZ(it->second.Z);
333 } else
334 LOG(warn) << "BmnFillDstTask::Init(): unknown beam '" << beam
335 << "', A and Z are not written to the run header";
336
337 target.ToLower();
338 it = mapParticleInfo.find(target);
339 if (it != mapParticleInfo.end()) {
340 fRunHeader->SetTargetA(it->second.A);
341 fRunHeader->SetTargetZ(it->second.Z);
342 } else
343 LOG(warn) << "BmnFillDstTask::Init(): unknown target '" << target
344 << "', A and Z are not written to the run header";
345 }
346 }
347
348 // Get summary event info to print
349 fPrimaryVertex = (CbmVertex*)ioman->GetObject("PrimaryVertex.");
350 if (!fPrimaryVertex) {
351 LOG(debug) << "BmnFillDstTask::Init(): branch PrimaryVertex not found! The task is deactivated" << endl;
352 // SetActive(kFALSE);
353 // return kERROR;
354 }
355 fGlobalTracks = (TClonesArray*)ioman->GetObject("BmnGlobalTrack");
356 if (!fGlobalTracks) {
357 LOG(debug) << "BmnFfBC1illDstTask::Init(): branch BmnGlobalTrack not found! The task is deactivated" << endl;
358 // SetActive(kFALSE);
359 // return kERROR;
360 }
361
362 // Add MC information (header and tracks)
363 if (isExpData == 0) {
364 fMCTracks = (TClonesArray*)ioman->GetObject("MCTrack");
365 if (!fMCTracks)
366 LOG(debug) << "BmnFillDstTask::Init(): branch MCTrack not found" << endl;
367
368 // Create and register MCInfo object for MC output data
369 fMCInfoDst = new BmnMCInfoDst();
370 ioman->Register("BmnMCInfo.", "MC", fMCInfoDst, kTRUE);
371 }
372
373 return kSUCCESS;
374}
375
376// ---- ReInit -------------------------------------------------------
378{
379 LOG(debug) << "Re-initilization of BmnFillDstTask";
380 return kSUCCESS;
381}
382
383// ---- ReInit -------------------------------------------------------
385{
386 if (fMCInfoDst != nullptr)
387 if (fMCInfoDst->GetMCTracks() != nullptr)
388 fMCInfoDst->GetMCTracks()->Delete();
389}
390
391// ---- Exec ----------------------------------------------------------
393{
394
395 TStopwatch sw;
396 sw.Start();
397
398 LOG(debug) << "Exec of BmnFillDstTask";
399 Reset();
400
401 // fill output DST event header
402 if (isExpData == 0) { // MC data
403 fDstHeader->SetPeriodId(fPeriodNumber);
404 fDstHeader->SetRunId(fMCEventHeader->GetRunID());
405 fDstHeader->SetEventId(fMCEventHeader->GetEventID());
406 fDstHeader->SetEventTime(fMCEventHeader->GetT());
408 fDstHeader->SetB(fMCEventHeader->GetB());
409
410 // copy MC information to DST branch in case of simulated data
411 fMCInfoDst->SetB(fMCEventHeader->GetB());
412 fMCInfoDst->SetVertex(fMCEventHeader->GetX(), fMCEventHeader->GetY(), fMCEventHeader->GetZ());
413 fMCInfoDst->SetRotX(fMCEventHeader->GetRotX());
414 fMCInfoDst->SetRotY(fMCEventHeader->GetRotY());
415 fMCInfoDst->SetRotZ(fMCEventHeader->GetRotZ());
416 fMCInfoDst->GetMCTracks()->AbsorbObjects(fMCTracks);
417 } else { // experimental data
418 fDstHeader->SetPeriodId(fEventHeader->GetPeriodId());
419 fDstHeader->SetRunId(fEventHeader->GetRunId());
420 fDstHeader->SetEventId(fEventHeader->GetEventId());
421 fDstHeader->SetEventTime(fEventHeader->GetEventTime());
422 fDstHeader->SetEventTimeTS(fEventHeader->GetEventTimeTS());
423 }
424
425 // calculate Z2in and Z2out:
426 Double_t Z2in = -100.0, Z2out = -100.0;
427 Double_t adcIn = -100.0, adcOut = -100.0;
428 Short_t Zin = -100;
429 Short_t Zout = -100;
430 if (fT0 && fBC1 && fBC2 && fBC3 && fBC4) {
431 BmnTrigDigit* digT0 = NULL;
432 Int_t t0Count = 0;
433 for (Int_t i = 0; i < fT0->GetEntriesFast(); i++) {
434 digT0 = (BmnTrigDigit*)fT0->At(i);
435 if (digT0->GetMod() == 0)
436 t0Count++;
437 }
438 if (t0Count == 1) {
439 Double_t t0Time = digT0->GetTime();
440
441 grabZ2(fBC1, fBC2, t0Time, Z2in, adcIn, fBC1Calib, fBC2Calib, Zin, true);
442 grabZ2(fBC3, fBC4, t0Time, Z2out, adcOut, 0, 0, Zout, false);
443 if (Z2out != -1000) {
444 Z2out = sqrt(Z2out);
445 Z2out = Z2out * fZCalib1 + fZCalib2;
446 Z2out = Z2out * Z2out;
447 }
448 // cout<<Z2out;
449 }
450 fDstHeader->SetZ2in(Z2in);
451 fDstHeader->SetZ2out(Z2out);
452 fDstHeader->SetADCin(adcIn);
453 fDstHeader->SetADCout(adcOut);
454 fDstHeader->SetZin(Zin);
455 } else if (fT0 && fBC1 && fBC2) {
456 BmnTrigDigit* digT0 = NULL;
457 Int_t t0Count = 0;
458 for (Int_t i = 0; i < fT0->GetEntriesFast(); i++) {
459 digT0 = (BmnTrigDigit*)fT0->At(i);
460 if (digT0->GetMod() == 0)
461 t0Count++;
462 }
463 if (t0Count == 1) {
464 Double_t t0Time = digT0->GetTime();
465
466 grabZ2(fBC1, fBC2, t0Time, Z2in, adcIn, fBC1Calib, fBC2Calib, Zin, true);
467 }
468 fDstHeader->SetZ2in(Z2in);
469 // fDstHead->SetZ2out(Z2out);
470 fDstHeader->SetADCin(adcIn);
471 // fDstHead->SetADCout(adcOut);
472 fDstHeader->SetZin(Zin);
473 }
474
475 Double_t Z1 = -100.0, Z2 = -100.0, Z3 = -100.0, Z4 = -100.0, ADC1 = -100.0, ADC2 = -100.0, ADC3 = -100.0,
476 ADC4 = -100.0;
477 if (fT0) {
478 Int_t t0Count = 0;
479 BmnTrigDigit* digT0 = NULL;
480 Double_t t0Time = -100000;
481 for (Int_t i = 0; i < fT0->GetEntriesFast(); i++) {
482 digT0 = (BmnTrigDigit*)fT0->At(i);
483 if (digT0->GetMod() == 0) {
484 t0Count++;
485 t0Time = digT0->GetTime();
486 }
487 }
488 if (t0Count == 1) {
489 if (fBC1 && fBC2) {
490 grabZ2OR(fBC1, fBC2, t0Time, Z1, Z2, ADC1, ADC2, true);
491 }
492 if (fBC3 && fBC4) {
493 grabZ2OR(fBC3, fBC4, t0Time, Z3, Z4, ADC3, ADC4, false);
494 }
495 }
496
497 // no calibration from single adc to charge yet
498 // fDstHeader->SetZ1(Z1);
499 // fDstHeader->SetZ2(Z2);
500 // fDstHeader->SetZ3(Z3);
501 // fDstHeader->SetZ4(Z4);
502
503 fDstHeader->SetADC1(ADC1);
504 fDstHeader->SetADC2(ADC2);
505 fDstHeader->SetADC3(ADC3);
506 fDstHeader->SetADC4(ADC4);
507 }
508
509 // printing progress bar in terminal (hidden option now)
510 if (fVerbose == -9999) {
511 if (gROOT->IsBatch()) {
512 if (fIEvent % 1000 == 0)
513 printf("%lld/%lld\n", fIEvent, fNEvents);
514 } else {
515 UInt_t fRunId = (fDstHeader) ? fDstHeader->GetRunId() : 0;
516
517 if (isExpData == 0)
518 printf(ANSI_COLOR_RED "SIMULATION RUN" ANSI_COLOR_RESET);
519 else {
520 printf(ANSI_COLOR_BLUE "RUN-" ANSI_COLOR_RESET);
521 printf(ANSI_COLOR_RED "%d" ANSI_COLOR_RESET, fRunId);
522 }
523 printf(ANSI_COLOR_BLUE ": [");
524
525 Float_t progress = fIEvent * 1.0 / fNEvents;
526 Int_t barWidth = 70;
527
528 Int_t pos = barWidth * progress;
529 for (Int_t i = 0; i < barWidth; ++i) {
530 if (i < pos)
531 printf("=");
532 else if (i == pos)
533 printf(">");
534 else
535 printf(" ");
536 }
537
538 printf("] " ANSI_COLOR_RESET);
539 printf(ANSI_COLOR_RED "%d%%\r" ANSI_COLOR_RESET, Int_t(progress * 100.0 + 0.5));
540 cout.flush();
541 }
542 } else {
543 LOG(info) << "Event #" << fNStartEvent + fIEvent;
544 if (fPrimaryVertex) {
545 TString strVertex = TString::Format(" vertex = %.3f:%.3f:%.3f", fPrimaryVertex->GetX(),
546 fPrimaryVertex->GetY(), fPrimaryVertex->GetZ());
547 LOG(info) << strVertex.Data();
548 }
549 if (fGlobalTracks)
550 LOG(info) << "\tglobal tracks = " << fGlobalTracks->GetEntries();
551 }
552 fIEvent++;
553
554 if (fIEvent == fNEvents)
555 printf("\n");
556
557 sw.Stop();
558 workTime += sw.RealTime();
559}
560
561// ---- Finish --------------------------------------------------------
563{
564 LOG(debug) << "Finish of BmnFillDstTask";
565
566 FairRootManager* ioman = FairRootManager::Instance();
567 FairSink* fSink = ioman->GetSink();
568 fSink->WriteObject(fRunHeader, "DstRunHeader", TObject::kSingleKey);
569
570 printf("Work time of BmnFillDstTask: %4.2f sec.\n", workTime);
571}
572
573// ---- Load the parameter container from the runtime database ------
575{
576 LOG(debug) << "SetParContainers of BmnFillDstTask";
577 // Load all necessary parameter containers from the runtime data base
578 /*
579 FairRunAna* ana = FairRunAna::Instance();
580 FairRuntimeDb* rtdb=ana->GetRuntimeDb();
581
582 <BmnFillDstTaskDataMember> = (<ClassPointer>*)
583 (rtdb->getContainer("<ContainerName>"));
584 */
585}
586
588{
589 if (!fDoCalibration)
590 return;
591
592 // Read in the z-calibration file
593 TString gPathWorkdir = gSystem->Getenv("VMCWORKDIR");
594 TString gPathFullBC = gPathWorkdir + "/input/BC12Corrections.txt";
595 ifstream fin(gPathFullBC.Data());
596 int runBC = 0;
597 int safeindex = 0;
598 while (runBC != fRunNumber && safeindex != 20000) {
599 fin >> runBC;
600 fin >> fBC1Calib;
601 fin >> fBC2Calib;
602 safeindex = safeindex + 1;
603 }
604 if (fVerbose > 0)
605 if (safeindex == 20000)
606 cout << "run number not found in file " << gPathFullBC << endl;
607
608 TString gPathFull = gPathWorkdir + "/input/ZOutCorrections5.txt";
609
610 string line;
611 ifstream f(gPathFull.Data(), ios::in);
612 vector<Double_t> axisAttr;
613
614 while (!f.eof()) {
615 getline(f, line);
616
617 TString currString(line);
618 int run;
619 TString str_run(currString(0, 4));
620 run = str_run.Atoi();
621
622 if (run == fRunNumber) {
623 // cout<<"++++++++++++FILLDSTTASK!!!!"<<endl;
624 cout << currString.Data() << endl;
625 TString ab(currString(5, currString.Length()));
626 TString a(ab(0, ab.First(" ")));
627 // float a_float;
628 fZCalib1 = a.Atof();
629 TString c(ab(a.Length() + 1, ab.Length()));
630 // cout<<"c = "<<c.Data()<<endl;
631 TString b(c(0, c.First(" ")));
632 fZCalib2 = b.Atof();
633 // cout<<"ab = "<<ab.Data()<<", a = "<<fZCalib1<<", b = "<<fZCalib2<<endl;
634 }
635 }
636 // f.close();
637}
638
640{
641 stParticleInfo particle_info;
642 particle_info.A = 2;
643 particle_info.Z = 1;
644 mapParticleInfo.insert(pair<TString, stParticleInfo>("d", particle_info));
645 particle_info.A = 12;
646 particle_info.Z = 6;
647 mapParticleInfo.insert(pair<TString, stParticleInfo>("c", particle_info));
648 particle_info.A = 40;
649 particle_info.Z = 18;
650 mapParticleInfo.insert(pair<TString, stParticleInfo>("ar", particle_info));
651 particle_info.A = 84;
652 particle_info.Z = 36;
653 mapParticleInfo.insert(pair<TString, stParticleInfo>("kr", particle_info));
654 particle_info.A = 124; // 124Xe beam
655 particle_info.Z = 54;
656 mapParticleInfo.insert(pair<TString, stParticleInfo>("xe", particle_info));
657 particle_info.A = 73;
658 particle_info.Z = 32;
659 mapParticleInfo.insert(pair<TString, stParticleInfo>("ge", particle_info));
660 particle_info.A = 27;
661 particle_info.Z = 13;
662 mapParticleInfo.insert(pair<TString, stParticleInfo>("al", particle_info));
663 particle_info.A = 207;
664 particle_info.Z = 82;
665 mapParticleInfo.insert(pair<TString, stParticleInfo>("pb", particle_info));
666 // lead targets of the SRC program are written as 'SRC Lead N' in the Condition Database
667 mapParticleInfo.insert(pair<TString, stParticleInfo>("src lead 1", particle_info));
668 mapParticleInfo.insert(pair<TString, stParticleInfo>("src lead 2", particle_info));
669 mapParticleInfo.insert(pair<TString, stParticleInfo>("src lead 3", particle_info));
670 particle_info.A = 119;
671 particle_info.Z = 50;
672 mapParticleInfo.insert(pair<TString, stParticleInfo>("sn", particle_info));
673 particle_info.A = 64;
674 particle_info.Z = 29;
675 mapParticleInfo.insert(pair<TString, stParticleInfo>("cu", particle_info));
676 particle_info.A = 1;
677 particle_info.Z = 1;
678 mapParticleInfo.insert(pair<TString, stParticleInfo>("h2", particle_info));
679 // for the compound targets A is the sum of the atomic weights of the constituent elements, Z is set to zero
680 particle_info.A = 29;
681 particle_info.Z = 0;
682 mapParticleInfo.insert(pair<TString, stParticleInfo>("c2h4", particle_info));
683 particle_info.A = 260; // Cs (132.9) + I (126.9)
684 particle_info.Z = 0;
685 mapParticleInfo.insert(pair<TString, stParticleInfo>("csi", particle_info));
686 // the empty target is written with the zero mass number
687 particle_info.A = 0;
688 particle_info.Z = 0;
689 mapParticleInfo.insert(pair<TString, stParticleInfo>("empty", particle_info));
690
691 return;
692}
static Double_t workTime
void grabZ2(TClonesArray *TQDC_BC1, TClonesArray *bc2Data, double t0Time, double &z2, double &x, double BC1calib, double BC2calib, short &Z, bool isIncoming)
Definition ExtractZ2.h:42
void grabZ2OR(TClonesArray *TQDC_BC1, TClonesArray *bc2Data, double t0Time, double &z2A, double &z2B, double &x, double &y, bool isIncoming)
Definition ExtractZ2.h:102
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
int Ssiz_t
float Float_t
short Short_t
constexpr Bool_t kFALSE
double Double_t
constexpr Ssiz_t kNPOS
long long Long64_t
constexpr Bool_t kTRUE
const char Option_t
R__EXTERN TGeoManager * gGeoManager
#define gROOT
R__EXTERN TSystem * gSystem
#define ANSI_COLOR_RED
Definition BmnMath.h:16
#define ANSI_COLOR_RESET
Definition BmnMath.h:18
#define ANSI_COLOR_BLUE
Definition BmnMath.h:17
Double_t GetZmin() const
Double_t GetYmin() const
virtual Double_t GetBz(Double_t x, Double_t y, Double_t z)
Double_t GetZmax() const
Double_t GetYmax() const
Double_t GetXmin() const
Accessors to field region.
virtual Double_t GetBy(Double_t x, Double_t y, Double_t z)
Double_t GetXmax() const
virtual Double_t GetBx(Double_t x, Double_t y, Double_t z)
Get components of field at a given point.
Double_t GetScale() const
Accessor to global scaling factor.
Definition BmnFieldMap.h:90
virtual void SetParContainers()
Load the parameter container from the runtime database.
virtual void Finish()
Finish task called at the end.
TClonesArray * fBC4
TClonesArray * fBC2
DstRunHeader * fRunHeader
Output BmnRunHeader.
void InitParticleInfo()
Fill map with weight-charge of possible particles.
Int_t fRunNumber
run number
Long64_t fNStartEvent
start event from which the processing is started
void Reset()
Reset variables between events.
TClonesArray * fMCTracks
Input Monte-Carlo tracks from Simulation File.
Long64_t fNEvents
event count to be processed
BmnEventHeader * fEventHeader
Input BmnEventHeader from Experimental Digit File.
TClonesArray * fT0
virtual InitStatus Init()
Initialization of task at the beginning.
FairMCEventHeader * fMCEventHeader
Input MCEventHeader from Simulation File.
TClonesArray * fBC1
DstEventHeader * fDstHeader
Output DstEventHeader prepared in FairRunAna.
CbmVertex * fPrimaryVertex
pointer to primary vertex in the current event
bool autoSetHeaders()
set headers with autodefinition whether experimental or simulation data are used
virtual void Exec(Option_t *opt)
Executed for each event.
Long64_t fIEvent
current event being processed for progress bar
Int_t fPeriodNumber
period number
TClonesArray * fGlobalTracks
pointer to global tracks in the current event
Double_t fZCalib1
z calibration parameters:
TClonesArray * fBC3
BmnFillDstTask()
Default constructor.
BmnMCInfoDst * fMCInfoDst
Output MC Information for physics analysis.
map< TString, stParticleInfo > mapParticleInfo
map with particle names and corresponding weight-charge pairs
virtual InitStatus ReInit()
ReInitialization of task when the runID/file changes.
~BmnFillDstTask()
Destructor.
BmnTask()
Default constructor.
Definition BmnTask.cxx:3
Double_t GetTime() const
Short_t GetMod() const
CbmVertex.h.
Definition CbmVertex.h:21
Int_t GetMonth() const
Int_t GetDay() const
Int_t GetHour() const
Int_t GetSecond() const
Int_t GetYear() const
Int_t GetMinute() const
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
virtual Bool_t InheritsFrom(const char *classname) const
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
void Stop()
Ssiz_t Length() const
void ToLower()
Int_t Atoi() const
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Ssiz_t First(char c) const
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
static TString Format(const char *fmt,...)
TString & Remove(EStripType s, char c)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
UniRun.h Class for the table: run_.
Definition UniRun.h:21
double * GetEnergy()
get energy of the current run
Definition UniRun.h:113
static UniRun * GetRun(int period_number, int run_number)
get run from the database
Definition UniRun.cxx:161
TDatime * GetEndDatetime()
get end datetime of the current run
Definition UniRun.h:101
TString GetBeamParticle()
get beam particle of the current run
Definition UniRun.h:109
TDatime GetStartDatetime()
get start datetime of the current run
Definition UniRun.h:99
TString GetTargetParticle()
get target particle of the current run
Definition UniRun.h:111
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
struct timespec convert_double_to_timespec(double sec)
Definition json.hpp:4446