ATLAS Offline Software
Loading...
Searching...
No Matches
ReadLArRaw.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6
7 Kin Yip : May 22, 2002
8
9 barrel_ec in software description has changed the definition.
10
11 Now, we have +-1 for Barrel
12 +-2,3 for EndCap
13
14 "pos_neg" in the ntuple is equivalent to "barrel_ec" in software description.
15
16 Hong Ma : Aug 30, 2002
17 Add testing of RoI.
18 */
19
20
21//#include <strstream>
22
23#include "GaudiKernel/MsgStream.h"
28
31#include "ReadLArRaw.h"
32
33// access all RawChannel
34//#include "EventContainers/SelectAllObject.h"
35// access RawChannel in TrigTower
36// #include "LArRawUtils/LArRawRoISelector.h"
37//#include "LArRawUtils/LArTT_Selector.h"
38
40
41using namespace std ;
42
43//const int max_chan = 2800 ;
44
46
47ReadLArRaw::ReadLArRaw(const std::string& name, ISvcLocator* pSvcLocator) :
48 AthAlgorithm(name, pSvcLocator),
49 m_ChannelContainerName("LArRawChannelContainer"),
50 m_onlineID(nullptr),
51 m_larem_id(nullptr)
52{
53 // Declare the properties
54 declareProperty("LArRawChannelContainerName",m_ChannelContainerName);
55 declareProperty("DumpFile",m_dumpFile="");
56}
57
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
59
61{
62 ATH_MSG_INFO( "in initialize()" );
63
64 ATH_CHECK(m_cablingKey.initialize());
65
66 ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
67
68// retrieve helpers for identifier
69 const CaloCell_ID* idHelper = nullptr;
70 ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
71 m_larem_id = idHelper->em_idHelper();
72
73
74
75 if (!m_dumpFile.empty()) {
76 m_outFile.open(m_dumpFile.c_str());
77 }
78
79 // after all these ...
80 return StatusCode::SUCCESS;
81
82}
83
84// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
85
86StatusCode ReadLArRaw::execute() {
87
88 ATH_MSG_DEBUG( "in execute()" );
89 const LArRawChannelContainer* LArRaw ;
90 ATH_CHECK( evtStore()->retrieve (LArRaw, m_ChannelContainerName) );
91
92
93 int emax= 0;
94 HWIdentifier maxId;
95
97 const LArOnOffIdMapping* cabling{*cablingHdl};
98 if(!cabling) {
99 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key());
100 return StatusCode::FAILURE;
101 }
102
103 LArRawChannelContainer::const_iterator it1 = LArRaw->begin();
104 LArRawChannelContainer::const_iterator it2 = LArRaw->end();
105 for(; it1!=it2; ++it1){
106 HWIdentifier ch_id=it1->identify();
107 if (m_outFile.is_open()) {
108 if(cabling->isOnlineConnected(ch_id))
109 m_outFile << "LArRawChannelDump: 0x" << std::hex << ch_id.get_compact() << std::dec << " E=" << it1->energy()
110 << " t=" << it1->time() << " g=" << (int)it1->gain() << " Q=" << it1->quality() << std::endl;
111 }
112
113 if(emax<it1->energy() ) {
114 emax=it1->energy() ;
115 maxId =ch_id;
116 // use LArOnlineID methods
117 ATH_MSG_VERBOSE( "--barrel_ec : " << m_onlineID->barrel_ec(ch_id)
118 << " Pos_neg : " << m_onlineID->pos_neg(ch_id)
119 << " FeedThrough no. : " << m_onlineID->feedthrough(ch_id)
120 << " slot no. : " << m_onlineID->slot(ch_id)
121 << " channel no. : " << m_onlineID->channel(ch_id)
122 );
123
124 ATH_MSG_DEBUG( "Energy = " << it1->energy() << "; Time = "
125 << it1->time()
126 << "; Chi-Square = " << it1->quality() );
127 }
128 ATH_MSG_DEBUG( " Channel with max energy , maxID = "<< emax<<" "<<maxId.getString() );
129 }
130
131 return StatusCode::SUCCESS;
132}
133
134// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
135
137
138 if (m_outFile.is_open())
139 m_outFile.close();
140 ATH_MSG_INFO( "in finalize()" );
141
142 return StatusCode::SUCCESS;
143}
144
145
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition CaloCell_ID.h:63
std::string getString() const
Provide a string form of the identifier - hexadecimal.
value_type get_compact() const
Get the compact id.
Container for LArRawChannel (IDC using LArRawChannelCollection)
std::string m_ChannelContainerName
Definition ReadLArRaw.h:35
virtual StatusCode execute()
virtual StatusCode finalize()
ReadLArRaw(const std::string &name, ISvcLocator *pSvcLocator)
std::ofstream m_outFile
Definition ReadLArRaw.h:37
const LArEM_ID * m_larem_id
Definition ReadLArRaw.h:42
std::string m_dumpFile
Definition ReadLArRaw.h:36
const LArOnlineID * m_onlineID
Definition ReadLArRaw.h:41
virtual StatusCode initialize()
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition ReadLArRaw.h:39
STL namespace.