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
 
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::vector< ModuleDescription const * > &modules, 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
 
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
 
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 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>
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 43 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 }

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

◆ ~HcalPedestalsCheck()

HcalPedestalsCheck::~HcalPedestalsCheck ( )
override

Definition at line 12 of file HcalPedestalsCheck.cc.

12 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 14 of file HcalPedestalsCheck.cc.

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

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

Member Data Documentation

◆ checkemapflag

bool HcalPedestalsCheck::checkemapflag
private

Definition at line 56 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ dumprefs

std::string HcalPedestalsCheck::dumprefs
private

Definition at line 53 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ dumpupdate

std::string HcalPedestalsCheck::dumpupdate
private

Definition at line 54 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ epsilon

double HcalPedestalsCheck::epsilon
private

◆ outfile

std::string HcalPedestalsCheck::outfile
private

Definition at line 52 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

◆ validatepedestalsflag

bool HcalPedestalsCheck::validatepedestalsflag
private

Definition at line 55 of file HcalPedestalsCheck.h.

Referenced by analyze(), and HcalPedestalsCheck().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
HcalPedestalsCheck::outfile
std::string outfile
Definition: HcalPedestalsCheck.h:52
HcalElectronicsMapRcd
Definition: HcalElectronicsMapRcd.h:8
HcalGenericDetId
Definition: HcalGenericDetId.h:15
HcalPedestalsCheck::validatepedestalsflag
bool validatepedestalsflag
Definition: HcalPedestalsCheck.h:55
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalPedestalsCheck::dumprefs
std::string dumprefs
Definition: HcalPedestalsCheck.h:53
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
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
edm::ESHandle
Definition: DTSurvey.h:22
HcalPedestal
Definition: HcalPedestal.h:15
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:57
get
#define get
HcalPedestals::isADC
bool isADC() const
Definition: HcalPedestals.h:30
HcalElectronicsMap
Definition: HcalElectronicsMap.h:31
HcalDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
Exception
Definition: hltDiff.cc:246
HcalPedestalsRcd
Definition: HcalPedestalsRcd.h:9
HcalPedestalsCheck::checkemapflag
bool checkemapflag
Definition: HcalPedestalsCheck.h:56
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:54