ATLAS Offline Software
Loading...
Searching...
No Matches
MuonPrdSelectorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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
170
171 unsigned int i_mdtColl(0);
172
173
174 for( ; mdtColl!=last_mdtColl ; ++mdtColl, ++i_mdtColl ){ //for each collection
175
176 Identifier ID = (*mdtColl)->identify() ;
177 IdentifierHash hashID = (*mdtColl)->identifyHash();
178 Muon::MdtPrepDataCollection * driftCircleColl = new Muon::MdtPrepDataCollection(hashID);
179 (driftCircleColl)->setIdentifier(ID);
180
181 Muon::MdtPrepDataCollection::const_iterator mdtItr = (*mdtColl)->begin();
182 Muon::MdtPrepDataCollection::const_iterator mdtEnd = (*mdtColl)->end();
183 int i = 0;
184
185 for(; mdtItr != mdtEnd; ++mdtItr,i++ ) { //for each hit in the collection
186 Identifier hitID =(*mdtItr)->identify();
187
188 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
189
190 driftCircleColl->push_back(new Muon::MdtPrepData(**mdtItr));
191 ATH_MSG_DEBUG( "Writing Event." );
192 }
193 else
194 ATH_MSG_DEBUG( "Rejecting Event." );
195
196 }
197
198
199 Identifier newID = (driftCircleColl)->identify();
200 ATH_MSG_DEBUG( "Adding New Collection to MDT list:" << newID );
201 if (StatusCode::SUCCESS != m_mdtPRDs_out->addCollection(driftCircleColl,hashID )) {
202 ATH_MSG_ERROR( "Couldn't record MDT Drift Circle Collection with hash=" << hashID
203 << " in StoreGate!" );
204 continue;
205 }
206 else{
207 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
208 << " in StoreGate!" );
209
210 }
211 }
212 return sc ;
213}
214
215
217 StatusCode sc = StatusCode::SUCCESS ;
218
219 // Clearing the outputContainers
220 m_rpcPRDs_out->cleanup();
221
222
225
226 unsigned int i_rpcColl(0);
227
228
229 for( ; rpcColl!=last_rpcColl ; ++rpcColl, ++i_rpcColl ){ //for each collection
230
231 Identifier ID = (*rpcColl)->identify() ;
232 IdentifierHash hashID = (*rpcColl)->identifyHash();
234 (rpcPrdColl)->setIdentifier(ID);
235
236 Muon::RpcPrepDataCollection::const_iterator rpcItr = (*rpcColl)->begin();
237 Muon::RpcPrepDataCollection::const_iterator rpcEnd = (*rpcColl)->end();
238 int i = 0;
239
240 for(; rpcItr != rpcEnd; ++rpcItr,i++ ) { //for each hit in the collection
241 Identifier hitID =(*rpcItr)->identify();
242
243 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
244
245 rpcPrdColl->push_back(new Muon::RpcPrepData(**rpcItr));
246 ATH_MSG_DEBUG( "Writing Event." );
247 }
248 else
249 ATH_MSG_DEBUG( "Rejecting Event." );
250
251 }
252
253
254 Identifier newID = (rpcPrdColl)->identify();
255 ATH_MSG_DEBUG( "Adding New Collection to RPC list:" << newID );
256 if (StatusCode::SUCCESS != m_rpcPRDs_out->addCollection(rpcPrdColl,hashID )) {
257 ATH_MSG_ERROR( "Couldn't record RPC Drift Circle Collection with hashID=" << hashID
258 << " in StoreGate!" );
259 continue;
260 }
261 else{
262 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
263 << " in StoreGate!" );
264
265 }
266 }
267 return sc ;
268}
269
270
272 StatusCode sc = StatusCode::SUCCESS ;
273
274 // Clearing the outputContainers
275 m_tgcPRDs_out->cleanup();
276
277
280
281 unsigned int i_tgcColl(0);
282
283
284 for( ; tgcColl!=last_tgcColl ; ++tgcColl, ++i_tgcColl ){ //for each collection
285
286 Identifier ID = (*tgcColl)->identify() ;
287 IdentifierHash hashID = (*tgcColl)->identifyHash();
289 (tgcPrdColl)->setIdentifier(ID);
290
291 Muon::TgcPrepDataCollection::const_iterator tgcItr = (*tgcColl)->begin();
292 Muon::TgcPrepDataCollection::const_iterator tgcEnd = (*tgcColl)->end();
293 int i = 0;
294
295 for(; tgcItr != tgcEnd; ++tgcItr,i++ ) { //for each hit in the collection
296 Identifier hitID =(*tgcItr)->identify();
297
298 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
299
300 tgcPrdColl->push_back(new Muon::TgcPrepData(**tgcItr));
301 ATH_MSG_DEBUG( "Writing Event." );
302 }
303 else
304 ATH_MSG_DEBUG( "Rejecting Event." );
305
306 }
307
308
309 Identifier newID = (tgcPrdColl)->identify();
310 ATH_MSG_DEBUG( "Adding New Collection to TGC list:" << newID );
311 if (StatusCode::SUCCESS != m_tgcPRDs_out->addCollection(tgcPrdColl,hashID )) {
312 ATH_MSG_ERROR( "Couldn't record TGC Drift Circle Collection with hashID=" << hashID
313 << " in StoreGate!" );
314 continue;
315 }
316 else{
317 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
318 << " in StoreGate!" );
319 }
320 }
321 return sc ;
322}
323
324
326 StatusCode sc = StatusCode::SUCCESS ;
327
328 // Clearing the outputContainers
329 m_cscPRDs_out->cleanup();
330
331
334
335 unsigned int i_cscColl(0);
336
337
338 for( ; cscColl!=last_cscColl ; ++cscColl, ++i_cscColl ){ //for each collection
339
340 Identifier ID = (*cscColl)->identify() ;
341 IdentifierHash hashID = (*cscColl)->identifyHash();
343 (cscPrdColl)->setIdentifier(ID);
344
345 Muon::CscStripPrepDataCollection::const_iterator cscItr = (*cscColl)->begin();
346 Muon::CscStripPrepDataCollection::const_iterator cscEnd = (*cscColl)->end();
347 int i = 0;
348
349 for(; cscItr != cscEnd; ++cscItr,i++ ) { //for each hit in the collection
350 Identifier hitID =(*cscItr)->identify();
351
352 if (!m_muonIdCutTool->isCut(hitID)){ //write event to new collection
353
354 cscPrdColl->push_back(new Muon::CscStripPrepData(**cscItr));
355 ATH_MSG_DEBUG( "Writing Event." );
356 }
357 else
358 ATH_MSG_DEBUG( "Rejecting Event." );
359 }
360
361
362 Identifier newID = (cscPrdColl)->identify();
363 ATH_MSG_DEBUG( "Adding New Collection to CSC list:" << newID );
364 if (StatusCode::SUCCESS != m_cscPRDs_out->addCollection(cscPrdColl,hashID )) {
365 ATH_MSG_ERROR( "Couldn't record CSC Collection with hashID=" << hashID
366 << " in StoreGate!" );
367 continue;
368 }
369 else{
370 ATH_MSG_DEBUG( " Added collection with hashID " << hashID
371 << " in StoreGate!" );
372
373 }
374 }
375 return sc ;
376}
377
378
382 unsigned int i_coll(0);
383 for( ; mdtColl!=last_mdtColl ; ++mdtColl, ++i_coll ){
384 Identifier ID = (*mdtColl)->identify() ;
385 ATH_MSG_DEBUG( "MDT IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
386 }
387
388 mdtColl = m_mdtPRDs_out->begin();
389 last_mdtColl = m_mdtPRDs_out->end();
390 i_coll = 0 ;
391 for( ; mdtColl!=last_mdtColl ; ++mdtColl, ++i_coll ){
392 Identifier ID = (*mdtColl)->identify() ;
393 ATH_MSG_DEBUG( "MDT OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
394 }
395
398 i_coll = 0 ;
399 for( ; rpcColl!=last_rpcColl ; ++rpcColl, ++i_coll ){
400 Identifier ID = (*rpcColl)->identify() ;
401 ATH_MSG_DEBUG( "RPC IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
402 }
403
404 rpcColl = m_rpcPRDs_out->begin();
405 last_rpcColl = m_rpcPRDs_out->end();
406 i_coll = 0 ;
407 for( ; rpcColl!=last_rpcColl ; ++rpcColl, ++i_coll ){
408 Identifier ID = (*rpcColl)->identify() ;
409 ATH_MSG_DEBUG( "RPC OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
410 }
411
412
415 i_coll = 0 ;
416 for( ; tgcColl!=last_tgcColl ; ++tgcColl, ++i_coll ){
417 Identifier ID = (*tgcColl)->identify() ;
418 ATH_MSG_DEBUG( "TGC IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
419 }
420
421 tgcColl = m_tgcPRDs_out->begin();
422 last_tgcColl = m_tgcPRDs_out->end();
423 i_coll = 0 ;
424 for( ; tgcColl!=last_tgcColl ; ++tgcColl, ++i_coll ){
425 Identifier ID = (*tgcColl)->identify() ;
426 ATH_MSG_DEBUG( "TGC OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
427 }
428
431 i_coll = 0 ;
432 for( ; cscColl!=last_cscColl ; ++cscColl, ++i_coll ){
433 Identifier ID = (*cscColl)->identify() ;
434 ATH_MSG_DEBUG( "CSC IN Collection(" << std::setw(2) << i_coll << ") : " << ID );
435 }
436
437 cscColl = m_cscPRDs_out->begin();
438 last_cscColl = m_cscPRDs_out->end();
439 i_coll = 0 ;
440 for( ; cscColl!=last_cscColl ; ++cscColl, ++i_coll ){
441 Identifier ID = (*cscColl)->identify() ;
442 ATH_MSG_DEBUG( "CSC OUT Collection(" << std::setw(2) << i_coll << ") : " << ID );
443 }
444
447 i_coll = 0;
448 if (evtStore()->retrieve(mdtCollection,lastColl) ==StatusCode::SUCCESS) {
449 for ( ; mdtCollection != lastColl ; ++mdtCollection ) {
450 ATH_MSG_DEBUG( "DIRECTLY FROM COLL (" <<std::setw(2) << i_coll << ") " << mdtCollection->identify() );
451 }
452 }
453
454}
455
456
457
#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)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
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