CMS 3D CMS Logo

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

#include <HcalPedestalsCheck.h>

Inheritance diagram for HcalPedestalsCheck:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &ev, const edm::EventSetup &es) override
 
 HcalPedestalsCheck (edm::ParameterSet const &ps)
 
 ~HcalPedestalsCheck () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

bool checkemapflag
 
std::string dumprefs
 
std::string dumpupdate
 
double epsilon
 
edm::ESGetToken< HcalPedestals, HcalPedestalsRcdm_tok1
 
edm::ESGetToken< HcalPedestals, HcalPedestalsRcdm_tok2
 
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcdm_tokmap
 
std::string outfile
 
bool validatepedestalsflag
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 42 of file HcalPedestalsCheck.h.

Constructor & Destructor Documentation

◆ HcalPedestalsCheck()

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

Definition at line 3 of file HcalPedestalsCheck.cc.

3  {
4  outfile = ps.getUntrackedParameter<std::string>("outFile", "null");
5  dumprefs = ps.getUntrackedParameter<std::string>("dumpRefPedsTo", "null");
6  dumpupdate = ps.getUntrackedParameter<std::string>("dumpUpdatePedsTo", "null");
7  checkemapflag = ps.getUntrackedParameter<bool>("checkEmap", true);
8  validatepedestalsflag = ps.getUntrackedParameter<bool>("validatePedestals", false);
9  epsilon = ps.getUntrackedParameter<double>("deltaP", 0);
10  m_tok1 = esConsumes<HcalPedestals, HcalPedestalsRcd>(edm::ESInputTag("", "update"));
11  m_tok2 = esConsumes<HcalPedestals, HcalPedestalsRcd>(edm::ESInputTag("", "reference"));
12  m_tokmap = esConsumes<HcalElectronicsMap, HcalElectronicsMapRcd>(edm::ESInputTag("", "reference"));
13 }

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

◆ ~HcalPedestalsCheck()

HcalPedestalsCheck::~HcalPedestalsCheck ( )
override

Definition at line 15 of file HcalPedestalsCheck.cc.

15 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 17 of file HcalPedestalsCheck.cc.

17  {
18  using namespace edm::eventsetup;
19 
20  // get fake pedestals from file ("new pedestals")
21  const HcalPedestals* myNewPeds = &es.getData(m_tok1);
22 
23  // get DB pedestals from Frontier/OrcoX ("reference")
24  const HcalPedestals* 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 (!(dumprefs == "null")) {
31  std::ofstream outStream(dumprefs.c_str());
32  std::cout << "--- Dumping Pedestals - reference ---" << std::endl;
33  HcalDbASCIIIO::dumpObject(outStream, (*myRefPeds));
34  }
35  if (!(dumpupdate == "null")) {
36  std::ofstream outStream2(dumpupdate.c_str());
37  std::cout << "--- Dumping Pedestals - updated ---" << std::endl;
38  HcalDbASCIIIO::dumpObject(outStream2, (*myNewPeds));
39  }
40 
42  std::vector<DetId> listNewChan = myNewPeds->getAllChannels();
43  std::vector<DetId> listRefChan = myRefPeds->getAllChannels();
44  std::vector<DetId>::iterator cell;
45  bool failflag = false;
46  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
47  DetId mydetid = *it;
48  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
49  if (cell == listNewChan.end()) // not present in new list, take old pedestals
50  {
51  throw cms::Exception("DataDoesNotMatch") << "Channel missing";
52  failflag = true;
53  break;
54  } else // present in new list, take new pedestals
55  {
56  const float* values = (myNewPeds->getValues(mydetid))->getValues();
57  const float* oldvalue = (myRefPeds->getValues(mydetid))->getValues();
58  if ((*oldvalue != *values) || (*(oldvalue + 1) != *(values + 1)) || (*(oldvalue + 2) != *(values + 2)) ||
59  (*(oldvalue + 3) != *(values + 3))) {
60  throw cms::Exception("DataDoesNotMatch") << "Value does not match";
61  failflag = true;
62  break;
63  }
64  // compare the values of the pedestals for valid channels between update and reference
65 
66  listNewChan.erase(cell); // fix 25.02.08
67  }
68  }
69  if (!failflag)
70  std::cout << "These are identical" << std::endl;
71  }
72 
73  if (epsilon != 0) {
74  std::vector<DetId> listNewChan = myNewPeds->getAllChannels();
75  std::vector<DetId> listRefChan = myRefPeds->getAllChannels();
76  std::vector<DetId>::iterator cell;
77  bool failflag = false;
78  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
79  DetId mydetid = *it;
80  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
81  if (cell == listNewChan.end()) {
82  continue;
83  } else {
84  const float* values = (myNewPeds->getValues(mydetid))->getValues();
85  const float* oldvalue = (myRefPeds->getValues(mydetid))->getValues();
86  if ((fabs(*oldvalue - *values) > epsilon) || (fabs(*(oldvalue + 1) - *(values + 1)) > epsilon) ||
87  (fabs(*(oldvalue + 2) - *(values + 2)) > epsilon) || (fabs(*(oldvalue + 3) - *(values + 3)) > epsilon)) {
88  throw cms::Exception("DataDoesNotMatch") << "Values differ by more than deltaP";
89  failflag = true;
90  break;
91  }
92  listNewChan.erase(cell); // fix 25.02.08
93  }
94  }
95  if (!failflag)
96  std::cout << "These are identical to within deltaP" << std::endl;
97  }
98  if (!(outfile == "null")) {
99  // first get the list of all channels from the update
100  std::vector<DetId> listNewChan = myNewPeds->getAllChannels();
101 
102  // go through list of valid channels from reference, look up if pedestals exist for update
103  // push back into new vector the corresponding updated pedestals,
104  // or if it doesn't exist, the reference
105  HcalPedestals* resultPeds = new HcalPedestals(myRefPeds->topo(), myRefPeds->isADC());
106  std::vector<DetId> listRefChan = myRefPeds->getAllChannels();
107  std::vector<DetId>::iterator cell;
108  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
109  DetId mydetid = *it;
110  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
111  if (cell == listNewChan.end()) // not present in new list, take old pedestals
112  {
113  // bool addValue (DetId fId, const float fValues [4]);
114  const HcalPedestal* item = myRefPeds->getValues(mydetid);
115  std::cout << "o";
116  resultPeds->addValues(*item);
117  } else // present in new list, take new pedestals
118  {
119  const HcalPedestal* item = myNewPeds->getValues(mydetid);
120  std::cout << "n";
121  resultPeds->addValues(*item);
122  // compare the values of the pedestals for valid channels between update and reference
123  listNewChan.erase(cell); // fix 25.02.08
124  }
125  }
126 
127  for (std::vector<DetId>::iterator it = listNewChan.begin(); it != listNewChan.end(); it++) // fix 25.02.08
128  {
129  DetId mydetid = *it;
130  const HcalPedestal* item = myNewPeds->getValues(mydetid);
131  std::cout << "N";
132  resultPeds->addValues(*item);
133  }
134 
135  std::cout << std::endl;
136 
137  std::vector<DetId> listResult = resultPeds->getAllChannels();
138  // get the e-map list of channels
139  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
140  // look up if emap channels are all present in pedestals, if not then cerr
141  if (checkemapflag) {
142  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++) {
143  DetId mydetid = DetId(it->rawId());
144  HcalGenericDetId mygenid(it->rawId());
145  // std::cout << "id = " << mygenid << ", hashed id = " << mygenid.hashedId() << std::endl;
146  if (std::find(listResult.begin(), listResult.end(), mydetid) == listResult.end()) {
147  std::cout << "Conditions not found for DetId = " << HcalGenericDetId(it->rawId()) << std::endl;
148  }
149  }
150  }
151 
152  // dump the resulting list of pedestals into a file
153  std::ofstream outStream3(outfile.c_str());
154  std::cout << "--- Dumping Pedestals - the combined ones ---" << std::endl;
155  HcalDbASCIIIO::dumpObject(outStream3, (*resultPeds));
156  }
157 
158  // const float* values = myped->getValues (channelID);
159  // if (values) std::cout << "pedestals for channel " << channelID << ": "
160  // << values [0] << '/' << values [1] << '/' << values [2] << '/' << values [3] << std::endl;
161 }

References HcalCondObjectContainer< Item >::addValues(), HcalElectronicsMap::allPrecisionId(), checkemapflag, gather_cfg::cout, HcalDbASCIIIO::dumpObject(), dumprefs, dumpupdate, epsilon, Exception, spr::find(), HcalCondObjectContainer< Item >::getAllChannels(), edm::EventSetup::getData(), HcalCondObjectContainer< Item >::getValues(), HcalPedestals::isADC(), B2GTnPMonitor_cfi::item, m_tok1, m_tok2, m_tokmap, outfile, HcalCondObjectContainerBase::topo(), validatepedestalsflag, and contentValuesCheck::values.

Member Data Documentation

◆ checkemapflag

bool HcalPedestalsCheck::checkemapflag
private

Definition at line 55 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ dumprefs

std::string HcalPedestalsCheck::dumprefs
private

Definition at line 52 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ dumpupdate

std::string HcalPedestalsCheck::dumpupdate
private

Definition at line 53 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ epsilon

double HcalPedestalsCheck::epsilon
private

◆ m_tok1

edm::ESGetToken<HcalPedestals, HcalPedestalsRcd> HcalPedestalsCheck::m_tok1
private

Definition at line 57 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ m_tok2

edm::ESGetToken<HcalPedestals, HcalPedestalsRcd> HcalPedestalsCheck::m_tok2
private

Definition at line 58 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ m_tokmap

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

Definition at line 59 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ outfile

std::string HcalPedestalsCheck::outfile
private

Definition at line 51 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ validatepedestalsflag

bool HcalPedestalsCheck::validatepedestalsflag
private

Definition at line 54 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

HcalPedestalsCheck::outfile
std::string outfile
Definition: HcalPedestalsCheck.h:51
edm::ESInputTag
Definition: ESInputTag.h:87
HcalGenericDetId
Definition: HcalGenericDetId.h:15
HcalPedestalsCheck::validatepedestalsflag
bool validatepedestalsflag
Definition: HcalPedestalsCheck.h:54
HcalPedestalsCheck::m_tokmap
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > m_tokmap
Definition: HcalPedestalsCheck.h:59
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalPedestalsCheck::dumprefs
std::string dumprefs
Definition: HcalPedestalsCheck.h:52
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
HcalElectronicsMap::allPrecisionId
std::vector< HcalGenericDetId > allPrecisionId() const
Definition: HcalElectronicsMap.cc:139
DetId
Definition: DetId.h:17
HcalPedestals
Definition: HcalPedestals.h:20
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
HcalPedestal
Definition: HcalPedestal.h:15
HcalPedestalsCheck::m_tok2
edm::ESGetToken< HcalPedestals, HcalPedestalsRcd > m_tok2
Definition: HcalPedestalsCheck.h:58
HcalCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: HcalCondObjectContainer.h:312
HcalCondObjectContainerBase::topo
const HcalTopology * topo() const
Definition: HcalCondObjectContainer.h:22
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HcalPedestalsCheck::epsilon
double epsilon
Definition: HcalPedestalsCheck.h:56
HcalPedestalsCheck::m_tok1
edm::ESGetToken< HcalPedestals, HcalPedestalsRcd > m_tok1
Definition: HcalPedestalsCheck.h:57
HcalPedestals::isADC
bool isADC() const
Definition: HcalPedestals.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
HcalElectronicsMap
Definition: HcalElectronicsMap.h:31
HcalDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
Exception
Definition: hltDiff.cc:245
HcalPedestalsCheck::checkemapflag
bool checkemapflag
Definition: HcalPedestalsCheck.h:55
HcalCondObjectContainer::addValues
bool addValues(const Item &myItem)
Definition: HcalCondObjectContainer.h:234
edm::eventsetup
Definition: ES_DDDetector.cc:16
HcalPedestalsCheck::dumpupdate
std::string dumpupdate
Definition: HcalPedestalsCheck.h:53