CMS 3D CMS Logo

OverlapProblemTSOSAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: OverlapProblemTSOSAnalyzer
4 // Class: OverlapProblemTSOSAnalyzer
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Thu Dec 16 16:32:56 CEST 2010
16 // $Id: OverlapProblemTSOSAnalyzer.cc,v 1.2 2013/04/10 21:08:01 venturia Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <numeric>
24 #include <vector>
25 
26 // user include files
29 
34 
36 
38 
41 
43 
50 
57 
58 #include "TH1F.h"
59 
61 //
62 // class decleration
63 //
64 
65 
67 public:
70 
71 private:
72  virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;
73  virtual void endRun(const edm::Run&, const edm::EventSetup&) override;
74  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
75 
76  // ----------member data ---------------------------
77 
78  TH1F* m_ptrk;
79  TH1F* m_etatrk;
80 
83  const bool m_debug;
84 
86 
87 };
88 
89 //
90 // constants, enums and typedefs
91 //
92 
93 //
94 // static data member definitions
95 //
96 
97 //
98 // constructors and destructor
99 //
101  m_validOnly(iConfig.getParameter<bool>("onlyValidRecHit")),
102  m_ttacollToken(consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajTrackAssoCollection"))),
103  m_debug(iConfig.getUntrackedParameter<bool>("debugMode",false)),
104  m_tsoshm(iConfig.getParameter<edm::ParameterSet>("tsosHMConf"))
105 {
106  //now do what ever initialization is needed
107 
108 
109 
111 
112  m_ptrk = tfserv->make<TH1F>("trkmomentum","Refitted Track momentum",100,0.,200.);
113  m_etatrk = tfserv->make<TH1F>("trketa","Refitted Track pseudorapidity",100,-4.,4.);
114 
115 
116 }
117 
118 
120 {
121 
122  // do anything here that needs to be done at desctruction time
123  // (e.g. close files, deallocate resources etc.)
124 
125 }
126 
127 
128 //
129 // member functions
130 //
131 
132 // ------------ method called to for each event ------------
133 void
135 {
136  using namespace edm;
137 
138  // loop on trajectories and plot TSOS local coordinate
139 
140  TrajectoryStateCombiner tsoscomb;
141 
142  // Trajectory Handle
143 
144  DetIdSelector selector("0x1fbff004-0x14ac1004");
145 
147  iEvent.getByToken(m_ttacollToken,ttac);
148 
149  for(TrajTrackAssociationCollection::const_iterator pair=ttac->begin();pair!=ttac->end();++pair) {
150 
151  const edm::Ref<std::vector<Trajectory> > & traj = pair->key;
152  const reco::TrackRef & trk = pair->val;
153  const std::vector<TrajectoryMeasurement> & tmcoll = traj->measurements();
154 
155  m_ptrk->Fill(trk->p());
156  m_etatrk->Fill(trk->eta());
157 
158 
159  for(std::vector<TrajectoryMeasurement>::const_iterator meas = tmcoll.begin() ; meas!= tmcoll.end() ; ++meas) {
160 
161  if(!meas->updatedState().isValid()) continue;
162 
163  TrajectoryStateOnSurface tsos = tsoscomb(meas->forwardPredictedState(), meas->backwardPredictedState());
165 
166  m_tsoshm.fill(tsos,hit);
167 
168  if(!hit->isValid() && m_validOnly) continue;
169 
170  if(m_debug) {
171  if(selector.isSelected(hit->geographicalId())) {
172  const SiPixelRecHit* pixelrh = dynamic_cast<const SiPixelRecHit*>(hit->hit());
173  if(pixelrh) {
174  edm::LogInfo("ClusterFound") << "Cluster reference" << pixelrh->cluster().key();
175  }
176  else {
177  edm::LogInfo("NoCluster") << "No cluster found!";
178  }
179  }
180  }
181 
182  }
183 
184  }
185 
186 
187 }
188 
189 void
191 {
192 }
193 
194 void
196 {
197 }
198 
199 
200 
201 //define this as a plug-in
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void fill(const TrajectoryStateOnSurface &tsos, TransientTrackingRecHit::ConstRecHitPointer hit) const
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
key_type key() const
Accessor for product key.
Definition: Ref.h:264
bool isSelected(const DetId &detid) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< TrajTrackAssociationCollection > m_ttacollToken
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
HLT enums.
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
OverlapProblemTSOSAnalyzer(const edm::ParameterSet &)
const_iterator begin() const
first iterator over the map (read only)
Definition: Run.h:42
Our base class.
Definition: SiPixelRecHit.h:23