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 // 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 
64 class OverlapProblemTSOSAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
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  usesResource(TFileService::kSharedResource);
105 
107 
108  m_ptrk = tfserv->make<TH1F>("trkmomentum", "Refitted Track momentum", 100, 0., 200.);
109  m_etatrk = tfserv->make<TH1F>("trketa", "Refitted Track pseudorapidity", 100, -4., 4.);
110 }
111 
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 }
116 
117 //
118 // member functions
119 //
120 
121 // ------------ method called to for each event ------------
123  using namespace edm;
124 
125  // loop on trajectories and plot TSOS local coordinate
126 
127  TrajectoryStateCombiner tsoscomb;
128 
129  // Trajectory Handle
130 
131  DetIdSelector selector("0x1fbff004-0x14ac1004");
132 
134  iEvent.getByToken(m_ttacollToken, ttac);
135 
136  for (TrajTrackAssociationCollection::const_iterator pair = ttac->begin(); pair != ttac->end(); ++pair) {
137  const edm::Ref<std::vector<Trajectory> >& traj = pair->key;
138  const reco::TrackRef& trk = pair->val;
139  const std::vector<TrajectoryMeasurement>& tmcoll = traj->measurements();
140 
141  m_ptrk->Fill(trk->p());
142  m_etatrk->Fill(trk->eta());
143 
144  for (std::vector<TrajectoryMeasurement>::const_iterator meas = tmcoll.begin(); meas != tmcoll.end(); ++meas) {
145  if (!meas->updatedState().isValid())
146  continue;
147 
148  TrajectoryStateOnSurface tsos = tsoscomb(meas->forwardPredictedState(), meas->backwardPredictedState());
150 
151  m_tsoshm.fill(tsos, hit);
152 
153  if (!hit->isValid() && m_validOnly)
154  continue;
155 
156  if (m_debug) {
157  if (selector.isSelected(hit->geographicalId())) {
158  const SiPixelRecHit* pixelrh = dynamic_cast<const SiPixelRecHit*>(hit->hit());
159  if (pixelrh) {
160  edm::LogInfo("ClusterFound") << "Cluster reference" << pixelrh->cluster().key();
161  } else {
162  edm::LogInfo("NoCluster") << "No cluster found!";
163  }
164  }
165  }
166  }
167  }
168 }
169 
171 
173 
174 //define this as a plug-in
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
static const std::string kSharedResource
Definition: TFileService.h:76
bool isSelected(const DetId &detid) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
key_type key() const
Accessor for product key.
Definition: Ref.h:250
const_iterator end() const
last iterator over the map (read only)
int iEvent
Definition: GenABIO.cc:224
void fill(const TrajectoryStateOnSurface &tsos, TransientTrackingRecHit::ConstRecHitPointer hit) const
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
const_iterator begin() const
first iterator over the map (read only)
HLT enums.
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
void beginRun(const edm::Run &, const edm::EventSetup &) override
OverlapProblemTSOSAnalyzer(const edm::ParameterSet &)
Definition: Run.h:45
Our base class.
Definition: SiPixelRecHit.h:23