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