ATLAS Offline Software
Loading...
Searching...
No Matches
TestLArRodDecoder.cxx
Go to the documentation of this file.
1
2#include "TestLArRodDecoder.h"
3
4TestLArRodDecoder::TestLArRodDecoder( const std::string& name, ISvcLocator* pSvcLocator ) : ::AthAlgorithm( name, pSvcLocator ){
5 std::cout << "Constructor" << name << std::endl;
6}
7
9
10StatusCode
12
13 ATH_CHECK( m_larDecoder.retrieve() );
14 ATH_CHECK( m_robDataProvider.retrieve() );
15 ATH_CHECK( m_onOffIdMappingKey.initialize() );
16 ATH_CHECK( m_larRoIMapKey.initialize() );
17 ATH_CHECK( m_febRodMappingKey.initialize() );
18 ATH_CHECK( m_mcsymKey.initialize() );
19 ATH_CHECK( m_bcContKey.initialize() );
20 ATH_CHECK( m_caloMgrKey.initialize());
21 std::cout << "Initializing " << name() << std::endl;
22 return StatusCode::SUCCESS;
23}
24
25void TestLArRodDecoder::lateInit(const EventContext& context){
26
27for (EventCache& cache : m_testSlot) {
28 cache.count=0;
29 cache.larContainer = std::make_unique<LArCellCont>();
36 const CaloDetDescrManager* theCaloDDM = *caloMgrHandle;
37 cache.larContainer->initialize(**roimap, **onoff, **mcsym, **febrod, **larBadChan, *theCaloDDM).orThrow("Cannot initialize LAr container", name());
38}
39}
40
41StatusCode
43 std::cout << "Finalizing " << name() << std::endl;
44 //ATH_CHECK( m_testSlot->larContainer->finalize() );
45 return StatusCode::SUCCESS;
46}
47
48StatusCode
49TestLArRodDecoder::execute( const EventContext& context) {
50 std::call_once(m_lateInitFlag, &TestLArRodDecoder::lateInit, this,context);
51 if ( m_printOut ) std::cout << "Executing " << name() << " " << m_testSlot.get(context)->count << std::endl;
52 m_testSlot.get(context)->count=m_testSlot.get(context)->count+1;
53 m_testSlot.get(context)->larContainer->eventNumber( context.evt() );
54 LArCellCont* larcell = m_testSlot.get(context)->larContainer.get();
55
56 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
57 m_robDataProvider->getROBData( context, m_vrodid32fullDet, robFrags );
58 if ( m_printOut ) std::cout << "robFrags.size() : " << robFrags.size() << std::endl;
59 if (robFrags.size() < 1 ){ // this is the end
60 return StatusCode::SUCCESS;
61 }
62 std::vector<LArCellCollection*> coll_of_coll;
63 struct timeval t1, t2;
64 int nunpacked=0;
65 gettimeofday(&t1, NULL);
66 for( auto rob : robFrags ){
67 if ( m_printOut ) std::cout << "Interpreting fragment" << std::endl;
68 // Get Rod Data and size of fragment
69 const uint32_t* roddata = 0;
70 rob->rod_data( roddata );
71 const size_t roddatasize = rob->rod_ndata();
72 if ( m_printOut ) { std::cout << "roddatasize : " << roddatasize << std::endl;
73 if (roddatasize > 30){
74 for(size_t i=0;i<30;i++){
75 std::cout << "0x" << std::hex << roddata[i] << " " << std::dec << roddata[i] << std::endl;
76 } //end of for
77 } // end of rodddatasize
78 } // end of print out if
79 uint32_t sourceID = rob->source_id();
80 const auto it = larcell->find( sourceID );
81 m_larDecoder->setsecfeb( larcell->findsec( sourceID ) );
82 if ( it != larcell->end() && ( *it )->size() != 0 ) {
83 LArCellCollection* coll = *it;
84 if ( m_printOut ) std::cout << "ROB of ID 0x" << std::hex << sourceID << std::dec << " to be decoded" << std::endl;
85 if ( !m_larDecoder->check_valid(rob,msg())) {std::cout << "Wrong Block" << std::endl;}
86 else {
87 LArRodBlockStructure* larRodBlockStructure_per_slot = nullptr;
88 uint16_t rodMinorVersion = 0;
89 uint32_t robBlockType = 0;
90 m_larDecoder->fillCollectionHLT( *rob, roddata, roddatasize, *coll, larRodBlockStructure_per_slot, rodMinorVersion, robBlockType );
91 coll_of_coll.push_back(coll);
92 nunpacked++;
93 } // enf of else
94 } // end of if
95 } // end of rob for
96 gettimeofday(&t2, NULL);
97 double delay = 1e6*(t2.tv_sec-t1.tv_sec) + (t2.tv_usec-t1.tv_usec);
98 delay*=1e-3;
99 std::cout << "TIME : " << delay << "; n unpacked : " << nunpacked << "; TIME/unpacked : " << delay/((double)nunpacked) << std::endl;
100 for( auto coll : coll_of_coll )
101 for( const auto& cell : *coll )
102 if ( cell && cell->caloDDE() ) std::cout << "Cell : 0x" << std::hex << cell->ID().get_identifier32().get_compact() << std::dec << " " << cell->energy() << " " << cell->eta() << " " << cell->phi() << " " << cell->caloDDE()->getSampling() << std::endl;
103
104 return StatusCode::SUCCESS;
105}
106
#define ATH_CHECK
Evaluate an expression and check for errors.
double delay(std::size_t d)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
This class provides the client interface for accessing the detector description information common to...
Container Class for LArCell in a ROB used by EF.
Class which contains statically allocated LArCellCollections.
Definition LArCellCont.h:42
HWIdentifier findsec(unsigned int id) const
Each Collection contains data from 2 FEBs.
const std::vector< LArCellCollection * >::const_iterator find(const HWIdentifier &id) const
Finds a collection by its LArReadoutModuleID.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
virtual StatusCode finalize() override
void lateInit(const EventContext &context)
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::once_flag m_lateInitFlag
Gaudi::Property< bool > m_printOut
Gaudi::Property< std::vector< uint32_t > > m_vrodid32fullDet
SG::SlotSpecificObj< EventCache > m_testSlot
virtual StatusCode initialize() override
SG::ReadCondHandleKey< LArFebRodMapping > m_febRodMappingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffIdMappingKey
virtual StatusCode execute(const EventContext &context) override
Execute method.
PublicToolHandle< LArRodDecoder > m_larDecoder
SG::ReadCondHandleKey< LArMCSym > m_mcsymKey
TestLArRodDecoder(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
SG::ReadCondHandleKey< LArRoIMap > m_larRoIMapKey