CMS 3D CMS Logo

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

#include <HcalPedestalWidthsCheck.h>

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

Public Member Functions

void analyze (const edm::Event &ev, const edm::EventSetup &es) override
 
 HcalPedestalWidthsCheck (edm::ParameterSet const &ps)
 
 ~HcalPedestalWidthsCheck () override
 
- 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)
 

Private Attributes

bool checkemapflag
 
std::string dumprefs
 
std::string dumpupdate
 
double epsilon
 
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcdm_tok1
 
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcdm_tok2
 
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcdm_tokmap
 
std::string outfile
 
bool validateflag
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Definition at line 42 of file HcalPedestalWidthsCheck.h.

Constructor & Destructor Documentation

◆ HcalPedestalWidthsCheck()

HcalPedestalWidthsCheck::HcalPedestalWidthsCheck ( edm::ParameterSet const &  ps)

Definition at line 3 of file HcalPedestalWidthsCheck.cc.

References checkemapflag, dumprefs, dumpupdate, epsilon, edm::ParameterSet::getUntrackedParameter(), m_tok1, m_tok2, m_tokmap, outfile, AlCaHLTBitMon_QueryRunRegistry::string, and validateflag.

3  {
4  outfile = ps.getUntrackedParameter<std::string>("outFile", "null");
5  dumprefs = ps.getUntrackedParameter<std::string>("dumpRefWidthsTo", "null");
6  dumpupdate = ps.getUntrackedParameter<std::string>("dumpUpdateWidthsTo", "null");
7  checkemapflag = ps.getUntrackedParameter<bool>("checkEmap", false);
8  validateflag = ps.getUntrackedParameter<bool>("validateWidths", false);
9  epsilon = ps.getUntrackedParameter<double>("deltaW", 0);
10  m_tok1 = esConsumes<HcalPedestalWidths, HcalPedestalWidthsRcd>(edm::ESInputTag("", "update"));
11  m_tok2 = esConsumes<HcalPedestalWidths, HcalPedestalWidthsRcd>(edm::ESInputTag("", "reference"));
12  m_tokmap = esConsumes<HcalElectronicsMap, HcalElectronicsMapRcd>(edm::ESInputTag("", "reference"));
13 }
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > m_tok2
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > m_tok1
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > m_tokmap

◆ ~HcalPedestalWidthsCheck()

HcalPedestalWidthsCheck::~HcalPedestalWidthsCheck ( )
override

Definition at line 15 of file HcalPedestalWidthsCheck.cc.

15 {}

Member Function Documentation

◆ analyze()

void HcalPedestalWidthsCheck::analyze ( const edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 17 of file HcalPedestalWidthsCheck.cc.

References HcalCondObjectContainer< Item >::addValues(), HcalElectronicsMap::allPrecisionId(), checkemapflag, gather_cfg::cout, HcalDbASCIIIO::dumpObject(), dumprefs, dumpupdate, epsilon, Exception, spr::find(), dqmdumpme::first, HcalCondObjectContainer< Item >::getAllChannels(), edm::EventSetup::getData(), HcalCondObjectContainer< Item >::getValues(), HcalPedestalWidths::isADC(), m_tok1, m_tok2, m_tokmap, outfile, edm::second(), HcalCondObjectContainerBase::topo(), and validateflag.

17  {
18  using namespace edm::eventsetup;
19 
20  // get fake pedestals from file ("new pedestals")
21  const HcalPedestalWidths* myNewPeds = &es.getData(m_tok1);
22 
23  // get DB pedestals from Frontier/OrcoX ("reference")
24  const HcalPedestalWidths* myRefPeds = &es.getData(m_tok2);
25 
26  // get e-map from reference
27  const HcalElectronicsMap* myRefEMap = &es.getData(m_tokmap);
28 
29  // dump pedestals:
30  if (dumpupdate != "null") {
31  std::ofstream outStream(dumpupdate.c_str());
32  std::cout << "--- Dumping PedestalWidths - update ---" << std::endl;
33  HcalDbASCIIIO::dumpObject(outStream, (*myNewPeds));
34  }
35  if (dumprefs != "null") {
36  std::ofstream outStream2(dumprefs.c_str());
37  std::cout << "--- Dumping PedestalWidths - reference ---" << std::endl;
38  HcalDbASCIIIO::dumpObject(outStream2, (*myRefPeds));
39  }
40  // first get the list of all channels from the update
41  std::vector<DetId> listNewChan = myNewPeds->getAllChannels();
42 
43  // go through list of valid channels from reference, look up if pedestals exist for update
44  // push back into new vector the corresponding updated pedestals,
45  // or if it doesn't exist, the reference
46  HcalPedestalWidths* resultPeds = new HcalPedestalWidths(myRefPeds->topo(), myRefPeds->isADC());
47  std::vector<DetId> listRefChan = myRefPeds->getAllChannels();
48  std::vector<DetId>::iterator cell;
49 
50  if (validateflag) {
51  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
52  DetId mydetid = *it;
53  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
54  if (cell == listNewChan.end()) // not present in new list, take old pedestals
55  {
56  throw cms::Exception("DataDoesNotMatch") << "Value not found in reference" << std::endl;
57  } else // present in new list, take new pedestals
58  {
59  const HcalPedestalWidth* first = myNewPeds->getValues(mydetid);
60  const HcalPedestalWidth* second = myRefPeds->getValues(mydetid);
61  const float* newwidth = first->getValues();
62  const float* oldwidth = second->getValues();
63  if ((*newwidth != *oldwidth) || (*(newwidth + 1) != *(oldwidth + 1)) || (*(newwidth + 2) != *(oldwidth + 2)) ||
64  (*(newwidth + 3) != *(oldwidth + 3)) || (*(newwidth + 4) != *(oldwidth + 4)) ||
65  (*(newwidth + 5) != *(oldwidth + 5)) || (*(newwidth + 6) != *(oldwidth + 6)) ||
66  (*(newwidth + 7) != *(oldwidth + 7)) || (*(newwidth + 8) != *(oldwidth + 8)) ||
67  (*(newwidth + 9) != *(oldwidth + 9))) {
68  throw cms::Exception("DataDoesNotMatch") << "Values are not identical" << std::endl;
69  }
70  listNewChan.erase(cell); // fix 25.02.08
71  }
72  }
73  std::cout << "These are identical" << std::endl;
74  }
75 
76  if (epsilon != 0) {
77  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
78  DetId mydetid = *it;
79  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
80  if (cell == listNewChan.end()) // not present in new list, take old pedestals
81  {
82  throw cms::Exception("DataDoesNotMatch") << "Value not found in reference" << std::endl;
83  } else // present in new list, take new pedestals
84  {
85  const HcalPedestalWidth* first = myNewPeds->getValues(mydetid);
86  const HcalPedestalWidth* second = myRefPeds->getValues(mydetid);
87  const float* newwidth = first->getValues();
88  const float* oldwidth = second->getValues();
89  if (fabs(*newwidth - *oldwidth) > epsilon || fabs(*(newwidth + 1) - *(oldwidth + 1)) > epsilon ||
90  fabs(*(newwidth + 2) - *(oldwidth + 2)) > epsilon || fabs(*(newwidth + 3) - *(oldwidth + 3)) > epsilon ||
91  fabs(*(newwidth + 4) - *(oldwidth + 4)) > epsilon || fabs(*(newwidth + 5) - *(oldwidth + 5)) > epsilon ||
92  fabs(*(newwidth + 6) - *(oldwidth + 6)) > epsilon || fabs(*(newwidth + 7) - *(oldwidth + 7)) > epsilon ||
93  fabs(*(newwidth + 8) - *(oldwidth + 8)) > epsilon || fabs(*(newwidth + 9) - *(oldwidth + 9)) > epsilon) {
94  throw cms::Exception("DataDoesNotMatch") << "Values differ by more than deltaW" << std::endl;
95  }
96  listNewChan.erase(cell); // fix 25.02.08
97  }
98  }
99  std::cout << "These are identical" << std::endl;
100  }
101  if (outfile != "null") {
102  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
103  DetId mydetid = *it;
104  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
105  if (cell == listNewChan.end()) // not present in new list, take old pedestals
106  {
107  const HcalPedestalWidth* mywidth = myRefPeds->getValues(mydetid);
108  std::cout << "o";
109  resultPeds->addValues(*mywidth);
110  } else // present in new list, take new pedestals
111  {
112  const HcalPedestalWidth* mywidth = myNewPeds->getValues(mydetid);
113  std::cout << "n";
114  resultPeds->addValues(*mywidth);
115 
116  listNewChan.erase(cell); // fix 25.02.08
117  }
118  }
119 
120  for (std::vector<DetId>::iterator it = listNewChan.begin(); it != listNewChan.end(); it++) // fix 25.02.08
121  {
122  DetId mydetid = *it;
123  const HcalPedestalWidth* mywidth = myNewPeds->getValues(mydetid);
124  std::cout << "N";
125  resultPeds->addValues(*mywidth);
126  }
127  // dump the resulting list of pedestals into a file
128  std::ofstream outStream3(outfile.c_str());
129  std::cout << "--- Dumping PedestalWidths - the combined ones ---" << std::endl;
130  HcalDbASCIIIO::dumpObject(outStream3, (*resultPeds));
131  }
132  std::cout << std::endl;
133  if (checkemapflag) {
134  std::vector<DetId> listResult = resultPeds->getAllChannels();
135  // get the e-map list of channels
136  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
137  // look up if emap channels are all present in pedestals, if not then cerr
138  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++) {
139  DetId mydetid = DetId(it->rawId());
140  if (std::find(listResult.begin(), listResult.end(), mydetid) == listResult.end()) {
141  std::cout << "Conditions not found for DetId = " << HcalGenericDetId(it->rawId()) << std::endl;
142  }
143  }
144  }
145 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const Item * getValues(DetId fId, bool throwOnFail=true) const
U second(std::pair< T, U > const &p)
const HcalTopology * topo() const
std::vector< DetId > getAllChannels() const
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > m_tok2
Definition: DetId.h:17
edm::ESGetToken< HcalPedestalWidths, HcalPedestalWidthsRcd > m_tok1
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
std::vector< HcalGenericDetId > allPrecisionId() const
bool addValues(const Item &myItem)
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > m_tokmap

Member Data Documentation

◆ checkemapflag

bool HcalPedestalWidthsCheck::checkemapflag
private

Definition at line 54 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ dumprefs

std::string HcalPedestalWidthsCheck::dumprefs
private

Definition at line 52 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ dumpupdate

std::string HcalPedestalWidthsCheck::dumpupdate
private

Definition at line 53 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ epsilon

double HcalPedestalWidthsCheck::epsilon
private

◆ m_tok1

edm::ESGetToken<HcalPedestalWidths, HcalPedestalWidthsRcd> HcalPedestalWidthsCheck::m_tok1
private

Definition at line 57 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ m_tok2

edm::ESGetToken<HcalPedestalWidths, HcalPedestalWidthsRcd> HcalPedestalWidthsCheck::m_tok2
private

Definition at line 58 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ m_tokmap

edm::ESGetToken<HcalElectronicsMap, HcalElectronicsMapRcd> HcalPedestalWidthsCheck::m_tokmap
private

Definition at line 59 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ outfile

std::string HcalPedestalWidthsCheck::outfile
private

Definition at line 51 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ validateflag

bool HcalPedestalWidthsCheck::validateflag
private

Definition at line 55 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().