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