CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonTrackingRegionBuilder.cc
Go to the documentation of this file.
1 
12 
13 //---------------
14 // C++ Headers --
15 //---------------
16 
17 
18 //-------------------------------
19 // Collaborating Class Headers --
20 //-------------------------------
21 
33 
34 using namespace std;
35 
36 //
37 // constructor
38 //
39 
40 void MuonTrackingRegionBuilder::init(const MuonServiceProxy* service) { theService= service;}
42 {
43  build(par);
44 }
46  // vertex Collection and Beam Spot
47  theBeamSpotTag = par.getParameter<edm::InputTag>("beamSpot");
48  theVertexCollTag = par.getParameter<edm::InputTag>("vertexCollection");
49 
50  // parmeters
51  theNsigmaEta = par.getParameter<double>("Rescale_eta");
52  theNsigmaPhi = par.getParameter<double>("Rescale_phi");
53  theNsigmaDz = par.getParameter<double>("Rescale_Dz");
54  theTkEscapePt = par.getParameter<double>("EscapePt");
55 
56  // upper limits parameters
57  theEtaRegionPar1 = par.getParameter<double>("EtaR_UpperLimit_Par1");
58  theEtaRegionPar2 = par.getParameter<double>("EtaR_UpperLimit_Par2");
59  thePhiRegionPar1 = par.getParameter<double>("PhiR_UpperLimit_Par1");
60  thePhiRegionPar2 = par.getParameter<double>("PhiR_UpperLimit_Par2");
61 
62  useVertex = par.getParameter<bool>("UseVertex");
63  useFixedRegion = par.getParameter<bool>("UseFixedRegion");
64 
65  // fixed limits
66  thePhiFixed = par.getParameter<double>("Phi_fixed");
67  theEtaFixed = par.getParameter<double>("Eta_fixed");
68 
69  thePhiMin = par.getParameter<double>("Phi_min");
70  theEtaMin = par.getParameter<double>("Eta_min");
71  theHalfZ = par.getParameter<double>("DeltaZ_Region");
72  theDeltaR = par.getParameter<double>("DeltaR");
73 
74  // perigee reference point
75 
76  theOnDemand = par.getParameter<double>("OnDemand");
77  theMeasurementTrackerName = par.getParameter<std::string>("MeasurementTrackerName");
78 }
79 
80 
81 //
82 //
83 //
86 
87  return region(*track);
88 
89 }
90 
91 
92 //
93 //
94 //
96 
97  theEvent = &event;
98 
99 }
100 
101 
102 //
103 //
104 //
107 
108  // get the free trajectory state of the muon updated at vertex
109  TSCPBuilderNoMaterial tscpBuilder;
110 
111  FreeTrajectoryState muFTS = trajectoryStateTransform::initialFreeState(staTrack,&*theService->magneticField());
112 
113  LogDebug("MuonTrackingRegionBuilder")<<"from state: "<<muFTS;
114 
115  // get track direction at vertex
116  GlobalVector dirVector(muFTS.momentum());
117 
118  // get track momentum
119  const math::XYZVector& mo = staTrack.innerMomentum();
120  GlobalVector mom(mo.x(),mo.y(),mo.z());
121  if ( staTrack.p() > 1.5 ) {
122  mom = dirVector;
123  }
124 
125  // initial vertex position - in the following it is replaced with beam spot/vertexing
126  GlobalPoint vertexPos(0.0,0.0,0.0);
127  double deltaZatVTX = 0.0;
128 
129  // retrieve beam spot information
131  bool bsHandleFlag = theEvent->getByLabel(theBeamSpotTag, bsHandle);
132  // check the validity, otherwise vertexing
133  // inizialization of BS
134 
135  if ( bsHandleFlag && !useVertex ) {
136  const reco::BeamSpot& bs = *bsHandle;
137  vertexPos = GlobalPoint(bs.x0(), bs.y0(), bs.z0());
138  } else {
139  // get originZPos from list of reconstructed vertices (first or all)
141  bool vtxHandleFlag = theEvent->getByLabel(theVertexCollTag,vertexCollection);
142  // check if there exists at least one reconstructed vertex
143  if ( vtxHandleFlag && !vertexCollection->empty() ) {
144  // use the first vertex in the collection and assume it is the primary event vertex
145  reco::VertexCollection::const_iterator vtx = vertexCollection->begin();
146  vertexPos = GlobalPoint(vtx->x(),vtx->y(),vtx->z());
147  // delta Z from vertex error
148  deltaZatVTX = vtx->zError() * theNsigmaDz;
149  }
150  }
151 
152 
153  // inizialize to the maximum possible value to avoit
154  // problems with TSCBL
155 
156  double deta = 0.4;
157  double dphi = 0.6;
158 
159  // take into account the correct beanspot rotation
160  if ( bsHandleFlag ) {
161 
162  const reco::BeamSpot& bs = *bsHandle;
163 
164  TSCBLBuilderNoMaterial tscblBuilder;
165  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(muFTS,bs);
166 
167 
168  // evaluate the dynamical region if possible
169  if(tscbl.isValid()){
170 
172  GlobalVector pTrack = tscbl.trackStateAtPCA().momentum();
173 
174  // calculate deltaEta from deltaTheta
175  double deltaTheta = trackPerigeeErrors.thetaError();
176  double theta = pTrack.theta();
177  double sin_theta = sin(theta);
178 
179  // get dEta and dPhi
180  deta = theNsigmaEta*(1/fabs(sin_theta))*deltaTheta;
181  dphi = theNsigmaPhi*(trackPerigeeErrors.phiError());
182 
183  }
184  }
185 
186  /* Region_Parametrizations to take into account possible
187  L2 error matrix inconsistencies. Detailed Explanation in TWIKI
188  page.
189  */
190  double region_dEta = 0;
191  double region_dPhi = 0;
192  double eta=0; double phi=0;
193 
194  // eta, pt parametrization from MC study
195  float pt = fabs(mom.perp());
196 
197  if ( pt <= 10. ) {
198  // angular coefficients
199  float acoeff_Phi = (thePhiRegionPar2 - thePhiRegionPar1)/5;
200  float acoeff_Eta = (theEtaRegionPar2 - theEtaRegionPar1)/5;
201 
202  eta = theEtaRegionPar1 + (acoeff_Eta)*(mom.perp()-5.);
203  phi = thePhiRegionPar1 + (acoeff_Phi)*(mom.perp()-5.) ;
204  }
205  // parametrization 2nd bin in pt from MC study
206  if ( pt > 10. && pt < 100. ) {
207  eta = theEtaRegionPar2;
208  phi = thePhiRegionPar2;
209  }
210  // parametrization 3rd bin in pt from MC study
211  if ( pt >= 100. ) {
212  // angular coefficients
213  float acoeff_Phi = (thePhiRegionPar1 - thePhiRegionPar2)/900;
214  float acoeff_Eta = (theEtaRegionPar1 - theEtaRegionPar2)/900;
215 
216  eta = theEtaRegionPar2 + (acoeff_Eta)*(mom.perp()-100.);
217  phi = thePhiRegionPar2 + (acoeff_Phi)*(mom.perp()-100.);
218  }
219 
220  // decide to use either a parametrization or a dynamical region
221  double region_dPhi1 = min(phi,dphi);
222  double region_dEta1 = min(eta,deta);
223 
224  // minimum size
225  region_dPhi = max(thePhiMin,region_dPhi1);
226  region_dEta = max(theEtaMin,region_dEta1);
227 
228  float deltaZ = 0.0;
229  // standard 15.9 is useVertex than region from vertexing
230  if ( useVertex ) {
231  deltaZ = max(theHalfZ,deltaZatVTX);
232  } else {
233  deltaZ = theHalfZ;
234  }
235 
236  float deltaR = theDeltaR;
237  double minPt = max(theTkEscapePt,mom.perp()*0.6);
238 
239  RectangularEtaPhiTrackingRegion* region = 0;
240 
241  if (useFixedRegion) {
242  region_dEta = theEtaFixed;
243  region_dPhi = thePhiFixed;
244  }
245 
246  region = new RectangularEtaPhiTrackingRegion(dirVector, vertexPos,
247  minPt, deltaR,
248  deltaZ, region_dEta, region_dPhi,
249  theOnDemand,
250  true,/*default in the header*/
251  theMeasurementTrackerName);
252 
253  LogDebug("MuonTrackingRegionBuilder")<<"the region parameters are:\n"
254  <<"\n dirVector: "<<dirVector
255  <<"\n vertexPos: "<<vertexPos
256  <<"\n minPt: "<<minPt
257  <<"\n deltaR:"<<deltaR
258  <<"\n deltaZ:"<<deltaZ
259  <<"\n region_dEta:"<<region_dEta
260  <<"\n region_dPhi:"<<region_dPhi
261  <<"\n on demand parameter: "<<theOnDemand;
262 
263 
264  return region;
265 
266 }
#define LogDebug(id)
void build(const edm::ParameterSet &)
RectangularEtaPhiTrackingRegion * region(const reco::TrackRef &) const
define tracking region
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
T getParameter(std::string const &) const
double z0() const
z coordinate
Definition: BeamSpot.h:68
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
T eta() const
tuple vertexCollection
const T & max(const T &a, const T &b)
MuonTrackingRegionBuilder(const edm::ParameterSet &)
constructor
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
GlobalVector momentum() const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void init(const MuonServiceProxy *)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:44
double y0() const
y coordinate
Definition: BeamSpot.h:66
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
double x0() const
x coordinate
Definition: BeamSpot.h:64
Definition: DDAxes.h:10