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