CMS 3D CMS Logo

SiStripQualityHotStripIdentifier.cc
Go to the documentation of this file.
2 
4 
12 #include <iostream>
13 #include <fstream>
14 #include <sstream>
15 
16 //Insert here the include to the algos
18 
19 
20 
22  m_cacheID_(0),
23  dataLabel_(iConfig.getUntrackedParameter<std::string>("dataLabel","")),
24  conf_(iConfig),
25  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
26  Cluster_src_(iConfig.getParameter<edm::InputTag>( "Cluster_src" )),
27  Track_src_(iConfig.getUntrackedParameter<edm::InputTag>( "Track_src" )),
28  tracksCollection_in_EventTree(iConfig.getUntrackedParameter<bool>("RemoveTrackClusters",false)),
29  tTopo(nullptr)
30 {
32 
34  MinClusterWidth_=pset.getUntrackedParameter<uint32_t>("minWidth",1);
35  MaxClusterWidth_=pset.getUntrackedParameter<uint32_t>("maxWidth",1000);
36 
37  bookHistos();
38 }
39 
41 }
42 
44 
46 
48  std::string AlgoName = parameters.getParameter<std::string>("AlgoName");
49  if (AlgoName=="SiStripHotStripAlgorithmFromClusterOccupancy"){
50 
51  edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] call to SiStripHotStripAlgorithmFromClusterOccupancy"<<std::endl;
52 
54  theIdentifier.setProbabilityThreshold(parameters.getUntrackedParameter<double>("ProbabilityThreshold",1.E-7));
55  theIdentifier.setMinNumEntries(parameters.getUntrackedParameter<uint32_t>("MinNumEntries",100));
56  theIdentifier.setMinNumEntriesPerStrip(parameters.getUntrackedParameter<uint32_t>("MinNumEntriesPerStrip",5));
57 
58  SiStripQuality* qobj = new SiStripQuality();
60 
61  edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] copy SiStripObject in SiStripBadStrip"<<std::endl;
62 
63  std::stringstream ss;
64 
67  for(;rIter!=rIterEnd;++rIter){
68  SiStripBadStrip::Range range(qobj->getDataVectorBegin()+rIter->ibegin,qobj->getDataVectorBegin()+rIter->iend);
69  if ( ! obj->put(rIter->detid,range) )
70  edm::LogError("SiStripQualityHotStripIdentifier")<<"[SiStripQualityHotStripIdentifier::getNewObject] detid already exists"<<std::endl;
71  }
72  edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] " << ss.str() << std::endl;
73 
74  } else {
75  edm::LogError("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] call for a unknow HotStrip identification algoritm"<<std::endl;
76 
77  std::vector<uint32_t> a;
78  SiStripBadStrip::Range range(a.begin(),a.end());
79  if ( ! obj->put(0xFFFFFFFF,range) )
80  edm::LogError("SiStripQualityHotStripIdentifier")<<"[SiStripQualityHotStripIdentifier::getNewObject] detid already exists"<<std::endl;
81  }
82 
83  return obj;
84 }
85 
87  //Retrieve tracker topology from geometry
89  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
90  tTopo = tTopoHandle.product();
91 
92  resetHistos();
93  unsigned long long cacheID = iSetup.get<SiStripQualityRcd>().cacheIdentifier();
94 
95  if (m_cacheID_ == cacheID)
96  return;
97 
98  m_cacheID_ = cacheID;
99 
101 
102 }
103 
105  //Clear map
106  ClusterPositionHistoMap.clear();
107 }
108 
110  edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::resetHistos] " << std::endl;
111  SiStrip::QualityHistosMap::iterator it=ClusterPositionHistoMap.begin();
112  SiStrip::QualityHistosMap::iterator iEnd=ClusterPositionHistoMap.end();
113  for (;it!=iEnd;++it){
114  it->second->Reset();
115  }
116 }
117 
119  edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::bookHistos] " << std::endl;
120  char hname[1024];
121  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it =reader->getAllData().begin();
122  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator iEnd =reader->getAllData().end();
123  for(; it!=iEnd; ++it){
124  sprintf(hname,"h_%d",it->first);
125  SiStrip::QualityHistosMap::iterator ref=ClusterPositionHistoMap.find(it->first);
126  if (ref==ClusterPositionHistoMap.end()){
127  ClusterPositionHistoMap[it->first]=boost::shared_ptr<TH1F>(new TH1F(hname,hname,it->second.nApvs*128,-0.5,it->second.nApvs*128-0.5));
128  }
129  else
130  edm::LogError("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::bookHistos] DetId " << it->first << " already found in map. Ignoring new data"<<std::endl;
131  }
132 }
133 
135 
136  SiStrip::QualityHistosMap::iterator ref=ClusterPositionHistoMap.find(detid);
137  if (ref!=ClusterPositionHistoMap.end())
138  ref->second->Fill(value);
139  else
140  edm::LogError("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::fillHisto] Histogram not found in the list for DetId " << detid << " Ignoring data value "<< value <<std::endl;
141 }
142 
143 
146  e.getByLabel( Cluster_src_, dsv_SiStripCluster);
147 
150  e.getByLabel(Track_src_, trackCollection);
151  if(!trackCollection.isValid()){
152  edm::LogError("SiStripQualityHotStripIdentifier")<<" [SiStripQualityHotStripIdentifier::algoAnalyze] missing trackCollection with label " << Track_src_ <<std::endl;
153  }
154  }
155 
156  std::set<const void*> vPSiStripCluster;
157  //Perform track study
159 
160  const reco::TrackCollection tC = *(trackCollection.product());
161  int i=0;
162  for (reco::TrackCollection::const_iterator track=tC.begin(); track!=tC.end(); track++){
163  LogTrace("SiStripQualityHotStripIdentifier")
164  << "Track number "<< i+1
165  << "\n\tmomentum: " << track->momentum()
166  << "\n\tPT: " << track->pt()
167  << "\n\tvertex: " << track->vertex()
168  << "\n\timpact parameter: " << track->d0()
169  << "\n\tcharge: " << track->charge()
170  << "\n\tnormalizedChi2: " << track->normalizedChi2()
171  <<"\n\tFrom EXTRA : "
172  <<"\n\t\touter PT "<< track->outerPt()<<std::endl;
173 
174  //Loop on rechits
175  for (trackingRecHit_iterator it = track->recHitsBegin(); it != track->recHitsEnd(); ++it){
176  const TrackingRecHit* recHit = &(**it);
177 
178  if (!recHit->isValid()){
179  LogTrace("SiStripQualityHotStripIdentifier") <<"\t\t Invalid Hit "<<std::endl;
180  continue;
181  }
182 
183  const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit);
184  const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
185  const ProjectedSiStripRecHit2D* projectedHit=dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit);
186 
187  if(matchedHit){
188  vPSiStripCluster.insert((void *)&(matchedHit->monoCluster()));
189  vPSiStripCluster.insert((void *)&(matchedHit->stereoCluster()));
190  } else if(projectedHit){
191  vPSiStripCluster.insert((void *)&*(projectedHit->originalHit().cluster()));
192  } else if(singleHit){
193  vPSiStripCluster.insert((void*)&*(singleHit->cluster()));
194  }else{
195  LogTrace("SiStripQualityHotStripIdentifier") << "NULL hit" << std::endl;
196  }
197  }
198  }
199  }
200 
201  std::stringstream ss;
202  //Loop on Det Clusters
203  edm::DetSetVector<SiStripCluster>::const_iterator DSViter=dsv_SiStripCluster->begin();
204  for (; DSViter!=dsv_SiStripCluster->end();DSViter++){
206  edm::DetSet<SiStripCluster>::const_iterator ClusIterEnd = DSViter->data.end();
207  for(; ClusIter!=ClusIterEnd; ++ClusIter) {
208  if (MinClusterWidth_<=ClusIter->amplitudes().size() && ClusIter->amplitudes().size()<=MaxClusterWidth_) {
209  if (std::find(vPSiStripCluster.begin(),vPSiStripCluster.end(),(void*) &*ClusIter) == vPSiStripCluster.end()){
210  if ( edm::isDebugEnabled() )
211  ss << " adding cluster to histo for detid " << DSViter->id << " with barycenter "<< ClusIter->barycenter() << std::endl;
212  fillHisto(DSViter->id,ClusIter->barycenter());
213  }
214  }
215  }
216  }
217  LogTrace("SiStripQualityHotStripIdentifier") << ss.str();
218 }
size
Write out results.
T getParameter(std::string const &) const
bool isDebugEnabled()
T getUntrackedParameter(std::string const &, T const &) const
void fillHisto(uint32_t detid, float value)
void extractBadStrips(SiStripQuality *, HistoMap &, edm::ESHandle< SiStripQuality > &)
SiStripCluster const & monoCluster() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
Registry::const_iterator RegistryIterator
#define nullptr
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
size_type size() const
Definition: DetSet.h:63
SiStripQualityHotStripIdentifier(const edm::ParameterSet &)
edmNew::DetSet< SiStripCluster >::const_iterator ClusIter
const std::map< uint32_t, DetInfo > & getAllData() const
RegistryIterator getRegistryVectorEnd() const
void algoBeginRun(const edm::Run &, const edm::EventSetup &)
ClusterRef cluster() const
edm::ESHandle< SiStripQuality > SiStripQuality_
Definition: value.py:1
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
#define LogTrace(id)
ContainerIterator getDataVectorBegin() const
SiStripRecHit2D originalHit() const
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
bool isValid() const
RegistryIterator getRegistryVectorBegin() const
SiStripCluster const & stereoCluster() const
HLT enums.
double a
Definition: hdecay.h:121
std::pair< ContainerIterator, ContainerIterator > Range
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
std::string fullPath() const
Definition: FileInPath.cc:184
bool put(const uint32_t &detID, const InputVector &vect)
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
T const * product() const
Definition: ESHandle.h:86
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
Definition: Run.h:42
void algoAnalyze(const edm::Event &, const edm::EventSetup &)