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