CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SegmentTrackAnalyzer.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Mila - INFN Torino
6  */
7 
9 
18 
20 #include <string>
21 
22 using namespace std;
23 using namespace edm;
24 
25 //#define DEBUG
26 
28  parameters = pSet;
29 
30  // MuonService
31  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"));
32 
33  // Read Data:
34  theMuTrackCollectionLabel_ = consumes<reco::TrackCollection>(parameters.getParameter<edm::InputTag>("MuTrackCollection"));
35 
36  // SegmentTrackAssociatior Parameters
37  const ParameterSet SegmentsTrackAssociatorParameters = parameters.getParameter<ParameterSet>("SegmentsTrackAssociatorParameters");
38 
39  edm::ConsumesCollector iC = consumesCollector();
40  theSegmentsAssociator = new SegmentsTrackAssociator(SegmentsTrackAssociatorParameters,iC);
41 
42  trackCollection = parameters.getParameter<edm::InputTag>("MuTrackCollection").label() + parameters.getParameter<edm::InputTag>("MuTrackCollection").instance();
43 
44  etaBin = parameters.getParameter<int>("etaBin");
45  etaMin = parameters.getParameter<double>("etaMin");
46  etaMax = parameters.getParameter<double>("etaMax");
47  phiBin = parameters.getParameter<int>("phiBin");
48  phiMin = parameters.getParameter<double>("phiMin");
49  phiMax = parameters.getParameter<double>("phiMax");
50  ptBin = parameters.getParameter<int>("ptBin");
51  ptMin = parameters.getParameter<double>("ptMin");
52  ptMax = parameters.getParameter<double>("ptMax");
53 }
55  const edm::Run& /*iRun*/,
56  const edm::EventSetup& /*iSetup*/){
57  ibooker.cd();
58  ibooker.setCurrentFolder("Muons/SegmentTrackAnalyzer");
59 
60 
61  // histograms initalization
62  hitsNotUsed = ibooker.book1D("HitsNotUsedForGlobalTracking_"+trackCollection, "recHits not used for GLB ["+trackCollection+"]", 50, -0.5, 49.5);
63  hitsNotUsedPercentual = ibooker.book1D("HitsNotUsedForGlobalTrackingDvHitUsed_"+trackCollection, "(recHits_{notUsedForGLB}) / (recHits_{GLB}) ["+trackCollection+"]", 100, 0, 1.);
64 
65  TrackSegm = ibooker.book2D("trackSegments_"+trackCollection, "Number of segments associated to the track ["+trackCollection+"]", 3, 0.5, 3.5, 8, 0, 8);
66  TrackSegm->setBinLabel(1,"DT+CSC",1);
67  TrackSegm->setBinLabel(2,"DT",1);
68  TrackSegm->setBinLabel(3,"CSC",1);
69 
70  hitStaProvenance = ibooker.book1D("trackHitStaProvenance_"+trackCollection, "Number of recHits_{STAinTrack} ["+trackCollection+"]", 7, 0.5, 7.5);
71  hitStaProvenance->setBinLabel(1,"DT");
72  hitStaProvenance->setBinLabel(2,"CSC");
73  hitStaProvenance->setBinLabel(3,"RPC");
74  hitStaProvenance->setBinLabel(4,"DT+CSC");
75  hitStaProvenance->setBinLabel(5,"DT+RPC");
76  hitStaProvenance->setBinLabel(6,"CSC+RPC");
77  hitStaProvenance->setBinLabel(7,"DT+CSC+RPC");
78 
79 
80  if(trackCollection!="standAloneMuons"){
81  hitTkrProvenance = ibooker.book1D("trackHitTkrProvenance_"+trackCollection, "Number of recHits_{TKinTrack} ["+trackCollection+"]", 6, 0.5, 6.5);
82  hitTkrProvenance->setBinLabel(1,"PixBarrel");
83  hitTkrProvenance->setBinLabel(2,"PixEndCap");
84  hitTkrProvenance->setBinLabel(3,"TIB");
85  hitTkrProvenance->setBinLabel(4,"TID");
86  hitTkrProvenance->setBinLabel(5,"TOB");
87  hitTkrProvenance->setBinLabel(6,"TEC");
88  }
89 
90  trackHitPercentualVsEta = ibooker.book2D("trackHitDivtrackSegmHitVsEta_"+trackCollection, "(recHits_{Track} / recHits_{associatedSegm}) vs #eta [" +trackCollection+"]", etaBin, etaMin, etaMax, 20, 0, 1);
91  dtTrackHitPercentualVsEta = ibooker.book2D("dtTrackHitDivtrackSegmHitVsEta_"+trackCollection, "(recHits_{DTinTrack} / recHits_{associatedSegm}) vs #eta [" +trackCollection+"]", etaBin, etaMin, etaMax, 20, 0, 1);
92  cscTrackHitPercentualVsEta = ibooker.book2D("cscTrackHitDivtrackSegmHitVsEta_"+trackCollection, "(recHits_{CSCinTrack} / recHits_{associatedSegm}) vs #eta [" +trackCollection+"]", etaBin, etaMin, etaMax, 20, 0, 1);
93 
94  trackHitPercentualVsPhi = ibooker.book2D("trackHitDivtrackSegmHitVsPhi_"+trackCollection, "(recHits_{Track} / recHits_{associatedSegm}) vs #phi [" +trackCollection+"]", phiBin, phiMin, phiMax, 20, 0, 1);
95  trackHitPercentualVsPhi->setAxisTitle("rad",2);
96  dtTrackHitPercentualVsPhi = ibooker.book2D("dtTrackHitDivtrackSegmHitVsPhi_"+trackCollection, "(recHits_{DTinTrack} / recHits_{associatedSegm}) vs #phi [" +trackCollection+"]", phiBin, phiMin, phiMax, 20, 0, 1);
97  dtTrackHitPercentualVsPhi->setAxisTitle("rad",2);
98  cscTrackHitPercentualVsPhi = ibooker.book2D("cscTrackHitDivtrackSegmHitVsPhi_"+trackCollection, "(recHits_{CSCinTrack} / recHits_{associatedSegm}) vs #phi [" +trackCollection+"]", phiBin, phiMin, phiMax, 20, 0, 1);
99  cscTrackHitPercentualVsPhi->setAxisTitle("rad",2);
100 
101  trackHitPercentualVsPt = ibooker.book2D("trackHitDivtrackSegmHitVsPt_"+trackCollection, "(recHits_{Track} / recHits_{associatedSegm}) vs 1/p_{t} [" +trackCollection+"]", ptBin, ptMin, ptMax, 20, 0, 1);
102  trackHitPercentualVsPt->setAxisTitle("GeV",2);
103  dtTrackHitPercentualVsPt = ibooker.book2D("dtTrackHitDivtrackSegmHitVsPt_"+trackCollection, "(recHits_{DTinTrack} / recHits_{associatedSegm}) vs 1/p_{t} [" +trackCollection+"]", ptBin, ptMin, ptMax, 20, 0, 1);
104  dtTrackHitPercentualVsPt->setAxisTitle("GeV",2);
105  cscTrackHitPercentualVsPt = ibooker.book2D("cscTrackHitDivtrackSegmHitVsPt_"+trackCollection, "(recHits_{CSCinTrack} / recHits_{associatedSegm}) vs 1/p_{t} [" +trackCollection+"]", ptBin, ptMin, ptMax, 20, 0, 1);
106  cscTrackHitPercentualVsPt->setAxisTitle("GeV",2);
107 }
108 
109 
111  theService->update(iSetup);
112 
114  iEvent.getByToken(theMuTrackCollectionLabel_,glbTracks);
115 
116  for (reco::TrackCollection::const_iterator recoTrack = glbTracks->begin(); recoTrack!=glbTracks->end(); ++recoTrack){
117  MuonTransientTrackingRecHit::MuonRecHitContainer segments = theSegmentsAssociator->associate(iEvent, iSetup, *recoTrack );
118 
119 #ifdef DEBUG
120  cout << "[SegmentTrackAnalyzer] # of segments associated to the track: "<<(segments).size() <<endl;
121 #endif
122 
123  // hit counters
124  int hitsFromDt=0;
125  int hitsFromCsc=0;
126  int hitsFromRpc=0;
127  int hitsFromTk=0;
128  int hitsFromTrack=0;
129  int hitsFromSegmDt=0;
130  int hitsFromSegmCsc=0;
131  // segment counters
132  int segmFromDt=0;
133  int segmFromCsc=0;
134 
135  for (MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator segment=segments.begin();
136  segment!=segments.end(); segment++) {
137 
138  DetId id = (*segment)->geographicalId();
139 
140  // hits from DT segments
141  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT ) {
142  ++segmFromDt;
143  const DTRecSegment4D *seg4D = dynamic_cast<const DTRecSegment4D*>((*segment)->hit());
144  if((*seg4D).hasPhi())
145  hitsFromSegmDt+=(*seg4D).phiSegment()->specificRecHits().size();
146  if((*seg4D).hasZed())
147  hitsFromSegmDt+=(*seg4D).zSegment()->specificRecHits().size();
148 
149  }
150 
151  // hits from CSC segments
152  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC ) {
153  hitsFromSegmCsc+=(*segment)->recHits().size();
154  segmFromCsc++;
155  }
156 
157  }
158 
159 
160  // hits from track
161  for(trackingRecHit_iterator recHit = recoTrack->recHitsBegin(); recHit != recoTrack->recHitsEnd(); ++recHit){
162 
163  hitsFromTrack++;
164  DetId id = (*recHit)->geographicalId();
165  // hits from DT
166  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT )
167  hitsFromDt++;
168  // hits from CSC
169  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC )
170  hitsFromCsc++;
171  // hits from RPC
172  if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::RPC )
173  hitsFromRpc++;
174  // hits from Tracker
175  if (id.det() == DetId::Tracker){
176  hitsFromTk++;
177  if(id.subdetId() == PixelSubdetector::PixelBarrel )
178  hitTkrProvenance->Fill(1);
179  if(id.subdetId() == PixelSubdetector::PixelEndcap )
180  hitTkrProvenance->Fill(2);
181  if(id.subdetId() == SiStripDetId::TIB )
182  hitTkrProvenance->Fill(3);
183  if(id.subdetId() == SiStripDetId::TID )
184  hitTkrProvenance->Fill(4);
185  if(id.subdetId() == SiStripDetId::TOB )
186  hitTkrProvenance->Fill(5);
187  if(id.subdetId() == SiStripDetId::TEC )
188  hitTkrProvenance->Fill(6);
189  }
190 
191  }
192 
193  // fill the histos
194  hitsNotUsed->Fill(hitsFromSegmDt+hitsFromSegmCsc+hitsFromRpc+hitsFromTk-hitsFromTrack);
195  hitsNotUsedPercentual->Fill(double(hitsFromSegmDt+hitsFromSegmCsc+hitsFromRpc+hitsFromTk-hitsFromTrack)/hitsFromTrack);
196 
197  if(hitsFromDt!=0 && hitsFromCsc!=0)
198  TrackSegm->Fill(1,segmFromDt+segmFromCsc);
199  if(hitsFromDt!=0 && hitsFromCsc==0)
200  TrackSegm->Fill(2,segmFromDt);
201  if(hitsFromDt==0 && hitsFromCsc!=0)
202  TrackSegm->Fill(3,segmFromCsc);
203 
204  if(hitsFromDt!=0 && hitsFromCsc==0 && hitsFromRpc==0) hitStaProvenance->Fill(1);
205  if(hitsFromCsc!=0 && hitsFromDt==0 && hitsFromRpc==0) hitStaProvenance->Fill(2);
206  if(hitsFromRpc!=0 && hitsFromDt==0 && hitsFromCsc==0) hitStaProvenance->Fill(3);
207  if(hitsFromDt!=0 && hitsFromCsc!=0 && hitsFromRpc==0) hitStaProvenance->Fill(4);
208  if(hitsFromDt!=0 && hitsFromRpc!=0 && hitsFromCsc==0) hitStaProvenance->Fill(5);
209  if(hitsFromCsc!=0 && hitsFromRpc!=0 && hitsFromDt==0) hitStaProvenance->Fill(6);
210  if(hitsFromDt!=0 && hitsFromCsc!=0 && hitsFromRpc!=0) hitStaProvenance->Fill(7);
211 
212  if(hitsFromSegmDt+hitsFromSegmCsc !=0){
213  trackHitPercentualVsEta->Fill(recoTrack->eta(), double(hitsFromDt+hitsFromCsc)/(hitsFromSegmDt+hitsFromSegmCsc));
214  trackHitPercentualVsPhi->Fill(recoTrack->phi(), double(hitsFromDt+hitsFromCsc)/(hitsFromSegmDt+hitsFromSegmCsc));
215  trackHitPercentualVsPt->Fill(recoTrack->pt(), double(hitsFromDt+hitsFromCsc)/(hitsFromSegmDt+hitsFromSegmCsc));
216  }
217 
218  if(hitsFromSegmDt!=0){
219  dtTrackHitPercentualVsEta->Fill(recoTrack->eta(), double(hitsFromDt)/hitsFromSegmDt);
220  dtTrackHitPercentualVsPhi->Fill(recoTrack->phi(), double(hitsFromDt)/hitsFromSegmDt);
221  dtTrackHitPercentualVsPt->Fill(recoTrack->pt(), double(hitsFromDt)/hitsFromSegmDt);
222  }
223 
224  if(hitsFromSegmCsc!=0){
225  cscTrackHitPercentualVsEta->Fill(recoTrack->eta(), double(hitsFromCsc)/hitsFromSegmCsc);
226  cscTrackHitPercentualVsPhi->Fill(recoTrack->phi(), double(hitsFromCsc)/hitsFromSegmCsc);
227  cscTrackHitPercentualVsPt->Fill(recoTrack->pt(), double(hitsFromCsc)/hitsFromSegmCsc);
228  }
229  }
230 
231 }
232 
dictionary parameters
Definition: Parameters.py:2
static PFTauRenderPlugin instance
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
void cd(void)
Definition: DQMStore.cc:266
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
int iEvent
Definition: GenABIO.cc:230
static const int CSC
Definition: MuonSubdetId.h:13
SegmentTrackAnalyzer(const edm::ParameterSet &)
Constructor.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
void analyze(const edm::Event &, const edm::EventSetup &)
Definition: DetId.h:18
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
static const int RPC
Definition: MuonSubdetId.h:14
tuple cout
Definition: gather_cfg.py:121
static const int DT
Definition: MuonSubdetId.h:12
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
std::vector< MuonRecHitPointer > MuonRecHitContainer
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
tuple size
Write out results.
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: Run.h:41