30 fMapFileName = TString(getenv(
"VMCWORKDIR")) + TString(
"/input/") + mappingFile;
31 LOG(info) <<
"Reading MSC16 channel mapping file " << fMapFileName <<
"...";
32 fMapFile.open((fMapFileName).Data());
33 if (!fMapFile.is_open()) {
34 fprintf(stderr,
"Error opening map-file (%s)!\n", fMapFileName.Data());
40 UShort_t slot, bt, btnbusy, l0, tp, bc1, bc2, bc3, BC1H, BC1BP, BC1xBC2, BC1nBusy, IntTrig, SRCTrig, TrignBusy;
42 fMapFile >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy
43 >> dummy >> dummy >> dummy >> dummy;
45 while (!fMapFile.eof()) {
46 fMapFile >> hex >> ser >> dec >> slot >> bt >> btnbusy >> l0 >> tp >> bc1 >> bc2 >> bc3 >> BC1H >> BC1BP
47 >> BC1xBC2 >> BC1nBusy >> IntTrig >> SRCTrig >> TrignBusy;
67 fMap.push_back(record);
70 if (fMap.size() == 0) {
71 fprintf(stderr,
"Map file is empty!\n");
81 Int_t log_shift_bmn = 6;
82 Int_t log_shift_src = -3;
83 fLogShift = fBmnSetup ==
kBMNSETUP ? log_shift_bmn : log_shift_src;
85 map<TDatime, vector<Int_t>> temp_spill_map;
87 vector<structParseValue*> parse_values;
88 vector<structParseSchema> vecElements;
89 int res_code = parser.ParseTxt2Struct(LogName, SchemeName, parse_values, vecElements, fVerbose);
91 cout << endl <<
"Error: parser error (" << res_code <<
")" << endl;
95 if (parse_values.size() < 1) {
96 cout << endl <<
"Error: there are no lines to parse" << endl;
102 TObjArray arrayConditions;
103 arrayConditions.SetOwner(kTRUE);
107 arrayConditions.Add((TObject*)searchCondition);
112 arrayConditions.Add((TObject*)searchCondition);
117 arrayConditions.Add((TObject*)searchCondition);
120 int sum_size = parse_values[0]->arrValues.size();
122 for (
size_t ind = 0; ind < parse_values.size(); ind++) {
125 for (Int_t iValue = 0; iValue < sum_size; iValue++)
126 vals.push_back(boost::any_cast<Int_t>(st->
arrValues[iValue]));
128 temp_spill_map.insert(pair<TDatime, vector<Int_t>>(st->
dtSpillEnd, vals));
131 vector<Long64_t> total_columns;
132 for (
int i_total = 0; i_total < sum_size; i_total++)
133 total_columns.push_back(0);
137 cout << endl <<
"Error: no experimental run was found " << fPeriodId <<
" : " << fRunId << endl;
142 if (dateEnd == NULL) {
143 cout <<
"Error: no end datetime in the database for this run" << endl;
153 fprintf(stderr,
"ELOG Error!\n");
155 }
else if (recs->GetEntries() == 0) {
156 fprintf(stderr,
"Run %d not found in ELOG!\n", fRunId);
159 printf(
"Run %d %s", fRunId, dtStart.AsSQLString());
160 printf(
" - %s\n", dtEnd.AsSQLString());
161 spill_map.insert(temp_spill_map.lower_bound(dtStart), temp_spill_map.upper_bound(dtEnd));
204 if (fRawSpillTree->GetEntriesFast() <= iSpill)
210 for (Int_t iAdc = 0; iAdc < msc->GetEntriesFast(); ++iAdc) {
215 fprintf(stderr,
"Spill %u last event %u lost! Curent evId %u \n", iSpill, dig->
GetLastEventId(), iEv);
216 fRawSpillTree->GetEntry(++iSpill);
223 printf(
"Spill %u last event %u Curent evId %u \n", iSpill, dig->
GetLastEventId(), iEv);
226 for (
auto& mRec : fMap) {
227 if (mRec.serial == serial) {
229 fBTnBusy += arr[mRec.BTnBusy];
230 fProtection += arr[mRec.TriggerProtection];
233 if ((fBmnSetup ==
kSRCSETUP) && (fPeriodId == 7) && (isValidSpillLog)) {
234 if (iSpillMap < spill_map.size()) {
235 map<TDatime, vector<Int_t>>::iterator SpillMapIter = spill_map.begin();
236 advance(SpillMapIter, iSpillMap);
238 printf(
" spill %s\n", SpillMapIter->first.AsSQLString());
239 vector<Int_t>
v = SpillMapIter->second;
242 Double_t DAQ_Busy =
v[21];
243 Double_t DAQ_Trigger =
v[22];
244 if (DAQ_Trigger - nPedEvBySpill != 0)
245 fBTAccepted += BT * (DAQ_Busy - nPedEvBySpill) / (DAQ_Trigger - nPedEvBySpill);
247 printf(
"BT %f DAQ_Busy %f DAQ_Trigger %f flux %f\n", BT, DAQ_Busy, DAQ_Trigger,
253 fBTAccepted += arr[mRec.BTnBusy] * AcceptedReal / (Double_t)den;
255 fAccepted += AcceptedReal;
258 sh->
SetBC1(arr[mRec.BC1]);
259 sh->
SetBC2(arr[mRec.BC2]);
260 sh->
SetBC3(arr[mRec.BC3]);
261 sh->
SetBT(arr[mRec.BT]);
263 sh->
SetL0(arr[mRec.L0]);
264 sh->
SetProt(arr[mRec.TriggerProtection]);
285 fDigSpillTree->Fill();
289 printf(
"iSpill %4u last EvId %7u pedestals %d\n", iSpill, dig->
GetLastEventId(), nPedEvBySpill);
292 "BC1 %7u, BC2 %7u, BC3 %4u, BeamTrigger %7u, L0 %7u, "
293 "TrigProtection %7u, BT&Busy %7u\n"
294 "\tBC1H %7u, BC1BP %7u, BC1xBC2 %4u, BC1nBusy %7u, IntTrig %7u, "
295 "SRCTrig %7u, TrignBusy %7u\n",
296 arr[mRec.BC1], arr[mRec.BC2], arr[mRec.BC3], arr[mRec.BT], arr[mRec.L0],
297 arr[mRec.TriggerProtection], arr[mRec.BTnBusy], arr[mRec.BC1H], arr[mRec.BC1BP],
298 arr[mRec.BC1xBC2], arr[mRec.BC1nBusy], arr[mRec.IntTrig], arr[mRec.SRCTrig],
299 arr[mRec.TrignBusy]);
302 "\tcand %7u, acc %7u, before %4u, after %6u, rjct %6u, all %7u, avail %7u\n\n",
308 Int_t r = fRawSpillTree->GetEntry(iSpill);
static TObjArray * GetRecords(int period_number, int run_number, bool findPreviousRun=false)
get array of ElogRecord-s for a given or a previous run from the database