ATLAS Offline Software
FilterUsingMBTSTiming.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 /****
11  * Simple filter for collisions based on the difference of the average MBTS hit time
12  * @author: Sebastian Boeser, Emily Nurse
13  ****/
14 
15 FilterUsingMBTSTiming::FilterUsingMBTSTiming(const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
16 {
17  declareProperty("StoreGateKey", m_mbtsContainerName = "MBTSContainer", "StoreGate key of the MBTS container (default=\"MBTSContainer\")");
18  declareProperty("CellChargeThreshold", m_MBTSThreshold= 40./222. ,"Only count cell above this threshold (default = 40/222[pC])");
19  declareProperty("MaxTimeDifference", m_maxTimeDifference=10., "Maximum difference of the average time of hits on A and C-side (default=10[ns])");
20 }
21 
23 {
24 
25  //Get tile identifier helper
26  if (detStore()->retrieve(m_tileTBID).isFailure()){
27  msg(MSG::ERROR) << "Unable to retrieve TileTBID helper" << endmsg;
28  return StatusCode::FAILURE;
29  }
30 
31 
32  return StatusCode::SUCCESS;
33 }
34 
36 {
37 
38  //Retrieve container from StoreGate
39  const TileCellContainer *tileCellCnt = NULL;
40  if (evtStore()->retrieve(tileCellCnt, m_mbtsContainerName).isFailure()) {
41  msg(MSG::WARNING) << "Unable to retrieving MBTS container with name " << m_mbtsContainerName << endmsg;
42  return StatusCode::SUCCESS;
43  }
44 
45  //Calculate average time for A and C side
46  float timeA = 0.;
47  float timeC = 0.;
48  unsigned int countA = 0;
49  unsigned int countC = 0;
50 
51  //Loop over tile cells
52  TileCellContainer::const_iterator MBTSCellItr = tileCellCnt->begin();
53  TileCellContainer::const_iterator MBTSCellsEnd = tileCellCnt->end();
54  for (; MBTSCellItr != MBTSCellsEnd; ++MBTSCellItr) {
55 
56  // Discriminate the signals
57  if ((*MBTSCellItr)->energy() < m_MBTSThreshold) continue ;
58 
59  msg(MSG::DEBUG) << "Energy = " << (*MBTSCellItr)->energy() << " pC\t";
60  msg(MSG::DEBUG) << "Time = " << (*MBTSCellItr)->time() << " ns\t";
61  msg(MSG::DEBUG) << "Side = " << (( m_tileTBID->type((*MBTSCellItr)->ID()) > 0 ) ? "A" : "C") << endmsg;
62 
63  // cache type, module and channel
64  // MBTS Id type is "side" +/- 1
65  if (m_tileTBID->type((*MBTSCellItr)->ID()) > 0) {
66  timeA += (*MBTSCellItr)->time();
67  countA++ ;
68  } else {
69  timeC += (*MBTSCellItr)->time();
70  countC++;
71  }
72  }
73 
74  //Make sure we have a least n hits on each side
75  if ( countA < 1 || countC < 1 ){
76  msg(MSG::INFO) << "Need at least one hit on each side" << endmsg;
77  setFilterPassed(false);
78  msg(MSG::INFO ) << "Event is rejected" << endmsg;
79  return StatusCode::SUCCESS;
80  }
81 
82  // Calculate the time difference
83  float timeDiff = fabs(timeA/countA - timeC/countC);
84  msg(MSG::INFO) << "Calculated time difference of " << timeDiff << " ns" << endmsg;
85 
86  //And cut
87  if (timeDiff <= m_maxTimeDifference) {
88  setFilterPassed(true);
89  msg(MSG::INFO ) << "Event is accepted" << endmsg;
90  } else {
91  setFilterPassed(false);
92  msg(MSG::INFO ) << "Event is rejected" << endmsg;
93  }
94 
95  return StatusCode::SUCCESS;
96 }
97 
99 {
100  return StatusCode::SUCCESS;
101 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
FilterUsingMBTSTiming::FilterUsingMBTSTiming
FilterUsingMBTSTiming(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FilterUsingMBTSTiming.cxx:15
FilterUsingMBTSTiming::execute
StatusCode execute()
Definition: FilterUsingMBTSTiming.cxx:35
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TileTBID::type
int type(const Identifier &id) const
extract type field from TileTB identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:146
FilterUsingMBTSTiming::initialize
StatusCode initialize()
Definition: FilterUsingMBTSTiming.cxx:22
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FilterUsingMBTSTiming::m_MBTSThreshold
float m_MBTSThreshold
Only count cell above this threshold (default = 40/222[pC])");.
Definition: FilterUsingMBTSTiming.h:32
FilterUsingMBTSTiming::finalize
StatusCode finalize()
Definition: FilterUsingMBTSTiming.cxx:98
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
FilterUsingMBTSTiming.h
FilterUsingMBTSTiming::m_tileTBID
const TileTBID * m_tileTBID
Definition: FilterUsingMBTSTiming.h:38
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
TileTBID.h
FilterUsingMBTSTiming::m_mbtsContainerName
std::string m_mbtsContainerName
MBTSContainer", "StoreGate key of the MBTS container (default="MBTSContainer")");.
Definition: FilterUsingMBTSTiming.h:30
TileContainer.h
TileContainer
Definition: TileContainer.h:38
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
FilterUsingMBTSTiming::m_maxTimeDifference
float m_maxTimeDifference
Maximum difference of the average time of hits on A and C-side (default=10[ns])");.
Definition: FilterUsingMBTSTiming.h:34