CMS 3D CMS Logo

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

#include <HcalPedestalWidthsCheck.h>

Inheritance diagram for HcalPedestalWidthsCheck:
edm::EDAnalyzer 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::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::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 validateflag
 

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 43 of file HcalPedestalWidthsCheck.h.

Constructor & Destructor Documentation

◆ HcalPedestalWidthsCheck()

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

Definition at line 3 of file HcalPedestalWidthsCheck.cc.

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 }

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

◆ ~HcalPedestalWidthsCheck()

HcalPedestalWidthsCheck::~HcalPedestalWidthsCheck ( )
override

Definition at line 12 of file HcalPedestalWidthsCheck.cc.

12 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 14 of file HcalPedestalWidthsCheck.cc.

14  {
15  using namespace edm::eventsetup;
16 
17  // get fake pedestals from file ("new pedestals")
19  es.get<HcalPedestalWidthsRcd>().get("update", newPeds);
20  const HcalPedestalWidths* myNewPeds = newPeds.product();
21 
22  // get DB pedestals from Frontier/OrcoX ("reference")
24  es.get<HcalPedestalWidthsRcd>().get("reference", refPeds);
25  const HcalPedestalWidths* 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 (dumpupdate != "null") {
34  std::ofstream outStream(dumpupdate.c_str());
35  std::cout << "--- Dumping PedestalWidths - update ---" << std::endl;
36  HcalDbASCIIIO::dumpObject(outStream, (*myNewPeds));
37  }
38  if (dumprefs != "null") {
39  std::ofstream outStream2(dumprefs.c_str());
40  std::cout << "--- Dumping PedestalWidths - reference ---" << std::endl;
41  HcalDbASCIIIO::dumpObject(outStream2, (*myRefPeds));
42  }
43  // first get the list of all channels from the update
44  std::vector<DetId> listNewChan = myNewPeds->getAllChannels();
45 
46  // go through list of valid channels from reference, look up if pedestals exist for update
47  // push back into new vector the corresponding updated pedestals,
48  // or if it doesn't exist, the reference
49  HcalPedestalWidths* resultPeds = new HcalPedestalWidths(myRefPeds->topo(), myRefPeds->isADC());
50  std::vector<DetId> listRefChan = myRefPeds->getAllChannels();
51  std::vector<DetId>::iterator cell;
52 
53  if (validateflag) {
54  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
55  DetId mydetid = *it;
56  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
57  if (cell == listNewChan.end()) // not present in new list, take old pedestals
58  {
59  throw cms::Exception("DataDoesNotMatch") << "Value not found in reference" << std::endl;
60  } else // present in new list, take new pedestals
61  {
62  const HcalPedestalWidth* first = myNewPeds->getValues(mydetid);
63  const HcalPedestalWidth* second = myRefPeds->getValues(mydetid);
64  const float* newwidth = first->getValues();
65  const float* oldwidth = second->getValues();
66  if ((*newwidth != *oldwidth) || (*(newwidth + 1) != *(oldwidth + 1)) || (*(newwidth + 2) != *(oldwidth + 2)) ||
67  (*(newwidth + 3) != *(oldwidth + 3)) || (*(newwidth + 4) != *(oldwidth + 4)) ||
68  (*(newwidth + 5) != *(oldwidth + 5)) || (*(newwidth + 6) != *(oldwidth + 6)) ||
69  (*(newwidth + 7) != *(oldwidth + 7)) || (*(newwidth + 8) != *(oldwidth + 8)) ||
70  (*(newwidth + 9) != *(oldwidth + 9))) {
71  throw cms::Exception("DataDoesNotMatch") << "Values are not identical" << std::endl;
72  }
73  listNewChan.erase(cell); // fix 25.02.08
74  }
75  }
76  std::cout << "These are identical" << std::endl;
77  }
78 
79  if (epsilon != 0) {
80  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
81  DetId mydetid = *it;
82  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
83  if (cell == listNewChan.end()) // not present in new list, take old pedestals
84  {
85  throw cms::Exception("DataDoesNotMatch") << "Value not found in reference" << std::endl;
86  } else // present in new list, take new pedestals
87  {
88  const HcalPedestalWidth* first = myNewPeds->getValues(mydetid);
89  const HcalPedestalWidth* second = myRefPeds->getValues(mydetid);
90  const float* newwidth = first->getValues();
91  const float* oldwidth = second->getValues();
92  if (fabs(*newwidth - *oldwidth) > epsilon || fabs(*(newwidth + 1) - *(oldwidth + 1)) > epsilon ||
93  fabs(*(newwidth + 2) - *(oldwidth + 2)) > epsilon || fabs(*(newwidth + 3) - *(oldwidth + 3)) > epsilon ||
94  fabs(*(newwidth + 4) - *(oldwidth + 4)) > epsilon || fabs(*(newwidth + 5) - *(oldwidth + 5)) > epsilon ||
95  fabs(*(newwidth + 6) - *(oldwidth + 6)) > epsilon || fabs(*(newwidth + 7) - *(oldwidth + 7)) > epsilon ||
96  fabs(*(newwidth + 8) - *(oldwidth + 8)) > epsilon || fabs(*(newwidth + 9) - *(oldwidth + 9)) > epsilon) {
97  throw cms::Exception("DataDoesNotMatch") << "Values differ by more than deltaW" << std::endl;
98  }
99  listNewChan.erase(cell); // fix 25.02.08
100  }
101  }
102  std::cout << "These are identical" << std::endl;
103  }
104  if (outfile != "null") {
105  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
106  DetId mydetid = *it;
107  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
108  if (cell == listNewChan.end()) // not present in new list, take old pedestals
109  {
110  const HcalPedestalWidth* mywidth = myRefPeds->getValues(mydetid);
111  std::cout << "o";
112  resultPeds->addValues(*mywidth);
113  } else // present in new list, take new pedestals
114  {
115  const HcalPedestalWidth* mywidth = myNewPeds->getValues(mydetid);
116  std::cout << "n";
117  resultPeds->addValues(*mywidth);
118 
119  listNewChan.erase(cell); // fix 25.02.08
120  }
121  }
122 
123  for (std::vector<DetId>::iterator it = listNewChan.begin(); it != listNewChan.end(); it++) // fix 25.02.08
124  {
125  DetId mydetid = *it;
126  const HcalPedestalWidth* mywidth = myNewPeds->getValues(mydetid);
127  std::cout << "N";
128  resultPeds->addValues(*mywidth);
129  }
130  // dump the resulting list of pedestals into a file
131  std::ofstream outStream3(outfile.c_str());
132  std::cout << "--- Dumping PedestalWidths - the combined ones ---" << std::endl;
133  HcalDbASCIIIO::dumpObject(outStream3, (*resultPeds));
134  }
135  std::cout << std::endl;
136  if (checkemapflag) {
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  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++) {
142  DetId mydetid = DetId(it->rawId());
143  if (std::find(listResult.begin(), listResult.end(), mydetid) == listResult.end()) {
144  std::cout << "Conditions not found for DetId = " << HcalGenericDetId(it->rawId()) << std::endl;
145  }
146  }
147  }
148 }

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

Member Data Documentation

◆ checkemapflag

bool HcalPedestalWidthsCheck::checkemapflag
private

Definition at line 55 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ dumprefs

std::string HcalPedestalWidthsCheck::dumprefs
private

Definition at line 53 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ dumpupdate

std::string HcalPedestalWidthsCheck::dumpupdate
private

Definition at line 54 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ epsilon

double HcalPedestalWidthsCheck::epsilon
private

◆ outfile

std::string HcalPedestalWidthsCheck::outfile
private

Definition at line 52 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

◆ validateflag

bool HcalPedestalWidthsCheck::validateflag
private

Definition at line 56 of file HcalPedestalWidthsCheck.h.

Referenced by analyze(), and HcalPedestalWidthsCheck().

HcalPedestalWidthsCheck::checkemapflag
bool checkemapflag
Definition: HcalPedestalWidthsCheck.h:55
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
HcalPedestalWidthsCheck::dumpupdate
std::string dumpupdate
Definition: HcalPedestalWidthsCheck.h:54
HcalElectronicsMapRcd
Definition: HcalElectronicsMapRcd.h:8
HcalPedestalWidthsCheck::validateflag
bool validateflag
Definition: HcalPedestalWidthsCheck.h:56
HcalGenericDetId
Definition: HcalGenericDetId.h:15
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
dqmdumpme.first
first
Definition: dqmdumpme.py:55
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
HcalPedestalWidths
Definition: HcalPedestalWidths.h:17
DetId
Definition: DetId.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
edm::ESHandle
Definition: DTSurvey.h:22
HcalPedestalWidthsCheck::outfile
std::string outfile
Definition: HcalPedestalWidthsCheck.h:52
HcalPedestalWidthsRcd
Definition: HcalPedestalWidthsRcd.h:8
HcalPedestalWidthsCheck::epsilon
double epsilon
Definition: HcalPedestalWidthsCheck.h:57
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalPedestalWidths::isADC
bool isADC() const
Definition: HcalPedestalWidths.h:28
HcalCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: HcalCondObjectContainer.h:312
HcalCondObjectContainerBase::topo
const HcalTopology * topo() const
Definition: HcalCondObjectContainer.h:22
get
#define get
HcalElectronicsMap
Definition: HcalElectronicsMap.h:31
HcalDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
Exception
Definition: hltDiff.cc:246
HcalCondObjectContainer::addValues
bool addValues(const Item &myItem)
Definition: HcalCondObjectContainer.h:234
HcalPedestalWidth
Definition: HcalPedestalWidth.h:15
HcalPedestalWidthsCheck::dumprefs
std::string dumprefs
Definition: HcalPedestalWidthsCheck.h:53
edm::eventsetup
Definition: ES_DDDetector.cc:16