ATLAS Offline Software
TBCheckBCIDs.cxx
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 
8 #include "TBCnv/TBCheckBCIDs.h"
9 
10 #include "GaudiKernel/MsgStream.h"
13 //#include "CLIDSvc/CLASS_DEF.h"
14 #include <map>
15 
16 
17 TBCheckBCIDs::TBCheckBCIDs(const std::string& name, ISvcLocator* pSvcLocator)
18  : AthAlgorithm(name, pSvcLocator),
19  m_count(0),
20  //m_ByteStreamEventAccess(0),
21  m_rdpSvc(0),
22  m_ntuplePtr(0)
23 {
24 }
25 
27 
29 {
30  ATH_MSG_DEBUG( " initialize " );
31  IService* svc;
32  //Get ByteStreamInputSvc (only necessary for reading of digits, not for writing and for channels)
33 
34  if(StatusCode::SUCCESS != serviceLocator()->getService("ROBDataProviderSvc",svc)){
35  ATH_MSG_WARNING( " Can't get ByteStreamInputSvc interface." );
36  return StatusCode::FAILURE;
37  }
38  m_rdpSvc=dynamic_cast<IROBDataProviderSvc*>(svc);
39  if(m_rdpSvc == 0 ) {
40  ATH_MSG_ERROR( " LArDigitContByteStreamCnv: Can't cast to ByteStreamInputSvc " );
41  return StatusCode::FAILURE;
42  }
43  //Book Ntuple
44 
45 
46  NTupleFilePtr file1(ntupleSvc(),"/NTUPLES/FILE1");
47  if (!file1) {
48  ATH_MSG_ERROR( "Booking of NTuple failed" );
49  return StatusCode::FAILURE;
50  }
51  NTuplePtr nt(ntupleSvc(),"/NTUPLES/FILE1/BCIDS");
52  if (!nt) {
53  nt=ntupleSvc()->book("/NTUPLES/FILE1/BCIDS",CLID_ColumnWiseTuple,"BCIDs");
54  }
55  if (!nt) {
56  ATH_MSG_ERROR( "Booking of NTuple failed" );
57  return StatusCode::FAILURE;
58  }
59 
60  ATH_CHECK( nt->addItem("GlobalEvtID",m_EventID,0,50000) );
61  ATH_CHECK( nt->addItem("LVL1ID",m_LVL1ID,0,50000) );
62  ATH_CHECK( nt->addItem("RODIndex",m_RODIndex,0,100) );
63  ATH_CHECK( nt->addItem("RODID",m_RODIndex,m_RODID) );
64  ATH_CHECK( nt->addItem("BCID",m_RODIndex,m_BCID) );
66  return StatusCode::SUCCESS;
67 }
68 
69 
70 //LArRawDataContByteStreamTool::ReadLArDigits(const RawEvent* re,LArDigitContainer* digitCont, const int gain, MsgStream& log)
72 {
73  ATH_MSG_DEBUG( "Executing event #"<< m_count++ );
74 
75  unsigned RODCounter=0;
76  const RawEvent* re = m_rdpSvc->getEvent();
77 
78  if (!re) {
79  ATH_MSG_FATAL( "RawEvent retrieved by TBCheckBCIDs is a null pointer!" );
80  return StatusCode::FAILURE;
81  }
82 
83  //Get ROB fragements from the raw event.
84  const size_t MAX_ROBFRAGMENTS = 2048*1024;
85  OFFLINE_FRAGMENTS_NAMESPACE::PointerType robF[MAX_ROBFRAGMENTS];
87  re->start(rePointer);
88  size_t robcount = re->children(robF,MAX_ROBFRAGMENTS);
89  if (robcount == MAX_ROBFRAGMENTS)
90  {
91  ATH_MSG_FATAL( "ROB buffer overflow" );
92  return StatusCode::FAILURE;
93  }
94 
95 
96  m_LVL1ID=re->lvl1_id();
97  m_EventID=re->global_id();
98 
99 
100 
101  for (size_t irob=0; irob<robcount; ++irob) //Loop over all ROB-Fragments
102  {
104 
105  try
106  {
107  rob.check();
108  }
109  catch (...)
110  {
111  ATH_MSG_ERROR( "Got invalid ROB fragment!" );
112  return StatusCode::FAILURE;
113  }
114 
115  ATH_MSG_VERBOSE( MSG::hex << "\t\tFull source ID: " << rob.source_id()<<MSG::dec );
116  ATH_MSG_VERBOSE( "This ROD-Fragment consists of " << rob.rod_fragment_size_word() << " words" );
117 
118  m_RODIndex=RODCounter;
119  m_RODID[m_RODIndex]=rob.rod_source_id();
120  m_BCID[m_RODIndex] =rob.rod_bc_id();
121  ATH_MSG_DEBUG( "RODID 0x" << MSG::hex << rob.rod_source_id() << " BCID 0x"
122  << rob.rod_bc_id() << MSG::dec );
123  RODCounter++;
124  }
125 
126  ATH_CHECK( ntupleSvc()->writeRecord(m_ntuplePtr) );
127  return StatusCode::SUCCESS;
128 }
129 
131 {return StatusCode::SUCCESS;}
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TBCheckBCIDs::m_EventID
NTuple::Item< long > m_EventID
Definition: TBCheckBCIDs.h:46
TBCheckBCIDs::~TBCheckBCIDs
~TBCheckBCIDs()
Definition: TBCheckBCIDs.cxx:26
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
IROBDataProviderSvc
Interface class for managing ROB for both online and offline.
Definition: IROBDataProviderSvc.h:25
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
eformat::ROBFragment
Definition: L1CaloBsDecoderUtil.h:12
RawEvent.h
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
TBCheckBCIDs::m_RODID
NTuple::Array< long > m_RODID
Definition: TBCheckBCIDs.h:48
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
FullEventAssembler.h
AthAlgorithm
Definition: AthAlgorithm.h:47
TBCheckBCIDs::m_count
int m_count
Definition: TBCheckBCIDs.h:38
IROBDataProviderSvc::getEvent
virtual const RawEvent * getEvent()=0
Retrieve the whole event.
TBCheckBCIDs::m_LVL1ID
NTuple::Item< long > m_LVL1ID
Definition: TBCheckBCIDs.h:46
TBCheckBCIDs::TBCheckBCIDs
TBCheckBCIDs(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TBCheckBCIDs.cxx:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TBCheckBCIDs::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition: TBCheckBCIDs.h:45
TBCheckBCIDs::m_RODIndex
NTuple::Item< long > m_RODIndex
Definition: TBCheckBCIDs.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
TBCheckBCIDs::m_BCID
NTuple::Array< long > m_BCID
Definition: TBCheckBCIDs.h:49
TBCheckBCIDs.h
TBCheckBCIDs::execute
StatusCode execute()
Definition: TBCheckBCIDs.cxx:71
beamspotnt.nt
def nt
Definition: bin/beamspotnt.py:1063
TBCheckBCIDs::initialize
StatusCode initialize()
Definition: TBCheckBCIDs.cxx:28
TBCheckBCIDs::m_rdpSvc
IROBDataProviderSvc * m_rdpSvc
Definition: TBCheckBCIDs.h:40
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
TBCheckBCIDs::finalize
StatusCode finalize()
Definition: TBCheckBCIDs.cxx:130