CMS 3D CMS Logo

HcalQIEDataCheck.cc
Go to the documentation of this file.
2 
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 }
12 
14 
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!="null"){
32  std::ofstream outStream(dumpupdate.c_str());
33  std::cout << "--- Dumping QIEs - update ---" << std::endl;
34  HcalDbASCIIIO::dumpObject (outStream, (*myNewQIEs) );
35  }
36  if(dumprefs!="null"){
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!="null"){
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 }
160 
HcalQIEDataCheck(edm::ParameterSet const &ps)
T getUntrackedParameter(std::string const &, T const &) const
float slope(unsigned fCapId, unsigned fRange) const
Definition: HcalQIECoder.cc:54
const HcalQIECoder * getCoder(DetId fId) const
get QIE parameters
Definition: HcalQIEData.h:39
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool ev
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
~HcalQIEDataCheck() override
void analyze(const edm::Event &ev, const edm::EventSetup &es) override
Definition: DetId.h:18
void sort()
Definition: HcalQIEData.h:45
const T & get() const
Definition: EventSetup.h:55
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