CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ShallowTrackClustersProducer.cc
Go to the documentation of this file.
2 
4 
11 
23 #include "boost/foreach.hpp"
24 
26 
28  : theTracksLabel( iConfig.getParameter<edm::InputTag>("Tracks") ),
29  theClustersLabel( iConfig.getParameter<edm::InputTag>("Clusters") ),
30  Suffix ( iConfig.getParameter<std::string>("Suffix") ),
31  Prefix ( iConfig.getParameter<std::string>("Prefix") )
32 {
33  produces <std::vector<unsigned int> > ( Prefix + "trackmulti" + Suffix );
34  produces <std::vector<int> > ( Prefix + "trackindex" + Suffix );
35  produces <std::vector<float> > ( Prefix + "localtheta" + Suffix );
36  produces <std::vector<float> > ( Prefix + "localphi" + Suffix );
37  produces <std::vector<float> > ( Prefix + "localpitch" + Suffix );
38  produces <std::vector<float> > ( Prefix + "localx" + Suffix );
39  produces <std::vector<float> > ( Prefix + "localy" + Suffix );
40  produces <std::vector<float> > ( Prefix + "localz" + Suffix );
41  produces <std::vector<float> > ( Prefix + "strip" + Suffix );
42  produces <std::vector<float> > ( Prefix + "globaltheta" + Suffix );
43  produces <std::vector<float> > ( Prefix + "globalphi" + Suffix );
44  produces <std::vector<float> > ( Prefix + "globalx" + Suffix );
45  produces <std::vector<float> > ( Prefix + "globaly" + Suffix );
46  produces <std::vector<float> > ( Prefix + "globalz" + Suffix );
47  produces <std::vector<float> > ( Prefix + "insidistance"+ Suffix );
48  produces <std::vector<float> > ( Prefix + "covered" + Suffix );
49  produces <std::vector<float> > ( Prefix + "projwidth" + Suffix );
50  produces <std::vector<float> > ( Prefix + "BdotY" + Suffix );
51 
52  produces <std::vector<float> > ( Prefix + "rhlocalx" + Suffix );
53  produces <std::vector<float> > ( Prefix + "rhlocaly" + Suffix );
54  produces <std::vector<float> > ( Prefix + "rhlocalxerr" + Suffix );
55  produces <std::vector<float> > ( Prefix + "rhlocalyerr" + Suffix );
56  produces <std::vector<float> > ( Prefix + "rhglobalx" + Suffix );
57  produces <std::vector<float> > ( Prefix + "rhglobaly" + Suffix );
58  produces <std::vector<float> > ( Prefix + "rhglobalz" + Suffix );
59  produces <std::vector<float> > ( Prefix + "rhstrip" + Suffix );
60  produces <std::vector<float> > ( Prefix + "rhmerr" + Suffix );
61 
62  produces <std::vector<float> > ( Prefix + "ubstrip" + Suffix );
63  produces <std::vector<float> > ( Prefix + "ubmerr" + Suffix );
64 
65  produces <std::vector<float> > ( Prefix + "driftx" + Suffix );
66  produces <std::vector<float> > ( Prefix + "drifty" + Suffix );
67  produces <std::vector<float> > ( Prefix + "driftz" + Suffix );
68  produces <std::vector<float> > ( Prefix + "globalZofunitlocalY" + Suffix );
69 }
70 
74 
75  int size = clustermap.size();
76  std::auto_ptr<std::vector<unsigned int> > trackmulti ( new std::vector<unsigned int>(size, 0) );
77  std::auto_ptr<std::vector<int> > trackindex ( new std::vector<int> (size, -1) );
78  std::auto_ptr<std::vector<float> > localtheta ( new std::vector<float> (size, -100) );
79  std::auto_ptr<std::vector<float> > localphi ( new std::vector<float> (size, -100) );
80  std::auto_ptr<std::vector<float> > localpitch ( new std::vector<float> (size, -100) );
81  std::auto_ptr<std::vector<float> > localx ( new std::vector<float> (size, -100) );
82  std::auto_ptr<std::vector<float> > localy ( new std::vector<float> (size, -100) );
83  std::auto_ptr<std::vector<float> > localz ( new std::vector<float> (size, -100) );
84  std::auto_ptr<std::vector<float> > strip ( new std::vector<float> (size, -100) );
85  std::auto_ptr<std::vector<float> > globaltheta ( new std::vector<float> (size, -100) );
86  std::auto_ptr<std::vector<float> > globalphi ( new std::vector<float> (size, -100) );
87  std::auto_ptr<std::vector<float> > globalx ( new std::vector<float> (size, -10000) );
88  std::auto_ptr<std::vector<float> > globaly ( new std::vector<float> (size, -10000) );
89  std::auto_ptr<std::vector<float> > globalz ( new std::vector<float> (size, -10000) );
90  std::auto_ptr<std::vector<float> > insidistance ( new std::vector<float> (size, -1) );
91  std::auto_ptr<std::vector<float> > projwidth ( new std::vector<float> (size, -1000) );
92  std::auto_ptr<std::vector<float> > BdotY ( new std::vector<float> (size, -1000) );
93  std::auto_ptr<std::vector<float> > covered ( new std::vector<float> (size, -1000) );
94  std::auto_ptr<std::vector<float> > rhlocalx ( new std::vector<float>(size, -10000 ));
95  std::auto_ptr<std::vector<float> > rhlocaly ( new std::vector<float>(size, -10000 ));
96  std::auto_ptr<std::vector<float> > rhlocalxerr ( new std::vector<float>(size, -1 ));
97  std::auto_ptr<std::vector<float> > rhlocalyerr ( new std::vector<float>(size, -1 ));
98  std::auto_ptr<std::vector<float> > rhglobalx ( new std::vector<float>(size, -10000 ));
99  std::auto_ptr<std::vector<float> > rhglobaly ( new std::vector<float>(size, -10000 ));
100  std::auto_ptr<std::vector<float> > rhglobalz ( new std::vector<float>(size, -10000 ));
101  std::auto_ptr<std::vector<float> > rhstrip ( new std::vector<float>(size, -10000 ));
102  std::auto_ptr<std::vector<float> > rhmerr ( new std::vector<float>(size, -10000 ));
103  std::auto_ptr<std::vector<float> > ubstrip ( new std::vector<float>(size, -10000 ));
104  std::auto_ptr<std::vector<float> > ubmerr ( new std::vector<float>(size, -10000 ));
105  std::auto_ptr<std::vector<float> > driftx ( new std::vector<float>(size, -10000 ));
106  std::auto_ptr<std::vector<float> > drifty ( new std::vector<float>(size, -10000 ));
107  std::auto_ptr<std::vector<float> > driftz ( new std::vector<float>(size, -10000 ));
108  std::auto_ptr<std::vector<float> > globalZofunitlocalY ( new std::vector<float>(size, -1000));
109 
110  edm::ESHandle<TrackerGeometry> theTrackerGeometry; iSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );
113 
115  edm::Handle<TrajTrackAssociationCollection> associations; iEvent.getByLabel(theTracksLabel, associations);
116 
118 
119  for( TrajTrackAssociationCollection::const_iterator association = associations->begin();
120  association != associations->end(); association++) {
121  const Trajectory* traj = association->key.get();
122  const reco::Track* track = association->val.get();
123 
124  BOOST_FOREACH( const TrajectoryMeasurement measurement, traj->measurements() ) {
125  const TrajectoryStateOnSurface tsos = measurement.updatedState();
126  const TrajectoryStateOnSurface unbiased = combiner(measurement.forwardPredictedState(), measurement.backwardPredictedState());
127 
128  const TrackingRecHit* hit = measurement.recHit()->hit();
129  const SiStripRecHit1D* hit1D = dynamic_cast<const SiStripRecHit1D*>(hit);
130  const SiStripRecHit2D* hit2D = dynamic_cast<const SiStripRecHit2D*>(hit);
131  const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>(hit);
132 
133  for(unsigned h=0; h<2; h++) {
134  const SiStripCluster* cluster_ptr;
135  if(!matchedhit && h==1) continue; else
136  if( matchedhit && h==0) cluster_ptr = &matchedhit->monoCluster(); else
137  if( matchedhit && h==1) cluster_ptr = &matchedhit->stereoCluster(); else
138  if(hit2D) cluster_ptr = (hit2D->cluster()).get(); else
139  if(hit1D) cluster_ptr = (hit1D->cluster()).get();
140  else continue;
141 
142  shallow::CLUSTERMAP::const_iterator cluster = clustermap.find( std::make_pair( hit->geographicalId().rawId(), cluster_ptr->firstStrip() ));
143  if(cluster == clustermap.end() ) throw cms::Exception("Logic Error") << "Cluster not found: this could be a configuration error" << std::endl;
144 
145  unsigned i = cluster->second;
146  if( 0 == (trackmulti->at(i))++ ) {
147  const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTrackerGeometry->idToDet( hit->geographicalId() ) );
148  LocalVector drift = shallow::drift( theStripDet, *magfield, *SiStripLorentzAngle);
149 
150  trackindex->at(i) = shallow::findTrackIndex(tracks, track);
151  localtheta->at(i) = (theStripDet->toLocal(tsos.globalDirection())).theta();
152  localphi->at(i) = (theStripDet->toLocal(tsos.globalDirection())).phi();
153  localpitch->at(i) = (theStripDet->specificTopology()).localPitch(theStripDet->toLocal(tsos.globalPosition()));
154  localx->at(i) = (theStripDet->toLocal(tsos.globalPosition())).x();
155  localy->at(i) = (theStripDet->toLocal(tsos.globalPosition())).y();
156  localz->at(i) = (theStripDet->toLocal(tsos.globalPosition())).z();
157  strip->at(i) = (theStripDet->specificTopology()).strip(theStripDet->toLocal(tsos.globalPosition()));
158  globaltheta->at(i) = tsos.globalDirection().theta();
159  globalphi->at(i) = tsos.globalDirection().phi();
160  globalx->at(i) = tsos.globalPosition().x();
161  globaly->at(i) = tsos.globalPosition().y();
162  globalz->at(i) = tsos.globalPosition().z();
163  insidistance->at(i) = 1./fabs(cos(localtheta->at(i)));
164  projwidth->at(i) = tan(localtheta->at(i))*cos(localphi->at(i));
165  BdotY->at(i) = (theStripDet->surface()).toLocal( magfield->inTesla(theStripDet->surface().position())).y();
166  covered->at(i) = drift.z()/localpitch->at(i) * fabs(projwidth->at(i) - drift.x()/drift.z());
167  rhlocalx->at(i) = hit->localPosition().x();
168  rhlocaly->at(i) = hit->localPosition().y();
169  rhlocalxerr->at(i) = sqrt(hit->localPositionError().xx());
170  rhlocalyerr->at(i) = sqrt(hit->localPositionError().yy());
171  rhglobalx->at(i) = theStripDet->toGlobal(hit->localPosition()).x();
172  rhglobaly->at(i) = theStripDet->toGlobal(hit->localPosition()).y();
173  rhglobalz->at(i) = theStripDet->toGlobal(hit->localPosition()).z();
174  rhstrip->at(i) = theStripDet->specificTopology().strip(hit->localPosition());
175  rhmerr->at(i) = sqrt(theStripDet->specificTopology().measurementError(hit->localPosition(), hit->localPositionError()).uu());
176  ubstrip->at(i) = theStripDet->specificTopology().strip(unbiased.localPosition());
177  ubmerr->at(i) = sqrt(theStripDet->specificTopology().measurementError(unbiased.localPosition(), unbiased.localError().positionError()).uu());
178  driftx->at(i) = drift.x();
179  drifty->at(i) = drift.y();
180  driftz->at(i) = drift.z();
181  globalZofunitlocalY->at(i) = (theStripDet->toGlobal(LocalVector(0,1,0))).z();
182  }
183  }
184  }
185  }
186 
187  iEvent.put(trackmulti, Prefix + "trackmulti" + Suffix );
188  iEvent.put(trackindex, Prefix + "trackindex" + Suffix );
189  iEvent.put(localtheta, Prefix + "localtheta" + Suffix );
190  iEvent.put(localphi, Prefix + "localphi" + Suffix );
191  iEvent.put(localpitch, Prefix + "localpitch" + Suffix );
192  iEvent.put(localx, Prefix + "localx" + Suffix );
193  iEvent.put(localy, Prefix + "localy" + Suffix );
194  iEvent.put(localz, Prefix + "localz" + Suffix );
195  iEvent.put(strip, Prefix + "strip" + Suffix );
196  iEvent.put(globaltheta, Prefix + "globaltheta" + Suffix );
197  iEvent.put(globalphi, Prefix + "globalphi" + Suffix );
198  iEvent.put(globalx, Prefix + "globalx" + Suffix );
199  iEvent.put(globaly, Prefix + "globaly" + Suffix );
200  iEvent.put(globalz, Prefix + "globalz" + Suffix );
201  iEvent.put(insidistance,Prefix + "insidistance"+ Suffix );
202  iEvent.put(covered, Prefix + "covered" + Suffix );
203  iEvent.put(projwidth, Prefix + "projwidth" + Suffix );
204  iEvent.put(BdotY, Prefix + "BdotY" + Suffix );
205  iEvent.put(rhlocalx, Prefix + "rhlocalx" + Suffix );
206  iEvent.put(rhlocaly, Prefix + "rhlocaly" + Suffix );
207  iEvent.put(rhlocalxerr, Prefix + "rhlocalxerr" + Suffix );
208  iEvent.put(rhlocalyerr, Prefix + "rhlocalyerr" + Suffix );
209  iEvent.put(rhglobalx, Prefix + "rhglobalx" + Suffix );
210  iEvent.put(rhglobaly, Prefix + "rhglobaly" + Suffix );
211  iEvent.put(rhglobalz, Prefix + "rhglobalz" + Suffix );
212  iEvent.put(rhstrip, Prefix + "rhstrip" + Suffix );
213  iEvent.put(rhmerr, Prefix + "rhmerr" + Suffix );
214  iEvent.put(ubstrip, Prefix + "ubstrip" + Suffix );
215  iEvent.put(ubmerr, Prefix + "ubmerr" + Suffix );
216  iEvent.put( driftx, Prefix + "driftx" + Suffix );
217  iEvent.put( drifty, Prefix + "drifty" + Suffix );
218  iEvent.put( driftz, Prefix + "driftz" + Suffix );
219  iEvent.put( globalZofunitlocalY, Prefix + "globalZofunitlocalY" + Suffix );
220 }
ClusterRef cluster() const
int i
Definition: DBlmapReader.cc:9
Local3DVector LocalVector
Definition: LocalVector.h:12
tuple SiStripLorentzAngle
Definition: redigi_cff.py:15
ConstRecHitPointer const & recHit() const
ShallowTrackClustersProducer(const edm::ParameterSet &)
int findTrackIndex(const edm::Handle< edm::View< reco::Track > > &h, const reco::Track *t)
Definition: ShallowTools.cc:29
SiStripCluster const & monoCluster() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:39
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
tuple magfield
Definition: HLT_ES_cff.py:2311
T y() const
Definition: PV3DBase.h:63
void produce(edm::Event &, const edm::EventSetup &)
GlobalPoint globalPosition() const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
uint16_t firstStrip() const
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
LocalError positionError() const
float float float z
virtual float strip(const LocalPoint &) const =0
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
DataContainer const & measurements() const
Definition: Trajectory.h:203
int iEvent
Definition: GenABIO.cc:230
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
ClusterRef cluster() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const LocalTrajectoryError & localError() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
CLUSTERMAP make_cluster_map(const edm::Event &, edm::InputTag &)
Definition: ShallowTools.cc:15
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
SiStripCluster const & stereoCluster() const
std::map< std::pair< uint32_t, uint16_t >, unsigned int > CLUSTERMAP
Definition: ShallowTools.h:16
TrajectoryStateOnSurface const & updatedState() const
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
tuple size
Write out results.
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
GlobalVector globalDirection() const