CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
58 
59 #include "TH1F.h"
60 
62 //
63 // class decleration
64 //
65 
66 
68 public:
71 
72 private:
73  virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;
74  virtual void endRun(const edm::Run&, const edm::EventSetup&) override;
75  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
76 
77  // ----------member data ---------------------------
78 
79  TH1F* m_ptrk;
80  TH1F* m_etatrk;
81 
84  const bool m_debug;
85 
87 
88 };
89 
90 //
91 // constants, enums and typedefs
92 //
93 
94 //
95 // static data member definitions
96 //
97 
98 //
99 // constructors and destructor
100 //
102  m_validOnly(iConfig.getParameter<bool>("onlyValidRecHit")),
103  m_ttacollToken(consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajTrackAssoCollection"))),
104  m_debug(iConfig.getUntrackedParameter<bool>("debugMode",false)),
105  m_tsoshm(iConfig.getParameter<edm::ParameterSet>("tsosHMConf"))
106 {
107  //now do what ever initialization is needed
108 
109 
110 
112 
113  m_ptrk = tfserv->make<TH1F>("trkmomentum","Refitted Track momentum",100,0.,200.);
114  m_etatrk = tfserv->make<TH1F>("trketa","Refitted Track pseudorapidity",100,-4.,4.);
115 
116 
117 }
118 
119 
121 {
122 
123  // do anything here that needs to be done at desctruction time
124  // (e.g. close files, deallocate resources etc.)
125 
126 }
127 
128 
129 //
130 // member functions
131 //
132 
133 // ------------ method called to for each event ------------
134 void
136 {
137  using namespace edm;
138 
139  // loop on trajectories and plot TSOS local coordinate
140 
141  TrajectoryStateCombiner tsoscomb;
142 
143  // Trajectory Handle
144 
145  DetIdSelector selector("0x1fbff004-0x14ac1004");
146 
148  iEvent.getByToken(m_ttacollToken,ttac);
149 
150  for(TrajTrackAssociationCollection::const_iterator pair=ttac->begin();pair!=ttac->end();++pair) {
151 
152  const edm::Ref<std::vector<Trajectory> > & traj = pair->key;
153  const reco::TrackRef & trk = pair->val;
154  const std::vector<TrajectoryMeasurement> & tmcoll = traj->measurements();
155 
156  m_ptrk->Fill(trk->p());
157  m_etatrk->Fill(trk->eta());
158 
159 
160  for(std::vector<TrajectoryMeasurement>::const_iterator meas = tmcoll.begin() ; meas!= tmcoll.end() ; ++meas) {
161 
162  if(!meas->updatedState().isValid()) continue;
163 
164  TrajectoryStateOnSurface tsos = tsoscomb(meas->forwardPredictedState(), meas->backwardPredictedState());
166 
167  m_tsoshm.fill(tsos,hit);
168 
169  if(!hit->isValid() && m_validOnly) continue;
170 
171  if(m_debug) {
172  if(selector.isSelected(hit->geographicalId())) {
173  const SiPixelRecHit* pixelrh = dynamic_cast<const SiPixelRecHit*>(hit->hit());
174  if(pixelrh) {
175  edm::LogInfo("ClusterFound") << "Cluster reference" << pixelrh->cluster().key();
176  }
177  else {
178  edm::LogInfo("NoCluster") << "No cluster found!";
179  }
180  }
181  }
182 
183  }
184 
185  }
186 
187 
188 }
189 
190 void
192 {
193 }
194 
195 void
197 {
198 }
199 
200 
201 
202 //define this as a plug-in
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#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:266
bool isSelected(const DetId &detid) const
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
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
OverlapProblemTSOSAnalyzer(const edm::ParameterSet &)
volatile std::atomic< bool > shutdown_flag false
Definition: Run.h:41
Our base class.
Definition: SiPixelRecHit.h:23