CMS 3D CMS Logo

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

#include <HcalQIEDataCheck.h>

Inheritance diagram for HcalQIEDataCheck:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &ev, const edm::EventSetup &es)
 
 HcalQIEDataCheck (edm::ParameterSet const &ps)
 
 ~HcalQIEDataCheck ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

bool checkemapflag
 
std::string dumprefs
 
std::string dumpupdate
 
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 &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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)
 

Detailed Description

Definition at line 38 of file HcalQIEDataCheck.h.

Constructor & Destructor Documentation

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

Definition at line 3 of file HcalQIEDataCheck.cc.

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

4 {
5  outfile = ps.getUntrackedParameter<std::string>("outFile","null");
6  dumprefs = ps.getUntrackedParameter<std::string>("dumpRefQIEsTo","null");
7  dumpupdate = ps.getUntrackedParameter<std::string>("dumpUpdateQIEsTo","null");
8  checkemapflag = ps.getUntrackedParameter<bool>("checkEmap",false);
9  validateflag = ps.getUntrackedParameter<bool>("validateQIEs",false);
10 // epsilon = ps.getUntrackedParameter<double>("deltaQIE",0);
11 }
std::string dumprefs
std::string outfile
std::string dumpupdate
HcalQIEDataCheck::~HcalQIEDataCheck ( )

Definition at line 13 of file HcalQIEDataCheck.cc.

13 {}

Member Function Documentation

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

Definition at line 15 of file HcalQIEDataCheck.cc.

References HcalQIEData::addCoder(), HcalElectronicsMap::allPrecisionId(), checkemapflag, gather_cfg::cout, DEFINE_FWK_MODULE, HcalDbASCIIIO::dumpObject(), dumprefs, dumpupdate, Exception, spr::find(), plotBeamSpotDB::first, edm::EventSetup::get(), HcalCondObjectContainer< Item >::getAllChannels(), HcalQIEData::getCoder(), HcalQIECoder::offset(), outfile, edm::ESHandle< T >::product(), edm::second(), HcalQIECoder::slope(), HcalQIEData::sort(), HcalCondObjectContainerBase::topo(), and validateflag.

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

Member Data Documentation

bool HcalQIEDataCheck::checkemapflag
private

Definition at line 51 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

std::string HcalQIEDataCheck::dumprefs
private

Definition at line 49 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

std::string HcalQIEDataCheck::dumpupdate
private

Definition at line 50 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

std::string HcalQIEDataCheck::outfile
private

Definition at line 48 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().

bool HcalQIEDataCheck::validateflag
private

Definition at line 52 of file HcalQIEDataCheck.h.

Referenced by analyze(), and HcalQIEDataCheck().