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