ATLAS Offline Software
RPC_TimingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "RPC_TimingTool.h"
8 
9 namespace Muon {
10 
11  RPC_TimingTool::RPC_TimingTool(const std::string& t, const std::string& n, const IInterface* p) :
12  AthAlgTool(t,n,p) {
13  declareInterface<IMuonHitTimingTool>(this);
14  }
15 
17  ATH_CHECK(m_idHelperSvc.retrieve());
18  return StatusCode::SUCCESS;
19  }
20 
21  IMuonHitTimingTool::TimingResult RPC_TimingTool::calculateTimingResult( const std::vector<const MuonClusterOnTrack*>& hits ) const {
22 
23  // sanity check
24  if( hits.empty() ) return {};
25 
26  ATH_MSG_DEBUG(" calculating timing for hits " << hits.size() );
27 
28  std::vector<int> histogram(100,0);
29  float minTime = -100.;
30  float binwidth = 2*std::abs(minTime)/histogram.size();
31  float invbinwidth = 1./binwidth;
32 
33 
34  for( const auto *hit : hits ){
35  const RpcClusterOnTrack* rpc = dynamic_cast<const RpcClusterOnTrack*>(hit);
36  if( !rpc ) continue;
37  int bin = invbinwidth*(rpc->time()-minTime);
38  ATH_MSG_DEBUG(m_idHelperSvc->toString(hit->identify()) << " time " << rpc->time() << " bin " << bin );
39  if( bin < 0 || bin >= (int)histogram.size() ) continue;
40  ++histogram[bin];
41  }
42  int maxbin = -1;
43  int maxval = 0;
44  for( unsigned int i=0; i<histogram.size();++i ){
45  int val = histogram[i];
46  if( val > maxval ){
47  maxbin = i;
48  maxval = val;
49  }
50  }
51  if( maxbin != -1 ){
52  double time = 0.;
53  unsigned int nhits = 0;
54  double error = getError(*hits.front());
55  for( const auto *hit : hits ){
56  const RpcClusterOnTrack* rpc = dynamic_cast<const RpcClusterOnTrack*>(hit);
57  if( !rpc ) continue;
58  int bin = invbinwidth*(rpc->time()-minTime);
59  ATH_MSG_DEBUG(m_idHelperSvc->toString(hit->identify()) << " time " << rpc->time() << " bin " << bin );
60  // select hits in the max bin or the two neighbouring ones
61  if( bin > maxbin+1 || bin < maxbin-1 ) continue;
62  time += rpc->time();
63  ++nhits;
64  }
65  if( nhits == 0 ) return {};
66  time /= nhits;
67  ATH_MSG_DEBUG( " final time " << time << " error " << error );
68  return {true,time,error};
69  }
70  return {};
71  }
72 
73  double RPC_TimingTool::getError(const MuonClusterOnTrack& rpcRIO) const {
74 
75  // S. Spagnolo: Aug. 5th 2011 - implementation for rel 17 reprocessing (based on slide 8 and 9 of
76  // https://indico.cern.ch/getFile.py/access?contribId=6&resId=0&materialId=slides&confId=147791
77  // ... no calibration offline yet, no correction for signal propagation time)
78  Identifier id = rpcRIO.identify();
79  int measPhi = m_idHelperSvc->measuresPhi(id);
80  MuonStationIndex::StIndex stIndex = m_idHelperSvc->stationIndex(id);
81  if( stIndex == MuonStationIndex::BO) {
82  // outer layer station => high pt
83  if (measPhi==1) return 5.10;
84  return 4.84;
85  }else{
86  // pivot plane of Middle station dbR=2 or low pT confirm dbR=1 but names like "BMS", "BML", etc
87  if (measPhi==1) return 5.04;
88  else return 4.18;
89  }
90  }
91 
92 }
Muon::RPC_TimingTool::initialize
virtual StatusCode initialize()
Definition: RPC_TimingTool.cxx:16
Muon::RPC_TimingTool::getError
double getError(const Muon::MuonClusterOnTrack &) const
calculate error on the RPC time
Definition: RPC_TimingTool.cxx:73
Muon::RPC_TimingTool::calculateTimingResult
TimingResult calculateTimingResult(const std::vector< const MuonClusterOnTrack * > &hits) const
Calculate the time offset of a given set of hits wrt to the current bunch.
Definition: RPC_TimingTool.cxx:21
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Muon::RPC_TimingTool::RPC_TimingTool
RPC_TimingTool(const std::string &, const std::string &, const IInterface *)
Definition: RPC_TimingTool.cxx:11
binwidth
bool binwidth
Definition: listroot.cxx:58
CompetingMuonClustersOnTrack.h
bin
Definition: BinsDiffFromStripMedian.h:43
Muon::RpcClusterOnTrack
Class to represent calibrated clusters formed from RPC strips.
Definition: RpcClusterOnTrack.h:35
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
RPC_TimingTool.h
RpcClusterOnTrack.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
beamspotman.n
n
Definition: beamspotman.py:731
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
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Muon::IMuonHitTimingTool::TimingResult
simple struct holding the result of the tool
Definition: IMuonHitTimingTool.h:39
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
Muon::RpcClusterOnTrack::time
float time() const
Return the time (ns)
Definition: RpcClusterOnTrack.h:159
Muon::RPC_TimingTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: RPC_TimingTool.h:42
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
Muon::MuonStationIndex::BO
@ BO
Definition: MuonStationIndex.h:25
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
Muon::MuonStationIndex::StIndex
StIndex
enum to classify the different station layers in the muon spectrometer
Definition: MuonStationIndex.h:23
AthAlgTool
Definition: AthAlgTool.h:26
error
Definition: IImpactPoint3dEstimator.h:70
histogram
std::string histogram
Definition: chains.cxx:52
Muon::MuonClusterOnTrack
Base class for Muon cluster RIO_OnTracks.
Definition: MuonClusterOnTrack.h:34