CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 // system include files
21 #include <memory>
22 #include <numeric>
23 #include <vector>
24 
25 // user include files
28 
33 
35 
37 
40 
42 
49 
56 
57 #include "TH1F.h"
58 
60 //
61 // class decleration
62 //
63 
65 public:
67  ~OverlapProblemTSOSAnalyzer() override;
68 
69 private:
70  void beginRun(const edm::Run&, const edm::EventSetup&) override;
71  void endRun(const edm::Run&, const edm::EventSetup&) override;
72  void analyze(const edm::Event&, const edm::EventSetup&) override;
73 
74  // ----------member data ---------------------------
75 
76  TH1F* m_ptrk;
77  TH1F* m_etatrk;
78 
81  const bool m_debug;
82 
84 };
85 
86 //
87 // constants, enums and typedefs
88 //
89 
90 //
91 // static data member definitions
92 //
93 
94 //
95 // constructors and destructor
96 //
98  : m_validOnly(iConfig.getParameter<bool>("onlyValidRecHit")),
99  m_ttacollToken(
100  consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajTrackAssoCollection"))),
101  m_debug(iConfig.getUntrackedParameter<bool>("debugMode", false)),
102  m_tsoshm(iConfig.getParameter<edm::ParameterSet>("tsosHMConf")) {
103  //now do what ever initialization is needed
104 
106 
107  m_ptrk = tfserv->make<TH1F>("trkmomentum", "Refitted Track momentum", 100, 0., 200.);
108  m_etatrk = tfserv->make<TH1F>("trketa", "Refitted Track pseudorapidity", 100, -4., 4.);
109 }
110 
112  // do anything here that needs to be done at desctruction time
113  // (e.g. close files, deallocate resources etc.)
114 }
115 
116 //
117 // member functions
118 //
119 
120 // ------------ method called to for each event ------------
122  using namespace edm;
123 
124  // loop on trajectories and plot TSOS local coordinate
125 
126  TrajectoryStateCombiner tsoscomb;
127 
128  // Trajectory Handle
129 
130  DetIdSelector selector("0x1fbff004-0x14ac1004");
131 
133  iEvent.getByToken(m_ttacollToken, ttac);
134 
135  for (TrajTrackAssociationCollection::const_iterator pair = ttac->begin(); pair != ttac->end(); ++pair) {
136  const edm::Ref<std::vector<Trajectory> >& traj = pair->key;
137  const reco::TrackRef& trk = pair->val;
138  const std::vector<TrajectoryMeasurement>& tmcoll = traj->measurements();
139 
140  m_ptrk->Fill(trk->p());
141  m_etatrk->Fill(trk->eta());
142 
143  for (std::vector<TrajectoryMeasurement>::const_iterator meas = tmcoll.begin(); meas != tmcoll.end(); ++meas) {
144  if (!meas->updatedState().isValid())
145  continue;
146 
147  TrajectoryStateOnSurface tsos = tsoscomb(meas->forwardPredictedState(), meas->backwardPredictedState());
149 
150  m_tsoshm.fill(tsos, hit);
151 
152  if (!hit->isValid() && m_validOnly)
153  continue;
154 
155  if (m_debug) {
156  if (selector.isSelected(hit->geographicalId())) {
157  const SiPixelRecHit* pixelrh = dynamic_cast<const SiPixelRecHit*>(hit->hit());
158  if (pixelrh) {
159  edm::LogInfo("ClusterFound") << "Cluster reference" << pixelrh->cluster().key();
160  } else {
161  edm::LogInfo("NoCluster") << "No cluster found!";
162  }
163  }
164  }
165  }
166  }
167 }
168 
170 
172 
173 //define this as a plug-in
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:250
bool isSelected(const DetId &detid) const
int iEvent
Definition: GenABIO.cc:224
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Log< level::Info, false > LogInfo
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< TrajTrackAssociationCollection > m_ttacollToken
void endRun(const edm::Run &, const edm::EventSetup &) override
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
void beginRun(const edm::Run &, const edm::EventSetup &) override
OverlapProblemTSOSAnalyzer(const edm::ParameterSet &)
Definition: Run.h:45
Our base class.
Definition: SiPixelRecHit.h:23