CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripMonitorTrack.cc
Go to the documentation of this file.
2 
5 
18 
20 
22 #include "TMath.h"
23 
25  conf_(conf),
26  tracksCollection_in_EventTree(true),
27  firstEvent(-1),
28  genTriggerEventFlag_(new GenericTriggerEventFlag(conf, consumesCollector()))
29 {
30  Cluster_src_ = conf.getParameter<edm::InputTag>("Cluster_src");
31  Mod_On_ = conf.getParameter<bool>("Mod_On");
32  Trend_On_ = conf.getParameter<bool>("Trend_On");
33  TkHistoMap_On_ = conf.getParameter<bool>("TkHistoMap_On");
34 
35  TrackProducer_ = conf_.getParameter<std::string>("TrackProducer");
36  TrackLabel_ = conf_.getParameter<std::string>("TrackLabel");
37 
38  topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
39 
40  clusterToken_ = consumes<edmNew::DetSetVector<SiStripCluster> >(Cluster_src_);
41  trackToken_ = consumes<reco::TrackCollection>(edm::InputTag(TrackProducer_,TrackLabel_) );
42  trackTrajToken_ = consumes<TrajTrackAssociationCollection>(edm::InputTag(TrackProducer_,TrackLabel_) );
43 
44  // cluster quality conditions
45  edm::ParameterSet cluster_condition = conf_.getParameter<edm::ParameterSet>("ClusterConditions");
46  applyClusterQuality_ = cluster_condition.getParameter<bool>("On");
47  sToNLowerLimit_ = cluster_condition.getParameter<double>("minStoN");
48  sToNUpperLimit_ = cluster_condition.getParameter<double>("maxStoN");
49  widthLowerLimit_ = cluster_condition.getParameter<double>("minWidth");
50  widthUpperLimit_ = cluster_condition.getParameter<double>("maxWidth");
51 
52 
53  // Create DCS Status
54  bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
55  if (checkDCS) dcsStatus_ = new SiStripDCSStatus(consumesCollector());
56  else dcsStatus_ = 0;
57 }
58 
59 //------------------------------------------------------------------------
61  if (dcsStatus_) delete dcsStatus_;
63 }
64 
65 //------------------------------------------------------------------------
67 {
68  //get geom
70  LogDebug("SiStripMonitorTrack") << "[SiStripMonitorTrack::beginRun] There are "<<tkgeom_->detUnits().size() <<" detectors instantiated in the geometry" << std::endl;
72 
73 
74  // Initialize the GenericTriggerEventFlag
76 }
77 
78 //------------------------------------------------------------------------
80 {
81  //Retrieve tracker topology from geometry
83  es.get<IdealGeometryRecord>().get(tTopoHandle);
84  const TrackerTopology* const tTopo = tTopoHandle.product();
85  book(ibooker , tTopo);
86 }
87 
88 // ------------ method called to produce the data ------------
90 {
91  // Filter out events if DCS checking is requested
92  if (dcsStatus_ && !dcsStatus_->getStatus(e,es)) return;
93 
94  // Filter out events if Trigger Filtering is requested
95  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( e, es) ) return;
96 
97  //initialization of global quantities
98  LogDebug("SiStripMonitorTrack") << "[SiStripMonitorTrack::analyse] " << "Run " << e.id().run() << " Event " << e.id().event() << std::endl;
99  eventNb = e.id().event();
100  vPSiStripCluster.clear();
101 
102  iLumisection = e.orbitNumber()/262144.0;
103 
104  // initialise # of clusters
105  for (std::map<std::string, SubDetMEs>::iterator iSubDet = SubDetMEsMap.begin();
106  iSubDet != SubDetMEsMap.end(); iSubDet++) {
107  iSubDet->second.totNClustersOnTrack = 0;
108  iSubDet->second.totNClustersOffTrack = 0;
109  }
110 
111  //Perform track study
112  trackStudy(e, es);
113 
114  //Perform Cluster Study (irrespectively to tracks)
115 
116  AllClusters(e, es); //analyzes the off Track Clusters
117 
118  //Summary Counts of clusters
119  std::map<std::string, MonitorElement*>::iterator iME;
120  std::map<std::string, LayerMEs>::iterator iLayerME;
121 
122  for (std::map<std::string, SubDetMEs>::iterator iSubDet = SubDetMEsMap.begin();
123  iSubDet != SubDetMEsMap.end(); iSubDet++) {
124  SubDetMEs subdet_mes = iSubDet->second;
125  if (subdet_mes.totNClustersOnTrack > 0) {
126  fillME(subdet_mes.nClustersOnTrack, subdet_mes.totNClustersOnTrack);
127  }
128  fillME(subdet_mes.nClustersOffTrack, subdet_mes.totNClustersOffTrack);
129  if (Trend_On_) {
132  }
133  }
134 }
135 
136 //------------------------------------------------------------------------
138 {
139 
140  SiStripFolderOrganizer folder_organizer;
141  folder_organizer.setSiStripFolderName(topFolderName_);
142  //******** TkHistoMaps
143  if (TkHistoMap_On_) {
144  tkhisto_StoNCorrOnTrack = new TkHistoMap(ibooker , topFolderName_ ,"TkHMap_StoNCorrOnTrack", 0.0,true);
145  tkhisto_NumOnTrack = new TkHistoMap(ibooker , topFolderName_, "TkHMap_NumberOfOnTrackCluster", 0.0,true);
146  tkhisto_NumOffTrack = new TkHistoMap(ibooker , topFolderName_, "TkHMap_NumberOfOfffTrackCluster",0.0,true);
147  }
148  //******** TkHistoMaps
149 
150  std::vector<uint32_t> vdetId_;
151  SiStripDetCabling_->addActiveDetectorsRawIds(vdetId_);
152  //Histos for each detector, layer and module
153  for (std::vector<uint32_t>::const_iterator detid_iter=vdetId_.begin();detid_iter!=vdetId_.end();detid_iter++){ //loop on all the active detid
154  uint32_t detid = *detid_iter;
155 
156  if (detid < 1){
157  edm::LogError("SiStripMonitorTrack")<< "[" <<__PRETTY_FUNCTION__ << "] invalid detid " << detid<< std::endl;
158  continue;
159  }
160 
161 
163 
164  // book Layer and RING plots
165  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid,tTopo,false);
166  /*
167  std::string thickness;
168  std::pair<std::string,int32_t> det_layer_pair_test = folder_organizer.GetSubDetAndLayerThickness(detid,tTopo,thickness);
169  std::cout << "[SiStripMonitorTrack::book] det_layer_pair " << det_layer_pair.first << " " << det_layer_pair.second << " " << thickness << std::endl;
170  */
171 
172  SiStripHistoId hidmanager;
173  std::string layer_id = hidmanager.getSubdetid(detid, tTopo, false);
174 
175  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_id);
176  if(iLayerME==LayerMEsMap.end()){
177  folder_organizer.setLayerFolder(detid, tTopo, det_layer_pair.second, false);
178  bookLayerMEs(ibooker , detid, layer_id);
179  }
180 
181  std::string subdet = det_layer_pair.first;
182  if ( subdet.find("TEC") != std::string::npos || subdet.find("TID") != std::string::npos ) {
183  std::pair<std::string,int32_t> det_ring_pair = folder_organizer.GetSubDetAndLayer(detid,tTopo,true);
184  std::string ring_id = hidmanager.getSubdetid(detid, tTopo, true);
185  std::map<std::string, RingMEs>::iterator iRingME = RingMEsMap.find(ring_id);
186  if(iRingME==RingMEsMap.end()){
187  folder_organizer.setLayerFolder(detid, tTopo, det_ring_pair.second, true);
188  bookRingMEs(ibooker , detid, ring_id);
189  }
190  }
191 
192  // book sub-detector plots
193  std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
194  if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
195  ibooker.setCurrentFolder(sdet_pair.first);
196  bookSubDetMEs(ibooker , sdet_pair.second);
197  }
198  // book module plots
199  if(Mod_On_) {
200  folder_organizer.setDetectorFolder(detid,tTopo);
201  bookModMEs(ibooker , *detid_iter);
202  }
203  }//end loop on detectors detid
204 }
205 
206 //--------------------------------------------------------------------------------
207 void SiStripMonitorTrack::bookModMEs(DQMStore::IBooker & ibooker , const uint32_t id)//Histograms at MODULE level
208 {
209  std::string name = "det";
210  SiStripHistoId hidmanager;
211  std::string hid = hidmanager.createHistoId("",name,id);
212  std::map<std::string, ModMEs>::iterator iModME = ModMEsMap.find(hid);
213  if(iModME==ModMEsMap.end()){
214  ModMEs theModMEs;
215  theModMEs.ClusterStoNCorr = 0;
216  theModMEs.ClusterCharge = 0;
217  theModMEs.ClusterChargeCorr = 0;
218  theModMEs.ClusterWidth = 0;
219  theModMEs.ClusterPos = 0;
220  theModMEs.ClusterPGV = 0;
221  theModMEs.ClusterChargePerCMfromTrack = 0;
222  theModMEs.ClusterChargePerCMfromOrigin = 0;
223 
224  // Cluster Width
225  theModMEs.ClusterWidth=bookME1D(ibooker , "TH1ClusterWidth", hidmanager.createHistoId("ClusterWidth_OnTrack",name,id).c_str());
226  ibooker.tag(theModMEs.ClusterWidth,id);
227  // Cluster Charge
228  theModMEs.ClusterCharge=bookME1D(ibooker , "TH1ClusterCharge", hidmanager.createHistoId("ClusterCharge_OnTrack",name,id).c_str());
229  ibooker.tag(theModMEs.ClusterCharge,id);
230  // Cluster Charge Corrected
231  theModMEs.ClusterChargeCorr=bookME1D(ibooker , "TH1ClusterChargeCorr", hidmanager.createHistoId("ClusterChargeCorr_OnTrack",name,id).c_str());
232  ibooker.tag(theModMEs.ClusterChargeCorr,id);
233  // Cluster StoN Corrected
234  theModMEs.ClusterStoNCorr=bookME1D(ibooker , "TH1ClusterStoNCorrMod", hidmanager.createHistoId("ClusterStoNCorr_OnTrack",name,id).c_str());
235  ibooker.tag(theModMEs.ClusterStoNCorr,id);
236  // Cluster Position
237  short total_nr_strips = SiStripDetCabling_->nApvPairs(id) * 2 * 128;
238  theModMEs.ClusterPos=ibooker.book1D(hidmanager.createHistoId("ClusterPosition_OnTrack",name,id).c_str(),hidmanager.createHistoId("ClusterPosition_OnTrack",name,id).c_str(),total_nr_strips,0.5,total_nr_strips+0.5);
239  ibooker.tag(theModMEs.ClusterPos,id);
240  // Cluster PGV
241  theModMEs.ClusterPGV=bookMEProfile(ibooker , "TProfileClusterPGV", hidmanager.createHistoId("PGV_OnTrack",name,id).c_str());
242  ibooker.tag(theModMEs.ClusterPGV,id);
243  // Cluster Charge per cm
244  theModMEs.ClusterChargePerCMfromTrack = bookME1D(ibooker , "TH1ClusterChargePerCM", hidmanager.createHistoId("ClusterChargePerCMfromTrack",name,id).c_str());
245  ibooker.tag(theModMEs.ClusterChargePerCMfromTrack,id);
246 
247  theModMEs.ClusterChargePerCMfromOrigin = bookME1D(ibooker , "TH1ClusterChargePerCM", hidmanager.createHistoId("ClusterChargePerCMfromOrigin",name,id).c_str());
248  ibooker.tag(theModMEs.ClusterChargePerCMfromOrigin,id);
249 
250  ModMEsMap[hid]=theModMEs;
251  }
252 }
253 
255 
256  MonitorElement* me = NULL;
257  bool view = false;
258  view = (conf_.getParameter<edm::ParameterSet>(histoParameters.c_str())).getParameter<bool>(viewParameter.c_str());
259  if ( id.find("TEC") == std::string::npos && id.find("TID") == std::string::npos ) {
260  me = bookME1D(ibooker , histoParameters.c_str(), histoName.c_str());
261  } else {
262  if (view) {
263  // histoName = histoName + "__" + thickness;
264  me = bookME1D(ibooker , histoParameters.c_str(), histoName.c_str());
265  }
266  }
267  return me;
268 }
269 
270 //
271 // -- Book Layer Level Histograms and Trend plots
272 //
273 //------------------------------------------------------------------------
274 void SiStripMonitorTrack::bookLayerMEs(DQMStore::IBooker & ibooker , const uint32_t mod_id, std::string& layer_id)
275 {
276  std::string name = "layer";
277  std::string view = "layerView";
278  std::string hname;
279  std::string hpar;
280  SiStripHistoId hidmanager;
281 
282  LayerMEs theLayerMEs;
283  theLayerMEs.ClusterStoNCorrOnTrack = 0;
284  theLayerMEs.ClusterChargeCorrOnTrack = 0;
285  theLayerMEs.ClusterChargeOnTrack = 0;
286  theLayerMEs.ClusterChargeOffTrack = 0;
287  theLayerMEs.ClusterNoiseOnTrack = 0;
288  theLayerMEs.ClusterNoiseOffTrack = 0;
289  theLayerMEs.ClusterWidthOnTrack = 0;
290  theLayerMEs.ClusterWidthOffTrack = 0;
291  theLayerMEs.ClusterPosOnTrack = 0;
292  theLayerMEs.ClusterPosOffTrack = 0;
293  theLayerMEs.ClusterChargePerCMfromTrack = 0;
294  theLayerMEs.ClusterChargePerCMfromOriginOnTrack = 0;
295  theLayerMEs.ClusterChargePerCMfromOriginOffTrack = 0;
296 
297  // Signal/Noise (w/ cluster charge corrected)
298  hname = hidmanager.createHistoLayer("Summary_ClusterStoNCorr",name,layer_id,"OnTrack");
299  hpar = "TH1ClusterStoNCorr";
300  theLayerMEs.ClusterStoNCorrOnTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
301 
302  // Cluster Charge Corrected
303  hname = hidmanager.createHistoLayer("Summary_ClusterChargeCorr",name,layer_id,"OnTrack");
304  hpar = "TH1ClusterChargeCorr";
305  theLayerMEs.ClusterChargeCorrOnTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
306 
307  // Cluster Charge (On and Off Track)
308  hname = hidmanager.createHistoLayer("Summary_ClusterCharge",name,layer_id,"OnTrack");
309  hpar = "TH1ClusterCharge";
310  theLayerMEs.ClusterChargeOnTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
311 
312  hname = hidmanager.createHistoLayer("Summary_ClusterCharge",name,layer_id,"OffTrack");
313  hpar = "TH1ClusterCharge";
314  theLayerMEs.ClusterChargeOffTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
315 
316  // Cluster Noise (On and Off Track)
317  hname = hidmanager.createHistoLayer("Summary_ClusterNoise",name,layer_id,"OnTrack");
318  hpar = "TH1ClusterNoise";
319  theLayerMEs.ClusterNoiseOnTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
320 
321  hname = hidmanager.createHistoLayer("Summary_ClusterNoise",name,layer_id,"OffTrack");
322  hpar = "TH1ClusterNoise";
323  theLayerMEs.ClusterNoiseOffTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
324 
325  // Cluster Width (On and Off Track)
326  hname = hidmanager.createHistoLayer("Summary_ClusterWidth",name,layer_id,"OnTrack");
327  hpar = "TH1ClusterWidth";
328  theLayerMEs.ClusterWidthOnTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
329 
330  hname = hidmanager.createHistoLayer("Summary_ClusterWidth",name,layer_id,"OffTrack");
331  hpar = "TH1ClusterWidth";
332  theLayerMEs.ClusterWidthOffTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
333 
334  //Cluster Position
335  short total_nr_strips = SiStripDetCabling_->nApvPairs(mod_id) * 2 * 128;
336  if (layer_id.find("TEC") != std::string::npos) total_nr_strips = 3 * 2 * 128;
337 
338  hname = hidmanager.createHistoLayer("Summary_ClusterPosition",name,layer_id,"OnTrack");
339  theLayerMEs.ClusterPosOnTrack = ibooker.book1D(hname, hname, total_nr_strips, 0.5,total_nr_strips+0.5);
340 
341  hname = hidmanager.createHistoLayer("Summary_ClusterPosition",name,layer_id,"OffTrack");
342  theLayerMEs.ClusterPosOffTrack = ibooker.book1D(hname, hname, total_nr_strips, 0.5,total_nr_strips+0.5);
343 
344  // dQ/dx
345  hname = hidmanager.createHistoLayer("Summary_ClusterChargePerCMfromTrack",name,layer_id,"");
346  hpar = "TH1ClusterChargePerCM";
347  theLayerMEs.ClusterChargePerCMfromTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
348 
349  hname = hidmanager.createHistoLayer("Summary_ClusterChargePerCMfromOrigin",name,layer_id,"OnTrack");
350  hpar = "TH1ClusterChargePerCM";
351  theLayerMEs.ClusterChargePerCMfromOriginOnTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
352 
353  hname = hidmanager.createHistoLayer("Summary_ClusterChargePerCMfromOrigin",name,layer_id,"OffTrack");
354  hpar = "TH1ClusterChargePerCM";
355  theLayerMEs.ClusterChargePerCMfromOriginOffTrack = handleBookMEs(ibooker,view,layer_id,hpar,hname);
356 
357  //bookeeping
358  LayerMEsMap[layer_id]=theLayerMEs;
359 
360 }
361 
363 {
364 
365  std::string name = "ring";
366  std::string view = "ringView";
367  std::string hname;
368  std::string hpar;
369  SiStripHistoId hidmanager;
370 
371  RingMEs theRingMEs;
372  theRingMEs.ClusterStoNCorrOnTrack = 0;
373  theRingMEs.ClusterChargeCorrOnTrack = 0;
374  theRingMEs.ClusterChargeOnTrack = 0;
375  theRingMEs.ClusterChargeOffTrack = 0;
376  theRingMEs.ClusterNoiseOnTrack = 0;
377  theRingMEs.ClusterNoiseOffTrack = 0;
378  theRingMEs.ClusterWidthOnTrack = 0;
379  theRingMEs.ClusterWidthOffTrack = 0;
380  theRingMEs.ClusterChargePerCMfromTrack = 0;
383 
384  hname = hidmanager.createHistoLayer("Summary_ClusterStoNCorr",name,ring_id,"OnTrack");
385  hpar = "TH1ClusterStoNCorr";
386  theRingMEs.ClusterStoNCorrOnTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
387 
388  // Cluster Charge Corrected
389  hname = hidmanager.createHistoLayer("Summary_ClusterChargeCorr",name,ring_id,"OnTrack");
390  hpar = "TH1ClusterChargeCorr";
391  theRingMEs.ClusterChargeCorrOnTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
392 
393  // Cluster Charge (On and Off Track)
394  hname = hidmanager.createHistoLayer("Summary_ClusterCharge",name,ring_id,"OnTrack");
395  hpar = "TH1ClusterCharge";
396  theRingMEs.ClusterChargeOnTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
397 
398  hname = hidmanager.createHistoLayer("Summary_ClusterCharge",name,ring_id,"OffTrack");
399  hpar = "TH1ClusterCharge";
400  theRingMEs.ClusterChargeOffTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
401 
402  // Cluster Noise (On and Off Track)
403  hname = hidmanager.createHistoLayer("Summary_ClusterNoise",name,ring_id,"OnTrack");
404  hpar = "TH1ClusterNoise";
405  theRingMEs.ClusterNoiseOnTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
406 
407  hname = hidmanager.createHistoLayer("Summary_ClusterNoise",name,ring_id,"OffTrack");
408  hpar = "TH1ClusterNoise";
409  theRingMEs.ClusterNoiseOffTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
410 
411  // Cluster Width (On and Off Track)
412  hname = hidmanager.createHistoLayer("Summary_ClusterWidth",name,ring_id,"OnTrack");
413  hpar = "TH1ClusterWidth";
414  theRingMEs.ClusterWidthOnTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
415 
416  hname = hidmanager.createHistoLayer("Summary_ClusterWidth",name,ring_id,"OffTrack");
417  hpar = "TH1ClusterWidth";
418  theRingMEs.ClusterWidthOffTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
419 
420  // dQ/dx
421  hname = hidmanager.createHistoLayer("Summary_ClusterChargePerCMfromTrack",name,ring_id,"");
422  hpar = "TH1ClusterChargePerCM";
423  theRingMEs.ClusterChargePerCMfromTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
424 
425  hname = hidmanager.createHistoLayer("Summary_ClusterChargePerCMfromOrigin",name,ring_id,"OnTrack");
426  hpar = "TH1ClusterChargePerCM";
427  theRingMEs.ClusterChargePerCMfromOriginOnTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
428 
429  hname = hidmanager.createHistoLayer("Summary_ClusterChargePerCMfromOrigin",name,ring_id,"OffTrack");
430  hpar = "TH1ClusterChargePerCM";
431  theRingMEs.ClusterChargePerCMfromOriginOffTrack = handleBookMEs(ibooker,view,ring_id,hpar,hname);
432 
433  //bookeeping
434  RingMEsMap[ring_id]=theRingMEs;
435 
436 }
437 //------------------------------------------------------------------------
438 //
439 // -- Book Histograms at Sub-Detector Level
440 //
442 
444  subdet_tag = "__" + name;
445  std::string completeName;
446 
447  SubDetMEs theSubDetMEs;
448  theSubDetMEs.totNClustersOnTrack = 0;
449  theSubDetMEs.totNClustersOffTrack = 0;
450  theSubDetMEs.nClustersOnTrack = 0;
451  theSubDetMEs.nClustersTrendOnTrack = 0;
452  theSubDetMEs.nClustersOffTrack = 0;
453  theSubDetMEs.nClustersTrendOffTrack = 0;
454  theSubDetMEs.ClusterStoNCorrOnTrack = 0;
455  theSubDetMEs.ClusterChargeOnTrack = 0;
456  theSubDetMEs.ClusterChargeOffTrack = 0;
457  theSubDetMEs.ClusterStoNOffTrack = 0;
458  theSubDetMEs.ClusterChargePerCMfromTrack = 0;
459  theSubDetMEs.ClusterChargePerCMfromOriginOnTrack = 0;
460  theSubDetMEs.ClusterChargePerCMfromOriginOffTrack = 0;
461 
462  // TotalNumber of Cluster OnTrack
463  completeName = "Summary_TotalNumberOfClusters_OnTrack" + subdet_tag;
464  theSubDetMEs.nClustersOnTrack = bookME1D(ibooker , "TH1nClustersOn", completeName.c_str());
465  theSubDetMEs.nClustersOnTrack->getTH1()->StatOverflows(kTRUE);
466 
467  // TotalNumber of Cluster OffTrack
468  completeName = "Summary_TotalNumberOfClusters_OffTrack" + subdet_tag;
469  theSubDetMEs.nClustersOffTrack = bookME1D(ibooker , "TH1nClustersOff", completeName.c_str());
470  theSubDetMEs.nClustersOffTrack->getTH1()->StatOverflows(kTRUE);
471 
472  // Cluster StoN On Track
473  completeName = "Summary_ClusterStoNCorr_OnTrack" + subdet_tag;
474  theSubDetMEs.ClusterStoNCorrOnTrack = bookME1D(ibooker , "TH1ClusterStoNCorr", completeName.c_str());
475 
476  // Cluster Charge On Track
477  completeName = "Summary_ClusterCharge_OnTrack" + subdet_tag;
478  theSubDetMEs.ClusterChargeOnTrack=bookME1D(ibooker , "TH1ClusterCharge", completeName.c_str());
479 
480  // Cluster Charge Off Track
481  completeName = "Summary_ClusterCharge_OffTrack" + subdet_tag;
482  theSubDetMEs.ClusterChargeOffTrack=bookME1D(ibooker , "TH1ClusterCharge", completeName.c_str());
483 
484  // Cluster Charge StoN Off Track
485  completeName = "Summary_ClusterStoN_OffTrack" + subdet_tag;
486  theSubDetMEs.ClusterStoNOffTrack = bookME1D(ibooker , "TH1ClusterStoN", completeName.c_str());
487 
488  // cluster charge per cm on track
489  completeName = "Summary_ClusterChargePerCMfromTrack" + subdet_tag;
490  theSubDetMEs.ClusterChargePerCMfromTrack=bookME1D(ibooker , "TH1ClusterChargePerCM", completeName.c_str());
491 
492  // cluster charge per cm on track
493  completeName = "Summary_ClusterChargePerCMfromOrigin_OnTrack" + subdet_tag;
494  theSubDetMEs.ClusterChargePerCMfromOriginOnTrack=bookME1D(ibooker , "TH1ClusterChargePerCM", completeName.c_str());
495 
496  // cluster charge per cm off track
497  completeName = "Summary_ClusterChargePerCMfromOrigin_OffTrack" + subdet_tag;
498  theSubDetMEs.ClusterChargePerCMfromOriginOffTrack=bookME1D(ibooker , "TH1ClusterChargePerCM", completeName.c_str());
499 
500  if(Trend_On_){
501  // TotalNumber of Cluster
502  completeName = "Trend_TotalNumberOfClusters_OnTrack" + subdet_tag;
503  theSubDetMEs.nClustersTrendOnTrack = bookMETrend(ibooker , completeName.c_str());
504  completeName = "Trend_TotalNumberOfClusters_OffTrack" + subdet_tag;
505  theSubDetMEs.nClustersTrendOffTrack = bookMETrend(ibooker , completeName.c_str());
506  }
507 
508  //bookeeping
509  SubDetMEsMap[name]=theSubDetMEs;
510 
511 }
512 //--------------------------------------------------------------------------------
513 
514 MonitorElement* SiStripMonitorTrack::bookME1D(DQMStore::IBooker & ibooker , const char* ParameterSetLabel, const char* HistoName)
515 {
516  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
517  return ibooker.book1D(HistoName,HistoName,
518  Parameters.getParameter<int32_t>("Nbinx"),
519  Parameters.getParameter<double>("xmin"),
520  Parameters.getParameter<double>("xmax")
521  );
522 }
523 
524 //--------------------------------------------------------------------------------
525 MonitorElement* SiStripMonitorTrack::bookME2D(DQMStore::IBooker & ibooker , const char* ParameterSetLabel, const char* HistoName)
526 {
527  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
528  return ibooker.book2D(HistoName,HistoName,
529  Parameters.getParameter<int32_t>("Nbinx"),
530  Parameters.getParameter<double>("xmin"),
531  Parameters.getParameter<double>("xmax"),
532  Parameters.getParameter<int32_t>("Nbiny"),
533  Parameters.getParameter<double>("ymin"),
534  Parameters.getParameter<double>("ymax")
535  );
536 }
537 
538 //--------------------------------------------------------------------------------
539 MonitorElement* SiStripMonitorTrack::bookME3D(DQMStore::IBooker & ibooker , const char* ParameterSetLabel, const char* HistoName)
540 {
541  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
542  return ibooker.book3D(HistoName,HistoName,
543  Parameters.getParameter<int32_t>("Nbinx"),
544  Parameters.getParameter<double>("xmin"),
545  Parameters.getParameter<double>("xmax"),
546  Parameters.getParameter<int32_t>("Nbiny"),
547  Parameters.getParameter<double>("ymin"),
548  Parameters.getParameter<double>("ymax"),
549  Parameters.getParameter<int32_t>("Nbinz"),
550  Parameters.getParameter<double>("zmin"),
551  Parameters.getParameter<double>("zmax")
552  );
553 }
554 
555 //--------------------------------------------------------------------------------
556 MonitorElement* SiStripMonitorTrack::bookMEProfile(DQMStore::IBooker & ibooker , const char* ParameterSetLabel, const char* HistoName)
557 {
558  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
559  return ibooker.bookProfile(HistoName,HistoName,
560  Parameters.getParameter<int32_t>("Nbinx"),
561  Parameters.getParameter<double>("xmin"),
562  Parameters.getParameter<double>("xmax"),
563  Parameters.getParameter<int32_t>("Nbiny"),
564  Parameters.getParameter<double>("ymin"),
565  Parameters.getParameter<double>("ymax"),
566  "" );
567 }
568 
569 //--------------------------------------------------------------------------------
571 {
572  edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
573  MonitorElement* me = ibooker.bookProfile(HistoName,HistoName,
574  ParametersTrend.getParameter<int32_t>("Nbins"),
575  ParametersTrend.getParameter<double>("xmin"),
576  ParametersTrend.getParameter<double>("xmax"),
577  0 , 0 , "" );
578  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetCanExtend(TH1::kAllAxes);
579 
580  if(!me) return me;
581  me->setAxisTitle("Lumisection",1);
582  return me;
583 }
584 
585 //------------------------------------------------------------------------------------------
586 void SiStripMonitorTrack::trajectoryStudy(const edm::Ref<std::vector<Trajectory> > traj, const edm::EventSetup& es) {
587 
588 
589  const std::vector<TrajectoryMeasurement> & measurements = traj->measurements();
590  std::vector<TrajectoryMeasurement>::const_iterator traj_mes_iterator;
591  for(std::vector<TrajectoryMeasurement>::const_iterator traj_mes_iterator= measurements.begin(), traj_mes_end=measurements.end();
592  traj_mes_iterator!=traj_mes_end;traj_mes_iterator++){//loop on measurements
593  //trajectory local direction and position on detector
594  LocalVector statedirection;
595 
596  TrajectoryStateOnSurface updatedtsos=traj_mes_iterator->updatedState();
597  ConstRecHitPointer ttrh=traj_mes_iterator->recHit();
598 
599  if (!ttrh->isValid()) continue;
600 
601  const ProjectedSiStripRecHit2D* projhit = dynamic_cast<const ProjectedSiStripRecHit2D*>( ttrh->hit() );
602  const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>( ttrh->hit() );
603  const SiStripRecHit2D* hit2D = dynamic_cast<const SiStripRecHit2D*>( ttrh->hit() );
604  const SiStripRecHit1D* hit1D = dynamic_cast<const SiStripRecHit1D*>( ttrh->hit() );
605 
606  // RecHitType type=Single;
607 
608  if(matchedhit){
609  LogTrace("SiStripMonitorTrack")<<"\nMatched recHit found"<< std::endl;
610  // type=Matched;
611 
612  GluedGeomDet * gdet=(GluedGeomDet *)tkgeom_->idToDet(matchedhit->geographicalId());
613  GlobalVector gtrkdirup=gdet->toGlobal(updatedtsos.localMomentum());
614  //mono side
615  const GeomDetUnit * monodet=gdet->monoDet();
616  statedirection=monodet->toLocal(gtrkdirup);
617  SiStripRecHit2D m = matchedhit->monoHit();
618  // if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&m,statedirection,trackref,es);
619  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&m,statedirection,es);
620  //stereo side
621  const GeomDetUnit * stereodet=gdet->stereoDet();
622  statedirection=stereodet->toLocal(gtrkdirup);
623  SiStripRecHit2D s = matchedhit->stereoHit();
624  // if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&s,statedirection,trackref,es);
625  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&s,statedirection,es);
626  }
627  else if(projhit){
628  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found"<< std::endl;
629  // type=Projected;
630  GluedGeomDet * gdet=(GluedGeomDet *)tkgeom_->idToDet(projhit->geographicalId());
631 
632  GlobalVector gtrkdirup=gdet->toGlobal(updatedtsos.localMomentum());
633  const SiStripRecHit2D originalhit=projhit->originalHit();
634  const GeomDetUnit * det;
635  if(!StripSubdetector(originalhit.geographicalId().rawId()).stereo()){
636  //mono side
637  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found MONO"<< std::endl;
638  det=gdet->monoDet();
639  statedirection=det->toLocal(gtrkdirup);
640  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&(originalhit),statedirection,es);
641  }
642  else{
643  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found STEREO"<< std::endl;
644  //stereo side
645  det=gdet->stereoDet();
646  statedirection=det->toLocal(gtrkdirup);
647  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&(originalhit),statedirection,es);
648  }
649  }else if (hit2D){
650  statedirection=updatedtsos.localMomentum();
651  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(hit2D,statedirection,es);
652  } else if (hit1D) {
653  statedirection=updatedtsos.localMomentum();
654  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit1D>(hit1D,statedirection,es);
655  } else {
656  LogDebug ("SiStripMonitorTrack")
657  << " LocalMomentum: "<<statedirection
658  << "\nLocal x-z plane angle: "<<atan2(statedirection.x(),statedirection.z());
659  }
660 
661  }
662 
663 }
664 //------------------------------------------------------------------------
666  const ProjectedSiStripRecHit2D* projhit,
667  const SiStripMatchedRecHit2D* matchedhit,
668  const SiStripRecHit2D* hit2D,
669  const SiStripRecHit1D* hit1D,
670  LocalVector localMomentum
671  ) {
672  LocalVector statedirection;
673  if(matchedhit){ // type=Matched;
674  LogTrace("SiStripMonitorTrack")<<"\nMatched recHit found"<< std::endl;
675 
676  GluedGeomDet * gdet=(GluedGeomDet *)tkgeom_->idToDet(matchedhit->geographicalId());
677 
678  GlobalVector gtrkdirup=gdet->toGlobal(localMomentum);
679 
680  //mono side
681  const GeomDetUnit * monodet=gdet->monoDet();
682  statedirection=monodet->toLocal(gtrkdirup);
683  SiStripRecHit2D m = matchedhit->monoHit();
684  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&m,statedirection,es);
685 
686  //stereo side
687  const GeomDetUnit * stereodet=gdet->stereoDet();
688  statedirection=stereodet->toLocal(gtrkdirup);
689  SiStripRecHit2D s = matchedhit->stereoHit();
690  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&s,statedirection,es);
691  }
692  else if(projhit){ // type=Projected;
693  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found"<< std::endl;
694 
695  GluedGeomDet * gdet=(GluedGeomDet *)tkgeom_->idToDet(projhit->geographicalId());
696 
697  GlobalVector gtrkdirup=gdet->toGlobal(localMomentum);
698  const SiStripRecHit2D originalhit=projhit->originalHit();
699 
700  const GeomDetUnit * det;
701  if(!StripSubdetector(originalhit.geographicalId().rawId()).stereo()){
702  //mono side
703  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found MONO"<< std::endl;
704  det=gdet->monoDet();
705  statedirection=det->toLocal(gtrkdirup);
706  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&(originalhit),statedirection,es);
707  }
708  else{
709  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found STEREO"<< std::endl;
710  //stereo side
711  det=gdet->stereoDet();
712  statedirection=det->toLocal(gtrkdirup);
713  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&(originalhit),statedirection,es);
714  }
715  } else if (hit2D){ // type=2D
716  statedirection=localMomentum;
717  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(hit2D,statedirection,es);
718  } else if (hit1D) { // type=1D
719  statedirection=localMomentum;
720  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit1D>(hit1D,statedirection,es);
721  } else {
722  LogDebug ("SiStripMonitorTrack")
723  << " LocalMomentum: "<<statedirection
724  << "\nLocal x-z plane angle: "<<atan2(statedirection.x(),statedirection.z());
725  }
726 
727 }
728 //------------------------------------------------------------------------
730 
731 using namespace std;
732 using namespace edm;
733 using namespace reco;
734 
735  // trajectory input
736  edm::Handle<TrajTrackAssociationCollection> TItkAssociatorCollection;
737  ev.getByToken(trackTrajToken_, TItkAssociatorCollection);
738  if( TItkAssociatorCollection.isValid()){
739  trackStudyFromTrajectory(TItkAssociatorCollection,es);
740  } else {
741  edm::LogError("SiStripMonitorTrack")<<"Association not found ... try w/ track collection"<<std::endl;
742 
743  // edm::Handle<std::vector<Trajectory> > trajectories;
744  // ev.getByToken(trajectoryToken_, trajectories);
745 
746  // track input
747  edm::Handle<reco::TrackCollection > trackCollectionHandle;
748  ev.getByToken(trackToken_, trackCollectionHandle);//takes the track collection
749  if (!trackCollectionHandle.isValid()){
750  edm::LogError("SiStripMonitorTrack")<<"also Track Collection is not valid !! " << TrackLabel_<<std::endl;
751  return;
752  } else {
753  trackStudyFromTrack(trackCollectionHandle,es);
754  }
755  }
756 
757 }
758 //------------------------------------------------------------------------
760 
761  // edm::ESHandle<TransientTrackBuilder> builder;
762  // es.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
763  // const TransientTrackBuilder* transientTrackBuilder = builder.product();
764 
765  reco::TrackCollection trackCollection = *trackCollectionHandle;
766  for (reco::TrackCollection::const_iterator track = trackCollection.begin(), etrack = trackCollection.end();
767  track!=etrack; ++track) {
768 
769  // const reco::TransientTrack transientTrack = transientTrackBuilder->build(track);
770 
771 
772  for (trackingRecHit_iterator hit = track->recHitsBegin(), ehit = track->recHitsEnd();
773  hit!=ehit; ++hit) {
774  if (!(*hit)->isValid()) continue;
775  DetId detID = (*hit)->geographicalId();
776  if (detID.det() != DetId::Tracker) continue;
777  const TrackingRecHit* theHit = (*hit);
778  const ProjectedSiStripRecHit2D* projhit = dynamic_cast<const ProjectedSiStripRecHit2D*>( (theHit) );
779  const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*> ( (theHit) );
780  const SiStripRecHit2D* hit2D = dynamic_cast<const SiStripRecHit2D*> ( (theHit) );
781  const SiStripRecHit1D* hit1D = dynamic_cast<const SiStripRecHit1D*> ( (theHit) );
782 
783  // GlobalPoint globalPoint = hit->globalPosition();
784  // reco::TrajectoryStateOnSurface stateOnSurface = transientTrack->stateOnSurface(globalPoint);
785 
786  LocalVector localMomentum;
787  hitStudy(es,projhit,matchedhit,hit2D,hit1D,localMomentum);
788  }
789 
790 
791 
792  // hit pattern of the track
793  const reco::HitPattern & hitsPattern = track->hitPattern();
794  // loop over the hits of the track
795  // for (int i=0; i<hitsPattern.numberOfHits(); i++) {
796  for (int i=0; i<hitsPattern.numberOfHits(reco::HitPattern::TRACK_HITS); i++) {
797  uint32_t hit = hitsPattern.getHitPattern(reco::HitPattern::TRACK_HITS,i);
798 
799  // if the hit is valid and in pixel barrel, print out the layer
800  if (hitsPattern.validHitFilter(hit) && hitsPattern.pixelBarrelHitFilter(hit))
801 
802  if (!hitsPattern.validHitFilter(hit)) continue;
803 // if (hitsPattern.pixelHitFilter(hit)) std::cout << "pixel" << std::endl; // pixel
804 // if (hitsPattern.pixelBarrelHitFilter(hit)) std::cout << "pixel barrel" << std::endl; // pixel barrel
805 // if (hitsPattern.pixelEndcapHitFilter(hit)) std::cout << "pixel endcap" << std::endl; // pixel endcap
806 // if (hitsPattern.stripHitFilter(hit)) std::cout << "strip" << std::endl; // strip
807 // if (hitsPattern.stripTIBHitFilter(hit)) std::cout << "TIB" << std::endl; // strip TIB
808 // if (hitsPattern.stripTIDHitFilter(hit)) std::cout << "TID" << std::endl; // strip TID
809 // if (hitsPattern.stripTOBHitFilter(hit)) std::cout << "TOB" << std::endl; // strip TOB
810 // if (hitsPattern.stripTECHitFilter(hit)) std::cout << "TEC" << std::endl; // strip TEC
811 // if (hitsPattern.muonDTHitFilter(hit)) std::cout << "DT" << std::endl; // muon DT
812 // if (hitsPattern.muonCSCHitFilter(hit)) std::cout << "CSC" << std::endl; // muon CSC
813 // if (hitsPattern.muonRPCHitFilter(hit)) std::cout << "RPC" << std::endl; // muon RPC
814 //
815 // // expert level: printout the hit in 10-bit binary format
816 // std::cout << "hit in 10-bit binary format = ";
817 // for (int j=9; j>=0; j--) {
818 // int bit = (hit >> j) & 0x1;
819 // std::cout << bit;
820 // }
821 // std::cout << std::endl;
822  }
823  }
824 }
825 //------------------------------------------------------------------------
827  //Perform track study
828  int i=0;
829  for(TrajTrackAssociationCollection::const_iterator it = TItkAssociatorCollection->begin();it != TItkAssociatorCollection->end(); ++it){
830  const edm::Ref<std::vector<Trajectory> > traj_iterator = it->key;
831 
832  // Trajectory Map, extract Trajectory for this track
833  reco::TrackRef trackref = it->val;
834  LogDebug("SiStripMonitorTrack")
835  << "Track number "<< i+1 << std::endl;
836  // << "\n\tmomentum: " << trackref->momentum()
837  // << "\n\tPT: " << trackref->pt()
838  // << "\n\tvertex: " << trackref->vertex()
839  // << "\n\timpact parameter: " << trackref->d0()
840  // << "\n\tcharge: " << trackref->charge()
841  // << "\n\tnormalizedChi2: " << trackref->normalizedChi2()
842  // <<"\n\tFrom EXTRA : "
843  // <<"\n\t\touter PT "<< trackref->outerPt()<<std::endl;
844  i++;
845 
846  // trajectoryStudy(traj_iterator,trackref,es);
847  trajectoryStudy(traj_iterator,es);
848 
849  }
850 }
851 //------------------------------------------------------------------------
852 template <class T> void SiStripMonitorTrack::RecHitInfo(const T* tkrecHit, LocalVector LV, const edm::EventSetup& es){
853 
854  if(!tkrecHit->isValid()){
855  LogTrace("SiStripMonitorTrack") <<"\t\t Invalid Hit " << std::endl;
856  return;
857  }
858 
859  const uint32_t& detid = tkrecHit->geographicalId().rawId();
860 
861  LogTrace("SiStripMonitorTrack")
862  <<"\n\t\tRecHit on det "<<tkrecHit->geographicalId().rawId()
863  <<"\n\t\tRecHit in LP "<<tkrecHit->localPosition()
864  <<"\n\t\tRecHit in GP "<<tkgeom_->idToDet(tkrecHit->geographicalId())->surface().toGlobal(tkrecHit->localPosition())
865  <<"\n\t\tRecHit trackLocal vector "<<LV.x() << " " << LV.y() << " " << LV.z() <<std::endl;
866 
867 
868  //Retrieve tracker topology from geometry
869  edm::ESHandle<TrackerTopology> tTopoHandle;
870  es.get<IdealGeometryRecord>().get(tTopoHandle);
871  const TrackerTopology* const tTopo = tTopoHandle.product();
872 
873  //Get SiStripCluster from SiStripRecHit
874  if ( tkrecHit != NULL ){
875  const SiStripCluster* SiStripCluster_ = &*(tkrecHit->cluster());
876  SiStripClusterInfo SiStripClusterInfo_(*SiStripCluster_,es,detid);
877 
878  const Det2MEs MEs = findMEs(tTopo, detid);
879  if (clusterInfos(&SiStripClusterInfo_,detid, OnTrack, LV, MEs))
880  {
881  vPSiStripCluster.insert(SiStripCluster_);
882  }
883  }
884  else
885  {
886  edm::LogError("SiStripMonitorTrack") << "NULL hit" << std::endl;
887  }
888  }
889 
890 //------------------------------------------------------------------------
892 {
893 
894  //Retrieve tracker topology from geometry
895  edm::ESHandle<TrackerTopology> tTopoHandle;
896  es.get<IdealGeometryRecord>().get(tTopoHandle);
897  const TrackerTopology* const tTopo = tTopoHandle.product();
898 
900  ev.getByToken( clusterToken_, siStripClusterHandle);
901  if (!siStripClusterHandle.isValid()){
902  edm::LogError("SiStripMonitorTrack")<< "ClusterCollection is not valid!!" << std::endl;
903  return;
904  }
905  else
906  {
907  //Loop on Dets
908  for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=siStripClusterHandle->begin();
909  DSViter!=siStripClusterHandle->end();
910  DSViter++)
911  {
912  uint32_t detid=DSViter->id();
913  const Det2MEs MEs = findMEs(tTopo, detid);
914 
915  LogDebug("SiStripMonitorTrack") << "on detid "<< detid << " N Cluster= " << DSViter->size();
916 
917  //Loop on Clusters
919  ClusIter!=DSViter->end();
920  ClusIter++)
921  {
922  if (vPSiStripCluster.find(&*ClusIter) == vPSiStripCluster.end())
923  {
924  SiStripClusterInfo SiStripClusterInfo_(*ClusIter,es,detid);
925  clusterInfos(&SiStripClusterInfo_,detid,OffTrack,LV,MEs);
926  }
927  }
928  }
929  }
930 }
931 
932 //------------------------------------------------------------------------
934  SiStripHistoId hidmanager1;
935 
936  std::string layer_id = hidmanager1.getSubdetid(detid, tTopo, false);
937  std::string ring_id = hidmanager1.getSubdetid(detid, tTopo, true);
938  std::string sdet_tag = folderOrganizer_.getSubDetFolderAndTag(detid, tTopo).second;
939 
940  Det2MEs me;
941  me.iLayer = nullptr;
942  me.iRing = nullptr;
943  me.iSubdet = nullptr;
944 
945  std::map<std::string, LayerMEs>::iterator iLayer = LayerMEsMap.find(layer_id);
946  if (iLayer != LayerMEsMap.end()) {
947  me.iLayer = &(iLayer->second);
948  }
949 
950  std::map<std::string, RingMEs>::iterator iRing = RingMEsMap.find(ring_id);
951  if (iRing != RingMEsMap.end()) {
952  me.iRing = &(iRing->second);
953  }
954 
955  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(sdet_tag);
956  if (iSubdet != SubDetMEsMap.end()) {
957  me.iSubdet = &(iSubdet->second);
958  }
959 
960  return me;
961 }
962 
963 //------------------------------------------------------------------------
964 bool SiStripMonitorTrack::clusterInfos(SiStripClusterInfo* cluster, const uint32_t detid, enum ClusterFlags flag, const LocalVector LV, const Det2MEs& MEs)
965 {
966 
967  if (cluster==NULL) return false;
968  // if one imposes a cut on the clusters, apply it
969  if( (applyClusterQuality_) &&
970  (cluster->signalOverNoise() < sToNLowerLimit_ ||
971  cluster->signalOverNoise() > sToNUpperLimit_ ||
972  cluster->width() < widthLowerLimit_ ||
973  cluster->width() > widthUpperLimit_) ) return false;
974  // start of the analysis
975 
976  if (MEs.iSubdet != nullptr) {
977  if (flag == OnTrack) MEs.iSubdet->totNClustersOnTrack++;
978  else if (flag == OffTrack) MEs.iSubdet->totNClustersOffTrack++;
979  }
980 
981  float cosRZ = -2;
982  LogDebug("SiStripMonitorTrack")<< "\n\tLV " << LV.x() << " " << LV.y() << " " << LV.z() << " " << LV.mag() << std::endl;
983  if (LV.mag()!=0){
984  cosRZ= fabs(LV.z())/LV.mag();
985  LogDebug("SiStripMonitorTrack")<< "\n\t cosRZ " << cosRZ << std::endl;
986  }
988 
989  // Filling SubDet/Layer Plots (on Track + off Track)
990  fillMEs(cluster,detid,cosRZ,flag,LV,MEs);
991 
992  //******** TkHistoMaps
993  if (TkHistoMap_On_) {
994  uint32_t adet=cluster->detId();
995  float noise = cluster->noiseRescaledByGain();
996  if(flag==OnTrack){
997  tkhisto_NumOnTrack->add(adet,1.);
998  if(noise > 0.0) tkhisto_StoNCorrOnTrack->fill(adet,cluster->signalOverNoise()*cosRZ);
999  if(noise == 0.0)
1000  LogDebug("SiStripMonitorTrack") << "Module " << detid << " in Event " << eventNb << " noise " << noise << std::endl;
1001  }
1002  else if(flag==OffTrack){
1003  tkhisto_NumOffTrack->add(adet,1.);
1004  if(cluster->charge() > 250){
1005  LogDebug("SiStripMonitorTrack") << "Module firing " << detid << " in Event " << eventNb << std::endl;
1006  }
1007  }
1008  }
1009 
1010  // Module plots filled only for onTrack Clusters
1011  if(Mod_On_){
1012  if(flag==OnTrack){
1013  SiStripHistoId hidmanager2;
1014  name =hidmanager2.createHistoId("","det",detid);
1015  fillModMEs(cluster,name,cosRZ,detid,LV);
1016  }
1017  }
1018  return true;
1019 }
1021 //--------------------------------------------------------------------------------
1023 {
1024  std::map<std::string, ModMEs>::iterator iModME = ModMEsMap.find(name);
1025  if(iModME!=ModMEsMap.end()){
1026 
1027  float StoN = cluster->signalOverNoise();
1028  uint16_t charge = cluster->charge();
1029  uint16_t width = cluster->width();
1030  float position = cluster->baryStrip();
1031 
1032  // new dE/dx (chargePerCM)
1033  // https://indico.cern.ch/event/342236/session/5/contribution/10/material/slides/0.pdf
1034  float dQdx_fromTrack = siStripClusterTools::chargePerCM(detid, *cluster, LV);
1035  // from straigth line origin-sensor centre
1036  const StripGeomDetUnit* DetUnit = (const StripGeomDetUnit*) tkgeom_->idToDetUnit(DetId(detid));
1037  LocalPoint locVtx = DetUnit->toLocal(GlobalPoint(0.0, 0.0, 0.0));
1038  LocalVector locDir(locVtx.x(), locVtx.y(), locVtx.z());
1039  float dQdx_fromOrigin = siStripClusterTools::chargePerCM(detid, *cluster, locDir);
1040 
1041  float noise = cluster->noiseRescaledByGain();
1042  if(noise > 0.0) fillME(iModME->second.ClusterStoNCorr ,StoN*cos);
1043  if(noise == 0.0) LogDebug("SiStripMonitorTrack") << "Module " << name << " in Event " << eventNb << " noise " << noise << std::endl;
1044  fillME(iModME->second.ClusterCharge,charge);
1045 
1046  fillME(iModME->second.ClusterChargeCorr,charge*cos);
1047 
1048  fillME(iModME->second.ClusterWidth ,width);
1049  fillME(iModME->second.ClusterPos ,position);
1050 
1051  fillME(iModME->second.ClusterChargePerCMfromTrack, dQdx_fromTrack);
1052  fillME(iModME->second.ClusterChargePerCMfromOrigin, dQdx_fromOrigin);
1053 
1054  //fill the PGV histo
1055  float PGVmax = cluster->maxCharge();
1056  int PGVposCounter = cluster->maxIndex();
1057  for (int i= int(conf_.getParameter<edm::ParameterSet>("TProfileClusterPGV").getParameter<double>("xmin"));i<PGVposCounter;++i)
1058  fillME(iModME->second.ClusterPGV, i,0.);
1059  for (auto it=cluster->stripCharges().begin();it<cluster->stripCharges().end();++it) {
1060  fillME(iModME->second.ClusterPGV, PGVposCounter++,(*it)/PGVmax);
1061  }
1062  for (int i= PGVposCounter;i<int(conf_.getParameter<edm::ParameterSet>("TProfileClusterPGV").getParameter<double>("xmax"));++i)
1063  fillME(iModME->second.ClusterPGV, i,0.);
1064  //end fill the PGV histo
1065  }
1066 }
1067 
1068 
1069 //------------------------------------------------------------------------
1070 void SiStripMonitorTrack::fillMEs(SiStripClusterInfo* cluster, const uint32_t detid, float cos, enum ClusterFlags flag, const LocalVector LV, const Det2MEs& MEs)
1071 {
1072  float StoN = cluster->signalOverNoise();
1073  float noise = cluster->noiseRescaledByGain();
1074  uint16_t charge = cluster->charge();
1075  uint16_t width = cluster->width();
1076  float position = cluster->baryStrip();
1077 
1078  // new dE/dx (chargePerCM)
1079  // https://indico.cern.ch/event/342236/session/5/contribution/10/material/slides/0.pdf
1080  float dQdx_fromTrack = siStripClusterTools::chargePerCM(detid, *cluster, LV);
1081  // from straigth line origin-sensor centre
1082  const StripGeomDetUnit* DetUnit = (const StripGeomDetUnit*) tkgeom_->idToDetUnit(DetId(detid));
1083  LocalPoint locVtx = DetUnit->toLocal(GlobalPoint(0.0, 0.0, 0.0));
1084  LocalVector locDir(locVtx.x(), locVtx.y(), locVtx.z());
1085  float dQdx_fromOrigin = siStripClusterTools::chargePerCM(detid, *cluster, locDir);
1086 
1087  // layerMEs
1088  if (MEs.iLayer != nullptr) {
1089  if(flag==OnTrack){
1090  if(noise > 0.0) fillME(MEs.iLayer->ClusterStoNCorrOnTrack, StoN*cos);
1091  if(noise == 0.0) LogDebug("SiStripMonitorTrack") << "Module " << detid << " in Event " << eventNb << " noise " << cluster->noiseRescaledByGain() << std::endl;
1092  fillME(MEs.iLayer->ClusterChargeCorrOnTrack, charge*cos);
1093  fillME(MEs.iLayer->ClusterChargeOnTrack, charge);
1094  fillME(MEs.iLayer->ClusterNoiseOnTrack, noise);
1095  fillME(MEs.iLayer->ClusterWidthOnTrack, width);
1096  fillME(MEs.iLayer->ClusterPosOnTrack, position);
1097  fillME(MEs.iLayer->ClusterChargePerCMfromTrack, dQdx_fromTrack);
1098  fillME(MEs.iLayer->ClusterChargePerCMfromOriginOnTrack, dQdx_fromOrigin);
1099  } else {
1100  fillME(MEs.iLayer->ClusterChargeOffTrack, charge);
1101  fillME(MEs.iLayer->ClusterNoiseOffTrack, noise);
1102  fillME(MEs.iLayer->ClusterWidthOffTrack, width);
1103  fillME(MEs.iLayer->ClusterPosOffTrack, position);
1104  fillME(MEs.iLayer->ClusterChargePerCMfromOriginOffTrack, dQdx_fromOrigin);
1105  }
1106  }
1107 
1108  // ringMEs
1109  if (MEs.iRing != nullptr) {
1110  if(flag==OnTrack){
1111  if(noise > 0.0) fillME(MEs.iRing->ClusterStoNCorrOnTrack, StoN*cos);
1112  if(noise == 0.0) LogDebug("SiStripMonitorTrack") << "Module " << detid << " in Event " << eventNb << " noise " << cluster->noiseRescaledByGain() << std::endl;
1113  fillME(MEs.iRing->ClusterChargeCorrOnTrack, charge*cos);
1114  fillME(MEs.iRing->ClusterChargeOnTrack, charge);
1115  fillME(MEs.iRing->ClusterNoiseOnTrack, noise);
1116  fillME(MEs.iRing->ClusterWidthOnTrack, width);
1117  fillME(MEs.iRing->ClusterChargePerCMfromTrack, dQdx_fromTrack);
1118  fillME(MEs.iRing->ClusterChargePerCMfromOriginOnTrack, dQdx_fromOrigin);
1119  } else {
1120  fillME(MEs.iRing->ClusterChargeOffTrack, charge);
1121  fillME(MEs.iRing->ClusterNoiseOffTrack, noise);
1122  fillME(MEs.iRing->ClusterWidthOffTrack, width);
1123  fillME(MEs.iRing->ClusterChargePerCMfromOriginOffTrack, dQdx_fromOrigin);
1124  }
1125  }
1126  // subdetMEs
1127  if(MEs.iSubdet != nullptr){
1128  if(flag==OnTrack){
1129  fillME(MEs.iSubdet->ClusterChargeOnTrack,charge);
1130  if(noise > 0.0) fillME(MEs.iSubdet->ClusterStoNCorrOnTrack,StoN*cos);
1131  fillME(MEs.iSubdet->ClusterChargePerCMfromTrack,dQdx_fromTrack);
1132  fillME(MEs.iSubdet->ClusterChargePerCMfromOriginOnTrack,dQdx_fromOrigin);
1133  } else {
1134  fillME(MEs.iSubdet->ClusterChargeOffTrack,charge);
1135  if(noise > 0.0) fillME(MEs.iSubdet->ClusterStoNOffTrack,StoN);
1136  fillME(MEs.iSubdet->ClusterChargePerCMfromOriginOffTrack,dQdx_fromOrigin);
1137  }
1138  }
1139 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
uint8_t maxCharge() const
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
Det2MEs findMEs(const TrackerTopology *tTopo, const uint32_t detid)
int i
Definition: DBlmapReader.cc:9
MonitorElement * ClusterChargePerCMfromTrack
void fillMEs(SiStripClusterInfo *, const uint32_t detid, float, enum ClusterFlags, const LocalVector LV, const Det2MEs &MEs)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
TkHistoMap * tkhisto_NumOffTrack
SiStripMonitorTrack(const edm::ParameterSet &)
void setSiStripFolderName(std::string name)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void trackStudy(const edm::Event &ev, const edm::EventSetup &es)
void trackStudyFromTrack(edm::Handle< reco::TrackCollection > trackCollectionHandle, const edm::EventSetup &es)
edm::EDGetTokenT< reco::TrackCollection > trackToken_
void trackStudyFromTrajectory(edm::Handle< TrajTrackAssociationCollection > TItkAssociatorCollection, const edm::EventSetup &es)
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
void fillME(MonitorElement *ME, float value1)
std::pair< const std::string, const char * > getSubDetFolderAndTag(const uint32_t &detid, const TrackerTopology *tTopo)
SiStripDCSStatus * dcsStatus_
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
void hitStudy(const edm::EventSetup &es, const ProjectedSiStripRecHit2D *projhit, const SiStripMatchedRecHit2D *matchedhit, const SiStripRecHit2D *hit2D, const SiStripRecHit1D *hit1D, LocalVector localMomentum)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
float noiseRescaledByGain() const
void book(DQMStore::IBooker &, const TrackerTopology *tTopo)
void AllClusters(const edm::Event &ev, const edm::EventSetup &es)
std::map< std::string, RingMEs > RingMEsMap
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:52
float chargePerCM(DetId detid, Iter a, Iter b)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
float baryStrip() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
edm::ParameterSet conf_
T y() const
Definition: PV3DBase.h:63
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:67
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
MonitorElement * bookME1D(DQMStore::IBooker &, const char *, const char *)
#define NULL
Definition: scimark2.h:8
MonitorElement * ClusterChargePerCMfromTrack
bool ev
MonitorElement * ClusterChargeCorrOnTrack
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
data_type const * const_iterator
Definition: DetSetNew.h:30
key_type key() const
Accessor for product key.
Definition: Ref.h:266
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
void bookLayerMEs(DQMStore::IBooker &, const uint32_t, std::string &)
uint16_t maxIndex() const
void trajectoryStudy(const edm::Ref< std::vector< Trajectory > > traj, const edm::EventSetup &es)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static bool pixelBarrelHitFilter(uint16_t pattern)
Definition: HitPattern.h:516
MonitorElement * ClusterChargePerCMfromOriginOffTrack
auto stripCharges() const -> decltype(cluster() ->amplitudes())
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:698
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
LocalVector localMomentum() const
edm::ESHandle< TrackerGeometry > tkgeom_
bool getStatus(edm::Event const &e, edm::EventSetup const &eSetup)
edmNew::DetSet< SiStripCluster >::const_iterator ClusIter
math::XYZTLorentzVectorD LV
float signalOverNoise() const
T mag() const
Definition: PV3DBase.h:67
vector< ParameterSet > Parameters
edm::EventNumber_t eventNb
uint16_t hitPattern[ARRAY_LENGTH]
Definition: HitPattern.h:418
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
uint16_t charge() const
std::unordered_set< const SiStripCluster * > vPSiStripCluster
std::map< std::string, SubDetMEs > SubDetMEsMap
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:180
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
const std::string subdet_tag("SubDet")
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
MonitorElement * bookME2D(DQMStore::IBooker &, const char *, const char *)
uint16_t width() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:286
TH1 * getTH1(void) const
void bookSubDetMEs(DQMStore::IBooker &, std::string &name)
MonitorElement * bookME3D(DQMStore::IBooker &, const char *, const char *)
int orbitNumber() const
Definition: EventBase.h:67
MonitorElement * ClusterChargePerCMfromOrigin
MonitorElement * ClusterChargePerCMfromOriginOffTrack
SiStripFolderOrganizer folderOrganizer_
std::string getSubdetid(uint32_t id, const TrackerTopology *tTopo, bool flag_ring)
MonitorElement * ClusterChargePerCMfromTrack
bool isValid() const
Definition: HandleBase.h:75
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
#define LogTrace(id)
tuple conf
Definition: dbtoconf.py:185
SiStripRecHit2D originalHit() const
Definition: DetId.h:18
edm::EDGetTokenT< TrajTrackAssociationCollection > trackTrajToken_
void bookModMEs(DQMStore::IBooker &, const uint32_t)
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=0)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
SiStripRecHit2D stereoHit() const
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
MonitorElement * ClusterChargePerCMfromTrack
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &es)
std::map< std::string, ModMEs > ModMEsMap
MonitorElement * bookMETrend(DQMStore::IBooker &, const char *)
std::string HistoName
TkHistoMap * tkhisto_NumOnTrack
SiStripRecHit2D monoHit() const
uint32_t detId() const
GenericTriggerEventFlag * genTriggerEventFlag_
void RecHitInfo(const T *tkrecHit, LocalVector LV, const edm::EventSetup &)
MonitorElement * ClusterChargePerCMfromOriginOnTrack
edm::EventID id() const
Definition: EventBase.h:60
MonitorElement * handleBookMEs(DQMStore::IBooker &, std::string &, std::string &, std::string &, std::string &)
static int position[264][3]
Definition: ReadPGInfo.cc:509
MonitorElement * bookMEProfile(DQMStore::IBooker &, const char *, const char *)
TkHistoMap * tkhisto_StoNCorrOnTrack
DetId geographicalId() const
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
MonitorElement * ClusterChargePerCMfromOriginOnTrack
bool clusterInfos(SiStripClusterInfo *cluster, const uint32_t detid, enum ClusterFlags flags, LocalVector LV, const Det2MEs &MEs)
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:456
void fillModMEs(SiStripClusterInfo *cluster, std::string name, float cos, const uint32_t detid, const LocalVector LV)
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
MonitorElement * book3D(Args &&...args)
Definition: DQMStore.h:151
long double T
T x() const
Definition: PV3DBase.h:62
void bookRingMEs(DQMStore::IBooker &, const uint32_t, std::string &)
MonitorElement * ClusterChargePerCMfromOriginOnTrack
void add(uint32_t &detid, float value)
Definition: TkHistoMap.cc:213
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: Run.h:41
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:718
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusterToken_
std::map< std::string, LayerMEs > LayerMEsMap
MonitorElement * ClusterChargePerCMfromOriginOffTrack