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 
21 
23 
25 #include "TMath.h"
26 
28  dbe(edm::Service<DQMStore>().operator->()),
29  conf_(conf),
30  tracksCollection_in_EventTree(true),
31  firstEvent(-1),
32  genTriggerEventFlag_(new GenericTriggerEventFlag(conf))
33 {
34  Cluster_src_ = conf.getParameter<edm::InputTag>("Cluster_src");
35  Mod_On_ = conf.getParameter<bool>("Mod_On");
36  Trend_On_ = conf.getParameter<bool>("Trend_On");
37  flag_ring = conf.getParameter<bool>("RingFlag_On");
38  TkHistoMap_On_ = conf.getParameter<bool>("TkHistoMap_On");
39 
40  edm::ParameterSet ParametersClustersOn = conf_.getParameter<edm::ParameterSet>("TH1nClustersOn");
41  layerontrack = ParametersClustersOn.getParameter<bool>("layerswitchon");
42 
43  edm::ParameterSet ParametersClustersOff = conf_.getParameter<edm::ParameterSet>("TH1nClustersOff");
44  layerofftrack = ParametersClustersOff.getParameter<bool>("layerswitchon");
45 
46  edm::ParameterSet ParametersClusterCharge = conf_.getParameter<edm::ParameterSet>("TH1ClusterCharge");
47  layercharge = ParametersClusterCharge.getParameter<bool>("layerswitchon");
48 
49  edm::ParameterSet ParametersClusterStoN = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoN");
50  layerston = ParametersClusterStoN.getParameter<bool>("layerswitchon");
51 
52  edm::ParameterSet ParametersClusterChargeCorr = conf_.getParameter<edm::ParameterSet>("TH1ClusterChargeCorr");
53  layerchargecorr = ParametersClusterChargeCorr.getParameter<bool>("layerswitchon");
54 
55  edm::ParameterSet ParametersClusterStoNCorrOn = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNCorr");
56  layerstoncorrontrack = ParametersClusterStoNCorrOn.getParameter<bool>("layerswitchon");
57 
58  edm::ParameterSet ParametersClusterNoise = conf_.getParameter<edm::ParameterSet>("TH1ClusterNoise");
59  layernoise = ParametersClusterNoise.getParameter<bool>("layerswitchon");
60 
61  edm::ParameterSet ParametersClusterWidth = conf_.getParameter<edm::ParameterSet>("TH1ClusterWidth");
62  layerwidth = ParametersClusterWidth.getParameter<bool>("layerswitchon");
63 
64  TrackProducer_ = conf_.getParameter<std::string>("TrackProducer");
65  TrackLabel_ = conf_.getParameter<std::string>("TrackLabel");
66 
67  // cluster quality conditions
68  edm::ParameterSet cluster_condition = conf_.getParameter<edm::ParameterSet>("ClusterConditions");
69  applyClusterQuality_ = cluster_condition.getParameter<bool>("On");
70  sToNLowerLimit_ = cluster_condition.getParameter<double>("minStoN");
71  sToNUpperLimit_ = cluster_condition.getParameter<double>("maxStoN");
72  widthLowerLimit_ = cluster_condition.getParameter<double>("minWidth");
73  widthUpperLimit_ = cluster_condition.getParameter<double>("maxWidth");
74 
75 
76  // Create DCS Status
77  bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
78  if (checkDCS) dcsStatus_ = new SiStripDCSStatus();
79  else dcsStatus_ = 0;
80 }
81 
82 //------------------------------------------------------------------------
84  if (dcsStatus_) delete dcsStatus_;
86 }
87 
88 //------------------------------------------------------------------------
90 {
91  //get geom
93  LogDebug("SiStripMonitorTrack") << "[SiStripMonitorTrack::beginRun] There are "<<tkgeom->detUnits().size() <<" detectors instantiated in the geometry" << std::endl;
95 
96  book();
97 
98  // Initialize the GenericTriggerEventFlag
100 }
101 
102 //------------------------------------------------------------------------
104 {
105  if(conf_.getParameter<bool>("OutputMEsInRootFile")){
107  dbe->save(conf_.getParameter<std::string>("OutputFileName"));
108  }
109 }
110 
111 // ------------ method called to produce the data ------------
113 {
114  // Filter out events if DCS checking is requested
115  if (dcsStatus_ && !dcsStatus_->getStatus(e,es)) return;
116 
117  // Filter out events if Trigger Filtering is requested
118  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( e, es) ) return;
119 
120  //initialization of global quantities
121  LogDebug("SiStripMonitorTrack") << "[SiStripMonitorTrack::analyse] " << "Run " << e.id().run() << " Event " << e.id().event() << std::endl;
122  runNb = e.id().run();
123  eventNb = e.id().event();
124  vPSiStripCluster.clear();
125 
126  iOrbitSec = e.orbitNumber()/11223.0;
127 
128  // initialise # of clusters
129  for (std::map<std::string, SubDetMEs>::iterator iSubDet = SubDetMEsMap.begin();
130  iSubDet != SubDetMEsMap.end(); iSubDet++) {
131  iSubDet->second.totNClustersOnTrack = 0;
132  iSubDet->second.totNClustersOffTrack = 0;
133  }
134 
135  //Perform track study
136  trackStudy(e, es);
137 
138  //Perform Cluster Study (irrespectively to tracks)
139 
140  AllClusters(e, es); //analyzes the off Track Clusters
141 
142  //Summary Counts of clusters
143  std::map<std::string, MonitorElement*>::iterator iME;
144  std::map<std::string, LayerMEs>::iterator iLayerME;
145 
146  for (std::map<std::string, SubDetMEs>::iterator iSubDet = SubDetMEsMap.begin();
147  iSubDet != SubDetMEsMap.end(); iSubDet++) {
148  SubDetMEs subdet_mes = iSubDet->second;
149  fillME(subdet_mes.nClustersOnTrack, subdet_mes.totNClustersOnTrack);
150  fillME(subdet_mes.nClustersOffTrack, subdet_mes.totNClustersOffTrack);
151  if (Trend_On_) {
154  }
155  }
156 }
157 
158 //------------------------------------------------------------------------
160 {
161 
162  SiStripFolderOrganizer folder_organizer;
163  //******** TkHistoMaps
164  if (TkHistoMap_On_) {
165  tkhisto_StoNCorrOnTrack = new TkHistoMap("SiStrip/TkHisto" ,"TkHMap_StoNCorrOnTrack",0.0,1);
166  tkhisto_NumOnTrack = new TkHistoMap("SiStrip/TkHisto", "TkHMap_NumberOfOnTrackCluster",0.0,1);
167  tkhisto_NumOffTrack = new TkHistoMap("SiStrip/TkHisto", "TkHMap_NumberOfOfffTrackCluster",0.0,1);
168  }
169  //******** TkHistoMaps
170 
171  std::vector<uint32_t> vdetId_;
172  SiStripDetCabling_->addActiveDetectorsRawIds(vdetId_);
173  //Histos for each detector, layer and module
174  for (std::vector<uint32_t>::const_iterator detid_iter=vdetId_.begin();detid_iter!=vdetId_.end();detid_iter++){ //loop on all the active detid
175  uint32_t detid = *detid_iter;
176 
177  if (detid < 1){
178  edm::LogError("SiStripMonitorTrack")<< "[" <<__PRETTY_FUNCTION__ << "] invalid detid " << detid<< std::endl;
179  continue;
180  }
181 
182 
183  std::string name;
184 
185  // book Layer and RING plots
186  std::pair<std::string,int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid,flag_ring);
187 
188  SiStripHistoId hidmanager;
189  std::string layer_id = hidmanager.getSubdetid(detid, flag_ring);
190  std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_id);
191  if(iLayerME==LayerMEsMap.end()){
192  folder_organizer.setLayerFolder(detid, det_layer_pair.second, flag_ring);
193  bookLayerMEs(detid, layer_id);
194  }
195  // book sub-detector plots
196  std::pair<std::string,std::string> sdet_pair = folder_organizer.getSubDetFolderAndTag(detid);
197  if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()){
198  dbe->setCurrentFolder(sdet_pair.first);
199  bookSubDetMEs(sdet_pair.second);
200  }
201  // book module plots
202  if(Mod_On_) {
203  folder_organizer.setDetectorFolder(detid);
204  bookModMEs(*detid_iter);
205  }
206  }//end loop on detectors detid
207 }
208 
209 //--------------------------------------------------------------------------------
210 void SiStripMonitorTrack::bookModMEs(const uint32_t & id)//Histograms at MODULE level
211 {
212  std::string name = "det";
213  SiStripHistoId hidmanager;
214  std::string hid = hidmanager.createHistoId("",name,id);
215  std::map<std::string, ModMEs>::iterator iModME = ModMEsMap.find(hid);
216  if(iModME==ModMEsMap.end()){
217  ModMEs theModMEs;
218  theModMEs.ClusterStoNCorr = 0;
219  theModMEs.ClusterCharge = 0;
220  theModMEs.ClusterChargeCorr = 0;
221  theModMEs.ClusterWidth = 0;
222  theModMEs.ClusterPos = 0;
223  theModMEs.ClusterPGV = 0;
224 
225  // Cluster Width
226  theModMEs.ClusterWidth=bookME1D("TH1ClusterWidth", hidmanager.createHistoId("ClusterWidth_OnTrack",name,id).c_str());
227  dbe->tag(theModMEs.ClusterWidth,id);
228  // Cluster Charge
229  theModMEs.ClusterCharge=bookME1D("TH1ClusterCharge", hidmanager.createHistoId("ClusterCharge_OnTrack",name,id).c_str());
230  dbe->tag(theModMEs.ClusterCharge,id);
231  // Cluster Charge Corrected
232  theModMEs.ClusterChargeCorr=bookME1D("TH1ClusterChargeCorr", hidmanager.createHistoId("ClusterChargeCorr_OnTrack",name,id).c_str());
233  dbe->tag(theModMEs.ClusterChargeCorr,id);
234  // Cluster StoN Corrected
235  theModMEs.ClusterStoNCorr=bookME1D("TH1ClusterStoNCorrMod", hidmanager.createHistoId("ClusterStoNCorr_OnTrack",name,id).c_str());
236  dbe->tag(theModMEs.ClusterStoNCorr,id);
237  // Cluster Position
238  short total_nr_strips = SiStripDetCabling_->nApvPairs(id) * 2 * 128;
239  theModMEs.ClusterPos=dbe->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  dbe->tag(theModMEs.ClusterPos,id);
241  // Cluster PGV
242  theModMEs.ClusterPGV=bookMEProfile("TProfileClusterPGV", hidmanager.createHistoId("PGV_OnTrack",name,id).c_str());
243  dbe->tag(theModMEs.ClusterPGV,id);
244 
245  ModMEsMap[hid]=theModMEs;
246  }
247 }
248 //
249 // -- Book Layer Level Histograms and Trend plots
250 //
251 void SiStripMonitorTrack::bookLayerMEs(const uint32_t& mod_id, std::string& layer_id)
252 {
253  std::string name = "layer";
254  std::string hname;
255  SiStripHistoId hidmanager;
256 
257  LayerMEs theLayerMEs;
258  theLayerMEs.ClusterStoNCorrOnTrack = 0;
259  theLayerMEs.ClusterChargeCorrOnTrack = 0;
260  theLayerMEs.ClusterChargeOnTrack = 0;
261  theLayerMEs.ClusterChargeOffTrack = 0;
262  theLayerMEs.ClusterNoiseOnTrack = 0;
263  theLayerMEs.ClusterNoiseOffTrack = 0;
264  theLayerMEs.ClusterWidthOnTrack = 0;
265  theLayerMEs.ClusterWidthOffTrack = 0;
266  theLayerMEs.ClusterPosOnTrack = 0;
267  theLayerMEs.ClusterPosOffTrack = 0;
268 
269  // Cluster StoN Corrected
271  hname = hidmanager.createHistoLayer("Summary_ClusterStoNCorr",name,layer_id,"OnTrack");
272  theLayerMEs.ClusterStoNCorrOnTrack = bookME1D("TH1ClusterStoNCorr", hname.c_str());
273  }
274  // Cluster Charge Corrected
275  if (layerchargecorr){
276  hname = hidmanager.createHistoLayer("Summary_ClusterChargeCorr",name,layer_id,"OnTrack");
277  theLayerMEs.ClusterChargeCorrOnTrack = bookME1D("TH1ClusterChargeCorr", hname.c_str());
278  }
279  // Cluster Charge (On and Off Track)
280  if (layercharge){
281  hname = hidmanager.createHistoLayer("Summary_ClusterCharge",name,layer_id,"OnTrack");
282  theLayerMEs.ClusterChargeOnTrack = bookME1D("TH1ClusterCharge", hname.c_str());
283 
284  hname = hidmanager.createHistoLayer("Summary_ClusterCharge",name,layer_id,"OffTrack");
285  theLayerMEs.ClusterChargeOffTrack = bookME1D("TH1ClusterCharge", hname.c_str());
286  }
287  // Cluster Noise (On and Off Track)
288  if (layernoise){
289  hname = hidmanager.createHistoLayer("Summary_ClusterNoise",name,layer_id,"OnTrack");
290  theLayerMEs.ClusterNoiseOnTrack = bookME1D("TH1ClusterNoise", hname.c_str());
291 
292  hname = hidmanager.createHistoLayer("Summary_ClusterNoise",name,layer_id,"OffTrack");
293  theLayerMEs.ClusterNoiseOffTrack = bookME1D("TH1ClusterNoise", hname.c_str());
294  }
295  // Cluster Width (On and Off Track)
296  if (layerwidth){
297  hname = hidmanager.createHistoLayer("Summary_ClusterWidth",name,layer_id,"OnTrack");
298  theLayerMEs.ClusterWidthOnTrack = bookME1D("TH1ClusterWidth", hname.c_str());
299 
300  hname = hidmanager.createHistoLayer("Summary_ClusterWidth",name,layer_id,"OffTrack");
301  theLayerMEs.ClusterWidthOffTrack = bookME1D("TH1ClusterWidth", hname.c_str());
302  }
303  //Cluster Position
304  short total_nr_strips = SiStripDetCabling_->nApvPairs(mod_id) * 2 * 128;
305  if (layer_id.find("TEC") != std::string::npos && !flag_ring) total_nr_strips = 3 * 2 * 128;
306 
307  hname = hidmanager.createHistoLayer("Summary_ClusterPosition",name,layer_id,"OnTrack");
308  theLayerMEs.ClusterPosOnTrack = dbe->book1D(hname, hname, total_nr_strips, 0.5,total_nr_strips+0.5);
309 
310  hname = hidmanager.createHistoLayer("Summary_ClusterPosition",name,layer_id,"OffTrack");
311  theLayerMEs.ClusterPosOffTrack = dbe->book1D(hname, hname, total_nr_strips, 0.5,total_nr_strips+0.5);
312 
313  //bookeeping
314  LayerMEsMap[layer_id]=theLayerMEs;
315 }
316 //
317 // -- Book Histograms at Sub-Detector Level
318 //
320 
321  std::string subdet_tag;
322  subdet_tag = "__" + name;
323  std::string completeName;
324 
325  SubDetMEs theSubDetMEs;
326  theSubDetMEs.totNClustersOnTrack = 0;
327  theSubDetMEs.totNClustersOffTrack = 0;
328  theSubDetMEs.nClustersOnTrack = 0;
329  theSubDetMEs.nClustersTrendOnTrack = 0;
330  theSubDetMEs.nClustersOffTrack = 0;
331  theSubDetMEs.nClustersTrendOffTrack = 0;
332  theSubDetMEs.ClusterStoNCorrOnTrack = 0;
333  theSubDetMEs.ClusterChargeOffTrack = 0;
334  theSubDetMEs.ClusterStoNOffTrack = 0;
335 
336  // TotalNumber of Cluster OnTrack
337  completeName = "Summary_TotalNumberOfClusters_OnTrack" + subdet_tag;
338  theSubDetMEs.nClustersOnTrack = bookME1D("TH1nClustersOn", completeName.c_str());
339  theSubDetMEs.nClustersOnTrack->getTH1()->StatOverflows(kTRUE);
340 
341  // TotalNumber of Cluster OffTrack
342  completeName = "Summary_TotalNumberOfClusters_OffTrack" + subdet_tag;
343  theSubDetMEs.nClustersOffTrack = bookME1D("TH1nClustersOff", completeName.c_str());
344  theSubDetMEs.nClustersOffTrack->getTH1()->StatOverflows(kTRUE);
345 
346  // Cluster StoN On Track
347  completeName = "Summary_ClusterStoNCorr_OnTrack" + subdet_tag;
348  theSubDetMEs.ClusterStoNCorrOnTrack = bookME1D("TH1ClusterStoNCorr", completeName.c_str());
349 
350  // Cluster Charge Off Track
351  completeName = "Summary_ClusterCharge_OffTrack" + subdet_tag;
352  theSubDetMEs.ClusterChargeOffTrack=bookME1D("TH1ClusterCharge", completeName.c_str());
353 
354  // Cluster Charge StoN Off Track
355  completeName = "Summary_ClusterStoN_OffTrack" + subdet_tag;
356  theSubDetMEs.ClusterStoNOffTrack = bookME1D("TH1ClusterStoN", completeName.c_str());
357 
358  if(Trend_On_){
359  // TotalNumber of Cluster
360  completeName = "Trend_TotalNumberOfClusters_OnTrack" + subdet_tag;
361  theSubDetMEs.nClustersTrendOnTrack = bookMETrend("TH1nClustersOn", completeName.c_str());
362  completeName = "Trend_TotalNumberOfClusters_OffTrack" + subdet_tag;
363  theSubDetMEs.nClustersTrendOffTrack = bookMETrend("TH1nClustersOff", completeName.c_str());
364  }
365  //bookeeping
366  SubDetMEsMap[name]=theSubDetMEs;
367 }
368 //--------------------------------------------------------------------------------
369 
370 MonitorElement* SiStripMonitorTrack::bookME1D(const char* ParameterSetLabel, const char* HistoName)
371 {
372  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
373  return dbe->book1D(HistoName,HistoName,
374  Parameters.getParameter<int32_t>("Nbinx"),
375  Parameters.getParameter<double>("xmin"),
376  Parameters.getParameter<double>("xmax")
377  );
378 }
379 
380 //--------------------------------------------------------------------------------
381 MonitorElement* SiStripMonitorTrack::bookME2D(const char* ParameterSetLabel, const char* HistoName)
382 {
383  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
384  return dbe->book2D(HistoName,HistoName,
385  Parameters.getParameter<int32_t>("Nbinx"),
386  Parameters.getParameter<double>("xmin"),
387  Parameters.getParameter<double>("xmax"),
388  Parameters.getParameter<int32_t>("Nbiny"),
389  Parameters.getParameter<double>("ymin"),
390  Parameters.getParameter<double>("ymax")
391  );
392 }
393 
394 //--------------------------------------------------------------------------------
395 MonitorElement* SiStripMonitorTrack::bookME3D(const char* ParameterSetLabel, const char* HistoName)
396 {
397  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
398  return dbe->book3D(HistoName,HistoName,
399  Parameters.getParameter<int32_t>("Nbinx"),
400  Parameters.getParameter<double>("xmin"),
401  Parameters.getParameter<double>("xmax"),
402  Parameters.getParameter<int32_t>("Nbiny"),
403  Parameters.getParameter<double>("ymin"),
404  Parameters.getParameter<double>("ymax"),
405  Parameters.getParameter<int32_t>("Nbinz"),
406  Parameters.getParameter<double>("zmin"),
407  Parameters.getParameter<double>("zmax")
408  );
409 }
410 
411 //--------------------------------------------------------------------------------
412 MonitorElement* SiStripMonitorTrack::bookMEProfile(const char* ParameterSetLabel, const char* HistoName)
413 {
414  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
415  return dbe->bookProfile(HistoName,HistoName,
416  Parameters.getParameter<int32_t>("Nbinx"),
417  Parameters.getParameter<double>("xmin"),
418  Parameters.getParameter<double>("xmax"),
419  Parameters.getParameter<int32_t>("Nbiny"),
420  Parameters.getParameter<double>("ymin"),
421  Parameters.getParameter<double>("ymax"),
422  "" );
423 }
424 
425 //--------------------------------------------------------------------------------
426 MonitorElement* SiStripMonitorTrack::bookMETrend(const char* ParameterSetLabel, const char* HistoName)
427 {
428  Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
429  edm::ParameterSet ParametersTrend = conf_.getParameter<edm::ParameterSet>("Trending");
430  MonitorElement* me = dbe->bookProfile(HistoName,HistoName,
431  ParametersTrend.getParameter<int32_t>("Nbins"),
432  0,
433  ParametersTrend.getParameter<int32_t>("Nbins"),
434  100, //that parameter should not be there !?
435  Parameters.getParameter<double>("xmin"),
436  Parameters.getParameter<double>("xmax"),
437  "" );
438  if (me->kind() == MonitorElement::DQM_KIND_TPROFILE) me->getTH1()->SetBit(TH1::kCanRebin);
439 
440  if(!me) return me;
441  me->setAxisTitle("Event Time in Seconds",1);
442  return me;
443 }
444 
445 //------------------------------------------------------------------------------------------
447 
448  // track input
449 
450  edm::Handle<reco::TrackCollection > trackCollectionHandle;
451  ev.getByLabel(TrackProducer_, TrackLabel_, trackCollectionHandle);//takes the track collection
452  if (!trackCollectionHandle.isValid()){
453  edm::LogError("SiStripMonitorTrack")<<" Track Collection is not valid !! " << TrackLabel_<<std::endl;
454  return;
455  }
456 
457  // trajectory input
458  edm::Handle<TrajTrackAssociationCollection> TItkAssociatorCollection;
459  ev.getByLabel(TrackProducer_, TrackLabel_, TItkAssociatorCollection);
460  if( !TItkAssociatorCollection.isValid()){
461  edm::LogError("SiStripMonitorTrack")<<"Association not found "<<std::endl;
462  return;
463  }
464 
465  //Perform track study
466  int i=0;
467  for(TrajTrackAssociationCollection::const_iterator it = TItkAssociatorCollection->begin();it != TItkAssociatorCollection->end(); ++it){
468  const edm::Ref<std::vector<Trajectory> > traj_iterator = it->key;
469  // Trajectory Map, extract Trajectory for this track
470  reco::TrackRef trackref = it->val;
471  LogDebug("SiStripMonitorTrack")
472  << "Track number "<< i+1
473  << "\n\tmomentum: " << trackref->momentum()
474  << "\n\tPT: " << trackref->pt()
475  << "\n\tvertex: " << trackref->vertex()
476  << "\n\timpact parameter: " << trackref->d0()
477  << "\n\tcharge: " << trackref->charge()
478  << "\n\tnormalizedChi2: " << trackref->normalizedChi2()
479  <<"\n\tFrom EXTRA : "
480  <<"\n\t\touter PT "<< trackref->outerPt()<<std::endl;
481  i++;
482 
483  const std::vector<TrajectoryMeasurement> & measurements = traj_iterator->measurements();
484  std::vector<TrajectoryMeasurement>::const_iterator traj_mes_iterator;
485  int nhit=0;
486  for(std::vector<TrajectoryMeasurement>::const_iterator traj_mes_iterator= measurements.begin();traj_mes_iterator!=measurements.end();traj_mes_iterator++){//loop on measurements
487  //trajectory local direction and position on detector
488  LocalPoint stateposition;
489  LocalVector statedirection;
490 
491  TrajectoryStateOnSurface updatedtsos=traj_mes_iterator->updatedState();
492  ConstRecHitPointer ttrh=traj_mes_iterator->recHit();
493  if (!ttrh->isValid()) {continue;}
494 
495  nhit++;
496 
497  const ProjectedSiStripRecHit2D* phit = dynamic_cast<const ProjectedSiStripRecHit2D*>( ttrh->hit() );
498  const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>( ttrh->hit() );
499  const SiStripRecHit2D* hit2D = dynamic_cast<const SiStripRecHit2D*>( ttrh->hit() );
500  const SiStripRecHit1D* hit1D = dynamic_cast<const SiStripRecHit1D*>( ttrh->hit() );
501 
502  // RecHitType type=Single;
503 
504  if(matchedhit){
505  LogTrace("SiStripMonitorTrack")<<"\nMatched recHit found"<< std::endl;
506  // type=Matched;
507 
508  GluedGeomDet * gdet=(GluedGeomDet *)tkgeom->idToDet(matchedhit->geographicalId());
509  GlobalVector gtrkdirup=gdet->toGlobal(updatedtsos.localMomentum());
510  //mono side
511  const GeomDetUnit * monodet=gdet->monoDet();
512  statedirection=monodet->toLocal(gtrkdirup);
513  SiStripRecHit2D m = matchedhit->monoHit();
514  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&m,statedirection,trackref,es);
515  //stereo side
516  const GeomDetUnit * stereodet=gdet->stereoDet();
517  statedirection=stereodet->toLocal(gtrkdirup);
518  SiStripRecHit2D s = matchedhit->stereoHit();
519  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&s,statedirection,trackref,es);
520  }
521  else if(phit){
522  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found"<< std::endl;
523  // type=Projected;
524  GluedGeomDet * gdet=(GluedGeomDet *)tkgeom->idToDet(phit->geographicalId());
525 
526  GlobalVector gtrkdirup=gdet->toGlobal(updatedtsos.localMomentum());
527  const SiStripRecHit2D& originalhit=phit->originalHit();
528  const GeomDetUnit * det;
529  if(!StripSubdetector(originalhit.geographicalId().rawId()).stereo()){
530  //mono side
531  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found MONO"<< std::endl;
532  det=gdet->monoDet();
533  statedirection=det->toLocal(gtrkdirup);
534  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&(phit->originalHit()),statedirection,trackref,es);
535  }
536  else{
537  LogTrace("SiStripMonitorTrack")<<"\nProjected recHit found STEREO"<< std::endl;
538  //stereo side
539  det=gdet->stereoDet();
540  statedirection=det->toLocal(gtrkdirup);
541  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(&(phit->originalHit()),statedirection,trackref,es);
542  }
543  }else if (hit2D){
544  statedirection=updatedtsos.localMomentum();
545  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit2D>(hit2D,statedirection,trackref,es);
546  } else if (hit1D) {
547  statedirection=updatedtsos.localMomentum();
548  if(statedirection.mag() != 0) RecHitInfo<SiStripRecHit1D>(hit1D,statedirection,trackref,es);
549  } else {
550  LogDebug ("SiStrioMonitorTrack")
551  << " LocalMomentum: "<<statedirection
552  << "\nLocal x-z plane angle: "<<atan2(statedirection.x(),statedirection.z());
553  }
554  }
555  }
556 }
557 
558 template <class T> void SiStripMonitorTrack::RecHitInfo(const T* tkrecHit, LocalVector LV,reco::TrackRef track_ref, const edm::EventSetup& es){
559 
560  if(!tkrecHit->isValid()){
561  LogTrace("SiStripMonitorTrack") <<"\t\t Invalid Hit " << std::endl;
562  return;
563  }
564 
565  const uint32_t& detid = tkrecHit->geographicalId().rawId();
567  LogTrace("SiStripMonitorTrack") << "Modules Excluded" << std::endl;
568  return;
569  }
570 
571  LogTrace("SiStripMonitorTrack")
572  <<"\n\t\tRecHit on det "<<tkrecHit->geographicalId().rawId()
573  <<"\n\t\tRecHit in LP "<<tkrecHit->localPosition()
574  <<"\n\t\tRecHit in GP "<<tkgeom->idToDet(tkrecHit->geographicalId())->surface().toGlobal(tkrecHit->localPosition())
575  <<"\n\t\tRecHit trackLocal vector "<<LV.x() << " " << LV.y() << " " << LV.z() <<std::endl;
576 
577  //Get SiStripCluster from SiStripRecHit
578  if ( tkrecHit != NULL ){
579  const SiStripCluster* SiStripCluster_ = &*(tkrecHit->cluster());
580  SiStripClusterInfo SiStripClusterInfo_(*SiStripCluster_,es,detid);
581 
582  if ( clusterInfos(&SiStripClusterInfo_,detid,OnTrack, LV ) ) {
583  vPSiStripCluster.push_back(SiStripCluster_);
584  }
585  }else{
586  edm::LogError("SiStripMonitorTrack") << "NULL hit" << std::endl;
587  }
588  }
589 
590 //------------------------------------------------------------------------
591 
593 {
595  ev.getByLabel( Cluster_src_, siStripClusterHandle);
596  if (!siStripClusterHandle.isValid()){
597  edm::LogError("SiStripMonitorTrack")<< "ClusterCollection is not valid!!" << std::endl;
598  return;
599  }
600  //Loop on Dets
601  for ( edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=siStripClusterHandle->begin(); DSViter!=siStripClusterHandle->end();DSViter++){
602  uint32_t detid=DSViter->id();
603  if (find(ModulesToBeExcluded_.begin(),ModulesToBeExcluded_.end(),detid)!=ModulesToBeExcluded_.end()) continue;
604  //Loop on Clusters
605  LogDebug("SiStripMonitorTrack") << "on detid "<< detid << " N Cluster= " << DSViter->size();
607  for(; ClusIter!=DSViter->end(); ClusIter++) {
609  SiStripClusterInfo SiStripClusterInfo_(*ClusIter,es,detid);
610  clusterInfos(&SiStripClusterInfo_,detid,OffTrack,LV);
611  }
612  }
613  }
614 }
615 
616 //------------------------------------------------------------------------
618 {
619  if (cluster==0) return false;
620  // if one imposes a cut on the clusters, apply it
621  if( (applyClusterQuality_) &&
622  (cluster->signalOverNoise() < sToNLowerLimit_ ||
623  cluster->signalOverNoise() > sToNUpperLimit_ ||
624  cluster->width() < widthLowerLimit_ ||
625  cluster->width() > widthUpperLimit_) ) return false;
626  // start of the analysis
627 
628  std::pair<std::string,std::string> sdet_pair = folderOrganizer_.getSubDetFolderAndTag(detid);
629  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(sdet_pair.second);
630  if(iSubdet != SubDetMEsMap.end()){
631  if (flag == OnTrack) iSubdet->second.totNClustersOnTrack++;
632  else if (flag == OffTrack) iSubdet->second.totNClustersOffTrack++;
633  }
634 
635  float cosRZ = -2;
636  LogDebug("SiStripMonitorTrack")<< "\n\tLV " << LV.x() << " " << LV.y() << " " << LV.z() << " " << LV.mag() << std::endl;
637  if (LV.mag()!=0){
638  cosRZ= fabs(LV.z())/LV.mag();
639  LogDebug("SiStripMonitorTrack")<< "\n\t cosRZ " << cosRZ << std::endl;
640  }
641  std::string name;
642 
643  // Filling SubDet/Layer Plots (on Track + off Track)
644  fillMEs(cluster,detid,cosRZ,flag);
645 
646 
647  //******** TkHistoMaps
648  if (TkHistoMap_On_) {
649  uint32_t adet=cluster->detId();
650  float noise = cluster->noiseRescaledByGain();
651  if(flag==OnTrack){
652  tkhisto_NumOnTrack->add(adet,1.);
653  if(noise > 0.0) tkhisto_StoNCorrOnTrack->fill(adet,cluster->signalOverNoise()*cosRZ);
654  if(noise == 0.0)
655  LogDebug("SiStripMonitorTrack") << "Module " << detid << " in Event " << eventNb << " noise " << noise << std::endl;
656  }
657  else if(flag==OffTrack){
658  tkhisto_NumOffTrack->add(adet,1.);
659  if(cluster->charge() > 250){
660  LogDebug("SiStripMonitorTrack") << "Module firing " << detid << " in Event " << eventNb << std::endl;
661  }
662  }
663  }
664 
665  // Module plots filled only for onTrack Clusters
666  if(Mod_On_){
667  if(flag==OnTrack){
668  SiStripHistoId hidmanager2;
669  name =hidmanager2.createHistoId("","det",detid);
670  fillModMEs(cluster,name,cosRZ);
671  }
672  }
673  return true;
674 }
675 
676 //--------------------------------------------------------------------------------
678 {
679  std::map<std::string, ModMEs>::iterator iModME = ModMEsMap.find(name);
680  if(iModME!=ModMEsMap.end()){
681 
682  float StoN = cluster->signalOverNoise();
683  uint16_t charge = cluster->charge();
684  uint16_t width = cluster->width();
685  float position = cluster->baryStrip();
686 
687  float noise = cluster->noiseRescaledByGain();
688  if(noise > 0.0) fillME(iModME->second.ClusterStoNCorr ,StoN*cos);
689  if(noise == 0.0) LogDebug("SiStripMonitorTrack") << "Module " << name << " in Event " << eventNb << " noise " << noise << std::endl;
690  fillME(iModME->second.ClusterCharge,charge);
691 
692  fillME(iModME->second.ClusterChargeCorr,charge*cos);
693 
694  fillME(iModME->second.ClusterWidth ,width);
695  fillME(iModME->second.ClusterPos ,position);
696 
697  //fill the PGV histo
698  float PGVmax = cluster->maxCharge();
699  int PGVposCounter = cluster->maxIndex();
700  for (int i= int(conf_.getParameter<edm::ParameterSet>("TProfileClusterPGV").getParameter<double>("xmin"));i<PGVposCounter;++i)
701  fillME(iModME->second.ClusterPGV, i,0.);
702  for (std::vector<uint8_t>::const_iterator it=cluster->stripCharges().begin();it<cluster->stripCharges().end();++it) {
703  fillME(iModME->second.ClusterPGV, PGVposCounter++,(*it)/PGVmax);
704  }
705  for (int i= PGVposCounter;i<int(conf_.getParameter<edm::ParameterSet>("TProfileClusterPGV").getParameter<double>("xmax"));++i)
706  fillME(iModME->second.ClusterPGV, i,0.);
707  //end fill the PGV histo
708  }
709 }
710 
711 //------------------------------------------------------------------------
713 {
714  std::pair<std::string,int32_t> SubDetAndLayer = folderOrganizer_.GetSubDetAndLayer(detid,flag_ring);
715  SiStripHistoId hidmanager1;
716  std::string layer_id = hidmanager1.getSubdetid(detid,flag_ring);
717 
718  std::pair<std::string,std::string> sdet_pair = folderOrganizer_.getSubDetFolderAndTag(detid);
719  float StoN = cluster->signalOverNoise();
720  float noise = cluster->noiseRescaledByGain();
721  uint16_t charge = cluster->charge();
722  uint16_t width = cluster->width();
723  float position = cluster->baryStrip();
724 
725  std::map<std::string, LayerMEs>::iterator iLayer = LayerMEsMap.find(layer_id);
726  if (iLayer != LayerMEsMap.end()) {
727  if(flag==OnTrack){
728  if(noise > 0.0 && layerstoncorrontrack) fillME(iLayer->second.ClusterStoNCorrOnTrack, StoN*cos);
729  if(noise == 0.0) LogDebug("SiStripMonitorTrack") << "Module " << detid << " in Event " << eventNb << " noise " << cluster->noiseRescaledByGain() << std::endl;
730  if(layerchargecorr) fillME(iLayer->second.ClusterChargeCorrOnTrack, charge*cos);
731  if (layercharge) fillME(iLayer->second.ClusterChargeOnTrack, charge);
732  if (layernoise) fillME(iLayer->second.ClusterNoiseOnTrack, noise);
733  if (layerwidth) fillME(iLayer->second.ClusterWidthOnTrack, width);
734  fillME(iLayer->second.ClusterPosOnTrack, position);
735  } else {
736  if (layercharge) fillME(iLayer->second.ClusterChargeOffTrack, charge);
737  if (layernoise) fillME(iLayer->second.ClusterNoiseOffTrack, noise);
738  if (layerwidth) fillME(iLayer->second.ClusterWidthOffTrack, width);
739  fillME(iLayer->second.ClusterPosOffTrack, position);
740  }
741  }
742  std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(sdet_pair.second);
743  if(iSubdet != SubDetMEsMap.end() ){
744  if(flag==OnTrack){
745  if(noise > 0.0) fillME(iSubdet->second.ClusterStoNCorrOnTrack,StoN*cos);
746  } else {
747  fillME(iSubdet->second.ClusterChargeOffTrack,charge);
748  if(noise > 0.0) fillME(iSubdet->second.ClusterStoNOffTrack,StoN);
749  }
750  }
751 }
752 //
753 // -- Get Subdetector Tag from the Folder name
754 //
755 void SiStripMonitorTrack::getSubDetTag(std::string& folder_name, std::string& tag){
756 
757  tag = folder_name.substr(folder_name.find("MechanicalView")+15);
758  if (tag.find("side_") != std::string::npos) {
759  tag.replace(tag.find_last_of("/"),1,"_");
760  }
761 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
uint8_t maxCharge() const
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
bool clusterInfos(SiStripClusterInfo *cluster, const uint32_t &detid, enum ClusterFlags flags, LocalVector LV)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
TkHistoMap * tkhisto_NumOffTrack
long int flag
Definition: mlp_lapack.h:47
SiStripMonitorTrack(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void trackStudy(const edm::Event &ev, const edm::EventSetup &es)
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
void fillME(MonitorElement *ME, float value1)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
SiStripDCSStatus * dcsStatus_
MonitorElement * book3D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ)
Book 3D histogram.
Definition: DQMStore.cc:979
float noiseRescaledByGain() const
void AllClusters(const edm::Event &ev, const edm::EventSetup &es)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
void bookLayerMEs(const uint32_t &, std::string &)
float baryStrip() const
edm::ParameterSet conf_
T y() const
Definition: PV3DBase.h:62
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
#define NULL
Definition: scimark2.h:8
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:25
void fillMEs(SiStripClusterInfo *, uint32_t detid, float, enum ClusterFlags)
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
uint16_t maxIndex() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void bookSubDetMEs(std::string &name)
double charge(const std::vector< uint8_t > &Ampls)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1354
LocalVector localMomentum() const
bool getStatus(edm::Event const &e, edm::EventSetup const &eSetup)
edmNew::DetSet< SiStripCluster >::const_iterator ClusIter
math::XYZTLorentzVectorD LV
float signalOverNoise() const
std::string getSubdetid(uint32_t id, bool flag_ring)
T mag() const
Definition: PV3DBase.h:66
vector< ParameterSet > Parameters
std::pair< std::string, std::string > getSubDetFolderAndTag(const uint32_t &detid)
uint16_t charge() const
std::map< std::string, SubDetMEs > SubDetMEsMap
void fillModMEs(SiStripClusterInfo *, std::string, float)
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:130
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:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
uint16_t width() const
TH1 * getTH1(void) const
std::vector< const SiStripCluster * > vPSiStripCluster
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1031
edm::ESHandle< TrackerGeometry > tkgeom
int orbitNumber() const
Definition: EventBase.h:63
void setDetectorFolder(uint32_t rawdetid=0)
SiStripFolderOrganizer folderOrganizer_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
tuple conf
Definition: dbtoconf.py:185
MonitorElement * bookMETrend(const char *, const char *)
void getSubDetTag(std::string &folder_name, std::string &tag)
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
const T & get() const
Definition: EventSetup.h:55
key_type key() const
Accessor for product key.
Definition: Ref.h:266
std::map< std::string, ModMEs > ModMEsMap
std::string HistoName
TkHistoMap * tkhisto_NumOnTrack
uint32_t detId() const
GenericTriggerEventFlag * genTriggerEventFlag_
const std::vector< uint8_t > & stripCharges() const
edm::EventID id() const
Definition: EventBase.h:56
iterator end()
Definition: DetSetNew.h:59
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
MonitorElement * bookME2D(const char *, const char *)
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, bool ring_flag=0)
MonitorElement * bookMEProfile(const char *, const char *)
MonitorElement * bookME3D(const char *, const char *)
TkHistoMap * tkhisto_StoNCorrOnTrack
DetId geographicalId() const
std::vector< uint32_t > ModulesToBeExcluded_
virtual void endJob(void)
void showDirStructure(void) const
Definition: DQMStore.cc:2761
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
void bookModMEs(const uint32_t &)
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
MonitorElement * bookME1D(const char *, const char *)
void setLayerFolder(uint32_t rawdetid=0, int32_t layer=0, bool ring_flag=0)
long double T
T x() const
Definition: PV3DBase.h:61
void add(uint32_t &detid, float value)
Definition: TkHistoMap.cc:163
const SiStripRecHit2D & originalHit() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
Definition: Run.h:33
std::map< std::string, LayerMEs > LayerMEsMap
void RecHitInfo(const T *tkrecHit, LocalVector LV, reco::TrackRef track_ref, const edm::EventSetup &)