ATLAS Offline Software
ALFA_Raw2Digit.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "GaudiKernel/MsgStream.h"
9 
10 #include <stdexcept>
11 
12 ALFA_Raw2Digit::ALFA_Raw2Digit(const std::string& name, ISvcLocator* pSvcLocator)
13  : AthAlgorithm(name, pSvcLocator),
14  m_key_DigitCollection("ALFA_DigitCollection"),
15  m_key_ODDigitCollection("ALFA_ODDigitCollection")
16 {
17  declareProperty("ALFA_RawDataCollectionKey", m_ALFA_RawDataCollectionKey = "ALFA_RawData");
18 
19  //allowed values (m_strMeasuredDataType="testbeam", "tunnel"), default value is "tunnel"
20  //this property is needed due to different mapping in the testbeam and the tunnel data
21  declareProperty("MeasuredDataType", m_strMeasuredDataType = "tunnel");
22 
23 
24  m_All_Trigger_norm = nullptr;
25  m_All_Trigger = nullptr;
26  m_ODdigitCollection = nullptr;
27  m_ODdigitObject = nullptr;
28  m_digitCollection = nullptr;
29  m_digitObject = nullptr;
30 // m_histSvc = NULL;
31  m_rootOutput = nullptr;
32  m_tree = nullptr;
33 
34  m_nEvents = 0;
35  m_mbID = 0;
36  m_pmfID = 0;
37  m_fibID = 0;
38  m_MAPMTChan = 0;
39  m_MapChan = 0;
40  m_pot = 0;
41  m_side = 0;
42  m_plate = 0;
43  m_fiber = 0;
44  m_ODpot = 0;
45  m_ODside = 0;
46  m_ODplate = 0;
47  m_ODfiber = 0;
48 
49  memset(&m_act_lay_h, 0, sizeof(m_act_lay_h));
50  memset(&m_hit_lay_h, 0, sizeof(m_hit_lay_h));
51  m_lumi_block = 0;
52  m_lumi_block_old = 0;
53  m_event_no = 0;
54  m_WordId_count = 0;
55  m_chan_i = 0;
56  m_chan_j = 0;
57 }
58 
60 {
61  ATH_MSG_DEBUG ("ALFA_Raw2Digit:initialize()");
62 
63  if (m_strMeasuredDataType=="tunnel")
64  {
65  m_mb2det[0] = 1; m_mb2det[1] = 0; m_mb2det[2] = 7; m_mb2det[3] = 2;
66  m_mb2det[4] = 4; m_mb2det[5] = 5; m_mb2det[6] = 6; m_mb2det[7] = 3;
67  }
68  else if (m_strMeasuredDataType=="testbeam")
69  {
70  m_mb2det[0] = 0; m_mb2det[1] = 1; m_mb2det[2] = 2; m_mb2det[3] = 3;
71  m_mb2det[4] = 4; m_mb2det[5] = 5; m_mb2det[6] = 6; m_mb2det[7] = 7;
72  }
73 
74  m_nEvents = 0;
75  m_MAPMTChan = -1;
76 
77  for (int m=0;m<8;m++)
78  {
79  m_hit_counter[m] = 0;
80  for (int k=0;k<23;k++)
81  {
82  for (int i=0;i<64;i++)
83  {
84  m_pmf_chan_hit_counter[m][k][i] = 0;
85  }
86  }
87  }
88 
89  StatusCode sc = mapping();
90 
91  if (sc.isFailure()) { msg (MSG::FATAL) << " Could not open mapping " << endmsg; return sc; }
92  else msg (MSG::DEBUG) << " mapping is fine " << endmsg;
93 
94 // sc = service("THistSvc", m_histSvc);
95 
96  // retrieve ThistSvc ...
97 // if(sc.isFailure())
98 // {
99 // msg(MSG::FATAL) << "Unable to retrieve pointer to THistSvc" << endmsg;
100 // return sc;
101 // }
102 
103 /*
104  m_rootOutputFileName = "ALFA_toy_tree_tom.root";
105  m_rootOutput = new TFile(m_rootOutputFileName,"RECREATE");
106  m_tree = new TTree("MyTree", "ALFA_toy_tree");
107 
108  TBranch *branch;
109  branch = m_tree->Branch("m_event_no", &m_event_no,"m_event_no/I"); branch->SetAutoDelete(kFALSE);
110  branch = m_tree->Branch("m_lumi_block", &m_lumi_block, "m_lumi_block/I"); branch->SetAutoDelete(kFALSE);
111  branch = m_tree->Branch("pot_b", m_pot_b, "pot_b[8]/O"); branch->SetAutoDelete(kFALSE);
112  branch = m_tree->Branch("layer_b", m_layer_b, "layer_b[8][20]/O"); branch->SetAutoDelete(kFALSE);
113  branch = m_tree->Branch("fiber_b", m_fiber_b, "fiber_b[8][20][64]/O"); branch->SetAutoDelete(kFALSE);
114  branch = m_tree->Branch("trigger_pattern_b", m_trigger_pattern_b, "trigger_pattern[8][16]/O"); branch->SetAutoDelete(kFALSE);
115  branch = m_tree->Branch("charge_1", &m_charge_1, "charge_1[8]/s"); branch->SetAutoDelete(kFALSE);
116  branch = m_tree->Branch("charge_2", &m_charge_2, "charge_2[8]/s"); branch->SetAutoDelete(kFALSE);
117 */
118 
119 // for (unsigned int j=0; j<8; j++)
120 // {
121 // m_h_name1 = "MAPMT_activity_p_";
122 // m_h_name2 = "PMFvsMAPMT_p_";
123 // m_h_name3 = "PMFvsMAROC_p_";
124 
125 // m_h_loc1 = "/AANT/MAPMT_activity_p_";
126 // m_h_loc2 = "/AANT/PMFvsMAPMT_p_";
127 // m_h_loc3 = "/AANT/PMFvsMAROC_p_";
128 
129 // m_s.str("");
130 // m_s << j+1;
131 
132 // m_h_name1 += m_s.str();
133 // m_h_name2 += m_s.str();
134 // m_h_name3 += m_s.str();
135 
136 // m_h_loc1 += m_s.str();
137 // m_h_loc2 += m_s.str();
138 // m_h_loc3 += m_s.str();
139 
140 /*
141  m_rootOutputFileName = "ALFA_toy_tree_tom.root";
142  m_rootOutput = new TFile(m_rootOutputFileName,"RECREATE");
143  m_tree = new TTree("MyTree", "ALFA_toy_tree");
144 
145  MAPMT_activity[j] = new TGraph(1472);
146 // MAPMT_activity[j]->SetTitle("Trigger efficiency for Upper pot;MAROC Channel; Trigger efficiency");
147  MAPMT_activity[j]->SetTitle(m_h_name1.c_str());
148  MAPMT_activity[j]->SetMarkerStyle(6);
149  MAPMT_activity[j]->Draw("AP");
150  MAPMT_activity[j]->SetName(m_h_name1.c_str());
151 
152 // sc = m_histSvc->regHist(m_h_loc1.c_str(),MAPMT_activity[j]);
153 
154  PMFvsMAPMT[j] = new TH2I(m_h_name2.c_str(),m_h_name2.c_str(),64,-0.5,63.5,23,-0.5,22.5);
155  sc = m_histSvc->regHist(m_h_loc2.c_str(),PMFvsMAPMT[j]);
156 
157  PMFvsMAROC[j] = new TH2I(m_h_name3.c_str(),m_h_name3.c_str(),64,-0.5,63.5,23,-0.5,22.5);
158  sc = m_histSvc->regHist(m_h_loc3.c_str(),PMFvsMAROC[j]);
159 
160  for (unsigned int i=0; i<23; i++)
161  {
162  MapmtHit[j][i] = new TH2I(m_h_name1.c_str(),m_h_name1.c_str(),8,0.5,8.5,8,0.5,8.5);
163  MAPMT_activity_h[j][i] = new TH2D("","",8,0.5,8.5,8,0.5,8.5);
164  sc = m_histSvc->regHist(m_h_loc1.c_str(),MAPMT_activity_h[j][i]);
165  }
166 */
167 // }
168 
169  return StatusCode::SUCCESS;
170 }
171 
173 {
174  ATH_MSG_DEBUG ("ALFA_Raw2Digit: BEGINING of execute");
175 
176  m_nEvents++;
177  msg(MSG::DEBUG) << "event # "<< m_nEvents << endmsg;
178 // m_toFile << "Event " << m_nEvents << std::endl;
179 
180  // retrieve the RawData RDO container from the TDS
181  const ALFA_RawDataContainer* container = nullptr;
182  StatusCode sc_read = evtStore()->retrieve(container, m_ALFA_RawDataCollectionKey);
183 
184  if ( sc_read != StatusCode::SUCCESS ) {
185  msg(MSG::ERROR) << "ALFA_Raw2Digit: Could not find container" << endmsg;
186  return StatusCode::SUCCESS;
187  }
188 
189  else if ( sc_read == StatusCode::SUCCESS ) {
190  msg(MSG::DEBUG) << "ALFA_Raw2Digit: Raw data container retrieved" << endmsg;
191  }
192 
193  msg(MSG::DEBUG) << "MD record_collection()" << endmsg;
194 
196  if (sc.isFailure()) {
197  msg(MSG::WARNING) << "ALFA_Raw2Digit: recordCollection failed" << endmsg;
198  return StatusCode::SUCCESS;
199  }
200 
201  msg(MSG::DEBUG) << "OD record_collection()" << endmsg;
202 
204  if (sc.isFailure()) {
205  msg(MSG::WARNING) << "ALFA_Raw2Digit, recordODCollection failed" << endmsg;
206  return StatusCode::SUCCESS;
207  }
208 
209 
210  for (unsigned int i=0;i<8;i++) {
211  m_pot_b[i] = false;
212  for (unsigned int j=0;j<20;j++) {
213  m_layer_b[i][j] = false;
214  for (unsigned int k=0;k<64;k++) {
215  m_fiber_b[i][j][k] = false;
216  }
217  }
218  for (unsigned int k=0;k<16;k++) {
219  m_trigger_pattern_b[i][k] = false;
220  }
221  }
222 
223 
225 
226 
227  m_lumi_block = container->GetLumiBlock();
228 // std::cout << "m_lumi_block = " << m_lumi_block << std::endl;
229 
230  // loop over container start
231  ALFA_RawDataContainer::const_iterator RawData_Collection_Beg = container->begin();
232  ALFA_RawDataContainer::const_iterator RawData_Collection_End = container->end();
233 
234  //loop over collection (container) with hits (i.e. over 1 event)
235  for(;RawData_Collection_Beg!=RawData_Collection_End; ++RawData_Collection_Beg)
236  {
237  m_mbID = ((*RawData_Collection_Beg)->GetMBId_POT());
238  msg(MSG::DEBUG) << "ALFA_Raw2Digit: MBId POT= " << m_mbID << endmsg;
239 
240 // std::cout << "******* Time stamp = " << (*RawData_Collection_Beg)->GetTimeStamp_POT() << std::endl;
241 // time_t rawtime = (*RawData_Collection_Beg)->GetTimeStamp_POT();
242 // struct tm * timeinfo;
245 // timeinfo = gmtime ( &rawtime );
246 // printf ( "The date/time is: %m_s", asctime (timeinfo) );
247 
248  m_pot_b[m_mbID-1] = true;
249  // m_event_no = ((*RawData_Collection_Beg)->GetEventCount_POT());
250 
251  m_charge_1[m_mbID-1] = ((*RawData_Collection_Beg)->Get_ADC1_POT());
252  m_charge_2[m_mbID-1] = ((*RawData_Collection_Beg)->Get_ADC2_POT());
253  for (unsigned int i=0;i<16;i++) {
254  m_trigger_pattern_b[m_mbID-1][i] = ((*RawData_Collection_Beg)->Get_pattern_POT())[i];
255 // msg(MSG::ERROR) << " pattern: bit " << i << ", value = "<< m_trigger_pattern_b[m_mbID-1][i] << " in MB = " << m_mbID-1 << endmsg;
256  }
257 
258 // loop over collection start
259  ALFA_RawDataCollection::const_iterator p_RawData_Beg=(*RawData_Collection_Beg)->begin();//pointer to RawData data vector
260  ALFA_RawDataCollection::const_iterator p_RawData_End=(*RawData_Collection_Beg)->end();
261 
262  for(;p_RawData_Beg!=p_RawData_End; ++p_RawData_Beg)
263  {
264 // msg(MSG::DEBUG) << " all, pmfId = " << (*p_RawData_Beg)->GetPMFId_PMF() << ", MBId = " << (*p_RawData_Beg)->GetMBId_PMF() << endmsg;
265 
266  if ((*p_RawData_Beg)->GetPMFId_PMF()>0 && ((*p_RawData_Beg)->GetWordId_PMF())<24)
267  {
268  m_pmfID= (*p_RawData_Beg)->GetPMFId_PMF();
269 
270  if (((*p_RawData_Beg)->GetWordId_PMF())==0) m_WordId_count=1;
271  else m_WordId_count=0;
272 
273  if (m_WordId_count==1){
274  msg(MSG::DEBUG) << " pmfId = " << (*p_RawData_Beg)->GetPMFId_PMF() << ", MBId = " << (*p_RawData_Beg)->GetMBId_PMF() <<endmsg;
275  }
276 
277 // msg(MSG::DEBUG) << " m_WordId_count " << m_WordId_count << endmsg;
278 
279  for (unsigned int i=0;i<16;i++)
280  {
281  if ((*p_RawData_Beg)->Get_Chan(i)!=100)
282  {
283  msg(MSG::DEBUG) <<"ALFA_Raw2Digit, maroc chanel # = " << (*p_RawData_Beg)->Get_Chan(i)<< endmsg;
284 
285  m_fibID = (*p_RawData_Beg)->Get_Chan(i);
286 
287  // in Sara Diglio Byte Stream Converter PMF are counted from 1, then OD detectors have values of PMF in the range 2-4; fibers start at 0
288  if ((m_pmfID == 1) || (m_pmfID > 4))
289  {
290  m_pot = m_mb2det[m_mbID-1];
291 // m_pot = m_mbID-1;
293  // changed by Petr - 19.12.2012 -----------------------------
294 // m_fiber = 63-m_maroc2fiber[m_pot][m_fibID];
296 
297  m_layer_b[m_mbID-1][m_plate] = true;
298  m_fiber_b[m_mbID-1][m_plate][m_fiber] = true;
299 // msg(MSG::ERROR) << " bim ho, lumi = " << m_lumi_block << ", pot = "<< m_mbID-1 << ", plate " << m_plate << endmsg;
301 // msg(MSG::ERROR) << " number of hits " << m_n_hits_lay[m_mbID-1][m_plate] << endmsg;
302 
303 // m_digitCollection->push_back(new ALFA_Digit(m_pot,m_plate,m_fiber));
305 
306  // changed by Petr - 19.12.2012 -----------------------------
307 // m_MapChan = m_maroc2mapmt[m_pot][m_fibID];
309  msg(MSG::DEBUG) << "pot = " << m_pot << ", pmf = " << m_pmfID-1 << ", maroc = " << m_fibID << ", mapmt = " << m_MapChan << endmsg;
310 
311 // PMFvsMAPMT[m_pot]->Fill(m_MapChan,m_pmfID-1);
312 // PMFvsMAROC[m_pot]->Fill(m_fibID,m_pmfID-1);
313  // changed by Petr - 19.12.2012 -----------------------------
314 // ChanPlot(m_pot,m_fibID,m_chan_i,m_chan_j);
315 // ChanPlot(m_pot,m_plate,m_fibID,m_chan_i,m_chan_j);
316 // MapmtHit[m_pot][m_pmfID-1]->Fill(m_chan_i,m_chan_j);
317  msg(MSG::DEBUG) << "fibID = " << m_fibID << ", chan_i " << m_chan_i << ", chan_j = " << m_chan_j << endmsg;
318 
320  m_hit_counter[m_pot]++;
321 
322  msg(MSG::DEBUG) << "ALFA_Raw2Digit: new digit (softsim numbering-starting from 0) in the collection, pot = " << m_pot << ", plate = " << m_plate << ", fiber = " << m_fiber << endmsg;
323  }
324  else
325  {
326  m_ODpot = m_mb2det[m_mbID-1];
327 // m_ODpot = m_mbID-1;
331 
332  // changed by Petr - 19.12.2012 ----------------------------- commented, is it needed by ODs? TODO: to correct m_MapChan for OD case
333 // m_MapChan = m_maroc2mapmt[m_ODpot][m_fibID];
334 // msg(MSG::DEBUG) << " pot = " << m_ODpot << ", pmf = " << m_pmfID-1 << ", maroc = " << m_fibID << ", mapmt = " << m_MapChan << endmsg;
335 
336  if (m_ODfiber!=98)
337  {
338 // m_ODfiber = (m_ODside==0)? m_ODfiber : 29-m_ODfiber;
339 
340 // m_ODdigitCollection->push_back(new ALFA_ODDigit(m_ODpot,m_ODside,m_ODplate,m_ODfiber));
342 
343 // msg(MSG::DEBUG) << "pot, side, plate, fiber = " << m_ODpot << ", " << m_ODside << ", " << m_ODplate << ", " << m_ODfiber << endmsg;
344 
345  }
346 
347 
348 // PMFvsMAPMT[m_ODpot]->Fill(m_MapChan,m_pmfID-1);
349 // PMFvsMAROC[m_ODpot]->Fill(m_fibID,m_pmfID-1);
350 
351  // changed by Petr - 19.12.2012 ----------------------------- commented, is it needed by ODs? TODO: to correct ChanPlot for OD case
352 // ChanPlot(m_ODpot,m_fibID,m_chan_i,m_chan_j);
353 // MapmtHit[m_ODpot][m_pmfID-1]->Fill(m_chan_i,m_chan_j);
354  msg(MSG::DEBUG) << "fibID = " << m_fibID << ", chan_i " << m_chan_i << ", chan_j = " << m_chan_j << endmsg;
355 
358 
359  msg(MSG::DEBUG) << "ALFA_Raw2Digit: new OD digit (softsim numbering-starting from 0) in the collection, pot = " << m_ODpot << ", side = " << m_ODside << ", plate = " << m_ODplate << ", fiber = " << m_ODfiber << endmsg;
360  }
361  }
362  // */
363  }
364  } //if (PFM!=0)
365  else
366  {
367  msg(MSG::DEBUG) << "ALFA_Raw2Digit: More than n Raw Data " <<endmsg;
368  break;
369  }
370  } // loop raw data
371 
372  msg(MSG::DEBUG) << "ALFA_Raw2Digit: finish loop over raw data " << endmsg;
373  } // loop collection
374 
375  msg(MSG::DEBUG) << "ALFA_Raw2Digit: finish loop over collection " << endmsg;
376 
377 // m_tree->Fill();
378 
379  return StatusCode::SUCCESS;
380 }
381 
383 {
384  ATH_MSG_DEBUG ("ALFA_Raw2Digit:finalize()");
385 
386 // m_toFile.close();
387 // m_tree->Write();
388 
389 /*
390  TCanvas *canvas = new TCanvas("MAPMT_activity", "MAPMT_activity");
391 // TCanvas *tcDistance = new TCanvas("tcDistance", "tcDistance");
392 
393  gStyle->SetPalette(1);
394 
395  for (int j=0;j<8;j++){
396  for (int k=0;k<23;k++){
397  for (int m=1;m<9;m++){
398  for (int n=1;n<9;n++){
399  MAPMT_activity_h[j][k]->SetBinContent(m,n,double(MapmtHit[j][k]->GetBinContent(m,n))/double(m_hit_counter[j]));
400  }
401  }
402  for (int i=0;i<64;i++){
403  MAPMT_activity[j]->SetPoint(k*64+i,k*64+i,double(m_pmf_chan_hit_counter[j][k][i])/double(m_hit_counter[j]));
404  }
405  }
406 
407  m_s.str("");
408  m_s << j+1;
409 
410  m_h_name1 = "MAPMT_activity_p_";
411  m_h_name1 += m_s.str();
412 
413  canvas->Clear();
414  canvas->cd();
415 
416  MAPMT_activity[j]->SetTitle(m_h_name1.c_str());
417  MAPMT_activity[j]->SetMarkerStyle(6);
418  MAPMT_activity[j]->Draw("AP");
419  MAPMT_activity[j]->SetName(m_h_name1.c_str());
420 
421  canvas->cd()->Update();
422 
423  m_h_name1 += ".eps";
424  canvas->Print(m_h_name1.c_str());
425  }
426 
427  delete canvas;
428 
429  for (int j=0;j<8;j++){
430  TCanvas *POT_View = new TCanvas("POT_View","POT_View");
431  POT_View->Divide(5,5);
432 
433  gStyle->SetPalette(1);
434 
435  for (unsigned int i=0;i<4;i++)
436  {
437  POT_View->cd(i+1);
438  // MapmtEff[i]->GetZaxis()->SetRangeUser(0,max_trig_eff_old[0]);
439  MAPMT_activity_h[j][i]->Draw("COLZ,A");
440  MAPMT_activity_h[j][i]->SetStats(0);
441  }
442 
443  for (unsigned int i=4;i<11;i++)
444  {
445  POT_View->cd(i+2);
446  // MapmtEff[i]->GetZaxis()->SetRangeUser(0,max_trig_eff_old[0]);
447  MAPMT_activity_h[j][i]->Draw("COLZ,A");
448  MAPMT_activity_h[j][i]->SetStats(0);
449  }
450 
451  for (unsigned int i=11;i<23;i++)
452  {
453  POT_View->cd(i+3);
454  // MapmtEff[i]->GetZaxis()->SetRangeUser(0,max_trig_eff_old[0]);
455  MAPMT_activity_h[j][i]->Draw("COLZ,A");
456  MAPMT_activity_h[j][i]->SetStats(0);
457  }
458 
459  POT_View->cd();
460 
461  m_s.str("");
462  m_s << j+1;
463  m_CanName = "h_MAPMT_activity_p_";
464  m_CanName += m_s.str();
465  m_CanName+=".eps";
466 
467  POT_View->Print(m_CanName.c_str());
468  POT_View->Close();
469  }
470 
471 */
472 
473 // m_rootOutput->Write();
474 // m_rootOutput->Close();
475 
476  return StatusCode::SUCCESS;
477 }
478 
479 
481 {
482  msg(MSG::DEBUG) << " ALFA_Digitization::recordCollection " << endmsg;
483 
485 
487  if (sc.isFailure()) { msg (MSG::FATAL) << " MD - Could not record the empty digit collection in StoreGate " << endmsg; return sc; }
488  else msg (MSG::DEBUG) << " MD - Digit collection is recorded in StoreGate " << endmsg;
489 
490  return sc;
491 }
492 
494 {
495  msg(MSG::DEBUG) << " ALFA_Digitization::recordODCollection " << endmsg;
496 
498 
500  if (sc.isFailure()) { msg (MSG::FATAL) << " OD - Could not record the empty digit collection in StoreGate " << endmsg; return sc; }
501  else msg (MSG::DEBUG) << " OD - Digit collection is recorded in StoreGate " << endmsg;
502 
503  return sc;
504 }
505 
507 {
508  int MarChan = 0;
509  int MapChan = 0;
510  int FibChan = 0;
511  int iLayer = 0;
512  int PMFNum = 0;
513  int LAYNum = 0;
514  int OD_PMFNum = 0;
515  int OD_Dieter = 0;
516  int OD_LAYNum = 0;
517  int OD_Side = 0;
518  int OD_MarChan = 0;
519  int OD_FibChan = 0;
520  int OD_MaPmtChan = 0;
521 
522 // int MBnum, DETnum;
523 
524 
525 // m_mapname = "./mapping/motheboard2detector.dat";
526 // m_inDet.open(m_mapname.c_str());
527 // msg(MSG::DEBUG) << "file name " << m_mapname.c_str() << endmsg;
528 // for (unsigned int i=0;i<64;i++) {
529 // m_inDet >> MBnum >> DETnum;
530 // m_mb2det[MBnum] = DETnum;
531 // }
532 
533  std::fill_n(&m_maroc2fiber[0][0][0], sizeof(m_maroc2fiber)/sizeof(int), -9999.0);
534  std::fill_n(&m_maroc2mapmt[0][0][0], sizeof(m_maroc2mapmt)/sizeof(int), -9999.0);
535  std::fill_n(&m_mapmt2maroc[0][0][0], sizeof(m_mapmt2maroc)/sizeof(int), -9999.0);
536 
537 
538  for (unsigned int j=0; j<8; j++)
539  {
540  m_s.str("");
541 
542 // m_mapname = "mapping/MAROC_MAPMT_FIBER_MD";
543 
544  // changed by Petr - 19.12.2012 -------------------------------------------------
545 // m_mapname = "MAROC_MAPMT_FIBER_MD";
546  m_mapname = "MAROC_MAPMT_FIBER_NEW_MD_";
547  m_s << j+1;
548  m_mapname += m_s.str();
549  m_mapname += ".dat";
550 
551  msg(MSG::DEBUG) << "file name " << m_mapname.c_str() << endmsg;
552 
553  // ************
555  if(filePath.length() == 0)
556  {
557  msg(MSG::FATAL) << " the mapping file MD maroc-mapmt \"" << m_mapname.c_str() << "\" not found in Datapath." << endmsg;
558  throw std::runtime_error("FATAL: mapping MD maroc-mapmt not found in Datapath.");
559  }
560  else
561  {
562  msg(MSG::DEBUG) << "DEBUG: the mapping file MD maroc-mapmt \"" << m_mapname.c_str() << "\" found in Datapath." << endmsg;
563  msg(MSG::DEBUG) << "DEBUG: filePath = " << filePath.c_str() << endmsg;
564  }
565  // **************
566 
567 // m_inChan.open(m_mapname.c_str());
568  m_inChan.open(filePath.c_str());
569  if (m_inChan.is_open())
570  {
571  // changed by Petr - 19.12.2012 ---------------------------------------------
572 // for (unsigned int i=0;i<64;i++){
573  for (unsigned int i=0;i<1280;i++){
574 // m_inChan >> MarChan >> MapChan >> FibChan;
575  m_inChan >> iLayer >> MarChan >> MapChan >> FibChan;
576 // msg(MSG::DEBUG) << i << " maroc_mapmt_fiber, maroc = " << MarChan << ", map = "<< MapChan << ", fib = " << FibChan << endmsg;
577  msg(MSG::DEBUG) << i << " maroc_mapmt_fiber, layer = " << iLayer << ", maroc = " << MarChan << ", map = "<< MapChan << ", fib = " << FibChan << endmsg;
578 
579  if ((MarChan < 0) || (MarChan > 63))
580  {
581  std::string s1("MarChan out of range; file corrupted");
582  throw std::runtime_error(s1);
583  }
584 
585  if ((MapChan < 0) || (MapChan > 63))
586  {
587  std::string s2("MapChan out of range; file corrupted");
588  throw std::runtime_error(s2);
589  }
590 
591  if ((iLayer < 0) || (iLayer > 19))
592  {
593  std::string s2("Layer out of range; file corrupted");
594  throw std::runtime_error(s2);
595  }
596 
597 // m_maroc2fiber[j][MarChan] = FibChan;
598 // m_maroc2mapmt[j][MarChan] = MapChan;
599 // m_mapmt2maroc[j][MapChan] = MarChan;
600  m_maroc2fiber[j][iLayer][MarChan] = FibChan;
601  m_maroc2mapmt[j][iLayer][MarChan] = MapChan;
602  m_mapmt2maroc[j][iLayer][MapChan] = MarChan;
603  }
604  m_inChan.close();
605  }
606  else
607  {
608  msg(MSG::ERROR) << "the file " << m_mapname.c_str() << " was not open" << endmsg;
609  return StatusCode::FAILURE;
610  }
611 
612 // m_mapname = "mapping/PMF_LAYER_MD";
613  m_mapname = "PMF_LAYER_MD";
614  m_mapname += m_s.str();
615  m_mapname += ".dat";
616  msg(MSG::DEBUG) << "file name " << m_mapname.c_str() << endmsg;
617 
618  // ************
620  if(filePath.length() == 0)
621  {
622  msg(MSG::FATAL) << " the mapping file PMF_LAYER_MD \"" << m_mapname.c_str() << "\" not found in Datapath." << endmsg;
623  throw std::runtime_error("FATAL: mapping PMF_LAYER_MD not found in Datapath.");
624  }
625  else
626  {
627  msg(MSG::DEBUG) << "DEBUG: the mapping file PMF_LAYER_MD \"" << m_mapname.c_str() << "\" found in Datapath." << endmsg;
628  msg(MSG::DEBUG) << "DEBUG: filePath = " << filePath.c_str() << endmsg;
629  }
630  // **************
631 
632  m_inPMF.open(filePath.c_str());
633  if (m_inPMF.is_open())
634  {
635  for (unsigned int i=0;i<20;i++)
636  {
637  m_inPMF >> PMFNum >> LAYNum;
638  msg(MSG::DEBUG) << i << " pmf2layer, pmf = " << PMFNum << ", layer = "<< LAYNum << endmsg;
639 
640  if ((PMFNum < 0) || ( PMFNum > 22))
641  {
642  std::string s3("PMFNum out of range; file corrupted");
643  throw std::runtime_error(s3);
644  }
645 
646 
647  m_pmf2layer[j][PMFNum] = LAYNum;
648  // // layer2pmf[j][LAYNum] = PMFNum;
649  }
650  m_inPMF.close();
651  }
652  else
653  {
654  msg(MSG::WARNING) << "the file " << m_mapname.c_str() << " was not open" << endmsg;
655  return StatusCode::FAILURE;
656  }
657 
658 // m_mapname="mapping/OD_MAP";
659  m_mapname="OD_MAP";
660  m_mapname += m_s.str();
661  m_mapname+=".dat";
662  msg(MSG::DEBUG) << "file name " << m_mapname.c_str() << endmsg;
663 
664  // ************
666  if(filePath.length() == 0)
667  {
668  msg(MSG::FATAL) << " the mapping file OD_MAP \"" << m_mapname.c_str() << "\" not found in Datapath." << endmsg;
669  throw std::runtime_error("FATAL: mapping OD_MAP not found in Datapath.");
670  }
671  else
672  {
673  msg(MSG::DEBUG) << "DEBUG: the mapping file OD_MAP \"" << m_mapname.c_str() << "\" found in Datapath." << endmsg;
674  msg(MSG::DEBUG) << "DEBUG: filePath = " << filePath.c_str() << endmsg;
675  }
676  // **************
677 
678  m_inOD.open(filePath.c_str());
679  if (m_inOD.is_open())
680  {
681  for(unsigned int jlay=0; jlay<3; jlay++)
682  {
683  for(unsigned int jside=0; jside<2; jside++)
684  {
685  for(unsigned int jch=0; jch<32; jch++)
686  {
687  m_inOD >> OD_PMFNum >> OD_Dieter >> OD_LAYNum >> OD_Side >> OD_MaPmtChan >> OD_FibChan; // warning!!! MaPmt, not Maroc!
688  msg(MSG::DEBUG) << " pmf2layer, OD_PMFNum = " << OD_PMFNum << ", OD_Dieter = "<< OD_Dieter << ", OD_LAYNum = " << OD_LAYNum << ", OD_Side = " << OD_Side << ", OD_MaPmtChan = " << OD_MaPmtChan << ", OD_FibChan = " << OD_FibChan << endmsg;
689 
690  if ((OD_PMFNum < 2) || ( OD_PMFNum > 4))
691  {
692  std::string s4("OD_PMFNum out of range; file corrupted");
693  throw std::runtime_error(s4);
694  }
695 
696  if ((OD_MaPmtChan < 1) || ( OD_MaPmtChan > 64))
697  {
698  std::string s5("OD_MaPmtChan out of range; file corrupted");
699  throw std::runtime_error(s5);
700  }
701 
702 
703 // m_OD_pmf2layer[j][OD_PMFNum-1] = OD_LAYNum-1;
704  // OD_layer2pmf[j][OD_LAYNum-1] = OD_PMFNum-1;
705  // changed by Petr - 19.12.2012 ---------------------------------
706 // OD_MarChan = m_mapmt2maroc[j][OD_MaPmtChan-1];
707 // OD_MarChan = m_mapmt2maroc[j][OD_LAYNum-1][OD_MaPmtChan-1];
708  //added to solve ATLAS coverity 13339 (only three OD layers are allowed)
709  if ((OD_LAYNum > 0) && ( OD_LAYNum < 4))
710  {
711  m_OD_pmf2layer[j][OD_PMFNum-1] = OD_LAYNum-1;
712  OD_MarChan = m_mapmt2maroc[j][OD_LAYNum-1][OD_MaPmtChan-1];
713  }
714  else
715  {
716  msg(MSG::DEBUG) << "OD_LAYNum out of bounds" << endmsg;
717  }
718 
719  m_OD_pmf_maroc2fiber[j][OD_PMFNum-1][OD_MarChan] = OD_FibChan-1;
720  m_OD_pmf_maroc2side[j][OD_PMFNum-1][OD_MarChan] = OD_Side;
721  }
722  }
723  }
724 
725  m_inOD.close();
726  }
727  else
728  {
729  msg(MSG::WARNING) << "the file " << m_mapname.c_str() << " was not open" << endmsg;
730  return StatusCode::FAILURE;
731  }
732  }
733 
734  return StatusCode::SUCCESS;
735 }
736 
737 // changed by Petr - 19.12.2012 ---------------------------------------------------------
738 //StatusCode ALFA_Raw2Digit::ChanPlot(uint32_t pot_n, uint32_t MarChan, uint32_t &m_chan_i, uint32_t &m_chan_j)
740 {
741  // returs values in range 1-8; input is 0-63!
742 // if (int(fmod(double(m_maroc2mapmt[pot_n][MarChan]+1),double(8)))>0)
743  if (int(fmod(double(m_maroc2mapmt[pot_n][iLayer][MarChan]+1),double(8)))>0)
744  {
745 // chan_i=int((m_maroc2mapmt[pot_n][MarChan]+1)/8)+1;
746 // chan_j=9-int(fmod(double(m_maroc2mapmt[pot_n][MarChan]+1),double(8)));
747  chan_i=int((m_maroc2mapmt[pot_n][iLayer][MarChan]+1)/8)+1;
748  chan_j=9-int(fmod(double(m_maroc2mapmt[pot_n][iLayer][MarChan]+1),double(8)));
749  }
750  else
751  {
752 // chan_i=int((m_maroc2mapmt[pot_n][MarChan]+1)/8);
753  chan_i=int((m_maroc2mapmt[pot_n][iLayer][MarChan]+1)/8);
754  chan_j=1;
755  }
756 
757 // msg(MSG::FATAL) << "in funct: m_fibID = " << MarChan << ", chan_i " << chan_i << ", chan_j = " << chan_j << endmsg;
758  return StatusCode::SUCCESS;
759 }
ALFA_Raw2Digit::m_nEvents
int m_nEvents
Definition: ALFA_Raw2Digit.h:57
ALFA_Raw2Digit::m_mb2det
int m_mb2det[8]
Definition: ALFA_Raw2Digit.h:87
ALFA_Raw2Digit::m_rootOutput
TFile * m_rootOutput
Definition: ALFA_Raw2Digit.h:103
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
ALFA_Raw2Digit::m_fiber
int m_fiber
Definition: ALFA_Raw2Digit.h:69
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
PathResolver::RecursiveSearch
@ RecursiveSearch
Definition: PathResolver.h:28
ALFA_Raw2Digit::m_WordId_count
int m_WordId_count
Definition: ALFA_Raw2Digit.h:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ALFA_Raw2Digit::m_maroc2mapmt
int m_maroc2mapmt[8][20][64]
Definition: ALFA_Raw2Digit.h:78
ALFA_Raw2Digit::m_ODdigitCollection
ALFA_ODDigitCollection * m_ODdigitCollection
Definition: ALFA_Raw2Digit.h:114
ALFA_Raw2Digit::m_chan_i
uint32_t m_chan_i
Definition: ALFA_Raw2Digit.h:132
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ALFA_Raw2Digit::m_hit_counter
Int_t m_hit_counter[8]
Definition: ALFA_Raw2Digit.h:108
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ALFA_Raw2Digit::m_ODside
int m_ODside
Definition: ALFA_Raw2Digit.h:72
ALFA_Raw2Digit::m_key_DigitCollection
std::string m_key_DigitCollection
Definition: ALFA_Raw2Digit.h:117
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ALFA_Raw2Digit::m_maroc2fiber
int m_maroc2fiber[8][20][64]
Definition: ALFA_Raw2Digit.h:77
ALFA_Raw2Digit::initialize
StatusCode initialize()
Definition: ALFA_Raw2Digit.cxx:59
ALFA_Raw2Digit::ALFA_Raw2Digit
ALFA_Raw2Digit(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ALFA_Raw2Digit.cxx:12
ReadCellNoiseFromCoolCompare.s4
s4
Definition: ReadCellNoiseFromCoolCompare.py:381
ALFA_Raw2Digit::m_lumi_block
uint32_t m_lumi_block
Definition: ALFA_Raw2Digit.h:96
ALFA_Raw2Digit::m_layer_b
bool m_layer_b[8][20]
Definition: ALFA_Raw2Digit.h:99
ALFA_Raw2Digit::ChanPlot
StatusCode ChanPlot(uint32_t pot_n, uint32_t iLayer, uint32_t MarChan, uint32_t &chan_i, uint32_t &chan_j)
Definition: ALFA_Raw2Digit.cxx:739
ALFA_Raw2Digit::m_charge_2
uint16_t m_charge_2[8]
Definition: ALFA_Raw2Digit.h:97
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ALFA_Raw2Digit::m_ODfiber
int m_ODfiber
Definition: ALFA_Raw2Digit.h:74
ALFA_Raw2Digit::m_trigger_pattern_b
bool m_trigger_pattern_b[8][16]
Definition: ALFA_Raw2Digit.h:99
ALFA_Raw2Digit::m_charge_1
uint16_t m_charge_1[8]
Definition: ALFA_Raw2Digit.h:97
ALFA_Raw2Digit::m_pmfID
int m_pmfID
Definition: ALFA_Raw2Digit.h:60
ALFA_Raw2Digit::m_pmf2layer
int m_pmf2layer[8][23]
Definition: ALFA_Raw2Digit.h:81
ALFA_Raw2Digit::m_mapname
std::string m_mapname
Definition: ALFA_Raw2Digit.h:125
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ALFA_Raw2Digit::m_mapmt2maroc
int m_mapmt2maroc[8][20][64]
Definition: ALFA_Raw2Digit.h:79
ALFA_Raw2Digit.h
ALFA_Raw2Digit::m_event_no
Int_t m_event_no
Definition: ALFA_Raw2Digit.h:101
ALFA_Digit
Definition: ALFA_Digit.h:8
ALFA_Raw2Digit::m_key_ODDigitCollection
std::string m_key_ODDigitCollection
Definition: ALFA_Raw2Digit.h:118
ALFA_Raw2Digit::m_pot
int m_pot
Definition: ALFA_Raw2Digit.h:66
ALFA_Raw2Digit::m_strMeasuredDataType
std::string m_strMeasuredDataType
Definition: ALFA_Raw2Digit.h:135
ALFA_Raw2Digit::m_plate
int m_plate
Definition: ALFA_Raw2Digit.h:68
lumiFormat.i
int i
Definition: lumiFormat.py:85
ALFA_Raw2Digit::m_chan_j
uint32_t m_chan_j
Definition: ALFA_Raw2Digit.h:132
ALFA_Raw2Digit::m_OD_pmf2layer
int m_OD_pmf2layer[8][4]
Definition: ALFA_Raw2Digit.h:83
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ALFA_Raw2Digit::m_lumi_block_old
uint32_t m_lumi_block_old
Definition: ALFA_Raw2Digit.h:96
ALFA_Raw2Digit::m_side
int m_side
Definition: ALFA_Raw2Digit.h:67
ALFA_RawDataContainer::GetLumiBlock
uint32_t GetLumiBlock() const
Definition: ALFA_RawDataContainer.h:110
ALFA_Raw2Digit::m_pot_b
bool m_pot_b[8]
Definition: ALFA_Raw2Digit.h:99
ALFA_Raw2Digit::m_ALFA_RawDataCollectionKey
std::string m_ALFA_RawDataCollectionKey
Definition: ALFA_Raw2Digit.h:55
ALFA_Raw2Digit::m_MAPMTChan
int m_MAPMTChan
Definition: ALFA_Raw2Digit.h:63
ALFA_Raw2Digit::m_digitCollection
ALFA_DigitCollection * m_digitCollection
Definition: ALFA_Raw2Digit.h:111
ALFA_Raw2Digit::m_inPMF
std::ifstream m_inPMF
Definition: ALFA_Raw2Digit.h:121
AthAlgorithm
Definition: AthAlgorithm.h:47
ALFA_Raw2Digit::m_ODplate
int m_ODplate
Definition: ALFA_Raw2Digit.h:73
ALFA_Raw2Digit::m_ODpot
int m_ODpot
Definition: ALFA_Raw2Digit.h:71
ALFA_Raw2Digit::finalize
StatusCode finalize()
Definition: ALFA_Raw2Digit.cxx:382
PathResolver.h
ALFA_DigitCollection
Definition: ALFA_DigitCollection.h:15
ReadCellNoiseFromCoolCompare.s3
s3
Definition: ReadCellNoiseFromCoolCompare.py:380
hancool.filePath
string filePath
Definition: hancool.py:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ALFA_Raw2Digit::m_All_Trigger_norm
TH2D * m_All_Trigger_norm
Definition: ALFA_Raw2Digit.h:92
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ALFA_Raw2Digit::m_All_Trigger
TH2I * m_All_Trigger
Definition: ALFA_Raw2Digit.h:91
ALFA_Raw2Digit::m_tree
TTree * m_tree
Definition: ALFA_Raw2Digit.h:102
ALFA_Raw2Digit::execute
StatusCode execute()
Definition: ALFA_Raw2Digit.cxx:172
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
ALFA_Raw2Digit::m_fiber_b
bool m_fiber_b[8][20][64]
Definition: ALFA_Raw2Digit.h:99
ALFA_Raw2Digit::mapping
StatusCode mapping()
Definition: ALFA_Raw2Digit.cxx:506
ALFA_Raw2Digit::m_s
std::stringstream m_s
Definition: ALFA_Raw2Digit.h:126
ALFA_Raw2Digit::m_MapChan
int m_MapChan
Definition: ALFA_Raw2Digit.h:64
ALFA_RawDataContainer
This container provides acces to the PMF RDOs.
Definition: ALFA_RawDataContainer.h:21
DEBUG
#define DEBUG
Definition: page_access.h:11
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
ALFA_Raw2Digit::m_inOD
std::ifstream m_inOD
Definition: ALFA_Raw2Digit.h:122
ALFA_Raw2Digit::m_OD_pmf_maroc2fiber
int m_OD_pmf_maroc2fiber[8][4][64]
Definition: ALFA_Raw2Digit.h:84
ALFA_Raw2Digit::m_n_hits_lay
Int_t m_n_hits_lay[8][20]
Definition: ALFA_Raw2Digit.h:100
ALFA_Raw2Digit::m_pmf_chan_hit_counter
Int_t m_pmf_chan_hit_counter[8][23][64]
Definition: ALFA_Raw2Digit.h:107
ALFA_Raw2Digit::m_OD_pmf_maroc2side
int m_OD_pmf_maroc2side[8][4][64]
Definition: ALFA_Raw2Digit.h:85
ALFA_Raw2Digit::recordCollection
StatusCode recordCollection()
Definition: ALFA_Raw2Digit.cxx:480
ALFA_Raw2Digit::m_ODdigitObject
ALFA_ODDigit * m_ODdigitObject
Definition: ALFA_Raw2Digit.h:115
ALFA_Raw2Digit::m_mbID
int m_mbID
Definition: ALFA_Raw2Digit.h:59
ALFA_Raw2Digit::recordODCollection
StatusCode recordODCollection()
Definition: ALFA_Raw2Digit.cxx:493
ALFA_Raw2Digit::m_hit_lay_h
TH1F * m_hit_lay_h[8]
Definition: ALFA_Raw2Digit.h:95
ALFA_ODDigit
Definition: ALFA_ODDigit.h:8
ALFA_Raw2Digit::m_fibID
int m_fibID
Definition: ALFA_Raw2Digit.h:61
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
fitman.k
k
Definition: fitman.py:528
ALFA_Raw2Digit::m_inChan
std::ifstream m_inChan
Definition: ALFA_Raw2Digit.h:120
ALFA_Raw2Digit::m_act_lay_h
TH1F * m_act_lay_h[8]
Definition: ALFA_Raw2Digit.h:94
ALFA_Raw2Digit::m_digitObject
ALFA_Digit * m_digitObject
Definition: ALFA_Raw2Digit.h:112
ALFA_ODDigitCollection
Definition: ALFA_ODDigitCollection.h:15