CMS 3D CMS Logo

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