ATLAS Offline Software
TBCheckBCIDs.cxx
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2024 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_rdpSvc("ROBDataProviderSvc", name),
21  m_ntuplePtr(0)
22 {
23 }
24 
26 
28 {
29  ATH_MSG_DEBUG( " initialize " );
30 
31  //Get ByteStreamInputSvc (only necessary for reading of digits, not for writing and for channels)
32  ATH_CHECK( m_rdpSvc.retrieve() );
33 
34  //Book Ntuple
35  NTupleFilePtr file1(ntupleSvc(),"/NTUPLES/FILE1");
36  if (!file1) {
37  ATH_MSG_ERROR( "Booking of NTuple failed" );
38  return StatusCode::FAILURE;
39  }
40  NTuplePtr nt(ntupleSvc(),"/NTUPLES/FILE1/BCIDS");
41  if (!nt) {
42  nt=ntupleSvc()->book("/NTUPLES/FILE1/BCIDS",CLID_ColumnWiseTuple,"BCIDs");
43  }
44  if (!nt) {
45  ATH_MSG_ERROR( "Booking of NTuple failed" );
46  return StatusCode::FAILURE;
47  }
48 
49  ATH_CHECK( nt->addItem("GlobalEvtID",m_EventID,0,50000) );
50  ATH_CHECK( nt->addItem("LVL1ID",m_LVL1ID,0,50000) );
51  ATH_CHECK( nt->addItem("RODIndex",m_RODIndex,0,100) );
52  ATH_CHECK( nt->addItem("RODID",m_RODIndex,m_RODID) );
53  ATH_CHECK( nt->addItem("BCID",m_RODIndex,m_BCID) );
55  return StatusCode::SUCCESS;
56 }
57 
58 
59 //LArRawDataContByteStreamTool::ReadLArDigits(const RawEvent* re,LArDigitContainer* digitCont, const int gain, MsgStream& log)
61 {
62  ATH_MSG_DEBUG( "Executing event #"<< m_count++ );
63 
64  unsigned RODCounter=0;
65  const RawEvent* re = m_rdpSvc->getEvent(Gaudi::Hive::currentContext());
66  if (!re) {
67  ATH_MSG_FATAL( "RawEvent retrieved by TBCheckBCIDs is a null pointer!" );
68  return StatusCode::FAILURE;
69  }
70 
71  //Get ROB fragements from the raw event.
72  const size_t MAX_ROBFRAGMENTS = 2048*1024;
73  OFFLINE_FRAGMENTS_NAMESPACE::PointerType robF[MAX_ROBFRAGMENTS];
75  re->start(rePointer);
76  size_t robcount = re->children(robF,MAX_ROBFRAGMENTS);
77  if (robcount == MAX_ROBFRAGMENTS)
78  {
79  ATH_MSG_FATAL( "ROB buffer overflow" );
80  return StatusCode::FAILURE;
81  }
82 
83 
84  m_LVL1ID=re->lvl1_id();
85  m_EventID=re->global_id();
86 
87 
88 
89  for (size_t irob=0; irob<robcount; ++irob) //Loop over all ROB-Fragments
90  {
92 
93  try
94  {
95  rob.check();
96  }
97  catch (...)
98  {
99  ATH_MSG_ERROR( "Got invalid ROB fragment!" );
100  return StatusCode::FAILURE;
101  }
102 
103  ATH_MSG_VERBOSE( MSG::hex << "\t\tFull source ID: " << rob.source_id()<<MSG::dec );
104  ATH_MSG_VERBOSE( "This ROD-Fragment consists of " << rob.rod_fragment_size_word() << " words" );
105 
106  m_RODIndex=RODCounter;
107  m_RODID[m_RODIndex]=rob.rod_source_id();
108  m_BCID[m_RODIndex] =rob.rod_bc_id();
109  ATH_MSG_DEBUG( "RODID 0x" << MSG::hex << rob.rod_source_id() << " BCID 0x"
110  << rob.rod_bc_id() << MSG::dec );
111  RODCounter++;
112  }
113 
114  ATH_CHECK( ntupleSvc()->writeRecord(m_ntuplePtr) );
115  return StatusCode::SUCCESS;
116 }
117 
119 {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:41
TBCheckBCIDs::~TBCheckBCIDs
~TBCheckBCIDs()
Definition: TBCheckBCIDs.cxx:25
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
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:43
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FullEventAssembler.h
AthAlgorithm
Definition: AthAlgorithm.h:47
TBCheckBCIDs::m_count
int m_count
Definition: TBCheckBCIDs.h:34
TBCheckBCIDs::m_LVL1ID
NTuple::Item< long > m_LVL1ID
Definition: TBCheckBCIDs.h:41
TBCheckBCIDs::TBCheckBCIDs
TBCheckBCIDs(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TBCheckBCIDs.cxx:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TBCheckBCIDs::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition: TBCheckBCIDs.h:40
TBCheckBCIDs::m_RODIndex
NTuple::Item< long > m_RODIndex
Definition: TBCheckBCIDs.h:42
re
const boost::regex re(r_e)
TBCheckBCIDs::m_BCID
NTuple::Array< long > m_BCID
Definition: TBCheckBCIDs.h:44
TBCheckBCIDs.h
TBCheckBCIDs::execute
StatusCode execute()
Definition: TBCheckBCIDs.cxx:60
beamspotnt.nt
def nt
Definition: bin/beamspotnt.py:1063
TBCheckBCIDs::m_rdpSvc
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
Definition: TBCheckBCIDs.h:35
TBCheckBCIDs::initialize
StatusCode initialize()
Definition: TBCheckBCIDs.cxx:27
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
TBCheckBCIDs::finalize
StatusCode finalize()
Definition: TBCheckBCIDs.cxx:118