CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripNoisesFromDBMiscalibrator Class Reference

#include <CondTools/SiStrip/plugins/SiStripNoisesFromDBMiscalibrator.cc>

Inheritance diagram for SiStripNoisesFromDBMiscalibrator:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 SiStripNoisesFromDBMiscalibrator (const edm::ParameterSet &)
 
 ~SiStripNoisesFromDBMiscalibrator () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 
SiStripNoises getNewObject (const std::map< std::pair< uint32_t, int >, float > &theMap)
 
SiStripNoises getNewObject_withDefaults (const std::map< std::pair< uint32_t, int >, float > &theMap, const float theDefault)
 

Private Attributes

const edm::FileInPath fp_
 
const bool m_fillDefaults
 
const edm::ESGetToken< SiStripNoises, SiStripNoisesRcdm_noiseToken
 
const std::vector< edm::ParameterSetm_parameters
 
const bool m_perDetIDdebug
 
const uint32_t m_printdebug
 
const bool m_saveMaps
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdm_tTopoToken
 
std::unique_ptr< TrackerMapmissing_map
 
std::unique_ptr< TrackerMapnew_payload_map
 
std::unique_ptr< TrackerMapold_payload_map
 
std::unique_ptr< TrackerMapratio_map
 
std::unique_ptr< TrackerMapscale_map
 
std::unique_ptr< TrackerMapsmear_map
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Class to miscalibrate a SiStrip Noise payload from Database

Implementation: Read a SiStrip Noise payload from DB (either central DB or sqlite file) and apply a miscalibration (either an offset / gaussian smearing or both) returns a local sqlite file with the same since of the original payload

Definition at line 51 of file SiStripNoisesFromDBMiscalibrator.cc.

Constructor & Destructor Documentation

◆ SiStripNoisesFromDBMiscalibrator()

SiStripNoisesFromDBMiscalibrator::SiStripNoisesFromDBMiscalibrator ( const edm::ParameterSet iConfig)
explicit

Definition at line 86 of file SiStripNoisesFromDBMiscalibrator.cc.

References edm::ParameterSet::getUntrackedParameter().

87  : m_printdebug{iConfig.getUntrackedParameter<uint32_t>("printDebug", 10)},
88  m_perDetIDdebug{iConfig.getUntrackedParameter<bool>("perDetIDdebug", false)},
89  m_fillDefaults{iConfig.getUntrackedParameter<bool>("fillDefaults", false)},
90  m_saveMaps{iConfig.getUntrackedParameter<bool>("saveMaps", true)},
91  m_parameters{iConfig.getParameter<std::vector<edm::ParameterSet> >("params")},
96  //now do what ever initialization is needed
97 
98  scale_map = std::make_unique<TrackerMap>("scale");
99  scale_map->setTitle("Tracker Map of Scale factor averaged by module");
100  scale_map->setPalette(1);
101 
102  smear_map = std::make_unique<TrackerMap>("smear");
103  smear_map->setTitle("Tracker Map of Smear factor averaged by module");
104  smear_map->setPalette(1);
105 
106  old_payload_map = std::make_unique<TrackerMap>("old_payload");
107  old_payload_map->setTitle("Tracker Map of Starting Noise Payload averaged by module");
108  old_payload_map->setPalette(1);
109 
110  new_payload_map = std::make_unique<TrackerMap>("new_payload");
111  new_payload_map->setTitle("Tracker Map of Modified Noise Payload averaged by module");
112  new_payload_map->setPalette(1);
113 
114  ratio_map = std::make_unique<TrackerMap>("ratio");
115  ratio_map->setTitle("Tracker Map of Average by module of the payload ratio (new/old)");
116  ratio_map->setPalette(1);
117 
118  if (m_fillDefaults) {
119  missing_map = std::make_unique<TrackerMap>("uncabled");
120  missing_map->setTitle("Tracker Map of uncabled modules");
121  missing_map->setPalette(1);
122  }
123 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< edm::ParameterSet > m_parameters
static constexpr char const *const kDefaultFile
const edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > m_noiseToken
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_tTopoToken

◆ ~SiStripNoisesFromDBMiscalibrator()

SiStripNoisesFromDBMiscalibrator::~SiStripNoisesFromDBMiscalibrator ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiStripNoisesFromDBMiscalibrator::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 130 of file SiStripNoisesFromDBMiscalibrator.cc.

References SiStripMiscalibrate::Entry::add(), cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::createOneIOV(), cond::service::PoolDBOutputService::currentTime(), ztail::d, spr::find(), edm::EventSetup::getData(), getNewObject(), getNewObject_withDefaults(), SiStripMiscalibrate::getRegionFromString(), SiStripMiscalibrate::getRegionsFromDetId(), edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, m_fillDefaults, m_noiseToken, m_parameters, m_perDetIDdebug, m_printdebug, m_tTopoToken, SiStripMiscalibrate::Entry::mean(), new_payload_map, hgchebackDigitizer_cfi::noise, me0TriggerPseudoDigis_cff::nStrips, old_payload_map, submitPVValidationJobs::params, l1ctLayer1_patternWriters_cff::partition, FastTimerService_cff::range, ratio_map, nano_mu_digi_cff::region, SiStripMiscalibrate::Entry::reset(), scale_map, smear_map, jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, and parallelization::uint.

130  {
131  using namespace edm;
132 
133  const auto tTopo = &iSetup.getData(m_tTopoToken);
134 
135  std::vector<std::string> partitions;
136 
137  // fill the list of partitions
138  for (auto& thePSet : m_parameters) {
139  const std::string partition(thePSet.getParameter<std::string>("partition"));
140  // only if it is not yet in the list
141  if (std::find(partitions.begin(), partitions.end(), partition) == partitions.end()) {
142  partitions.push_back(partition);
143  }
144  }
145 
146  std::map<sistripsummary::TrackerRegion, SiStripMiscalibrate::Smearings> mapOfSmearings;
147 
148  for (auto& thePSet : m_parameters) {
149  const std::string partition(thePSet.getParameter<std::string>("partition"));
151 
152  bool m_doScale(thePSet.getParameter<bool>("doScale"));
153  bool m_doSmear(thePSet.getParameter<bool>("doSmear"));
154  double m_scaleFactor(thePSet.getParameter<double>("scaleFactor"));
155  double m_smearFactor(thePSet.getParameter<double>("smearFactor"));
156 
158  params.setSmearing(m_doScale, m_doSmear, m_scaleFactor, m_smearFactor);
159  mapOfSmearings[region] = params;
160  }
161 
162  const auto& stripNoises = iSetup.getData(m_noiseToken);
163 
164  std::map<std::pair<uint32_t, int>, float> theMap, oldPayloadMap;
165 
166  std::vector<uint32_t> detid;
167  stripNoises.getDetIds(detid);
168  for (const auto& d : detid) {
169  SiStripNoises::Range range = stripNoises.getRange(d);
170 
172 
173  // sort by largest to smallest
174  std::sort(regions.rbegin(), regions.rend());
175 
177 
178  for (unsigned int j = 0; j < regions.size(); j++) {
179  bool checkRegion = (mapOfSmearings.count(regions[j]) != 0);
180 
181  if (!checkRegion) {
182  // if the subdetector is not in the list and there's no indication for the whole tracker, just use the default
183  // i.e. no change
184  continue;
185  } else {
186  params = mapOfSmearings[regions[j]];
187  break;
188  }
189  }
190 
191  scale_map->fill(d, params.m_scaleFactor);
192  smear_map->fill(d, params.m_smearFactor);
193 
194  int nStrips = 0;
195  for (int it = 0; it < (range.second - range.first) * 8 / 9; ++it) {
196  auto noise = stripNoises.getNoise(it, range);
197  std::pair<uint32_t, int> index = std::make_pair(d, nStrips);
198 
199  oldPayloadMap[index] = noise;
200 
201  if (params.m_doScale) {
202  noise *= params.m_scaleFactor;
203  }
204 
205  if (params.m_doSmear) {
206  float smearedNoise = CLHEP::RandGauss::shoot(noise, params.m_smearFactor);
207  noise = smearedNoise;
208  }
209 
210  theMap[index] = noise;
211 
212  nStrips += 1;
213 
214  } // loop over APVs
215  } // loop over DetIds
216 
217  SiStripNoises theSiStripNoises{};
218  if (!m_fillDefaults) {
219  theSiStripNoises = this->getNewObject(theMap);
220  } else {
221  theSiStripNoises = this->getNewObject_withDefaults(theMap, -1.);
222  }
223 
224  // make the payload ratio map
225  uint32_t cachedId(0);
226  SiStripMiscalibrate::Entry noise_ratio;
229  uint countDetIds(0); // count DetIds to print
230  uint countStrips(0);
231  for (const auto& element : theMap) {
232  countStrips++;
233  uint32_t DetId = element.first.first;
234  int nstrip = element.first.second;
235  float new_noise = element.second;
236  float old_noise = oldPayloadMap[std::make_pair(DetId, nstrip)];
237 
238  // flush the counters
239  if (cachedId != 0 && DetId != cachedId) {
240  ratio_map->fill(cachedId, noise_ratio.mean());
241  old_payload_map->fill(cachedId, o_noise.mean());
242  new_payload_map->fill(cachedId, n_noise.mean());
243 
244  //auto test = new_payload_map.get()->smoduleMap;
245 
246  noise_ratio.reset();
247  o_noise.reset();
248  n_noise.reset();
249  countDetIds++;
250 
251  if (m_perDetIDdebug && (countDetIds < m_printdebug)) {
252  edm::LogPrint("SiStripNoisesFromDBMiscalibrator")
253  << "SiStripNoisesFromDBMiscalibrator"
254  << "::" << __FUNCTION__ << " detid " << DetId << " \t"
255  << " strip " << nstrip << " \t new <noise>: " << std::setw(5) << std::setprecision(2) << n_noise.mean()
256  << " \t old <noise>: " << o_noise.mean() << " \t" << std::endl;
257  }
258  }
259 
260  // printout for debug
261  if ((countStrips < m_printdebug) && !m_perDetIDdebug) {
262  edm::LogPrint("SiStripNoisesFromDBMiscalibrator")
263  << "SiStripNoisesFromDBMiscalibrator"
264  << "::" << __FUNCTION__ << " detid " << DetId << " \t"
265  << " strip " << nstrip << " \t new noise: " << std::setw(5) << std::setprecision(2) << new_noise
266  << " \t old noise: " << old_noise << " \t" << std::endl;
267  }
268 
269  cachedId = DetId;
270  noise_ratio.add(new_noise / old_noise);
271  o_noise.add(old_noise);
272  n_noise.add(new_noise);
273  }
274 
275  // write out the SiStripNoises record
277 
278  if (poolDbService.isAvailable()) {
279  if (poolDbService->isNewTagRequest("SiStripNoisesRcd")) {
280  poolDbService->createOneIOV(theSiStripNoises, poolDbService->currentTime(), "SiStripNoisesRcd");
281  } else {
282  poolDbService->appendOneIOV(theSiStripNoises, poolDbService->currentTime(), "SiStripNoisesRcd");
283  }
284  } else {
285  throw std::runtime_error("PoolDBService required.");
286  }
287 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::vector< sistripsummary::TrackerRegion > getRegionsFromDetId(const TrackerTopology *m_trackerTopo, DetId detid)
sistripsummary::TrackerRegion getRegionFromString(std::string region)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
SiStripNoises getNewObject_withDefaults(const std::map< std::pair< uint32_t, int >, float > &theMap, const float theDefault)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
bool isNewTagRequest(const std::string &recordName)
Log< level::Warning, true > LogPrint
d
Definition: ztail.py:151
Definition: DetId.h:17
HLT enums.
const std::vector< edm::ParameterSet > m_parameters
SiStripNoises getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
bool isAvailable() const
Definition: Service.h:40
const edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > m_noiseToken
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_tTopoToken

◆ endJob()

void SiStripNoisesFromDBMiscalibrator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 290 of file SiStripNoisesFromDBMiscalibrator.cc.

References SiStripMiscalibrate::getTruncatedRange(), m_fillDefaults, m_saveMaps, missing_map, new_payload_map, old_payload_map, FastTimerService_cff::range, ratio_map, scale_map, and smear_map.

290  {
291  if (m_saveMaps) {
292  scale_map->save(true, 0, 0, "noise_scale_map.pdf");
293  scale_map->save(true, 0, 0, "noise_scale_map.png");
294 
295  smear_map->save(true, 0, 0, "noise_smear_map.pdf");
296  smear_map->save(true, 0, 0, "noise_smear_map.png");
297 
298  ratio_map->save(true, 0, 0, "noise_ratio_map.pdf");
299  ratio_map->save(true, 0, 0, "noise_ratio_map.png");
300 
302 
303  old_payload_map->save(true, range.first, range.second, "starting_noise_payload_map.pdf");
304  old_payload_map->save(true, range.first, range.second, "starting_noise_payload_map.png");
305 
307 
308  new_payload_map->save(true, range.first, range.second, "new_noise_payload_map.pdf");
309  new_payload_map->save(true, range.first, range.second, "new_noise_payload_map.png");
310 
311  if (m_fillDefaults) {
312  missing_map->save(true, 0, 0, "missing_map.pdf");
313  missing_map->save(true, 0, 0, "missing_map.png");
314  }
315  }
316 }
std::pair< float, float > getTruncatedRange(const TrackerMap *theMap)

◆ fillDescriptions()

void SiStripNoisesFromDBMiscalibrator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 406 of file SiStripNoisesFromDBMiscalibrator.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

406  {
408 
409  desc.setComment(
410  "Creates rescaled / smeared SiStrip Noise payload."
411  "PoolDBOutputService must be set up for 'SiSiStripNoisesRcd'.");
412 
413  edm::ParameterSetDescription descScaler;
414  descScaler.setComment(
415  "ParameterSet specifying the Strip tracker partition to be scaled / smeared "
416  "by a given factor.");
417 
418  descScaler.add<std::string>("partition", "Tracker");
419  descScaler.add<bool>("doScale", true);
420  descScaler.add<bool>("doSmear", true);
421  descScaler.add<double>("scaleFactor", 1.0);
422  descScaler.add<double>("smearFactor", 1.0);
423  desc.addVPSet("params", descScaler, std::vector<edm::ParameterSet>(1));
424 
425  desc.addUntracked<unsigned int>("printDebug", 10);
426  desc.addUntracked<bool>("perDetIDdebug", false);
427  desc.addUntracked<bool>("fillDefaults", false);
428  desc.addUntracked<bool>("saveMaps", true);
429 
430  descriptions.add("scaleAndSmearSiStripNoises", desc);
431 }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ getNewObject()

SiStripNoises SiStripNoisesFromDBMiscalibrator::getNewObject ( const std::map< std::pair< uint32_t, int >, float > &  theMap)
private

Definition at line 380 of file SiStripNoisesFromDBMiscalibrator.cc.

References hgchebackDigitizer_cfi::noise, and getGTfromDQMFile::obj.

Referenced by analyze().

380  {
381  SiStripNoises obj{};
382 
383  uint32_t PreviousDetId = 0;
384  SiStripNoises::InputVector theSiStripVector;
385  for (const auto& element : theMap) {
386  uint32_t DetId = element.first.first;
387  float noise = element.second;
388 
389  if (DetId != PreviousDetId) {
390  if (!theSiStripVector.empty()) {
391  if (!obj.put(PreviousDetId, theSiStripVector)) {
392  edm::LogError("SiStripNoisesFromDBMiscalibrator")
393  << "[SiStripNoisesFromDBMiscalibrator::analyze] detid already exists" << std::endl;
394  }
395  }
396 
397  theSiStripVector.clear();
398  PreviousDetId = DetId;
399  }
400  obj.setData(noise, theSiStripVector);
401  }
402  return obj;
403 }
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:50
Log< level::Error, false > LogError
Definition: DetId.h:17

◆ getNewObject_withDefaults()

SiStripNoises SiStripNoisesFromDBMiscalibrator::getNewObject_withDefaults ( const std::map< std::pair< uint32_t, int >, float > &  theMap,
const float  theDefault 
)
private

Definition at line 319 of file SiStripNoisesFromDBMiscalibrator.cc.

References fp_, edm::FileInPath::fullPath(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogDebug, combine::missing, missing_map, Skims_PA_cff::name, hgchebackDigitizer_cfi::noise, getGTfromDQMFile::obj, SiStripDetInfoFileReader::read(), DQM::reader, and pileupReCalc_HLTpaths::trunc.

Referenced by analyze().

320  {
321  SiStripNoises obj{};
322 
323  std::vector<uint32_t> missingDetIds;
324 
326  const auto& DetInfos = reader.getAllData();
327 
328  for (const auto& it : DetInfos) {
329  const auto& nAPVs = it.second.nApvs;
330  //Generate Noise for det detid
331  bool isMissing(false);
332  SiStripNoises::InputVector theSiStripVector;
333  for (int t_strip = 0; t_strip < 128 * nAPVs; ++t_strip) {
334  std::pair<uint32_t, int> index = std::make_pair(it.first, t_strip);
335 
336  if (theMap.find(index) == theMap.end()) {
337  LogDebug("SiStripNoisesFromDBMiscalibrator") << "detid " << it.first << " \t"
338  << " strip " << t_strip << " \t"
339  << " not found" << std::endl;
340 
341  isMissing = true;
342  obj.setData(theDefault, theSiStripVector);
343 
344  } else {
345  float noise = theMap.at(index);
346  obj.setData(noise, theSiStripVector);
347  }
348  }
349 
350  if (isMissing)
351  missingDetIds.push_back(it.first);
352 
353  if (!obj.put(it.first, theSiStripVector)) {
354  edm::LogError("SiStripNoisesFromDBMiscalibrator")
355  << "[SiStripNoisesFromDBMiscalibrator::analyze] detid already exists" << std::endl;
356  }
357  }
358 
359  if (!missingDetIds.empty()) {
360  // open output file
361  std::stringstream name;
362  name << "missing_modules.txt";
363  std::ofstream* ofile = new std::ofstream(name.str(), std::ofstream::trunc);
364  if (!ofile->is_open())
365  throw "cannot open output file!";
366  for (const auto& missing : missingDetIds) {
367  edm::LogVerbatim("SiStripNoisesFromDBMiscalibrator") << missing << " " << 1 << std::endl;
368  (*ofile) << missing << " " << 1 << std::endl;
369  missing_map->fill(missing, 1);
370  }
371 
372  ofile->close();
373  delete ofile;
374  }
375 
376  return obj;
377 }
Log< level::Info, true > LogVerbatim
std::string fullPath() const
Definition: FileInPath.cc:161
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:50
reader
Definition: DQM.py:105
Log< level::Error, false > LogError
missing
Definition: combine.py:5
SiStripDetInfo read(std::string filePath)
#define LogDebug(id)

Member Data Documentation

◆ fp_

const edm::FileInPath SiStripNoisesFromDBMiscalibrator::fp_
private

Definition at line 71 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by getNewObject_withDefaults().

◆ m_fillDefaults

const bool SiStripNoisesFromDBMiscalibrator::m_fillDefaults
private

Definition at line 68 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze(), and endJob().

◆ m_noiseToken

const edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> SiStripNoisesFromDBMiscalibrator::m_noiseToken
private

Definition at line 73 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze().

◆ m_parameters

const std::vector<edm::ParameterSet> SiStripNoisesFromDBMiscalibrator::m_parameters
private

Definition at line 70 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze().

◆ m_perDetIDdebug

const bool SiStripNoisesFromDBMiscalibrator::m_perDetIDdebug
private

Definition at line 67 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze().

◆ m_printdebug

const uint32_t SiStripNoisesFromDBMiscalibrator::m_printdebug
private

Definition at line 66 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze().

◆ m_saveMaps

const bool SiStripNoisesFromDBMiscalibrator::m_saveMaps
private

Definition at line 69 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by endJob().

◆ m_tTopoToken

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripNoisesFromDBMiscalibrator::m_tTopoToken
private

Definition at line 72 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze().

◆ missing_map

std::unique_ptr<TrackerMap> SiStripNoisesFromDBMiscalibrator::missing_map
private

Definition at line 80 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by endJob(), and getNewObject_withDefaults().

◆ new_payload_map

std::unique_ptr<TrackerMap> SiStripNoisesFromDBMiscalibrator::new_payload_map
private

Definition at line 79 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze(), and endJob().

◆ old_payload_map

std::unique_ptr<TrackerMap> SiStripNoisesFromDBMiscalibrator::old_payload_map
private

Definition at line 78 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze(), and endJob().

◆ ratio_map

std::unique_ptr<TrackerMap> SiStripNoisesFromDBMiscalibrator::ratio_map
private

Definition at line 77 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze(), and endJob().

◆ scale_map

std::unique_ptr<TrackerMap> SiStripNoisesFromDBMiscalibrator::scale_map
private

Definition at line 75 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze(), and endJob().

◆ smear_map

std::unique_ptr<TrackerMap> SiStripNoisesFromDBMiscalibrator::smear_map
private

Definition at line 76 of file SiStripNoisesFromDBMiscalibrator.cc.

Referenced by analyze(), and endJob().