CMS 3D CMS Logo

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

#include <HcalQIEDataCheck.h>

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

Public Member Functions

void analyze (const edm::Event &ev, const edm::EventSetup &es) override
 
 HcalQIEDataCheck (edm::ParameterSet const &ps)
 
 ~HcalQIEDataCheck () 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
 
edm::ESGetToken< HcalQIEData, HcalQIEDataRcdm_tok1
 
edm::ESGetToken< HcalQIEData, HcalQIEDataRcdm_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 37 of file HcalQIEDataCheck.h.

Constructor & Destructor Documentation

◆ HcalQIEDataCheck()

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

Definition at line 3 of file HcalQIEDataCheck.cc.

References checkemapflag, dumprefs, dumpupdate, 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>("dumpRefQIEsTo", "null");
6  dumpupdate = ps.getUntrackedParameter<std::string>("dumpUpdateQIEsTo", "null");
7  checkemapflag = ps.getUntrackedParameter<bool>("checkEmap", false);
8  validateflag = ps.getUntrackedParameter<bool>("validateQIEs", false);
9  // epsilon = ps.getUntrackedParameter<double>("deltaQIE",0);
10  m_tok1 = esConsumes<HcalQIEData, HcalQIEDataRcd>(edm::ESInputTag("", "update"));
11  m_tok2 = esConsumes<HcalQIEData, HcalQIEDataRcd>(edm::ESInputTag("", "reference"));
12  m_tokmap = esConsumes<HcalElectronicsMap, HcalElectronicsMapRcd>(edm::ESInputTag("", "reference"));
13 }
edm::ESGetToken< HcalQIEData, HcalQIEDataRcd > m_tok1
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > m_tokmap
std::string dumprefs
std::string outfile
edm::ESGetToken< HcalQIEData, HcalQIEDataRcd > m_tok2
std::string dumpupdate

◆ ~HcalQIEDataCheck()

HcalQIEDataCheck::~HcalQIEDataCheck ( )
override

Definition at line 15 of file HcalQIEDataCheck.cc.

15 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 17 of file HcalQIEDataCheck.cc.

References HcalQIEData::addCoder(), HcalElectronicsMap::allPrecisionId(), checkemapflag, gather_cfg::cout, HcalDbASCIIIO::dumpObject(), dumprefs, dumpupdate, Exception, spr::find(), dqmdumpme::first, HcalCondObjectContainer< Item >::getAllChannels(), HcalQIEData::getCoder(), edm::EventSetup::getData(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_tok1, m_tok2, m_tokmap, outfile, edm::second(), HcalQIEData::sort(), HcalCondObjectContainerBase::topo(), and validateflag.

17  {
18  using namespace edm::eventsetup;
19 
20  const HcalQIEData* myNewQIEs = &es.getData(m_tok1);
21  const HcalQIEData* myRefQIEs = &es.getData(m_tok2);
22  const HcalElectronicsMap* myRefEMap = &es.getData(m_tokmap);
23 
24  if (dumpupdate != "null") {
25  std::ofstream outStream(dumpupdate.c_str());
26  std::cout << "--- Dumping QIEs - update ---" << std::endl;
27  HcalDbASCIIIO::dumpObject(outStream, (*myNewQIEs));
28  }
29  if (dumprefs != "null") {
30  std::ofstream outStream2(dumprefs.c_str());
31  std::cout << "--- Dumping QIEs - reference ---" << std::endl;
32  HcalDbASCIIIO::dumpObject(outStream2, (*myRefQIEs));
33  }
34 
35  // first get the list of all channels from the update
36  std::vector<DetId> listNewChan = myNewQIEs->getAllChannels();
37 
38  HcalQIEData* resultQIEs = new HcalQIEData(myRefQIEs->topo());
39  std::vector<DetId> listRefChan = myRefQIEs->getAllChannels();
40  std::vector<DetId>::iterator cell;
41 
42  if (validateflag) {
43  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
44  DetId mydetid = *it;
45  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
46  if (cell == listNewChan.end()) // not present in new list
47  {
48  throw cms::Exception("DataDoesNotMatch") << "Value not found in reference" << std::endl;
49  } else // present in new list
50  {
51  const HcalQIECoder* first = myNewQIEs->getCoder(mydetid);
52  const HcalQIECoder* second = myRefQIEs->getCoder(mydetid);
53  {
54  bool failflag = false;
55  if (first->offset(0, 0) != second->offset(0, 0))
56  failflag = true;
57  if (first->offset(0, 1) != second->offset(0, 1))
58  failflag = true;
59  if (first->offset(0, 2) != second->offset(0, 2))
60  failflag = true;
61  if (first->offset(0, 3) != second->offset(0, 3))
62  failflag = true;
63  if (first->offset(1, 0) != second->offset(1, 0))
64  failflag = true;
65  if (first->offset(1, 1) != second->offset(1, 1))
66  failflag = true;
67  if (first->offset(1, 2) != second->offset(1, 2))
68  failflag = true;
69  if (first->offset(1, 3) != second->offset(1, 3))
70  failflag = true;
71  if (first->offset(2, 0) != second->offset(2, 0))
72  failflag = true;
73  if (first->offset(2, 1) != second->offset(2, 1))
74  failflag = true;
75  if (first->offset(2, 2) != second->offset(2, 2))
76  failflag = true;
77  if (first->offset(2, 3) != second->offset(2, 3))
78  failflag = true;
79  if (first->offset(3, 0) != second->offset(3, 0))
80  failflag = true;
81  if (first->offset(3, 1) != second->offset(3, 1))
82  failflag = true;
83  if (first->offset(3, 2) != second->offset(3, 2))
84  failflag = true;
85  if (first->offset(3, 3) != second->offset(3, 3))
86  failflag = true;
87  if (first->slope(0, 0) != second->slope(0, 0))
88  failflag = true;
89  if (first->slope(0, 1) != second->slope(0, 1))
90  failflag = true;
91  if (first->slope(0, 2) != second->slope(0, 2))
92  failflag = true;
93  if (first->slope(0, 3) != second->slope(0, 3))
94  failflag = true;
95  if (first->slope(1, 0) != second->slope(1, 0))
96  failflag = true;
97  if (first->slope(1, 1) != second->slope(1, 1))
98  failflag = true;
99  if (first->slope(1, 2) != second->slope(1, 2))
100  failflag = true;
101  if (first->slope(1, 3) != second->slope(1, 3))
102  failflag = true;
103  if (first->slope(2, 0) != second->slope(2, 0))
104  failflag = true;
105  if (first->slope(2, 1) != second->slope(2, 1))
106  failflag = true;
107  if (first->slope(2, 2) != second->slope(2, 2))
108  failflag = true;
109  if (first->slope(2, 3) != second->slope(2, 3))
110  failflag = true;
111  if (first->slope(3, 0) != second->slope(3, 0))
112  failflag = true;
113  if (first->slope(3, 1) != second->slope(3, 1))
114  failflag = true;
115  if (first->slope(3, 2) != second->slope(3, 2))
116  failflag = true;
117  if (first->slope(3, 3) != second->slope(3, 3))
118  failflag = true;
119  if (failflag)
120  throw cms::Exception("DataDoesNotMatch") << "Values are do not match";
121  }
122  listNewChan.erase(cell); // fix 25.02.08
123  }
124  }
125  std::cout << "These are identical" << std::endl;
126  }
127 
128  // if(epsilon!=0){
129  //implement compare qies -- different epsilon for slope and offset?
130  // }
131 
132  if (outfile != "null") {
133  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
134  DetId mydetid = *it;
135  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
136  if (cell == listNewChan.end()) // not present in new list
137  {
138  const HcalQIECoder* myCoder = myRefQIEs->getCoder(mydetid);
139  std::cout << "o";
140  resultQIEs->addCoder(*myCoder);
141  } else // present in new list
142  {
143  const HcalQIECoder* myCoder = myNewQIEs->getCoder(mydetid);
144  std::cout << "n";
145  resultQIEs->addCoder(*myCoder);
146  listNewChan.erase(cell); // fix 25.02.08
147  }
148  }
149  for (std::vector<DetId>::iterator it = listNewChan.begin(); it != listNewChan.end(); it++) // fix 25.02.08
150  {
151  DetId mydetid = *it;
152  const HcalQIECoder* myCoder = myNewQIEs->getCoder(mydetid);
153  std::cout << "N";
154  resultQIEs->addCoder(*myCoder);
155  }
156 
157  std::ofstream outStream3(outfile.c_str());
158  std::cout << "--- Dumping QIEs - the combined ones ---" << std::endl;
159  resultQIEs->sort();
160  HcalDbASCIIIO::dumpObject(outStream3, (*resultQIEs));
161  }
162 
163  std::cout << std::endl;
164  if (checkemapflag) {
165  std::vector<DetId> listResult = resultQIEs->getAllChannels();
166  // get the e-map list of channels
167  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
168  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++) {
169  DetId mydetid = DetId(it->rawId());
170  if (std::find(listResult.begin(), listResult.end(), mydetid) == listResult.end()) {
171  std::cout << "Conditions not found for DetId = " << HcalGenericDetId(it->rawId()) << std::endl;
172  }
173  }
174  }
175 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< HcalQIEData, HcalQIEDataRcd > m_tok1
edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > m_tokmap
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
bool addCoder(const HcalQIECoder &fCoder)
Definition: HcalQIEData.h:41
U second(std::pair< T, U > const &p)
const HcalQIECoder * getCoder(DetId fId) const
get QIE parameters
Definition: HcalQIEData.h:37
const HcalTopology * topo() const
std::vector< DetId > getAllChannels() const
Definition: DetId.h:17
void sort()
Definition: HcalQIEData.h:43
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
std::string dumprefs
std::vector< HcalGenericDetId > allPrecisionId() const
std::string outfile
edm::ESGetToken< HcalQIEData, HcalQIEDataRcd > m_tok2
std::string dumpupdate

Member Data Documentation

◆ checkemapflag

bool HcalQIEDataCheck::checkemapflag
private

Definition at line 49 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

◆ dumprefs

std::string HcalQIEDataCheck::dumprefs
private

Definition at line 47 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

◆ dumpupdate

std::string HcalQIEDataCheck::dumpupdate
private

Definition at line 48 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

◆ m_tok1

edm::ESGetToken<HcalQIEData, HcalQIEDataRcd> HcalQIEDataCheck::m_tok1
private

Definition at line 51 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

◆ m_tok2

edm::ESGetToken<HcalQIEData, HcalQIEDataRcd> HcalQIEDataCheck::m_tok2
private

Definition at line 52 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

◆ m_tokmap

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

Definition at line 53 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

◆ outfile

std::string HcalQIEDataCheck::outfile
private

Definition at line 46 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

◆ validateflag

bool HcalQIEDataCheck::validateflag
private

Definition at line 50 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().