CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhysicsObjectsMonitor.cc
Go to the documentation of this file.
1 
9 
10 // Collaborating Class Header
14 
16 
20 
21 // Not needed for data monitoring! #include "SimDataFormats/Track/interface/SimTrackContainer.h"
23 
27 
28 
29 using namespace std;
30 using namespace edm;
31 
34  theSTAMuonLabel = pset.getUntrackedParameter<string>("StandAloneTrackCollectionLabel");
35  theSeedCollectionLabel = pset.getUntrackedParameter<string>("MuonSeedCollectionLabel");
36 
37  theRootFileName = pset.getUntrackedParameter<string>("rootFileName");
38  saveRootFile = pset.getUntrackedParameter<bool>("produceRootFile");
39 
40  theDataType = pset.getUntrackedParameter<string>("DataType");
41 
42  if(theDataType != "RealData" && theDataType != "SimData")
43  edm::LogInfo ("PhysicsObjectsMonitor") << "Error in Data Type!!"<<endl;
44 
45  numberOfSimTracks=0;
46  numberOfRecTracks=0;
47 
49  dbe = edm::Service<DQMStore>().operator->();
50 
51 
52  //set Token(-s)
53  theSTAMuonToken_ = consumes<reco::TrackCollection>(pset.getUntrackedParameter<string>("StandAloneTrackCollectionLabel"));
54 
55 }
56 
59 }
60 
62 
63  dbe->setCurrentFolder("PhysicsObjects/MuonReconstruction");
64 
65 
66  hPres = dbe->book1D("pTRes","pT Resolution",100,-2,2);
67  h1_Pres =dbe->book1D("invPTRes","1/pT Resolution",100,-2,2);
68 
69  charge= dbe->book1D("charge","track charge",5,-2.5,2.5);
70  ptot = dbe->book1D("ptot","track momentum",50,0,50);
71  pt = dbe->book1D("pt","track pT",100,0,50);
72  px = dbe->book1D("px ","track px",100,-50,50);
73  py = dbe->book1D("py","track py",100,-50,50);
74  pz = dbe->book1D("pz","track pz",100,-50,50);
75  Nmuon = dbe->book1D("Nmuon","Number of muon tracks",11,-.5,10.5);
76  Nrechits = dbe->book1D("Nrechits","Number of RecHits/Segments on track",21,-.5,21.5);
77  NDThits = dbe->book1D("NDThits","Number of DT Hits/Segments on track",31,-.5,31.5);
78  NCSChits = dbe->book1D("NCSChits","Number of CSC Hits/Segments on track",31,-.5,31.5);
79  NRPChits = dbe->book1D("NRPChits","Number of RPC hits on track",11,-.5,11.5);
80 
81  DTvsCSC = dbe->book2D("DTvsCSC","Number of DT vs CSC hits on track",29,-.5,28.5,29,-.5,28.5);
82  TH2F * root_ob = DTvsCSC->getTH2F();
83  root_ob->SetXTitle("Number of DT hits");
84  root_ob->SetYTitle("Number of CSC hits");
85 
86 }
87 
89 
90  if(theDataType == "SimData"){
91  // edm::LogInfo ("PhysicsObjectsMonitor") << "Number of Sim tracks: " << numberOfSimTracks;
92  edm::LogInfo ("PhysicsObjectsMonitor") << "Sorry! Running this package on simulation is no longer supported! ";
93  }
94 
95  edm::LogInfo ("PhysicsObjectsMonitor") << "Number of Reco tracks: " << numberOfRecTracks ;
96 
97  if(saveRootFile) dbe->save(theRootFileName);
98  dbe->setCurrentFolder("PhysicsObjects/MuonReconstruction");
99  dbe->removeContents();
100 
101 
102 }
103 
104 
105 void PhysicsObjectsMonitor::analyze(const Event & event, const EventSetup& eventSetup){
106 
107  edm::LogInfo ("PhysicsObjectsMonitor") << "Run: " << event.id().run() << " Event: " << event.id().event();
109 
110  // Get the RecTrack collection from the event
112  event.getByToken(theSTAMuonToken_, staTracks);
113 
114  ESHandle<MagneticField> theMGField;
115  eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);
116 
117 
118  double recPt=0.;
119  double simPt=0.;
120 
121  // Get the SimTrack collection from the event
122  // if(theDataType == "SimData"){
123  // Handle<SimTrackContainer> simTracks;
124 
125  // numberOfRecTracks += staTracks->size();
126 
127  // SimTrackContainer::const_iterator simTrack;
128 
129  // edm::LogInfo ("PhysicsObjectsMonitor") <<"Simulated tracks: ";
130  // for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack){
131  // if (abs((*simTrack).type()) == 13) {
132  // edm::LogInfo ("PhysicsObjectsMonitor") << "Sim pT: "<<(*simTrack).momentum().perp()<<endl;
133  // simPt=(*simTrack).momentum().perp();
134  // edm::LogInfo ("PhysicsObjectsMonitor") <<"Sim Eta: "<<(*simTrack).momentum().eta()<<endl;
135  // numberOfSimTracks++;
136  // }
137  // }
138  // edm::LogInfo ("PhysicsObjectsMonitor") << "\n";
139  //}
140 
141  reco::TrackCollection::const_iterator staTrack;
142 
143  edm::LogInfo ("PhysicsObjectsMonitor") << "Reconstructed tracks: " << staTracks->size() << endl;
144  Nmuon->Fill(staTracks->size());
145  for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack){
146  reco::TransientTrack track(*staTrack,&*theMGField);
147 
148  int nrechits=0;
149  int nDThits=0;
150  int nCSChits=0;
151  int nRPChits=0;
152 
153  for (trackingRecHit_iterator it = track.recHitsBegin (); it != track.recHitsEnd (); it++) {
154  if ((*it)->isValid ()) {
155  edm::LogInfo ("PhysicsObjectsMonitor") << "Analyzer: Aha this looks like a Rechit!" << std::endl;
156  if((*it)->geographicalId().subdetId() == MuonSubdetId::DT) {
157  nDThits++;
158  } else if((*it)->geographicalId().subdetId() == MuonSubdetId::CSC) {
159  nCSChits++;
160  } else if((*it)->geographicalId().subdetId() == MuonSubdetId::RPC) {
161  nRPChits++;
162  } else {
163  edm::LogInfo ("PhysicsObjectsMonitor") << "This is an UNKNOWN hit !! " << std::endl;
164  }
165  nrechits++;
166  }
167  }
168 
169  Nrechits->Fill(nrechits);
170  NDThits->Fill(nDThits);
171  NCSChits->Fill(nCSChits);
172  DTvsCSC->Fill(nDThits,nCSChits);
173  NRPChits->Fill(nRPChits);
174 
175  debug.dumpFTS(track.impactPointTSCP().theState());
176 
177  recPt = track.impactPointTSCP().momentum().perp();
178  edm::LogInfo ("PhysicsObjectsMonitor") << " p: "<<track.impactPointTSCP().momentum().mag()<< " pT: "<<recPt<<endl;
179  pt->Fill(recPt);
180  ptot->Fill(track.impactPointTSCP().momentum().mag());
181  charge->Fill(track.impactPointTSCP().charge());
182  px->Fill(track.impactPointTSCP().momentum().x());
183  py->Fill(track.impactPointTSCP().momentum().y());
184  pz->Fill(track.impactPointTSCP().momentum().z());
185  }
186  edm::LogInfo ("PhysicsObjectsMonitor") <<"---"<<endl;
187  if(recPt && theDataType == "SimData"){
188  hPres->Fill( (recPt-simPt)/simPt);
189  h1_Pres->Fill( ( 1/recPt - 1/simPt)/ (1/simPt));
190 
191  }
192 }
193 
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.
double charge(const std::vector< uint8_t > &Ampls)
std::string dumpFTS(const FreeTrajectoryState &fts) const
static const int CSC
Definition: MuonSubdetId.h:13
T mag() const
Definition: PV3DBase.h:67
T z() const
Definition: PV3DBase.h:64
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
virtual ~PhysicsObjectsMonitor()
Destructor.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
#define debug
Definition: HDRShower.cc:19
const T & get() const
Definition: EventSetup.h:55
static const int RPC
Definition: MuonSubdetId.h:14
static const int DT
Definition: MuonSubdetId.h:12
double recPt
T x() const
Definition: PV3DBase.h:62
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits