CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonTimingFiller Class Reference

#include <RecoMuon/MuonIdentification/src/MuonTimingFiller.cc>

Public Member Functions

void fillTiming (const reco::Muon &muon, reco::MuonTimeExtra &dtTime, reco::MuonTimeExtra &cscTime, reco::MuonTimeExtra &combinedTime, edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 MuonTimingFiller (const edm::ParameterSet &)
 
 ~MuonTimingFiller ()
 

Private Member Functions

void addEcalTime (const reco::Muon &muon, TimeMeasurementSequence &cmbSeq)
 
void combineTMSequences (const reco::Muon &muon, TimeMeasurementSequence dtSeq, TimeMeasurementSequence cscSeq, TimeMeasurementSequence &cmbSeq)
 
void fillTimeFromMeasurements (TimeMeasurementSequence tmSeq, reco::MuonTimeExtra &muTime)
 
void rawFit (double &a, double &da, double &b, double &db, const std::vector< double > hitsx, const std::vector< double > hitsy)
 

Private Attributes

double ecalEcut_
 
double errorEB_
 
double errorEE_
 
CSCTimingExtractortheCSCTimingExtractor_
 
DTTimingExtractortheDTTimingExtractor_
 
bool useCSC_
 
bool useDT_
 
bool useECAL_
 

Detailed Description

Description: Class filling the DT, CSC and Combined MuonTimeExtra objects

Implementation: <Notes on="" implementation>="">

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 43 of file MuonTimingFiller.h.

Constructor & Destructor Documentation

MuonTimingFiller::MuonTimingFiller ( const edm::ParameterSet iConfig)

Definition at line 44 of file MuonTimingFiller.cc.

References ecalEcut_, errorEB_, errorEE_, edm::ParameterSet::getParameter(), theCSCTimingExtractor_, theDTTimingExtractor_, useCSC_, useDT_, and useECAL_.

45 {
46  // Load parameters for the DTTimingExtractor
47  edm::ParameterSet dtTimingParameters = iConfig.getParameter<edm::ParameterSet>("DTTimingParameters");
48  theDTTimingExtractor_ = new DTTimingExtractor(dtTimingParameters);
49 
50  // Load parameters for the CSCTimingExtractor
51  edm::ParameterSet cscTimingParameters = iConfig.getParameter<edm::ParameterSet>("CSCTimingParameters");
52  theCSCTimingExtractor_ = new CSCTimingExtractor(cscTimingParameters);
53 
54  errorEB_ = iConfig.getParameter<double>("ErrorEB");
55  errorEE_ = iConfig.getParameter<double>("ErrorEE");
56  ecalEcut_ = iConfig.getParameter<double>("EcalEnergyCut");
57 
58  useDT_ = iConfig.getParameter<bool>("UseDT");
59  useCSC_ = iConfig.getParameter<bool>("UseCSC");
60  useECAL_ = iConfig.getParameter<bool>("UseECAL");
61 
62 }
T getParameter(std::string const &) const
DTTimingExtractor * theDTTimingExtractor_
CSCTimingExtractor * theCSCTimingExtractor_
MuonTimingFiller::~MuonTimingFiller ( )

Definition at line 65 of file MuonTimingFiller.cc.

References theCSCTimingExtractor_, and theDTTimingExtractor_.

66 {
69 }
DTTimingExtractor * theDTTimingExtractor_
CSCTimingExtractor * theCSCTimingExtractor_

Member Function Documentation

void MuonTimingFiller::addEcalTime ( const reco::Muon muon,
TimeMeasurementSequence cmbSeq 
)
private

Definition at line 192 of file MuonTimingFiller.cc.

References reco::Muon::calEnergy(), TimeMeasurementSequence::dstnc, reco::MuonEnergy::ecal_id, reco::MuonEnergy::ecal_position, reco::MuonEnergy::ecal_time, EcalBarrel, ecalEcut_, reco::MuonEnergy::emMax, errorEB_, errorEE_, reco::Muon::isEnergyValid(), TimeMeasurementSequence::local_t0, DetId::subdetId(), TimeMeasurementSequence::totalWeightInvbeta, TimeMeasurementSequence::totalWeightVertex, TimeMeasurementSequence::weightInvbeta, and TimeMeasurementSequence::weightVertex.

Referenced by fillTiming().

193  {
194 
195  reco::MuonEnergy muonE;
196  if (muon.isEnergyValid())
197  muonE = muon.calEnergy();
198 
199  // Cut on the crystal energy and restrict to the ECAL barrel for now
200 // if (muonE.emMax<ecalEcut_ || fabs(muon.eta())>1.5) return;
201  if (muonE.emMax<ecalEcut_) return;
202 
203  // A simple parametrization of the error on the ECAL time measurement
204  double emErr;
205  if (muonE.ecal_id.subdetId()==EcalBarrel) emErr= errorEB_/muonE.emMax; else
206  emErr=errorEE_/muonE.emMax;
207  double hitWeight = 1/(emErr*emErr);
208  double hitDist=muonE.ecal_position.r();
209 
210  cmbSeq.local_t0.push_back(muonE.ecal_time);
211  cmbSeq.weightVertex.push_back(hitWeight);
212  cmbSeq.weightInvbeta.push_back(hitDist*hitDist*hitWeight/(30.*30.));
213 
214  cmbSeq.dstnc.push_back(hitDist);
215 
216  cmbSeq.totalWeightVertex+=hitWeight;
217  cmbSeq.totalWeightInvbeta+=hitDist*hitDist*hitWeight/(30.*30.);
218 
219 }
std::vector< double > local_t0
float ecal_time
Calorimeter timing.
Definition: MuonEnergy.h:37
std::vector< double > weightInvbeta
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool isEnergyValid() const
Definition: Muon.h:110
MuonEnergy calEnergy() const
get energy deposition information
Definition: Muon.h:112
float emMax
maximal energy of ECAL crystal in the 5x5 shape
Definition: MuonEnergy.h:22
DetId ecal_id
DetId of the central ECAL crystal.
Definition: MuonEnergy.h:47
std::vector< double > dstnc
math::XYZPointF ecal_position
Trajectory position at the calorimeter.
Definition: MuonEnergy.h:43
std::vector< double > weightVertex
void MuonTimingFiller::combineTMSequences ( const reco::Muon muon,
TimeMeasurementSequence  dtSeq,
TimeMeasurementSequence  cscSeq,
TimeMeasurementSequence cmbSeq 
)
private

Definition at line 164 of file MuonTimingFiller.cc.

References TimeMeasurementSequence::dstnc, i, TimeMeasurementSequence::local_t0, TimeMeasurementSequence::totalWeightInvbeta, TimeMeasurementSequence::totalWeightVertex, useCSC_, useDT_, TimeMeasurementSequence::weightInvbeta, and TimeMeasurementSequence::weightVertex.

Referenced by fillTiming().

167  {
168 
169  if (useDT_) for (unsigned int i=0;i<dtSeq.dstnc.size();i++) {
170  cmbSeq.dstnc.push_back(dtSeq.dstnc.at(i));
171  cmbSeq.local_t0.push_back(dtSeq.local_t0.at(i));
172  cmbSeq.weightVertex.push_back(dtSeq.weightVertex.at(i));
173  cmbSeq.weightInvbeta.push_back(dtSeq.weightInvbeta.at(i));
174 
175  cmbSeq.totalWeightVertex+=dtSeq.weightVertex.at(i);
176  cmbSeq.totalWeightInvbeta+=dtSeq.weightInvbeta.at(i);
177  }
178 
179  if (useCSC_) for (unsigned int i=0;i<cscSeq.dstnc.size();i++) {
180  cmbSeq.dstnc.push_back(cscSeq.dstnc.at(i));
181  cmbSeq.local_t0.push_back(cscSeq.local_t0.at(i));
182  cmbSeq.weightVertex.push_back(cscSeq.weightVertex.at(i));
183  cmbSeq.weightInvbeta.push_back(cscSeq.weightInvbeta.at(i));
184 
185  cmbSeq.totalWeightVertex+=cscSeq.weightVertex.at(i);
186  cmbSeq.totalWeightInvbeta+=cscSeq.weightInvbeta.at(i);
187  }
188 }
int i
Definition: DBlmapReader.cc:9
std::vector< double > local_t0
std::vector< double > weightInvbeta
std::vector< double > dstnc
std::vector< double > weightVertex
void MuonTimingFiller::fillTimeFromMeasurements ( TimeMeasurementSequence  tmSeq,
reco::MuonTimeExtra muTime 
)
private

Definition at line 116 of file MuonTimingFiller.cc.

References diffTreeTool::diff, TimeMeasurementSequence::dstnc, i, TimeMeasurementSequence::local_t0, rawFit(), reco::MuonTimeExtra::setFreeInverseBeta(), reco::MuonTimeExtra::setFreeInverseBetaErr(), reco::MuonTimeExtra::setInverseBeta(), reco::MuonTimeExtra::setInverseBetaErr(), reco::MuonTimeExtra::setNDof(), reco::MuonTimeExtra::setTimeAtIpInOut(), reco::MuonTimeExtra::setTimeAtIpInOutErr(), reco::MuonTimeExtra::setTimeAtIpOutIn(), reco::MuonTimeExtra::setTimeAtIpOutInErr(), mathSSE::sqrt(), TimeMeasurementSequence::totalWeightInvbeta, TimeMeasurementSequence::totalWeightVertex, TimeMeasurementSequence::weightInvbeta, TimeMeasurementSequence::weightVertex, vdt::x, and detailsBasic3DVector::y.

Referenced by fillTiming().

116  {
117 
118  std::vector <double> x,y;
119  double invbeta=0, invbetaerr=0;
120  double vertexTime=0, vertexTimeErr=0, vertexTimeR=0, vertexTimeRErr=0;
121  double freeBeta, freeBetaErr, freeTime, freeTimeErr;
122 
123  if (tmSeq.dstnc.size()<=1) return;
124 
125  for (unsigned int i=0;i<tmSeq.dstnc.size();i++) {
126  invbeta+=(1.+tmSeq.local_t0.at(i)/tmSeq.dstnc.at(i)*30.)*tmSeq.weightInvbeta.at(i)/tmSeq.totalWeightInvbeta;
127  x.push_back(tmSeq.dstnc.at(i)/30.);
128  y.push_back(tmSeq.local_t0.at(i)+tmSeq.dstnc.at(i)/30.);
129  vertexTime+=tmSeq.local_t0.at(i)*tmSeq.weightVertex.at(i)/tmSeq.totalWeightVertex;
130  vertexTimeR+=(tmSeq.local_t0.at(i)+2*tmSeq.dstnc.at(i)/30.)*tmSeq.weightVertex.at(i)/tmSeq.totalWeightVertex;
131  }
132 
133  double diff;
134  for (unsigned int i=0;i<tmSeq.dstnc.size();i++) {
135  diff=(1.+tmSeq.local_t0.at(i)/tmSeq.dstnc.at(i)*30.)-invbeta;
136  invbetaerr+=diff*diff*tmSeq.weightInvbeta.at(i);
137  diff=tmSeq.local_t0.at(i)-vertexTime;
138  vertexTimeErr+=diff*diff*tmSeq.weightVertex.at(i);
139  diff=tmSeq.local_t0.at(i)+2*tmSeq.dstnc.at(i)/30.-vertexTimeR;
140  vertexTimeRErr+=diff*diff*tmSeq.weightVertex.at(i);
141  }
142 
143  double cf = 1./(tmSeq.dstnc.size()-1);
144  invbetaerr=sqrt(invbetaerr/tmSeq.totalWeightInvbeta*cf);
145  vertexTimeErr=sqrt(vertexTimeErr/tmSeq.totalWeightVertex*cf);
146  vertexTimeRErr=sqrt(vertexTimeRErr/tmSeq.totalWeightVertex*cf);
147 
148  muTime.setInverseBeta(invbeta);
149  muTime.setInverseBetaErr(invbetaerr);
150  muTime.setTimeAtIpInOut(vertexTime);
151  muTime.setTimeAtIpInOutErr(vertexTimeErr);
152  muTime.setTimeAtIpOutIn(vertexTimeR);
153  muTime.setTimeAtIpOutInErr(vertexTimeRErr);
154 
155  rawFit(freeBeta, freeBetaErr, freeTime, freeTimeErr, x, y);
156 
157  muTime.setFreeInverseBeta(freeBeta);
158  muTime.setFreeInverseBetaErr(freeBetaErr);
159 
160  muTime.setNDof(tmSeq.dstnc.size());
161 }
int i
Definition: DBlmapReader.cc:9
void setTimeAtIpOutInErr(const float timeErr)
Definition: MuonTimeExtra.h:52
std::vector< double > local_t0
void rawFit(double &a, double &da, double &b, double &db, const std::vector< double > hitsx, const std::vector< double > hitsy)
void setTimeAtIpOutIn(const float timeIp)
Definition: MuonTimeExtra.h:51
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< double > weightInvbeta
void setNDof(const int nDof)
Definition: MuonTimeExtra.h:24
void setInverseBetaErr(const float iBetaErr)
Definition: MuonTimeExtra.h:31
void setFreeInverseBetaErr(const float iBetaErr)
Definition: MuonTimeExtra.h:40
std::vector< double > dstnc
x
Definition: VDTMath.h:216
void setFreeInverseBeta(const float iBeta)
Definition: MuonTimeExtra.h:39
std::vector< double > weightVertex
void setTimeAtIpInOut(const float timeIp)
Definition: MuonTimeExtra.h:46
void setTimeAtIpInOutErr(const float timeErr)
Definition: MuonTimeExtra.h:47
void setInverseBeta(const float iBeta)
Definition: MuonTimeExtra.h:30
void MuonTimingFiller::fillTiming ( const reco::Muon muon,
reco::MuonTimeExtra dtTime,
reco::MuonTimeExtra cscTime,
reco::MuonTimeExtra combinedTime,
edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 77 of file MuonTimingFiller.cc.

References addEcalTime(), reco::Muon::combinedMuon(), combineTMSequences(), reco::MuonTimeExtra::direction(), fillTimeFromMeasurements(), CSCTimingExtractor::fillTiming(), DTTimingExtractor::fillTiming(), reco::MuonTimeExtra::freeInverseBeta(), reco::MuonTimeExtra::freeInverseBetaErr(), iEvent, reco::MuonTimeExtra::inverseBeta(), reco::MuonTimeExtra::inverseBetaErr(), edm::Ref< C, T, F >::isNull(), LogTrace, reco::MuonTimeExtra::nDof(), reco::Muon::standAloneMuon(), theCSCTimingExtractor_, theDTTimingExtractor_, reco::MuonTimeExtra::timeAtIpInOut(), reco::MuonTimeExtra::timeAtIpInOutErr(), reco::MuonTimeExtra::timeAtIpOutIn(), reco::MuonTimeExtra::timeAtIpOutInErr(), and useECAL_.

Referenced by MuonTimingProducer::produce(), and MuonIdProducer::produce().

78 {
79  TimeMeasurementSequence dtTmSeq,cscTmSeq;
80 
81  if ( !(muon.combinedMuon().isNull()) ) {
82  theDTTimingExtractor_->fillTiming(dtTmSeq, muon.combinedMuon(), iEvent, iSetup);
83  theCSCTimingExtractor_->fillTiming(cscTmSeq, muon.combinedMuon(), iEvent, iSetup);
84  } else
85  if ( !(muon.standAloneMuon().isNull()) ) {
86  theDTTimingExtractor_->fillTiming(dtTmSeq, muon.standAloneMuon(), iEvent, iSetup);
87  theCSCTimingExtractor_->fillTiming(cscTmSeq, muon.standAloneMuon(), iEvent, iSetup);
88  }
89 
90  // Fill DT-specific timing information block
91  fillTimeFromMeasurements(dtTmSeq, dtTime);
92 
93  // Fill CSC-specific timing information block
94  fillTimeFromMeasurements(cscTmSeq, cscTime);
95 
96  // Combine the TimeMeasurementSequences from all subdetectors
97  TimeMeasurementSequence combinedTmSeq;
98  combineTMSequences(muon,dtTmSeq,cscTmSeq,combinedTmSeq);
99  // add ECAL info
100  if (useECAL_) addEcalTime(muon,combinedTmSeq);
101 
102  // Fill the master timing block
103  fillTimeFromMeasurements(combinedTmSeq, combinedTime);
104 
105  LogTrace("MuonTime") << "Global 1/beta: " << combinedTime.inverseBeta() << " +/- " << combinedTime.inverseBetaErr()<<std::endl;
106  LogTrace("MuonTime") << " Free 1/beta: " << combinedTime.freeInverseBeta() << " +/- " << combinedTime.freeInverseBetaErr()<<std::endl;
107  LogTrace("MuonTime") << " Vertex time (in-out): " << combinedTime.timeAtIpInOut() << " +/- " << combinedTime.timeAtIpInOutErr()
108  << " # of points: " << combinedTime.nDof() <<std::endl;
109  LogTrace("MuonTime") << " Vertex time (out-in): " << combinedTime.timeAtIpOutIn() << " +/- " << combinedTime.timeAtIpOutInErr()<<std::endl;
110  LogTrace("MuonTime") << " direction: " << combinedTime.direction() << std::endl;
111 
112 }
void addEcalTime(const reco::Muon &muon, TimeMeasurementSequence &cmbSeq)
float inverseBetaErr() const
Definition: MuonTimeExtra.h:29
float inverseBeta() const
Definition: MuonTimeExtra.h:28
void combineTMSequences(const reco::Muon &muon, TimeMeasurementSequence dtSeq, TimeMeasurementSequence cscSeq, TimeMeasurementSequence &cmbSeq)
Direction direction() const
direction estimation based on time dispersion
Definition: MuonTimeExtra.h:55
float timeAtIpOutInErr() const
Definition: MuonTimeExtra.h:50
int nDof() const
number of measurements used in timing calculation
Definition: MuonTimeExtra.h:23
void fillTiming(TimeMeasurementSequence &tmSequence, reco::TrackRef muonTrack, const edm::Event &iEvent, const edm::EventSetup &iSetup)
int iEvent
Definition: GenABIO.cc:243
bool isNull() const
Checks for null.
Definition: Ref.h:247
float timeAtIpInOutErr() const
Definition: MuonTimeExtra.h:45
float freeInverseBetaErr() const
Definition: MuonTimeExtra.h:38
#define LogTrace(id)
virtual TrackRef combinedMuon() const
reference to a stand-alone muon Track
Definition: Muon.h:56
float timeAtIpInOut() const
Definition: MuonTimeExtra.h:44
DTTimingExtractor * theDTTimingExtractor_
CSCTimingExtractor * theCSCTimingExtractor_
void fillTiming(TimeMeasurementSequence &tmSequence, reco::TrackRef muonTrack, const edm::Event &iEvent, const edm::EventSetup &iSetup)
float freeInverseBeta() const
Definition: MuonTimeExtra.h:37
float timeAtIpOutIn() const
b) particle is moving from outside in
Definition: MuonTimeExtra.h:49
void fillTimeFromMeasurements(TimeMeasurementSequence tmSeq, reco::MuonTimeExtra &muTime)
virtual TrackRef standAloneMuon() const
reference to a stand-alone muon Track
Definition: Muon.h:53
void MuonTimingFiller::rawFit ( double &  a,
double &  da,
double &  b,
double &  db,
const std::vector< double >  hitsx,
const std::vector< double >  hitsy 
)
private

Definition at line 224 of file MuonTimingFiller.cc.

References i, alignCSCRings::s, mathSSE::sqrt(), vdt::x, and detailsBasic3DVector::y.

Referenced by fillTimeFromMeasurements().

224  {
225 
226  double s=0,sx=0,sy=0,x,y;
227  double sxx=0,sxy=0;
228 
229  a=b=0;
230  if (hitsx.size()==0) return;
231  if (hitsx.size()==1) {
232  b=hitsy[0];
233  } else {
234  for (unsigned int i = 0; i != hitsx.size(); i++) {
235  x=hitsx[i];
236  y=hitsy[i];
237  sy += y;
238  sxy+= x*y;
239  s += 1.;
240  sx += x;
241  sxx += x*x;
242  }
243 
244  double d = s*sxx - sx*sx;
245  b = (sxx*sy- sx*sxy)/ d;
246  a = (s*sxy - sx*sy) / d;
247  da = sqrt(sxx/d);
248  db = sqrt(s/d);
249  }
250 }
int i
Definition: DBlmapReader.cc:9
tuple db
Definition: EcalCondDB.py:151
T sqrt(T t)
Definition: SSEVec.h:46
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
x
Definition: VDTMath.h:216

Member Data Documentation

double MuonTimingFiller::ecalEcut_
private

Definition at line 61 of file MuonTimingFiller.h.

Referenced by addEcalTime(), and MuonTimingFiller().

double MuonTimingFiller::errorEB_
private

Definition at line 61 of file MuonTimingFiller.h.

Referenced by addEcalTime(), and MuonTimingFiller().

double MuonTimingFiller::errorEE_
private

Definition at line 61 of file MuonTimingFiller.h.

Referenced by addEcalTime(), and MuonTimingFiller().

CSCTimingExtractor* MuonTimingFiller::theCSCTimingExtractor_
private

Definition at line 60 of file MuonTimingFiller.h.

Referenced by fillTiming(), MuonTimingFiller(), and ~MuonTimingFiller().

DTTimingExtractor* MuonTimingFiller::theDTTimingExtractor_
private

Definition at line 59 of file MuonTimingFiller.h.

Referenced by fillTiming(), MuonTimingFiller(), and ~MuonTimingFiller().

bool MuonTimingFiller::useCSC_
private

Definition at line 62 of file MuonTimingFiller.h.

Referenced by combineTMSequences(), and MuonTimingFiller().

bool MuonTimingFiller::useDT_
private

Definition at line 62 of file MuonTimingFiller.h.

Referenced by combineTMSequences(), and MuonTimingFiller().

bool MuonTimingFiller::useECAL_
private

Definition at line 62 of file MuonTimingFiller.h.

Referenced by fillTiming(), and MuonTimingFiller().