ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ShallowTools/plugins/ShallowTrackClustersProducer.cc
(Generate patch)

Comparing UserCode/ShallowTools/plugins/ShallowTrackClustersProducer.cc (file contents):
Revision 1.2 by bbetchar, Wed Jun 10 01:24:50 2009 UTC vs.
Revision 1.10 by bbetchar, Tue Sep 29 10:16:31 2009 UTC

# Line 4 | Line 4
4  
5   #include "TrackingTools/PatternTools/interface/Trajectory.h"
6   #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
7 + #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
8   #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
9  
10   #include "MagneticField/Engine/interface/MagneticField.h"
# Line 15 | Line 16
16   #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
17   #include "Geometry/CommonTopologies/interface/StripTopology.h"
18   #include "FWCore/Framework/interface/ESHandle.h"
19 + #include "FWCore/Framework/interface/Event.h"
20   #include "boost/foreach.hpp"
21  
22 +
23   ShallowTrackClustersProducer::ShallowTrackClustersProducer(const edm::ParameterSet& iConfig)
24    :  theTracksLabel( iConfig.getParameter<edm::InputTag>("Tracks") ),
25 +     theClustersLabel( iConfig.getParameter<edm::InputTag>("Clusters") ),
26       Suffix       ( iConfig.getParameter<std::string>("Suffix")    ),
27       Prefix       ( iConfig.getParameter<std::string>("Prefix") )
28   {
# Line 39 | Line 43 | ShallowTrackClustersProducer::ShallowTra
43    produces <std::vector<float> >        ( Prefix + "insidistance"+ Suffix );
44    produces <std::vector<float> >        ( Prefix + "covered"     + Suffix );
45    produces <std::vector<float> >        ( Prefix + "projwidth"   + Suffix );
46 <  produces <std::vector<float> >        ( Prefix + "projlength"  + Suffix );
46 >  produces <std::vector<float> >        ( Prefix + "BdotY"       + Suffix );
47  
48    produces <std::vector<float> >        ( Prefix + "rhlocalx"     + Suffix );  
49    produces <std::vector<float> >        ( Prefix + "rhlocaly"     + Suffix );  
# Line 51 | Line 55 | ShallowTrackClustersProducer::ShallowTra
55    produces <std::vector<float> >        ( Prefix + "rhstrip"      + Suffix );  
56    produces <std::vector<float> >        ( Prefix + "rhmerr"       + Suffix );  
57  
58 +  produces <std::vector<float> >        ( Prefix + "ubstrip"      + Suffix );  
59 +  produces <std::vector<float> >        ( Prefix + "ubmerr"       + Suffix );  
60 +
61    produces <std::vector<float> >       ( Prefix + "driftx"        + Suffix );
62    produces <std::vector<float> >       ( Prefix + "drifty"        + Suffix );
63    produces <std::vector<float> >       ( Prefix + "driftz"        + Suffix );
64 +  produces <std::vector<float> >       ( Prefix + "globalZofunitlocalY" + Suffix );            
65   }
66  
67   void ShallowTrackClustersProducer::
68   produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
69 <  shallow::CLUSTERMAP clustermap = shallow::make_cluster_map(iEvent);
69 >  shallow::CLUSTERMAP clustermap = shallow::make_cluster_map(iEvent,theClustersLabel);
70  
71    int size = clustermap.size();
72    std::auto_ptr<std::vector<unsigned int> > trackmulti   ( new std::vector<unsigned int>(size,    0)   );
# Line 77 | Line 85 | produce(edm::Event& iEvent, const edm::E
85    std::auto_ptr<std::vector<float> >        globalz      ( new std::vector<float>       (size, -10000) );
86    std::auto_ptr<std::vector<float> >        insidistance ( new std::vector<float>       (size,     -1) );
87    std::auto_ptr<std::vector<float> >        projwidth    ( new std::vector<float>       (size,  -1000) );
88 +  std::auto_ptr<std::vector<float> >        BdotY        ( new std::vector<float>       (size,  -1000) );
89    std::auto_ptr<std::vector<float> >        covered      ( new std::vector<float>       (size,  -1000) );
81  std::auto_ptr<std::vector<float> >        projlength   ( new std::vector<float>       (size,  -1000) );
90    std::auto_ptr<std::vector<float> >  rhlocalx      ( new std::vector<float>(size,  -10000  ));  
91    std::auto_ptr<std::vector<float> >  rhlocaly      ( new std::vector<float>(size,  -10000  ));  
92    std::auto_ptr<std::vector<float> >  rhlocalxerr   ( new std::vector<float>(size,  -1  ));  
# Line 88 | Line 96 | produce(edm::Event& iEvent, const edm::E
96    std::auto_ptr<std::vector<float> >  rhglobalz     ( new std::vector<float>(size,  -10000  ));  
97    std::auto_ptr<std::vector<float> >  rhstrip       ( new std::vector<float>(size,  -10000  ));  
98    std::auto_ptr<std::vector<float> >  rhmerr        ( new std::vector<float>(size,  -10000  ));  
99 +  std::auto_ptr<std::vector<float> >  ubstrip       ( new std::vector<float>(size,  -10000  ));  
100 +  std::auto_ptr<std::vector<float> >  ubmerr        ( new std::vector<float>(size,  -10000  ));  
101    std::auto_ptr<std::vector<float> >  driftx        ( new std::vector<float>(size,  -10000  ));
102    std::auto_ptr<std::vector<float> >  drifty        ( new std::vector<float>(size,  -10000  ));
103    std::auto_ptr<std::vector<float> >  driftz        ( new std::vector<float>(size,  -10000  ));
104 +  std::auto_ptr<std::vector<float> >  globalZofunitlocalY ( new std::vector<float>(size, -1000));
105  
106    edm::ESHandle<TrackerGeometry> theTrackerGeometry;         iSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );  
107    edm::ESHandle<MagneticField> magfield;                     iSetup.get<IdealMagneticFieldRecord>().get(magfield);                    
108    edm::ESHandle<SiStripLorentzAngle> SiStripLorentzAngle;    iSetup.get<SiStripLorentzAngleRcd>().get(SiStripLorentzAngle);      
109  
110 <  edm::Handle<std::vector<reco::Track> > tracks;             iEvent.getByLabel(theTracksLabel, tracks);  
110 >  edm::Handle<edm::View<reco::Track> > tracks;               iEvent.getByLabel(theTracksLabel, tracks);  
111    edm::Handle<TrajTrackAssociationCollection> associations;  iEvent.getByLabel(theTracksLabel, associations);
112  
113 +  TrajectoryStateCombiner combiner;
114 +
115    for( TrajTrackAssociationCollection::const_iterator association = associations->begin();
116         association != associations->end(); association++) {
117      const Trajectory*  traj  = association->key.get();
# Line 106 | Line 119 | produce(edm::Event& iEvent, const edm::E
119  
120      BOOST_FOREACH( const TrajectoryMeasurement measurement, traj->measurements() ) {
121        const TrajectoryStateOnSurface tsos = measurement.updatedState();
122 +      const TrajectoryStateOnSurface unbiased = combiner(measurement.forwardPredictedState(), measurement.backwardPredictedState());
123        const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*> ( measurement.recHit()->hit() );  
124        
125 <      if(!hit) break;
125 >      if(!hit) continue;
126        shallow::CLUSTERMAP::const_iterator cluster = clustermap.find( std::make_pair(hit->geographicalId().rawId(), hit->cluster()->firstStrip() ));
127 <      if(cluster == clustermap.end() ) break;
127 >      if(cluster == clustermap.end() ) throw cms::Exception("Logic Error") << "Cluster not found: this could be a configuration error" << std::endl;
128        
129        unsigned i = cluster->second;
130        if( 0 == (trackmulti->at(i))++ ) {
131          const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTrackerGeometry->idToDet( hit->geographicalId() ) );
132          LocalVector drift = shallow::drift( theStripDet, *magfield, *SiStripLorentzAngle);
133 <        
133 >
134          trackindex->at(i)   = shallow::findTrackIndex(tracks, track);
135          localtheta->at(i)   = (theStripDet->toLocal(tsos.globalDirection())).theta();
136          localphi->at(i)     = (theStripDet->toLocal(tsos.globalDirection())).phi();  
# Line 132 | Line 146 | produce(edm::Event& iEvent, const edm::E
146          globalz->at(i)      = tsos.globalPosition().z();                            
147          insidistance->at(i) = 1./fabs(cos(localtheta->at(i)));                      
148          projwidth->at(i)    = tan(localtheta->at(i))*cos(localphi->at(i));        
149 +        BdotY->at(i)        = (theStripDet->surface()).toLocal( magfield->inTesla(theStripDet->surface().position())).y();
150          covered->at(i)      = drift.z()/localpitch->at(i) * fabs(projwidth->at(i) - drift.x()/drift.z());
136        projlength->at(i)   = tan(localtheta->at(i))*cos(localphi->at(i)) ;        
151          rhlocalx->at(i)     = hit->localPosition().x();
152          rhlocaly->at(i)     = hit->localPosition().y();
153          rhlocalxerr->at(i)  = sqrt(hit->localPositionError().xx());
# Line 143 | Line 157 | produce(edm::Event& iEvent, const edm::E
157          rhglobalz->at(i)    = theStripDet->toGlobal(hit->localPosition()).z();
158          rhstrip->at(i)      = theStripDet->specificTopology().strip(hit->localPosition());
159          rhmerr->at(i)       = sqrt(theStripDet->specificTopology().measurementError(hit->localPosition(), hit->localPositionError()).uu());
160 <        driftx->push_back(drift.x());
161 <        drifty->push_back(drift.y());
162 <        driftz->push_back(drift.z());
160 >        ubstrip->at(i)      = theStripDet->specificTopology().strip(unbiased.localPosition());
161 >        ubmerr->at(i)       = sqrt(theStripDet->specificTopology().measurementError(unbiased.localPosition(), unbiased.localError().positionError()).uu());
162 >        driftx->at(i)       = drift.x();
163 >        drifty->at(i)       = drift.y();
164 >        driftz->at(i)       = drift.z();
165 >        globalZofunitlocalY->at(i) = (theStripDet->toGlobal(LocalVector(0,1,0))).z();
166        }
167      }
168    }
# Line 167 | Line 184 | produce(edm::Event& iEvent, const edm::E
184    iEvent.put(insidistance,Prefix + "insidistance"+ Suffix );
185    iEvent.put(covered,     Prefix + "covered"     + Suffix );
186    iEvent.put(projwidth,   Prefix + "projwidth"   + Suffix );
187 <  iEvent.put(projlength,  Prefix + "projlength"  + Suffix );
187 >  iEvent.put(BdotY,       Prefix + "BdotY"       + Suffix );
188    iEvent.put(rhlocalx,    Prefix + "rhlocalx"    + Suffix );  
189    iEvent.put(rhlocaly,    Prefix + "rhlocaly"    + Suffix );  
190    iEvent.put(rhlocalxerr, Prefix + "rhlocalxerr" + Suffix );  
# Line 177 | Line 194 | produce(edm::Event& iEvent, const edm::E
194    iEvent.put(rhglobalz,   Prefix + "rhglobalz"   + Suffix );  
195    iEvent.put(rhstrip,     Prefix + "rhstrip"     + Suffix );  
196    iEvent.put(rhmerr,      Prefix + "rhmerr"      + Suffix );  
197 <  iEvent.put( driftx,        Prefix + "driftx"        );
198 <  iEvent.put( drifty,        Prefix + "drifty"        );
199 <  iEvent.put( driftz,        Prefix + "driftz"        );
197 >  iEvent.put(ubstrip,     Prefix + "ubstrip"     + Suffix );  
198 >  iEvent.put(ubmerr,      Prefix + "ubmerr"      + Suffix );  
199 >  iEvent.put( driftx,     Prefix + "driftx"      + Suffix );
200 >  iEvent.put( drifty,     Prefix + "drifty"      + Suffix );
201 >  iEvent.put( driftz,     Prefix + "driftz"      + Suffix );
202 >  iEvent.put( globalZofunitlocalY, Prefix + "globalZofunitlocalY" + Suffix );
203   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines