ATLAS Offline Software
Loading...
Searching...
No Matches
MuonPrdSelectorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <iomanip>
8
9// Constructor with parameters:
10MuonPrdSelectorAlg::MuonPrdSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
11 : AthAlgorithm(name,pSvcLocator),
12 m_mdtPRDs_in(nullptr), m_rpcPRDs_in(nullptr), m_tgcPRDs_in(nullptr), m_cscPRDs_in(nullptr),
13 m_mdtPRDs_out(nullptr), m_rpcPRDs_out(nullptr), m_tgcPRDs_out(nullptr), m_cscPRDs_out(nullptr)
14{
15 declareProperty("MDT_PRDinputContainer" , m_inputContainer_mdt = "MDT_DriftCircles_unfiltered" );
16 declareProperty("MDT_PRDoutputContainer" , m_outputContainer_mdt = "MDT_DriftCircles" );
17
18 declareProperty("RPC_PRDinputContainer" , m_inputContainer_rpc = "RPC_Measurements_unfiltered" );
19 declareProperty("RPC_PRDoutputContainer" , m_outputContainer_rpc = "RPC_Measurements" );
20
21 declareProperty("TGC_PRDinputContainer" , m_inputContainer_tgc = "TGC_Measurements_unfiltered" );
22 declareProperty("TGC_PRDoutputContainer" , m_outputContainer_tgc = "TGC_Measurements" );
23
24 declareProperty("CSC_PRDinputContainer" , m_inputContainer_csc = "CSC_Measurements_unfiltered" );
25 declareProperty("CSC_PRDoutputContainer" , m_outputContainer_csc = "CSC_Measurements" );
26}
27
28
29// Initialize method:
31{
32 ATH_MSG_DEBUG( "initialize() called" );
33
34 ATH_CHECK( m_idHelperSvc.retrieve() );
35
36 // retrieve test tool
37 ATH_CHECK( m_muonIdCutTool.retrieve() );
38
39 try {
40 m_mdtPRDs_out = new Muon::MdtPrepDataContainer(m_idHelperSvc->mdtIdHelper().module_hash_max());
41 } catch(const std::bad_alloc&) {
42 ATH_MSG_FATAL( "Could not create a new MDT PrepRawData container!" );
43 return StatusCode::FAILURE;
44 }
45 m_mdtPRDs_out->addRef();
46
47
48
49 try {
50 m_rpcPRDs_out = new Muon::RpcPrepDataContainer(m_idHelperSvc->rpcIdHelper().module_hash_max());
51 } catch(const std::bad_alloc&) {
52 ATH_MSG_FATAL( "Could not create a new RPC PrepRawData container!" );
53 return StatusCode::FAILURE;
54 }
55 m_rpcPRDs_out->addRef();
56
57 try {
58 m_tgcPRDs_out = new Muon::TgcPrepDataContainer(m_idHelperSvc->tgcIdHelper().module_hash_max());
59 } catch(const std::bad_alloc&) {
60 ATH_MSG_FATAL( "Could not create a new TGC PrepRawData container!" );
61 return StatusCode::FAILURE;
62 }
63 m_tgcPRDs_out->addRef();
64
65
66 try {
67 m_cscPRDs_out = new Muon::CscStripPrepDataContainer(m_idHelperSvc->cscIdHelper().module_hash_max());
68 } catch(const std::bad_alloc&) {
69 ATH_MSG_FATAL( "Could not create a new CSC PrepRawData container!" );
70 return StatusCode::FAILURE;
71 }
72 m_cscPRDs_out->addRef();
73
74
75 return StatusCode::SUCCESS;
76}
77
79{
80 ATH_MSG_DEBUG( "execute() called" );
84 return StatusCode::SUCCESS;
85}
86
88 ATH_MSG_DEBUG( "retrieveContainers() called" );
89
90 //resetting the inputcollections.
91 m_mdtPRDs_in = nullptr;
92 m_rpcPRDs_in = nullptr;
93 m_tgcPRDs_in = nullptr;
94 m_cscPRDs_in = nullptr;
95
96 StatusCode sc = evtStore()->retrieve( m_mdtPRDs_in, m_inputContainer_mdt );
97 if( sc.isFailure() ) {
98 ATH_MSG_WARNING( "Could not retrieve MDT PRDs input container "
100 } else {
101 ATH_MSG_DEBUG( "Retrieved MDT PRDs input container " << m_inputContainer_mdt << " ( "
102 << m_mdtPRDs_in->size() << " ) " );
103 }
104
106 if( sc.isFailure() ) {
107 ATH_MSG_WARNING( "Could not retrieve RPC PRDs input container "
109 } else {
110 ATH_MSG_DEBUG( "Retrieved RPC PRDs input container " << m_inputContainer_rpc << " ( "
111 << m_rpcPRDs_in->size() << " ) " );
112 }
113
115 if( sc.isFailure() ) {
116 ATH_MSG_WARNING( "Could not retrieve TGC PRDs input container "
118 } else {
119 ATH_MSG_DEBUG( "Retrieved TGC PRDs input container " << m_inputContainer_tgc << " ( "
120 << m_tgcPRDs_in->size() << " ) " );
121 }
122
124 if( sc.isFailure() ) {
125 ATH_MSG_WARNING( "Could not retrieve CSC PRDs input container "
127 } else {
128 ATH_MSG_DEBUG( "Retrieved CSC PRDs input container " << m_inputContainer_csc << " ( "
129 << m_cscPRDs_in->size() << " ) " );
130 }
131
132 return StatusCode::SUCCESS;
133}
134
135
137 StatusCode sc = evtStore()->record( m_mdtPRDs_out, m_outputContainer_mdt );
138 if( sc.isFailure() ) ATH_MSG_DEBUG( "Could not record MDT PRDs to output container " << m_outputContainer_mdt );
139
141 if( sc.isFailure() ) ATH_MSG_DEBUG( "Could not record RPC PRDs to output container " << m_outputContainer_rpc );
142
144 if( sc.isFailure() ) ATH_MSG_DEBUG( "Could not record TGC PRDs to output container " << m_outputContainer_tgc );
145
147 if( sc.isFailure() ) ATH_MSG_DEBUG( "Could not record CSC PRDs to output container " << m_outputContainer_csc );
148 return sc;
149}
150
156
157 return StatusCode::SUCCESS;
158}
159
160
162 StatusCode sc = StatusCode::SUCCESS ;
163
164 // Clearing the outputContainers
165 m_mdtPRDs_out->cleanup();
166
167
168 for (const Muon::MdtPrepDataCollection* mdtColl : *m_mdtPRDs_in) {
169
170 Identifier ID = mdtColl->identify() ;
171 IdentifierHash hashID = mdtColl->identifyHash();
172 auto driftCircleColl = std::make_unique<Muon::MdtPrepDataCollection>(hashID);
173 driftCircleColl->setIdentifier(ID);
174
175 for (const Muon::MdtPrepData* mdt : *mdtColl) {
176 Identifier hitID =mdt->identify();
177
178 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
179
180 driftCircleColl->push_back(new Muon::MdtPrepData(*mdt));
181 ATH_MSG_DEBUG( "Writing Event." );
182 }
183 else
184 ATH_MSG_DEBUG( "Rejecting Event." );
185
186 }
187
188
189 Identifier newID = driftCircleColl->identify();
190 ATH_MSG_DEBUG( "Adding New Collection to MDT list:" << newID );
191 if (StatusCode::SUCCESS != m_mdtPRDs_out->addCollection(driftCircleColl.release(),hashID )) {
192 ATH_MSG_ERROR( "Couldn't record MDT Drift Circle Collection with hash=" << hashID
193 << " in StoreGate!" );
194 continue;
195 }
196 else{
197 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
198 << " in StoreGate!" );
199
200 }
201 }
202 return sc ;
203}
204
205
207 StatusCode sc = StatusCode::SUCCESS ;
208
209 // Clearing the outputContainers
210 m_rpcPRDs_out->cleanup();
211
212
213 for (const Muon::RpcPrepDataCollection* rpcColl : *m_rpcPRDs_in) {
214
215 Identifier ID = rpcColl->identify() ;
216 IdentifierHash hashID = rpcColl->identifyHash();
217 auto rpcPrdColl = std::make_unique<Muon::RpcPrepDataCollection>(hashID);
218 rpcPrdColl->setIdentifier(ID);
219
220 for (const Muon::RpcPrepData* rpc : *rpcColl) {
221 Identifier hitID = rpc->identify();
222
223 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
224
225 rpcPrdColl->push_back(new Muon::RpcPrepData(*rpc));
226 ATH_MSG_DEBUG( "Writing Event." );
227 }
228 else
229 ATH_MSG_DEBUG( "Rejecting Event." );
230
231 }
232
233
234 Identifier newID = rpcPrdColl->identify();
235 ATH_MSG_DEBUG( "Adding New Collection to RPC list:" << newID );
236 if (StatusCode::SUCCESS != m_rpcPRDs_out->addCollection(rpcPrdColl.release(),hashID )) {
237 ATH_MSG_ERROR( "Couldn't record RPC Drift Circle Collection with hashID=" << hashID
238 << " in StoreGate!" );
239 continue;
240 }
241 else{
242 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
243 << " in StoreGate!" );
244
245 }
246 }
247 return sc ;
248}
249
250
252 StatusCode sc = StatusCode::SUCCESS ;
253
254 // Clearing the outputContainers
255 m_tgcPRDs_out->cleanup();
256
257
258 for (const Muon::TgcPrepDataCollection* tgcColl : *m_tgcPRDs_in) {
259
260 Identifier ID = tgcColl->identify() ;
261 IdentifierHash hashID = tgcColl->identifyHash();
262 auto tgcPrdColl = std::make_unique<Muon::TgcPrepDataCollection>(hashID);
263 tgcPrdColl->setIdentifier(ID);
264
265 for (const Muon::TgcPrepData* tgc : *tgcColl) {
266 Identifier hitID = tgc->identify();
267
268 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
269
270 tgcPrdColl->push_back(new Muon::TgcPrepData(*tgc));
271 ATH_MSG_DEBUG( "Writing Event." );
272 }
273 else
274 ATH_MSG_DEBUG( "Rejecting Event." );
275
276 }
277
278
279 Identifier newID = tgcPrdColl->identify();
280 ATH_MSG_DEBUG( "Adding New Collection to TGC list:" << newID );
281 if (StatusCode::SUCCESS != m_tgcPRDs_out->addCollection(tgcPrdColl.release(),hashID )) {
282 ATH_MSG_ERROR( "Couldn't record TGC Drift Circle Collection with hashID=" << hashID
283 << " in StoreGate!" );
284 continue;
285 }
286 else{
287 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
288 << " in StoreGate!" );
289 }
290 }
291 return sc ;
292}
293
294
296 StatusCode sc = StatusCode::SUCCESS ;
297
298 // Clearing the outputContainers
299 m_cscPRDs_out->cleanup();
300
301
302 for (const Muon::CscStripPrepDataCollection* cscColl : *m_cscPRDs_in) {
303
304 Identifier ID = cscColl->identify() ;
305 IdentifierHash hashID = cscColl->identifyHash();
306 auto cscPrdColl = std::make_unique<Muon::CscStripPrepDataCollection>(hashID);
307 cscPrdColl->setIdentifier(ID);
308
309 for (const Muon::CscStripPrepData* csc : *cscColl) {
310 Identifier hitID = csc->identify();
311
312 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
313
314 cscPrdColl->push_back(new Muon::CscStripPrepData(*csc));
315 ATH_MSG_DEBUG( "Writing Event." );
316 }
317 else
318 ATH_MSG_DEBUG( "Rejecting Event." );
319 }
320
321
322 Identifier newID = cscPrdColl->identify();
323 ATH_MSG_DEBUG( "Adding New Collection to CSC list:" << newID );
324 if (StatusCode::SUCCESS != m_cscPRDs_out->addCollection(cscPrdColl.release(),hashID )) {
325 ATH_MSG_ERROR( "Couldn't record CSC Collection with hashID=" << hashID
326 << " in StoreGate!" );
327 continue;
328 }
329 else{
330 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
331 << " in StoreGate!" );
332
333 }
334 }
335 return sc ;
336}
337
338
342 unsigned int i_coll(0);
343 for( ; mdtColl!=last_mdtColl ; ++mdtColl, ++i_coll ){
344 Identifier ID = (*mdtColl)->identify() ;
345 ATH_MSG_DEBUG( "MDT IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
346 }
347
348 mdtColl = m_mdtPRDs_out->begin();
349 last_mdtColl = m_mdtPRDs_out->end();
350 i_coll = 0 ;
351 for( ; mdtColl!=last_mdtColl ; ++mdtColl, ++i_coll ){
352 Identifier ID = (*mdtColl)->identify() ;
353 ATH_MSG_DEBUG( "MDT OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
354 }
355
358 i_coll = 0 ;
359 for( ; rpcColl!=last_rpcColl ; ++rpcColl, ++i_coll ){
360 Identifier ID = (*rpcColl)->identify() ;
361 ATH_MSG_DEBUG( "RPC IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
362 }
363
364 rpcColl = m_rpcPRDs_out->begin();
365 last_rpcColl = m_rpcPRDs_out->end();
366 i_coll = 0 ;
367 for( ; rpcColl!=last_rpcColl ; ++rpcColl, ++i_coll ){
368 Identifier ID = (*rpcColl)->identify() ;
369 ATH_MSG_DEBUG( "RPC OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
370 }
371
372
375 i_coll = 0 ;
376 for( ; tgcColl!=last_tgcColl ; ++tgcColl, ++i_coll ){
377 Identifier ID = (*tgcColl)->identify() ;
378 ATH_MSG_DEBUG( "TGC IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
379 }
380
381 tgcColl = m_tgcPRDs_out->begin();
382 last_tgcColl = m_tgcPRDs_out->end();
383 i_coll = 0 ;
384 for( ; tgcColl!=last_tgcColl ; ++tgcColl, ++i_coll ){
385 Identifier ID = (*tgcColl)->identify() ;
386 ATH_MSG_DEBUG( "TGC OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
387 }
388
391 i_coll = 0 ;
392 for( ; cscColl!=last_cscColl ; ++cscColl, ++i_coll ){
393 Identifier ID = (*cscColl)->identify() ;
394 ATH_MSG_DEBUG( "CSC IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
395 }
396
397 cscColl = m_cscPRDs_out->begin();
398 last_cscColl = m_cscPRDs_out->end();
399 i_coll = 0 ;
400 for( ; cscColl!=last_cscColl ; ++cscColl, ++i_coll ){
401 Identifier ID = (*cscColl)->identify() ;
402 ATH_MSG_DEBUG( "CSC OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
403 }
404
407 i_coll = 0;
408 if (evtStore()->retrieve(mdtCollection,lastColl) ==StatusCode::SUCCESS) {
409 for ( ; mdtCollection != lastColl ; ++mdtCollection ) {
410 ATH_MSG_DEBUG( "DIRECTLY FROM COLL (" <<std::setw(2) << i_coll << ") " << mdtCollection->identify() );
411 }
412 }
413
414}
415
416
417
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::vector< Identifier > ID
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
This is a "hash" representation of an Identifier.
std::string m_outputContainer_rpc
virtual StatusCode execute()
Retrieves and records containers, performs selection.
std::string m_inputContainer_tgc
StatusCode performSelection()
checks if each hit in each collection passes a set of cuts these hits are written to new collections
Muon::RpcPrepDataContainer * m_rpcPRDs_out
std::string m_inputContainer_mdt
Muon::MdtPrepDataContainer * m_mdtPRDs_out
const Muon::RpcPrepDataContainer * m_rpcPRDs_in
std::string m_outputContainer_csc
StatusCode selectMDTs()
selects the hits from MDTcollections
StatusCode retrieveContainers()
retrieves input MuonPrepDataContainers from StoreGate
const Muon::MdtPrepDataContainer * m_mdtPRDs_in
std::string m_inputContainer_csc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode selectCSCs()
selects the hits from CSCcollections
StatusCode selectTGCs()
selects the hits from TGCcollections
MuonPrdSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Athena algorithm constructor.
const Muon::CscStripPrepDataContainer * m_cscPRDs_in
Muon::TgcPrepDataContainer * m_tgcPRDs_out
std::string m_inputContainer_rpc
Muon::CscStripPrepDataContainer * m_cscPRDs_out
ToolHandle< IMuonIdCutTool > m_muonIdCutTool
virtual StatusCode initialize()
Algorithm initialization: retrieves StoreGate/DetectorStore/MuonIdHelpers/MuonPrepDataContainers.
std::string m_outputContainer_mdt
const Muon::TgcPrepDataContainer * m_tgcPRDs_in
StatusCode selectRPCs()
selects the hits from RPCcollections
std::string m_outputContainer_tgc
StatusCode recordContainers()
records output MuonPrepDataContainers to StoreGate
void print()
method for DEBUG purposes: prints the content of input and output MuonPrepDataContainer
Class representing the raw data of one CSC strip (for clusters look at Muon::CscPrepData).
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
Class to represent RPC measurements.
Definition RpcPrepData.h:35
Class to represent TGC measurements.
Definition TgcPrepData.h:32
a const_iterator facade to DataHandle.
Definition SGIterator.h:164
MuonPrepDataCollection< TgcPrepData > TgcPrepDataCollection
MuonPrepDataCollection< CscStripPrepData > CscStripPrepDataCollection
MuonPrepDataContainerT< RpcPrepData > RpcPrepDataContainer
MuonPrepDataContainerT< TgcPrepData > TgcPrepDataContainer
MuonPrepDataContainerT< MdtPrepData > MdtPrepDataContainer
MuonPrepDataContainerT< CscStripPrepData > CscStripPrepDataContainer
MuonPrepDataCollection< MdtPrepData > MdtPrepDataCollection
MuonPrepDataCollection< RpcPrepData > RpcPrepDataCollection