CMS 3D CMS Logo

PhysicsObjectsMonitor.cc
Go to the documentation of this file.
1 
10 
11 // Collaborating Class Header
15 
17 
21 
23 
27 
28 using namespace std;
29 using namespace edm;
30 
33  theSTAMuonLabel =
34  pset.getUntrackedParameter<string>("StandAloneTrackCollectionLabel");
35  theSeedCollectionLabel =
36  pset.getUntrackedParameter<string>("MuonSeedCollectionLabel");
37  theDataType = pset.getUntrackedParameter<string>("DataType");
38 
39  if (theDataType != "RealData" && theDataType != "SimData")
40  edm::LogInfo("PhysicsObjectsMonitor") << "Error in Data Type!!" << endl;
41 
42  if (theDataType == "SimData") {
43  edm::LogInfo("PhysicsObjectsMonitor")
44  << "Sorry! Running this package on simulation is no longer supported! ";
45  }
46 
47  // set Token(-s)
48  theSTAMuonToken_ = consumes<reco::TrackCollection>(
49  pset.getUntrackedParameter<string>("StandAloneTrackCollectionLabel"));
50 }
51 
54 
56  edm::Run const&,
57  edm::EventSetup const&) {
58  iBooker.setCurrentFolder("PhysicsObjects/MuonReconstruction");
59 
60  hPres = iBooker.book1D("pTRes", "pT Resolution", 100, -2, 2);
61  h1_Pres = iBooker.book1D("invPTRes", "1/pT Resolution", 100, -2, 2);
62 
63  charge = iBooker.book1D("charge", "track charge", 5, -2.5, 2.5);
64  ptot = iBooker.book1D("ptot", "track momentum", 50, 0, 50);
65  pt = iBooker.book1D("pt", "track pT", 100, 0, 50);
66  px = iBooker.book1D("px ", "track px", 100, -50, 50);
67  py = iBooker.book1D("py", "track py", 100, -50, 50);
68  pz = iBooker.book1D("pz", "track pz", 100, -50, 50);
69  Nmuon = iBooker.book1D("Nmuon", "Number of muon tracks", 11, -.5, 10.5);
70  Nrechits = iBooker.book1D("Nrechits", "Number of RecHits/Segments on track",
71  21, -.5, 21.5);
72  NDThits = iBooker.book1D("NDThits", "Number of DT Hits/Segments on track", 31,
73  -.5, 31.5);
74  NCSChits = iBooker.book1D("NCSChits", "Number of CSC Hits/Segments on track",
75  31, -.5, 31.5);
76  NRPChits =
77  iBooker.book1D("NRPChits", "Number of RPC hits on track", 11, -.5, 11.5);
78 
79  DTvsCSC = iBooker.book2D("DTvsCSC", "Number of DT vs CSC hits on track", 29,
80  -.5, 28.5, 29, -.5, 28.5);
81  TH2F* root_ob = DTvsCSC->getTH2F();
82  root_ob->SetXTitle("Number of DT hits");
83  root_ob->SetYTitle("Number of CSC hits");
84 }
85 
87  const EventSetup& eventSetup) {
88  edm::LogInfo("PhysicsObjectsMonitor") << "Run: " << event.id().run()
89  << " Event: " << event.id().event();
91 
92  // Get the RecTrack collection from the event
94  event.getByToken(theSTAMuonToken_, staTracks);
95 
96  ESHandle<MagneticField> theMGField;
97  eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);
98 
99  double recPt = 0.;
100  double simPt = 0.;
101 
102  reco::TrackCollection::const_iterator staTrack;
103 
104  edm::LogInfo("PhysicsObjectsMonitor")
105  << "Reconstructed tracks: " << staTracks->size() << endl;
106  Nmuon->Fill(staTracks->size());
107  for (staTrack = staTracks->begin(); staTrack != staTracks->end();
108  ++staTrack) {
109  reco::TransientTrack track(*staTrack, &*theMGField);
110 
111  int nrechits = 0;
112  int nDThits = 0;
113  int nCSChits = 0;
114  int nRPChits = 0;
115 
116  for (trackingRecHit_iterator it = track.recHitsBegin();
117  it != track.recHitsEnd(); it++) {
118  if ((*it)->isValid()) {
119  edm::LogInfo("PhysicsObjectsMonitor")
120  << "Analyzer: Aha this looks like a Rechit!" << std::endl;
121  if ((*it)->geographicalId().subdetId() == MuonSubdetId::DT) {
122  nDThits++;
123  } else if ((*it)->geographicalId().subdetId() == MuonSubdetId::CSC) {
124  nCSChits++;
125  } else if ((*it)->geographicalId().subdetId() == MuonSubdetId::RPC) {
126  nRPChits++;
127  } else {
128  edm::LogInfo("PhysicsObjectsMonitor") << "This is an UNKNOWN hit !! "
129  << std::endl;
130  }
131  nrechits++;
132  }
133  }
134 
135  Nrechits->Fill(nrechits);
136  NDThits->Fill(nDThits);
137  NCSChits->Fill(nCSChits);
138  DTvsCSC->Fill(nDThits, nCSChits);
139  NRPChits->Fill(nRPChits);
140 
141  debug.dumpFTS(track.impactPointTSCP().theState());
142 
143  recPt = track.impactPointTSCP().momentum().perp();
144  edm::LogInfo("PhysicsObjectsMonitor")
145  << " p: " << track.impactPointTSCP().momentum().mag()
146  << " pT: " << recPt << endl;
147  pt->Fill(recPt);
148  ptot->Fill(track.impactPointTSCP().momentum().mag());
149  charge->Fill(track.impactPointTSCP().charge());
150  px->Fill(track.impactPointTSCP().momentum().x());
151  py->Fill(track.impactPointTSCP().momentum().y());
152  pz->Fill(track.impactPointTSCP().momentum().z());
153  }
154  edm::LogInfo("PhysicsObjectsMonitor") << "---" << endl;
155  if (recPt && theDataType == "SimData") {
156  hPres->Fill((recPt - simPt) / simPt);
157  h1_Pres->Fill((1 / recPt - 1 / simPt) / (1 / simPt));
158  }
159 }
160 
T getUntrackedParameter(std::string const &, T const &) const
T perp() const
Definition: PV3DBase.h:72
TrajectoryStateClosestToPoint impactPointTSCP() const
const FreeTrajectoryState & theState() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T y() const
Definition: PV3DBase.h:63
PhysicsObjectsMonitor(const edm::ParameterSet &pset)
Constructor.
std::string dumpFTS(const FreeTrajectoryState &fts) const
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
static const int CSC
Definition: MuonSubdetId.h:13
T mag() const
Definition: PV3DBase.h:67
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T z() const
Definition: PV3DBase.h:64
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
virtual ~PhysicsObjectsMonitor()
Destructor.
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
#define debug
Definition: HDRShower.cc:19
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
HLT enums.
static const int RPC
Definition: MuonSubdetId.h:14
static const int DT
Definition: MuonSubdetId.h:12
double recPt
TH2F * getTH2F(void) const
T x() const
Definition: PV3DBase.h:62
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: event.py:1
Definition: Run.h:42