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
19 
22  dataLabel_(iConfig.getUntrackedParameter<std::string>("dataLabel", "")),
23  conf_(iConfig),
24  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",
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  tTopoToken_(esConsumes<edm::Transition::BeginRun>()),
30  stripQualityToken_(esConsumes<edm::Transition::BeginRun>()) {
32  MinClusterWidth_ = pset.getUntrackedParameter<uint32_t>("minWidth", 1);
33  MaxClusterWidth_ = pset.getUntrackedParameter<uint32_t>("maxWidth", 1000);
34 
35  bookHistos();
36 }
37 
39 
40 std::unique_ptr<SiStripBadStrip> SiStripQualityHotStripIdentifier::getNewObject() {
41  auto obj = std::make_unique<SiStripBadStrip>();
42 
44  std::string AlgoName = parameters.getParameter<std::string>("AlgoName");
45  if (AlgoName == "SiStripHotStripAlgorithmFromClusterOccupancy") {
46  edm::LogInfo("SiStripQualityHotStripIdentifier")
47  << " [SiStripQualityHotStripIdentifier::getNewObject] call to SiStripHotStripAlgorithmFromClusterOccupancy"
48  << std::endl;
49 
51  theIdentifier.setProbabilityThreshold(parameters.getUntrackedParameter<double>("ProbabilityThreshold", 1.E-7));
52  theIdentifier.setMinNumEntries(parameters.getUntrackedParameter<uint32_t>("MinNumEntries", 100));
53  theIdentifier.setMinNumEntriesPerStrip(parameters.getUntrackedParameter<uint32_t>("MinNumEntriesPerStrip", 5));
54 
55  const auto detInfo =
57  SiStripQuality* qobj = new SiStripQuality(detInfo);
59 
60  edm::LogInfo("SiStripQualityHotStripIdentifier")
61  << " [SiStripQualityHotStripIdentifier::getNewObject] copy SiStripObject in SiStripBadStrip" << std::endl;
62 
63  std::stringstream ss;
64 
65  SiStripBadStrip::RegistryIterator rIter = qobj->getRegistryVectorBegin();
66  SiStripBadStrip::RegistryIterator rIterEnd = qobj->getRegistryVectorEnd();
67  for (; rIter != rIterEnd; ++rIter) {
68  SiStripBadStrip::Range range(qobj->getDataVectorBegin() + rIter->ibegin,
69  qobj->getDataVectorBegin() + rIter->iend);
70  if (!obj->put(rIter->detid, range))
71  edm::LogError("SiStripQualityHotStripIdentifier")
72  << "[SiStripQualityHotStripIdentifier::getNewObject] detid already exists" << std::endl;
73  }
74  edm::LogInfo("SiStripQualityHotStripIdentifier")
75  << " [SiStripQualityHotStripIdentifier::getNewObject] " << ss.str() << std::endl;
76 
77  } else {
78  edm::LogError("SiStripQualityHotStripIdentifier")
79  << " [SiStripQualityHotStripIdentifier::getNewObject] call for a unknow HotStrip identification algoritm"
80  << std::endl;
81 
82  std::vector<uint32_t> a;
83  SiStripBadStrip::Range range(a.begin(), a.end());
84  if (!obj->put(0xFFFFFFFF, range))
85  edm::LogError("SiStripQualityHotStripIdentifier")
86  << "[SiStripQualityHotStripIdentifier::getNewObject] detid already exists" << std::endl;
87  }
88 
89  return obj;
90 }
91 
93  tTopo = &iSetup.getData(tTopoToken_);
94 
95  resetHistos();
96 
97  if (stripQualityWatcher_.check(iSetup)) {
99  }
100 }
101 
103  //Clear map
104  ClusterPositionHistoMap.clear();
105 }
106 
108  edm::LogInfo("SiStripQualityHotStripIdentifier") << " [SiStripQualityHotStripIdentifier::resetHistos] " << std::endl;
109  for (const auto& it : ClusterPositionHistoMap) {
110  it.second->Reset();
111  }
112 }
113 
115  edm::LogInfo("SiStripQualityHotStripIdentifier") << " [SiStripQualityHotStripIdentifier::bookHistos] " << std::endl;
116  char hname[1024];
117  for (const auto& it : SiStripDetInfoFileReader::read(fp_.fullPath()).getAllData()) {
118  sprintf(hname, "h_%d", it.first);
119  auto ref = ClusterPositionHistoMap.find(it.first);
120  if (ref == ClusterPositionHistoMap.end()) {
121  ClusterPositionHistoMap[it.first] =
122  std::make_shared<TH1F>(hname, hname, it.second.nApvs * 128, -0.5, it.second.nApvs * 128 - 0.5);
123  } else
124  edm::LogError("SiStripQualityHotStripIdentifier")
125  << " [SiStripQualityHotStripIdentifier::bookHistos] DetId " << it.first
126  << " already found in map. Ignoring new data" << std::endl;
127  }
128 }
129 
131  auto ref = ClusterPositionHistoMap.find(detid);
132  if (ref != ClusterPositionHistoMap.end())
133  ref->second->Fill(value);
134  else
135  edm::LogError("SiStripQualityHotStripIdentifier")
136  << " [SiStripQualityHotStripIdentifier::fillHisto] Histogram not found in the list for DetId " << detid
137  << " Ignoring data value " << value << std::endl;
138 }
139 
142  e.getByLabel(Cluster_src_, dsv_SiStripCluster);
143 
146  e.getByLabel(Track_src_, trackCollection);
147  if (!trackCollection.isValid()) {
148  edm::LogError("SiStripQualityHotStripIdentifier")
149  << " [SiStripQualityHotStripIdentifier::algoAnalyze] missing trackCollection with label " << Track_src_
150  << std::endl;
151  }
152  }
153 
154  std::set<const void*> vPSiStripCluster;
155  //Perform track study
157  int i = 0;
158  for (const auto& track : *(trackCollection.product())) {
159  LogTrace("SiStripQualityHotStripIdentifier")
160  << "Track number " << i + 1 << "\n\tmomentum: " << track.momentum() << "\n\tPT: " << track.pt()
161  << "\n\tvertex: " << track.vertex() << "\n\timpact parameter: " << track.d0()
162  << "\n\tcharge: " << track.charge() << "\n\tnormalizedChi2: " << track.normalizedChi2() << "\n\tFrom EXTRA : "
163  << "\n\t\touter PT " << track.outerPt() << std::endl;
164 
165  //Loop on rechits
166  for (auto const& recHit : track.recHits()) {
167  if (!recHit->isValid()) {
168  LogTrace("SiStripQualityHotStripIdentifier") << "\t\t Invalid Hit " << std::endl;
169  continue;
170  }
171 
172  const SiStripRecHit2D* singleHit = dynamic_cast<const SiStripRecHit2D*>(recHit);
173  const SiStripMatchedRecHit2D* matchedHit = dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
174  const ProjectedSiStripRecHit2D* projectedHit = dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit);
175 
176  if (matchedHit) {
177  vPSiStripCluster.insert((void*)&(matchedHit->monoCluster()));
178  vPSiStripCluster.insert((void*)&(matchedHit->stereoCluster()));
179  } else if (projectedHit) {
180  vPSiStripCluster.insert((void*)&*(projectedHit->originalHit().cluster()));
181  } else if (singleHit) {
182  vPSiStripCluster.insert((void*)&*(singleHit->cluster()));
183  } else {
184  LogTrace("SiStripQualityHotStripIdentifier") << "NULL hit" << std::endl;
185  }
186  }
187  }
188  }
189 
190  std::stringstream ss;
191  //Loop on Det Clusters
192  for (const auto& dSet : *dsv_SiStripCluster) {
193  for (const auto& clus : dSet.data) {
194  if (MinClusterWidth_ <= clus.amplitudes().size() && clus.amplitudes().size() <= MaxClusterWidth_) {
195  if (std::find(vPSiStripCluster.begin(), vPSiStripCluster.end(), (void*)&clus) == vPSiStripCluster.end()) {
196  if (edm::isDebugEnabled())
197  ss << " adding cluster to histo for detid " << dSet.id << " with barycenter " << clus.barycenter()
198  << std::endl;
199  fillHisto(dSet.id, clus.barycenter());
200  }
201  }
202  }
203  }
204  LogTrace("SiStripQualityHotStripIdentifier") << ss.str();
205 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
SiStripQualityHotStripIdentifier::Track_src_
edm::InputTag Track_src_
Definition: SiStripQualityHotStripIdentifier.h:53
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:11724
funct::false
false
Definition: Factorize.h:29
SiStripHotStripAlgorithmFromClusterOccupancy::setMinNumEntriesPerStrip
void setMinNumEntriesPerStrip(unsigned short m)
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:60
SiStripMatchedRecHit2D::stereoCluster
SiStripCluster const & stereoCluster() const
Definition: SiStripMatchedRecHit2D.h:40
SiStripHotStripAlgorithmFromClusterOccupancy::setProbabilityThreshold
void setProbabilityThreshold(long double prob)
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:58
SiStripQualityHotStripIdentifier::getNewObject
std::unique_ptr< SiStripBadStrip > getNewObject() override
Definition: SiStripQualityHotStripIdentifier.cc:40
AlCaHarvesting_cff.SiStripQuality
SiStripQuality
Definition: AlCaHarvesting_cff.py:233
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripQualityHotStripIdentifier::conf_
const edm::ParameterSet conf_
Definition: SiStripQualityHotStripIdentifier.h:50
SiStripQualityHotStripIdentifier::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: SiStripQualityHotStripIdentifier.h:61
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:7
SiStripRecHit2D
Definition: SiStripRecHit2D.h:7
SiStripQualityHotStripIdentifier::~SiStripQualityHotStripIdentifier
~SiStripQualityHotStripIdentifier() override
Definition: SiStripQualityHotStripIdentifier.cc:38
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
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
SiStripDetInfoFileReader::read
SiStripDetInfo read(std::string filePath)
Definition: SiStripDetInfoFileReader.cc:11
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
edm::FileInPath
Definition: FileInPath.h:61
TrackingRecHit.h
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
Track.h
TrackFwd.h
SiStripQualityHotStripIdentifier::fp_
edm::FileInPath fp_
Definition: SiStripQualityHotStripIdentifier.h:51
ConditionDBWriter
Definition: ConditionDBWriter.h:149
SiStripQualityHotStripIdentifier::bookHistos
void bookHistos()
Definition: SiStripQualityHotStripIdentifier.cc:114
SiStripHotStripAlgorithmFromClusterOccupancy::setMinNumEntries
void setMinNumEntries(unsigned short m)
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:59
SiStripQualityHotStripIdentifier::MinClusterWidth_
unsigned short MinClusterWidth_
Definition: SiStripQualityHotStripIdentifier.h:57
SiStripQualityHotStripIdentifier::fillHisto
void fillHisto(uint32_t detid, float value)
Definition: SiStripQualityHotStripIdentifier.cc:130
ProjectedSiStripRecHit2D::originalHit
SiStripRecHit2D originalHit() const
Definition: ProjectedSiStripRecHit2D.h:56
SiStripQualityHotStripIdentifier::stripQualityWatcher_
edm::ESWatcher< SiStripQualityRcd > stripQualityWatcher_
Definition: SiStripQualityHotStripIdentifier.h:63
SiStripQualityHotStripIdentifier::ClusterPositionHistoMap
SiStrip::QualityHistosMap ClusterPositionHistoMap
Definition: SiStripQualityHotStripIdentifier.h:59
SiStripQualityHotStripIdentifier::algoAnalyze
void algoAnalyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripQualityHotStripIdentifier.cc:140
SiStripDetInfoFileReader.h
SiStripQualityHotStripIdentifier::tTopo
const TrackerTopology * tTopo
Definition: SiStripQualityHotStripIdentifier.h:55
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
SiStripQualityHotStripIdentifier::algoBeginRun
void algoBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: SiStripQualityHotStripIdentifier.cc:92
SiStripQualityHotStripIdentifier::tracksCollection_in_EventTree
bool tracksCollection_in_EventTree
Definition: SiStripQualityHotStripIdentifier.h:54
SiStripQualityHotStripIdentifier::stripQuality_
const SiStripQuality * stripQuality_
Definition: SiStripQualityHotStripIdentifier.h:49
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:102
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
value
Definition: value.py:1
ProjectedSiStripRecHit2D.h
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:62
SiStripQualityHotStripIdentifier::resetHistos
void resetHistos()
Definition: SiStripQualityHotStripIdentifier.cc:107
SiStripMatchedRecHit2D::monoCluster
SiStripCluster const & monoCluster() const
Definition: SiStripMatchedRecHit2D.h:41
SiStripDetInfoFileReader::kDefaultFile
constexpr static char const *const kDefaultFile
Definition: SiStripDetInfoFileReader.h:10
SiStripQuality.h
SiStripHotStripAlgorithmFromClusterOccupancy
Definition: SiStripHotStripAlgorithmFromClusterOccupancy.h:50
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:57
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:52
SiStripRecHit2D.h
SiStripQualityHotStripIdentifier::SiStripQualityHotStripIdentifier
SiStripQualityHotStripIdentifier(const edm::ParameterSet &)
Definition: SiStripQualityHotStripIdentifier.cc:20
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
SiStripQuality
Definition: SiStripQuality.h:32