-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreader.cxx
138 lines (113 loc) · 5.13 KB
/
reader.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "TStopwatch.h"
#include "ext_h101_unpack.h"
#include "ext_h101_tpat.h"
#include "ext_h101_los_dez19.h"
#include "ext_h101_raw_nnp_tamex.h"
#include "R3BUcesbSource.h"
#include "R3BUnpackReader.h"
#include "R3BTrloiiTpatReader.h"
#include "R3BLosReader.h"
#include "R3BNeulandTamexReader.h"
#include "FairRunOnline.h"
#include "FairRun.h"
#include "FairParRootFileIo.h"
#include "R3BLosMapped2Cal.h"
#include "R3BNeulandMapped2Cal.h"
#include "R3BLosProvideTStart.h"
#include "R3BNeulandCal2Hit.h"
#include "FairLogger.h"
#include "FairRuntimeDb.h"
#include <iostream>
struct EXT_STR_h101_t
{
EXT_STR_h101_unpack_t unpack;
EXT_STR_h101_TPAT tpat;
EXT_STR_h101_LOS_t los;
EXT_STR_h101_raw_nnp_tamex_onion_t raw_nnp;
};
int main()
{
TStopwatch timer;
timer.Start();
const Int_t nBarsPerPlane = 50; // number of scintillator bars per plane
const Int_t nPlanes = 26; // number of planes (for TCAL calibration)
const double distanceToTarget = 1520.;
const Int_t nev = -1; /* number of events to read, -1 - until CTRL+C */
const Int_t trigger = -1; // 1 - onspill, 2 - offspill. -1 - all
const TString filename = "/d/land4/202205_s522/lmd/main0122_0021.lmd";
const TString ucesbPath = "/u/land/fake_cvmfs/9.13/upexps/202205_s522/202205_s522";
// const TString usesbCall = ucesbPath + " --allow-errors --input-buffer=135Mi";
const TString usesbCall = ucesbPath + " --allow-errors --input-buffer=135Mi --max-events=100";
const TString outputFileName = "output.root";
// Event IO Setup
// -------------------------------------------
EXT_STR_h101 ucesbStruct;
// auto source = new R3BUcesbSource(filename, "RAW,time-stitch=1000", usesbCall, &ucesbStruct, sizeof(ucesbStruct));
auto source = new R3BUcesbSource(filename, "UNPACK:EVENTNO,UNPACK:TRIGGER,RAW", usesbCall, &ucesbStruct, sizeof(ucesbStruct));
//auto source = new R3BUcesbSource(filename, "RAW", usesbCall, &ucesbStruct, sizeof(ucesbStruct));
source->SetMaxEvents(nev);
source->AddReader(new R3BUnpackReader(&ucesbStruct.unpack, offsetof(EXT_STR_h101, unpack)));
source->AddReader(new R3BTrloiiTpatReader((EXT_STR_h101_TPAT_t*)&ucesbStruct.tpat, offsetof(EXT_STR_h101, tpat)));
source->AddReader(new R3BLosReader(&ucesbStruct.los, offsetof(EXT_STR_h101, los)));
source->AddReader(new R3BNeulandTamexReader(&ucesbStruct.raw_nnp, offsetof(EXT_STR_h101, raw_nnp)));
auto run = new FairRunOnline(source);
run->SetRunId(999);
// run->ActivateHttpServer(1, 8885);
run->SetOutputFile(outputFileName.Data());
// run->SetSink(new FairRootFileSink(outputFileName));
// Parameter IO Setup
// -------------------------------------------
auto rtdb = run->GetRuntimeDb();
auto parList = new TList();
//parList->Add(new TObjString("LosTcalPar_0010.root")); // no time ref
parList->Add(new TObjString("../parameters/loscalpar_v1.root"));
parList->Add(new TObjString("../parameters/params_tcal_180522xx.root"));
//parList->Add(new TObjString("params_sync_s522_0999_190522.root"));
parList->Add(new TObjString("../parameters/params_sync_s522_0999_310522x.root"));
//parList->Add(new TObjString("params_ig_fine.root"));
//parList->Add(new TObjString("params_sync_0047_49_0999.root"));
auto parIO = new FairParRootFileIo(false);
parIO->open(parList);
rtdb->setFirstInput(parIO);
rtdb->addRun(999);
rtdb->getContainer("LosTCalPar");
rtdb->setInputVersion(999, (char*)"LosTCalPar", 1, 1);
rtdb->getContainer("LandTCalPar");
rtdb->setInputVersion(999, (char*)"LandTCalPar", 1, 1);
rtdb->getContainer("NeulandHitPar");
rtdb->setInputVersion(999, (char*)"NeulandHitPar", 1, 1);
auto losMapped2Cal=new R3BLosMapped2Cal("LosTCalPar", 1);
losMapped2Cal->SetNofModules(1,8);
losMapped2Cal->SetTrigger(1);
run->AddTask( losMapped2Cal );
auto tcal = new R3BNeulandMapped2Cal();
tcal->SetTrigger(trigger);
tcal->SetNofModules(nPlanes, nBarsPerPlane);
tcal->SetNhitmin(1);
tcal->EnableWalk(true);
//tcal->SubtractTriggerTime(false);
run->AddTask(tcal);
run->AddTask(new R3BLosProvideTStart());
auto nlhit = new R3BNeulandCal2Hit();
nlhit->SetDistanceToTarget(distanceToTarget);
nlhit->SetGlobalTimeOffset(-400);//5850
nlhit->SetEnergyCutoff(0.0);
run->AddTask(nlhit);
// auto r3bNeulandOnlineSpectra = new R3BNeulandOnlineSpectra();
// r3bNeulandOnlineSpectra->SetDistanceToTarget(distanceToTarget);
// r3bNeulandOnlineSpectra->SetCosmicTpat(0x2000);
// run->AddTask(r3bNeulandOnlineSpectra);
// Go!
// -------------------------------------------
run->Init();
FairLogger::GetLogger()->SetLogScreenLevel("ERROR");
run->Run((nev < 0) ? nev : 0, (nev < 0) ? 0 : nev);
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
std::cout << std::endl << std::endl;
std::cout << "Macro finished succesfully." << std::endl;
std::cout << "Output file is " << outputFileName << std::endl;
std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl << std::endl;
return 0;
}