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 &, edm::ConsumesCollector &&iC)
 
 ~MuonTimingFiller ()
 

Private Member Functions

void addEcalTime (const reco::Muon &muon, TimeMeasurementSequence &cmbSeq)
 
void combineTMSequences (const reco::Muon &muon, const TimeMeasurementSequence &dtSeq, const TimeMeasurementSequence &cscSeq, TimeMeasurementSequence &cmbSeq)
 
void fillTimeFromMeasurements (const 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 42 of file MuonTimingFiller.h.

Constructor & Destructor Documentation

MuonTimingFiller::MuonTimingFiller ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 43 of file MuonTimingFiller.cc.

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

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

Definition at line 64 of file MuonTimingFiller.cc.

References theCSCTimingExtractor_, and theDTTimingExtractor_.

65 {
68 }
DTTimingExtractor * theDTTimingExtractor_
CSCTimingExtractor * theCSCTimingExtractor_

Member Function Documentation

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

Definition at line 191 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().

192  {
193 
194  reco::MuonEnergy muonE;
195  if (muon.isEnergyValid())
196  muonE = muon.calEnergy();
197 
198  // Cut on the crystal energy and restrict to the ECAL barrel for now
199 // if (muonE.emMax<ecalEcut_ || fabs(muon.eta())>1.5) return;
200  if (muonE.emMax<ecalEcut_) return;
201 
202  // A simple parametrization of the error on the ECAL time measurement
203  double emErr;
204  if (muonE.ecal_id.subdetId()==EcalBarrel) emErr= errorEB_/muonE.emMax; else
205  emErr=errorEE_/muonE.emMax;
206  double hitWeight = 1/(emErr*emErr);
207  double hitDist=muonE.ecal_position.r();
208 
209  cmbSeq.local_t0.push_back(muonE.ecal_time);
210  cmbSeq.weightVertex.push_back(hitWeight);
211  cmbSeq.weightInvbeta.push_back(hitDist*hitDist*hitWeight/(30.*30.));
212 
213  cmbSeq.dstnc.push_back(hitDist);
214 
215  cmbSeq.totalWeightVertex+=hitWeight;
216  cmbSeq.totalWeightInvbeta+=hitDist*hitDist*hitWeight/(30.*30.);
217 
218 }
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:37
bool isEnergyValid() const
Definition: Muon.h:109
MuonEnergy calEnergy() const
get energy deposition information
Definition: Muon.h:111
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,
const TimeMeasurementSequence dtSeq,
const TimeMeasurementSequence cscSeq,
TimeMeasurementSequence cmbSeq 
)
private

Definition at line 163 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().

166  {
167 
168  if (useDT_) for (unsigned int i=0;i<dtSeq.dstnc.size();i++) {
169  cmbSeq.dstnc.push_back(dtSeq.dstnc.at(i));
170  cmbSeq.local_t0.push_back(dtSeq.local_t0.at(i));
171  cmbSeq.weightVertex.push_back(dtSeq.weightVertex.at(i));
172  cmbSeq.weightInvbeta.push_back(dtSeq.weightInvbeta.at(i));
173 
174  cmbSeq.totalWeightVertex+=dtSeq.weightVertex.at(i);
175  cmbSeq.totalWeightInvbeta+=dtSeq.weightInvbeta.at(i);
176  }
177 
178  if (useCSC_) for (unsigned int i=0;i<cscSeq.dstnc.size();i++) {
179  cmbSeq.dstnc.push_back(cscSeq.dstnc.at(i));
180  cmbSeq.local_t0.push_back(cscSeq.local_t0.at(i));
181  cmbSeq.weightVertex.push_back(cscSeq.weightVertex.at(i));
182  cmbSeq.weightInvbeta.push_back(cscSeq.weightInvbeta.at(i));
183 
184  cmbSeq.totalWeightVertex+=cscSeq.weightVertex.at(i);
185  cmbSeq.totalWeightInvbeta+=cscSeq.weightInvbeta.at(i);
186  }
187 }
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 ( const TimeMeasurementSequence tmSeq,
reco::MuonTimeExtra muTime 
)
private

Definition at line 115 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, x, and detailsBasic3DVector::y.

Referenced by fillTiming().

115  {
116 
117  std::vector <double> x,y;
118  double invbeta=0, invbetaerr=0;
119  double vertexTime=0, vertexTimeErr=0, vertexTimeR=0, vertexTimeRErr=0;
120  double freeBeta, freeBetaErr, freeTime, freeTimeErr;
121 
122  if (tmSeq.dstnc.size()<=1) return;
123 
124  for (unsigned int i=0;i<tmSeq.dstnc.size();i++) {
125  invbeta+=(1.+tmSeq.local_t0.at(i)/tmSeq.dstnc.at(i)*30.)*tmSeq.weightInvbeta.at(i)/tmSeq.totalWeightInvbeta;
126  x.push_back(tmSeq.dstnc.at(i)/30.);
127  y.push_back(tmSeq.local_t0.at(i)+tmSeq.dstnc.at(i)/30.);
128  vertexTime+=tmSeq.local_t0.at(i)*tmSeq.weightVertex.at(i)/tmSeq.totalWeightVertex;
129  vertexTimeR+=(tmSeq.local_t0.at(i)+2*tmSeq.dstnc.at(i)/30.)*tmSeq.weightVertex.at(i)/tmSeq.totalWeightVertex;
130  }
131 
132  double diff;
133  for (unsigned int i=0;i<tmSeq.dstnc.size();i++) {
134  diff=(1.+tmSeq.local_t0.at(i)/tmSeq.dstnc.at(i)*30.)-invbeta;
135  invbetaerr+=diff*diff*tmSeq.weightInvbeta.at(i);
136  diff=tmSeq.local_t0.at(i)-vertexTime;
137  vertexTimeErr+=diff*diff*tmSeq.weightVertex.at(i);
138  diff=tmSeq.local_t0.at(i)+2*tmSeq.dstnc.at(i)/30.-vertexTimeR;
139  vertexTimeRErr+=diff*diff*tmSeq.weightVertex.at(i);
140  }
141 
142  double cf = 1./(tmSeq.dstnc.size()-1);
143  invbetaerr=sqrt(invbetaerr/tmSeq.totalWeightInvbeta*cf);
144  vertexTimeErr=sqrt(vertexTimeErr/tmSeq.totalWeightVertex*cf);
145  vertexTimeRErr=sqrt(vertexTimeRErr/tmSeq.totalWeightVertex*cf);
146 
147  muTime.setInverseBeta(invbeta);
148  muTime.setInverseBetaErr(invbetaerr);
149  muTime.setTimeAtIpInOut(vertexTime);
150  muTime.setTimeAtIpInOutErr(vertexTimeErr);
151  muTime.setTimeAtIpOutIn(vertexTimeR);
152  muTime.setTimeAtIpOutInErr(vertexTimeRErr);
153 
154  rawFit(freeBeta, freeBetaErr, freeTime, freeTimeErr, x, y);
155 
156  muTime.setFreeInverseBeta(freeBeta);
157  muTime.setFreeInverseBetaErr(freeBetaErr);
158 
159  muTime.setNDof(tmSeq.dstnc.size());
160 }
int i
Definition: DBlmapReader.cc:9
void setTimeAtIpOutInErr(const float timeErr)
Definition: MuonTimeExtra.h:51
std::vector< double > local_t0
void setTimeAtIpOutIn(const float timeIp)
Definition: MuonTimeExtra.h:50
T sqrt(T t)
Definition: SSEVec.h:48
void rawFit(double &a, double &da, double &b, double &db, const std::vector< double > &hitsx, const std::vector< double > &hitsy)
std::vector< double > weightInvbeta
void setNDof(const int nDof)
Definition: MuonTimeExtra.h:23
void setInverseBetaErr(const float iBetaErr)
Definition: MuonTimeExtra.h:30
void setFreeInverseBetaErr(const float iBetaErr)
Definition: MuonTimeExtra.h:39
Definition: DDAxes.h:10
std::vector< double > dstnc
void setFreeInverseBeta(const float iBeta)
Definition: MuonTimeExtra.h:38
std::vector< double > weightVertex
void setTimeAtIpInOut(const float timeIp)
Definition: MuonTimeExtra.h:45
void setTimeAtIpInOutErr(const float timeErr)
Definition: MuonTimeExtra.h:46
void setInverseBeta(const float iBeta)
Definition: MuonTimeExtra.h:29
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 76 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().

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

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

Referenced by fillTimeFromMeasurements().

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

Member Data Documentation

double MuonTimingFiller::ecalEcut_
private

Definition at line 60 of file MuonTimingFiller.h.

Referenced by addEcalTime(), and MuonTimingFiller().

double MuonTimingFiller::errorEB_
private

Definition at line 60 of file MuonTimingFiller.h.

Referenced by addEcalTime(), and MuonTimingFiller().

double MuonTimingFiller::errorEE_
private

Definition at line 60 of file MuonTimingFiller.h.

Referenced by addEcalTime(), and MuonTimingFiller().

CSCTimingExtractor* MuonTimingFiller::theCSCTimingExtractor_
private

Definition at line 59 of file MuonTimingFiller.h.

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

DTTimingExtractor* MuonTimingFiller::theDTTimingExtractor_
private

Definition at line 58 of file MuonTimingFiller.h.

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

bool MuonTimingFiller::useCSC_
private

Definition at line 61 of file MuonTimingFiller.h.

Referenced by combineTMSequences(), and MuonTimingFiller().

bool MuonTimingFiller::useDT_
private

Definition at line 61 of file MuonTimingFiller.h.

Referenced by combineTMSequences(), and MuonTimingFiller().

bool MuonTimingFiller::useECAL_
private

Definition at line 61 of file MuonTimingFiller.h.

Referenced by fillTiming(), and MuonTimingFiller().