ATLAS Offline Software
MBTSTimeFilterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <float.h>
8 namespace {
9  constexpr float tile_eta_start = 1.5;
10 }
11 
12 
13 MBTSTimeFilterTool::MBTSTimeFilterTool( const std::string& tool_name) :
14  asg::AsgTool( tool_name) {}
15 
17  ATH_MSG_DEBUG ("initialize()");
19  return StatusCode::SUCCESS;
20 }
21 
22 
24  const TileCellContainer* tileCellCnt = nullptr;
26  fillTimeDifference(time_info,tileCellCnt);
27  return StatusCode::SUCCESS;
28 }
31  const EventContext& ctx) const{
32  ATH_MSG_DEBUG ("execute()");
33  SG::ReadHandle<TileCellContainer> readHandle{key,ctx};
34  if (!readHandle.isValid()){
35  ATH_MSG_FATAL (key <<" requested but not found.");
36  return StatusCode::FAILURE;
37  }
38  fillTimeDifference(time_info, readHandle.cptr());
39  return StatusCode::SUCCESS;
40 }
42 
43  for(const TileCell* tile : *tileCellCnt) {
44 
45  // check charge passes threshold
46  const float charge = tile->energy();
47  ATH_MSG_DEBUG ("Energy =" << charge << "pC");
48  if(charge < m_chargethreshold) continue;
49 
50  // only endcap
51  const float eta = tile->eta();
52  ATH_MSG_DEBUG ("Eta =" << eta);
53  if ( std::abs(eta) < tile_eta_start) continue;
54 
55  const Identifier id= tile->ID();
56  // cache type, module and channel
57  // MBTS Id type is "side" +/- 1
58  const int type_id = m_tileTBID->type(id);
59  // MBTS Id module is "phi" 0-7
60  const int module_id = m_tileTBID->module(id);
61  // MBTS Id channel is "eta" 0-1 zero is closer to beam pipe
62  const int channel_id = m_tileTBID->channel(id);
63 
64  // Catch errors
65  if( std::abs(type_id) != 1 ){
66  ATH_MSG_WARNING ("MBTS identifier type is out of range.");
67  continue;
68  }
69  if( channel_id < 0 || channel_id > 1 ){
70  ATH_MSG_WARNING ("MBTS identifier channel is out of range.");
71  continue;
72  }
73  if( module_id < 0 || module_id > 7 ){
74  ATH_MSG_WARNING ("MBTS identifier module is out of range.");
75  continue;
76  }
77 
78  if (type_id > 0) {
79  time_info.timeA += tile->time();
80  ++time_info.ncellA ;
81  } else {
82  time_info.timeC += tile->time();
83  ++time_info.ncellC;
84  }
85  }
86 
87  if(time_info.ncellA + time_info.ncellC > 32)
88  ATH_MSG_WARNING ("There shoule be <=32 MBTS TileCells " << (time_info.ncellA + time_info.ncellC) << " were found.");
89 
90  if ( time_info.ncellA > 0 ) time_info.timeA /= time_info.ncellA;
91  if ( time_info.ncellC > 0 ) time_info.timeC /= time_info.ncellC;
92 
93  time_info.timeDiff = FLT_MAX; // Or whatever default you want
94  if ( time_info.ncellA >= m_minhitsperside && time_info.ncellC >= m_minhitsperside ) { time_info.timeDiff = (time_info.timeA - time_info.timeC); }
95  time_info.passCut = ( std::abs(time_info.timeDiff) < m_maxtimediff);
96 
97 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileCell
Definition: TileCell.h:57
MBTSTimeFilterTool::m_mbtsContainerName
Gaudi::Property< std::string > m_mbtsContainerName
Definition: MBTSTimeFilterTool.h:41
TimingFilterInformation
Simple helper struct used to obtain the timing information by the IMBTSTimeFilter and ICaloTimerFilte...
Definition: TimingFilterInformation.h:10
TimingFilterInformation::ncellA
int ncellA
Definition: TimingFilterInformation.h:20
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MBTSTimeFilterTool::m_maxtimediff
Gaudi::Property< float > m_maxtimediff
Definition: MBTSTimeFilterTool.h:40
MBTSTimeFilterTool::MBTSTimeFilterTool
MBTSTimeFilterTool(const std::string &tool_name)
Definition: MBTSTimeFilterTool.cxx:13
MBTSTimeFilterTool.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MBTSTimeFilterTool::m_tileTBID
const TileTBID * m_tileTBID
For access to the tile test beam identifiers.
Definition: MBTSTimeFilterTool.h:35
TimingFilterInformation::passCut
bool passCut
Definition: TimingFilterInformation.h:12
asg
Definition: DataHandleTestTool.h:28
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
TileTBID::type
int type(const Identifier &id) const
extract type field from TileTB identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:146
MBTSTimeFilterTool::initialize
virtual StatusCode initialize() override
Overriding initialize and finalize.
Definition: MBTSTimeFilterTool.cxx:16
TileTBID::module
int module(const Identifier &id) const
extract module field from TileTB identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:150
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
ReadCellNoiseFromCool.tile
tile
Definition: ReadCellNoiseFromCool.py:92
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
TimingFilterInformation::ncellC
int ncellC
Definition: TimingFilterInformation.h:21
TimingFilterInformation::timeDiff
double timeDiff
Definition: TimingFilterInformation.h:14
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
createCoolChannelIdFile.channel_id
channel_id
Definition: createCoolChannelIdFile.py:52
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileTBID::channel
int channel(const Identifier &id) const
extract channel field from TileTB identifier
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:154
charge
double charge(const T &p)
Definition: AtlasPID.h:494
MBTSTimeFilterTool::m_minhitsperside
Gaudi::Property< int > m_minhitsperside
Definition: MBTSTimeFilterTool.h:39
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MBTSTimeFilterTool::m_chargethreshold
Gaudi::Property< float > m_chargethreshold
Definition: MBTSTimeFilterTool.h:38
TimingFilterInformation::timeA
double timeA
Definition: TimingFilterInformation.h:16
MBTSTimeFilterTool::fillTimeDifference
void fillTimeDifference(TimingFilterInformation &time_info, const TileCellContainer *container) const
Once the container is retrieve the filling mechanism is the same.
Definition: MBTSTimeFilterTool.cxx:41
TileContainer.h
TileContainer
Definition: TileContainer.h:38
TimingFilterInformation::timeC
double timeC
Definition: TimingFilterInformation.h:18
MBTSTimeFilterTool::getTimeDifference
virtual StatusCode getTimeDifference(TimingFilterInformation &time_info, const SG::ReadHandleKey< TileCellContainer > &key, const EventContext &ctx) const override
Caching method using the ReadHandles.
Definition: MBTSTimeFilterTool.cxx:29
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37