CMS 3D CMS Logo

SiStripQualityHotStripIdentifier.cc
Go to the documentation of this file.
2 
4 
11 #include <fstream>
12 #include <iostream>
13 #include <memory>
14 #include <sstream>
15 
16 //Insert here the include to the algos
18 
21  dataLabel_(iConfig.getUntrackedParameter<std::string>("dataLabel", "")),
22  conf_(iConfig),
23  fp_(iConfig.getUntrackedParameter<edm::FileInPath>(
24  "file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
25  Cluster_src_(iConfig.getParameter<edm::InputTag>("Cluster_src")),
26  Track_src_(iConfig.getUntrackedParameter<edm::InputTag>("Track_src")),
27  tracksCollection_in_EventTree(iConfig.getUntrackedParameter<bool>("RemoveTrackClusters", false)),
28  tTopoToken_(esConsumes<edm::Transition::BeginRun>()),
29  stripQualityToken_(esConsumes<edm::Transition::BeginRun>()) {
31 
33  MinClusterWidth_ = pset.getUntrackedParameter<uint32_t>("minWidth", 1);
34  MaxClusterWidth_ = pset.getUntrackedParameter<uint32_t>("maxWidth", 1000);
35 
36  bookHistos();
37 }
38 
40 
41 std::unique_ptr<SiStripBadStrip> SiStripQualityHotStripIdentifier::getNewObject() {
42  auto obj = std::make_unique<SiStripBadStrip>();
43 
45  std::string AlgoName = parameters.getParameter<std::string>("AlgoName");
46  if (AlgoName == "SiStripHotStripAlgorithmFromClusterOccupancy") {
47  edm::LogInfo("SiStripQualityHotStripIdentifier")
48  << " [SiStripQualityHotStripIdentifier::getNewObject] call to SiStripHotStripAlgorithmFromClusterOccupancy"
49  << std::endl;
50 
52  theIdentifier.setProbabilityThreshold(parameters.getUntrackedParameter<double>("ProbabilityThreshold", 1.E-7));
53  theIdentifier.setMinNumEntries(parameters.getUntrackedParameter<uint32_t>("MinNumEntries", 100));
54  theIdentifier.setMinNumEntriesPerStrip(parameters.getUntrackedParameter<uint32_t>("MinNumEntriesPerStrip", 5));
55 
56  SiStripQuality* qobj = new SiStripQuality();
58 
59  edm::LogInfo("SiStripQualityHotStripIdentifier")
60  << " [SiStripQualityHotStripIdentifier::getNewObject] copy SiStripObject in SiStripBadStrip" << std::endl;
61 
62  std::stringstream ss;
63 
66  for (; rIter != rIterEnd; ++rIter) {
67  SiStripBadStrip::Range range(qobj->getDataVectorBegin() + rIter->ibegin,
68  qobj->getDataVectorBegin() + rIter->iend);
69  if (!obj->put(rIter->detid, range))
70  edm::LogError("SiStripQualityHotStripIdentifier")
71  << "[SiStripQualityHotStripIdentifier::getNewObject] detid already exists" << std::endl;
72  }
73  edm::LogInfo("SiStripQualityHotStripIdentifier")
74  << " [SiStripQualityHotStripIdentifier::getNewObject] " << ss.str() << std::endl;
75 
76  } else {
77  edm::LogError("SiStripQualityHotStripIdentifier")
78  << " [SiStripQualityHotStripIdentifier::getNewObject] call for a unknow HotStrip identification algoritm"
79  << std::endl;
80 
81  std::vector<uint32_t> a;
82  SiStripBadStrip::Range range(a.begin(), a.end());
83  if (!obj->put(0xFFFFFFFF, range))
84  edm::LogError("SiStripQualityHotStripIdentifier")
85  << "[SiStripQualityHotStripIdentifier::getNewObject] detid already exists" << std::endl;
86  }
87 
88  return obj;
89 }
90 
92  tTopo = &iSetup.getData(tTopoToken_);
93 
94  resetHistos();
95 
96  if (stripQualityWatcher_.check(iSetup)) {
98  }
99 }
100 
102  //Clear map
103  ClusterPositionHistoMap.clear();
104 }
105 
107  edm::LogInfo("SiStripQualityHotStripIdentifier") << " [SiStripQualityHotStripIdentifier::resetHistos] " << std::endl;
108  SiStrip::QualityHistosMap::iterator it = ClusterPositionHistoMap.begin();
109  SiStrip::QualityHistosMap::iterator iEnd = ClusterPositionHistoMap.end();
110  for (; it != iEnd; ++it) {
111  it->second->Reset();
112  }
113 }
114 
116  edm::LogInfo("SiStripQualityHotStripIdentifier") << " [SiStripQualityHotStripIdentifier::bookHistos] " << std::endl;
117  char hname[1024];
118  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator it = reader->getAllData().begin();
119  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>::const_iterator iEnd = reader->getAllData().end();
120  for (; it != iEnd; ++it) {
121  sprintf(hname, "h_%d", it->first);
122  SiStrip::QualityHistosMap::iterator ref = ClusterPositionHistoMap.find(it->first);
123  if (ref == ClusterPositionHistoMap.end()) {
124  ClusterPositionHistoMap[it->first] =
125  std::make_shared<TH1F>(hname, hname, it->second.nApvs * 128, -0.5, it->second.nApvs * 128 - 0.5);
126  } else
127  edm::LogError("SiStripQualityHotStripIdentifier")
128  << " [SiStripQualityHotStripIdentifier::bookHistos] DetId " << it->first
129  << " already found in map. Ignoring new data" << std::endl;
130  }
131 }
132 
134  SiStrip::QualityHistosMap::iterator ref = ClusterPositionHistoMap.find(detid);
135  if (ref != ClusterPositionHistoMap.end())
136  ref->second->Fill(value);
137  else
138  edm::LogError("SiStripQualityHotStripIdentifier")
139  << " [SiStripQualityHotStripIdentifier::fillHisto] Histogram not found in the list for DetId " << detid
140  << " Ignoring data value " << value << std::endl;
141 }
142 
145  e.getByLabel(Cluster_src_, dsv_SiStripCluster);
146 
149  e.getByLabel(Track_src_, trackCollection);
150  if (!trackCollection.isValid()) {
151  edm::LogError("SiStripQualityHotStripIdentifier")
152  << " [SiStripQualityHotStripIdentifier::algoAnalyze] missing trackCollection with label " << Track_src_
153  << std::endl;
154  }
155  }
156 
157  std::set<const void*> vPSiStripCluster;
158  //Perform track study
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 << "\n\tmomentum: " << track->momentum() << "\n\tPT: " << track->pt()
165  << "\n\tvertex: " << track->vertex() << "\n\timpact parameter: " << track->d0()
166  << "\n\tcharge: " << track->charge() << "\n\tnormalizedChi2: " << track->normalizedChi2()
167  << "\n\tFrom EXTRA : "
168  << "\n\t\touter PT " << track->outerPt() << std::endl;
169 
170  //Loop on rechits
171  for (auto const& recHit : track->recHits()) {
172  if (!recHit->isValid()) {
173  LogTrace("SiStripQualityHotStripIdentifier") << "\t\t Invalid Hit " << std::endl;
174  continue;
175  }
176 
177  const SiStripRecHit2D* singleHit = dynamic_cast<const SiStripRecHit2D*>(recHit);
178  const SiStripMatchedRecHit2D* matchedHit = dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
179  const ProjectedSiStripRecHit2D* projectedHit = dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit);
180 
181  if (matchedHit) {
182  vPSiStripCluster.insert((void*)&(matchedHit->monoCluster()));
183  vPSiStripCluster.insert((void*)&(matchedHit->stereoCluster()));
184  } else if (projectedHit) {
185  vPSiStripCluster.insert((void*)&*(projectedHit->originalHit().cluster()));
186  } else if (singleHit) {
187  vPSiStripCluster.insert((void*)&*(singleHit->cluster()));
188  } else {
189  LogTrace("SiStripQualityHotStripIdentifier") << "NULL hit" << std::endl;
190  }
191  }
192  }
193  }
194 
195  std::stringstream ss;
196  //Loop on Det Clusters
197  edm::DetSetVector<SiStripCluster>::const_iterator DSViter = dsv_SiStripCluster->begin();
198  for (; DSViter != dsv_SiStripCluster->end(); DSViter++) {
200  edm::DetSet<SiStripCluster>::const_iterator ClusIterEnd = DSViter->data.end();
201  for (; ClusIter != ClusIterEnd; ++ClusIter) {
202  if (MinClusterWidth_ <= ClusIter->amplitudes().size() && ClusIter->amplitudes().size() <= MaxClusterWidth_) {
203  if (std::find(vPSiStripCluster.begin(), vPSiStripCluster.end(), (void*)&*ClusIter) == vPSiStripCluster.end()) {
204  if (edm::isDebugEnabled())
205  ss << " adding cluster to histo for detid " << DSViter->id << " with barycenter " << ClusIter->barycenter()
206  << std::endl;
207  fillHisto(DSViter->id, ClusIter->barycenter());
208  }
209  }
210  }
211  }
212  LogTrace("SiStripQualityHotStripIdentifier") << ss.str();
213 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
SiStripQualityHotStripIdentifier::Track_src_
edm::InputTag Track_src_
Definition: SiStripQualityHotStripIdentifier.h:55
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
SiStripRecHit2D::cluster
ClusterRef cluster() const
Definition: SiStripRecHit2D.h:22
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
funct::false
false
Definition: Factorize.h:29
SiStripHotStripAlgorithmFromClusterOccupancy::setMinNumEntriesPerStrip
void setMinNumEntriesPerStrip(unsigned short m)
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:61
ClusIter
edmNew::DetSet< SiStripCluster >::const_iterator ClusIter
Definition: PrintRecoObjects.h:15
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
SiStripMatchedRecHit2D::stereoCluster
SiStripCluster const & stereoCluster() const
Definition: SiStripMatchedRecHit2D.h:40
SiStripHotStripAlgorithmFromClusterOccupancy::setProbabilityThreshold
void setProbabilityThreshold(long double prob)
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:59
SiStripQualityHotStripIdentifier::getNewObject
std::unique_ptr< SiStripBadStrip > getNewObject() override
Definition: SiStripQualityHotStripIdentifier.cc:41
AlCaHarvesting_cff.SiStripQuality
SiStripQuality
Definition: AlCaHarvesting_cff.py:223
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripQualityHotStripIdentifier::conf_
const edm::ParameterSet conf_
Definition: SiStripQualityHotStripIdentifier.h:51
SiStripQualityHotStripIdentifier::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: SiStripQualityHotStripIdentifier.h:63
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::DetSetVector::begin
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
SiStripRecHit2D
Definition: SiStripRecHit2D.h:7
SiStripQualityHotStripIdentifier::~SiStripQualityHotStripIdentifier
~SiStripQualityHotStripIdentifier() override
Definition: SiStripQualityHotStripIdentifier.cc:39
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:30
SiStripBadStrip::getDataVectorBegin
ContainerIterator getDataVectorBegin() const
Definition: SiStripBadStrip.h:73
edm::Handle
Definition: AssociativeIterator.h:50
HLTSiStripMonitoring_cff.AlgoName
AlgoName
Definition: HLTSiStripMonitoring_cff.py:232
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
ProjectedSiStripRecHit2D
Definition: ProjectedSiStripRecHit2D.h:8
SiStripHotStripAlgorithmFromClusterOccupancy.h
SiStripBadStrip
Definition: SiStripBadStrip.h:30
SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips
void extractBadStrips(SiStripQuality *, HistoMap &, const SiStripQuality *)
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.cc:24
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
TrackingRecHit.h
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
SiStripBadStrip::getRegistryVectorBegin
RegistryIterator getRegistryVectorBegin() const
Definition: SiStripBadStrip.h:75
Track.h
TrackFwd.h
SiStripQualityHotStripIdentifier::fp_
edm::FileInPath fp_
Definition: SiStripQualityHotStripIdentifier.h:52
ConditionDBWriter
Definition: ConditionDBWriter.h:149
SiStripQualityHotStripIdentifier::bookHistos
void bookHistos()
Definition: SiStripQualityHotStripIdentifier.cc:115
SiStripHotStripAlgorithmFromClusterOccupancy::setMinNumEntries
void setMinNumEntries(unsigned short m)
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:60
SiStripQualityHotStripIdentifier::MinClusterWidth_
unsigned short MinClusterWidth_
Definition: SiStripQualityHotStripIdentifier.h:59
SiStripQualityHotStripIdentifier::fillHisto
void fillHisto(uint32_t detid, float value)
Definition: SiStripQualityHotStripIdentifier.cc:133
ProjectedSiStripRecHit2D::originalHit
SiStripRecHit2D originalHit() const
Definition: ProjectedSiStripRecHit2D.h:56
SiStripQualityHotStripIdentifier::stripQualityWatcher_
edm::ESWatcher< SiStripQualityRcd > stripQualityWatcher_
Definition: SiStripQualityHotStripIdentifier.h:65
SiStripQualityHotStripIdentifier::ClusterPositionHistoMap
SiStrip::QualityHistosMap ClusterPositionHistoMap
Definition: SiStripQualityHotStripIdentifier.h:61
SiStripQualityHotStripIdentifier::algoAnalyze
void algoAnalyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripQualityHotStripIdentifier.cc:143
SiStripQualityHotStripIdentifier::tTopo
const TrackerTopology * tTopo
Definition: SiStripQualityHotStripIdentifier.h:57
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripQualityHotStripIdentifier::algoBeginRun
void algoBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: SiStripQualityHotStripIdentifier.cc:91
SiStripQualityHotStripIdentifier::tracksCollection_in_EventTree
bool tracksCollection_in_EventTree
Definition: SiStripQualityHotStripIdentifier.h:56
SiStripQualityHotStripIdentifier::stripQuality_
const SiStripQuality * stripQuality_
Definition: SiStripQualityHotStripIdentifier.h:50
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
a
double a
Definition: hdecay.h:119
SiStripQualityHotStripIdentifier::algoEndJob
void algoEndJob() override
Definition: SiStripQualityHotStripIdentifier.cc:101
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
SiStripQualityHotStripIdentifier::reader
SiStripDetInfoFileReader * reader
Definition: SiStripQualityHotStripIdentifier.h:53
value
Definition: value.py:1
ProjectedSiStripRecHit2D.h
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripQualityHotStripIdentifier.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripMatchedRecHit2D
Definition: SiStripMatchedRecHit2D.h:8
SiStripQualityHotStripIdentifier::stripQualityToken_
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
Definition: SiStripQualityHotStripIdentifier.h:64
SiStripQualityHotStripIdentifier::resetHistos
void resetHistos()
Definition: SiStripQualityHotStripIdentifier.cc:106
SiStripMatchedRecHit2D::monoCluster
SiStripCluster const & monoCluster() const
Definition: SiStripMatchedRecHit2D.h:41
SiStripDetInfoFileReader::getAllData
const std::map< uint32_t, DetInfo > & getAllData() const
Definition: SiStripDetInfoFileReader.h:58
SiStripQuality.h
SiStripHotStripAlgorithmFromClusterOccupancy
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:51
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripBadStrip::RegistryIterator
Registry::const_iterator RegistryIterator
Definition: SiStripBadStrip.h:55
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:12
SiStripQualityHotStripIdentifier::MaxClusterWidth_
unsigned short MaxClusterWidth_
Definition: SiStripQualityHotStripIdentifier.h:59
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
SiStripMatchedRecHit2D.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
edm::Log
Definition: MessageLogger.h:70
SiStripQualityHotStripIdentifier::Cluster_src_
edm::InputTag Cluster_src_
Definition: SiStripQualityHotStripIdentifier.h:54
SiStripRecHit2D.h
SiStripQualityHotStripIdentifier::SiStripQualityHotStripIdentifier
SiStripQualityHotStripIdentifier(const edm::ParameterSet &)
Definition: SiStripQualityHotStripIdentifier.cc:19
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
SiStripBadStrip::getRegistryVectorEnd
RegistryIterator getRegistryVectorEnd() const
Definition: SiStripBadStrip.h:76
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
SiStripQuality
Definition: SiStripQuality.h:32
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31