CMS 3D CMS Logo

PhysicsObjectsMonitor.cc
Go to the documentation of this file.
1 
10 
11 // Collaborating Class Header
15 
17 
21 
23 
26 
27 using namespace std;
28 using namespace edm;
29 
32  theSTAMuonLabel = pset.getUntrackedParameter<string>("StandAloneTrackCollectionLabel");
33  theSeedCollectionLabel = pset.getUntrackedParameter<string>("MuonSeedCollectionLabel");
34  theDataType = pset.getUntrackedParameter<string>("DataType");
35 
36  if (theDataType != "RealData" && theDataType != "SimData")
37  edm::LogInfo("PhysicsObjectsMonitor") << "Error in Data Type!!" << endl;
38 
39  if (theDataType == "SimData") {
40  edm::LogInfo("PhysicsObjectsMonitor") << "Sorry! Running this package on simulation is no longer supported! ";
41  }
42 
43  // set Token(-s)
44  theSTAMuonToken_ =
45  consumes<reco::TrackCollection>(pset.getUntrackedParameter<string>("StandAloneTrackCollectionLabel"));
46 }
47 
50 
52  iBooker.setCurrentFolder("PhysicsObjects/MuonReconstruction");
53 
54  hPres = iBooker.book1D("pTRes", "pT Resolution", 100, -2, 2);
55  h1_Pres = iBooker.book1D("invPTRes", "1/pT Resolution", 100, -2, 2);
56 
57  charge = iBooker.book1D("charge", "track charge", 5, -2.5, 2.5);
58  ptot = iBooker.book1D("ptot", "track momentum", 50, 0, 50);
59  pt = iBooker.book1D("pt", "track pT", 100, 0, 50);
60  px = iBooker.book1D("px ", "track px", 100, -50, 50);
61  py = iBooker.book1D("py", "track py", 100, -50, 50);
62  pz = iBooker.book1D("pz", "track pz", 100, -50, 50);
63  Nmuon = iBooker.book1D("Nmuon", "Number of muon tracks", 11, -.5, 10.5);
64  Nrechits = iBooker.book1D("Nrechits", "Number of RecHits/Segments on track", 21, -.5, 21.5);
65  NDThits = iBooker.book1D("NDThits", "Number of DT Hits/Segments on track", 31, -.5, 31.5);
66  NCSChits = iBooker.book1D("NCSChits", "Number of CSC Hits/Segments on track", 31, -.5, 31.5);
67  NRPChits = iBooker.book1D("NRPChits", "Number of RPC hits on track", 11, -.5, 11.5);
68 
69  DTvsCSC = iBooker.book2D("DTvsCSC", "Number of DT vs CSC hits on track", 29, -.5, 28.5, 29, -.5, 28.5);
70  TH2F *root_ob = DTvsCSC->getTH2F();
71  root_ob->SetXTitle("Number of DT hits");
72  root_ob->SetYTitle("Number of CSC hits");
73 }
74 
75 void PhysicsObjectsMonitor::analyze(const Event &event, const EventSetup &eventSetup) {
76  edm::LogInfo("PhysicsObjectsMonitor") << "Run: " << event.id().run() << " Event: " << event.id().event();
78 
79  // Get the RecTrack collection from the event
81  event.getByToken(theSTAMuonToken_, staTracks);
82 
83  ESHandle<MagneticField> theMGField;
84  eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);
85 
86  double recPt = 0.;
87  double simPt = 0.;
88 
89  reco::TrackCollection::const_iterator staTrack;
90 
91  edm::LogInfo("PhysicsObjectsMonitor") << "Reconstructed tracks: " << staTracks->size() << endl;
92  Nmuon->Fill(staTracks->size());
93  for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack) {
94  reco::TransientTrack track(*staTrack, &*theMGField);
95 
96  int nrechits = 0;
97  int nDThits = 0;
98  int nCSChits = 0;
99  int nRPChits = 0;
100 
101  for (trackingRecHit_iterator it = track.recHitsBegin(); it != track.recHitsEnd(); it++) {
102  if ((*it)->isValid()) {
103  edm::LogInfo("PhysicsObjectsMonitor") << "Analyzer: Aha this looks like a Rechit!" << std::endl;
104  if ((*it)->geographicalId().subdetId() == MuonSubdetId::DT) {
105  nDThits++;
106  } else if ((*it)->geographicalId().subdetId() == MuonSubdetId::CSC) {
107  nCSChits++;
108  } else if ((*it)->geographicalId().subdetId() == MuonSubdetId::RPC) {
109  nRPChits++;
110  } else {
111  edm::LogInfo("PhysicsObjectsMonitor") << "This is an UNKNOWN hit !! " << std::endl;
112  }
113  nrechits++;
114  }
115  }
116 
117  Nrechits->Fill(nrechits);
118  NDThits->Fill(nDThits);
119  NCSChits->Fill(nCSChits);
120  DTvsCSC->Fill(nDThits, nCSChits);
121  NRPChits->Fill(nRPChits);
122 
123  debug.dumpFTS(track.impactPointTSCP().theState());
124 
125  recPt = track.impactPointTSCP().momentum().perp();
126  edm::LogInfo("PhysicsObjectsMonitor")
127  << " p: " << track.impactPointTSCP().momentum().mag() << " pT: " << recPt << endl;
128  pt->Fill(recPt);
129  ptot->Fill(track.impactPointTSCP().momentum().mag());
130  charge->Fill(track.impactPointTSCP().charge());
131  px->Fill(track.impactPointTSCP().momentum().x());
132  py->Fill(track.impactPointTSCP().momentum().y());
133  pz->Fill(track.impactPointTSCP().momentum().z());
134  }
135  edm::LogInfo("PhysicsObjectsMonitor") << "---" << endl;
136  if (recPt && theDataType == "SimData") {
137  hPres->Fill((recPt - simPt) / simPt);
138  h1_Pres->Fill((1 / recPt - 1 / simPt) / (1 / simPt));
139  }
140 }
141 
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
PhysicsObjectsMonitor::analyze
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: PhysicsObjectsMonitor.cc:75
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
MessageLogger.h
MuonPatternRecoDumper.h
ESHandle.h
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::Run
Definition: Run.h:45
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
PhysicsObjectsMonitor
Definition: PhysicsObjectsMonitor.h:30
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TransientTrack.h
edm::Handle< reco::TrackCollection >
recPt
double recPt
Definition: PFJetBenchmarkAnalyzer.cc:75
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
MakerMacros.h
debug
#define debug
Definition: HDRShower.cc:19
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MuonPatternRecoDumper
Definition: MuonPatternRecoDumper.h:18
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::EventSetup
Definition: EventSetup.h:57
muonTagProbeFilters_cff.staTracks
staTracks
Definition: muonTagProbeFilters_cff.py:29
get
#define get
MuonSubdetId.h
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
PhysicsObjectsMonitor::PhysicsObjectsMonitor
PhysicsObjectsMonitor(const edm::ParameterSet &pset)
Constructor.
Definition: PhysicsObjectsMonitor.cc:31
PhysicsObjectsMonitor::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: PhysicsObjectsMonitor.cc:51
dqm::implementation::IBooker
Definition: DQMStore.h:43
PhysicsObjectsMonitor.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
PhysicsObjectsMonitor::~PhysicsObjectsMonitor
~PhysicsObjectsMonitor() override
Destructor.
Definition: PhysicsObjectsMonitor.cc:49
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:490