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