CMS 3D CMS Logo

HcalAutoPedestalValidator.cc
Go to the documentation of this file.
2 
4  outfile = ps.getUntrackedParameter<std::string>("outFile", "changed.bool");
5  epsilon = ps.getUntrackedParameter<double>("deltaP", .25);
6 }
7 
9 
11  using namespace edm::eventsetup;
12  // get fake pedestals from file ("new pedestals")
14  es.get<HcalPedestalsRcd>().get("update", newPeds);
15  const HcalPedestals* myNewPeds = newPeds.product();
16 
17  // get DB pedestals from Frontier/OrcoX ("reference")
19  es.get<HcalPedestalsRcd>().get("reference", refPeds);
20  const HcalPedestals* myRefPeds = refPeds.product();
21 
22  std::vector<DetId> listNewChan = myNewPeds->getAllChannels();
23  std::vector<DetId> listRefChan = myRefPeds->getAllChannels();
24  std::vector<DetId>::iterator cell;
25  bool failflag = false;
26  for (std::vector<DetId>::iterator it = listRefChan.begin(); it != listRefChan.end(); it++) {
27  DetId mydetid = *it;
28  cell = std::find(listNewChan.begin(), listNewChan.end(), mydetid);
29  if (cell == listNewChan.end()) {
30  continue;
31  } else {
32  const float* values = (myNewPeds->getValues(mydetid))->getValues();
33  const float* oldvalue = (myRefPeds->getValues(mydetid))->getValues();
34  if ((*values == 0) && (*(values + 1) == 0) && (*(values + 2) == 0) && (*(values + 3) == 0))
35  continue;
36  if ((*oldvalue - *values) + (*(oldvalue + 1) - *(values + 1)) + (*(oldvalue + 2) - *(values + 2)) +
37  (*(oldvalue + 3) - *(values + 3)) / 4 >
38  epsilon) {
39  std::cout << "Channel " << std::hex << mydetid.rawId() << " Values differ by " << std::dec
40  << (*oldvalue - *values) << " " << (*(oldvalue + 1) - *(values + 1)) << " "
41  << (*(oldvalue + 2) - *(values + 2)) << " " << (*(oldvalue + 3) - *(values + 3)) << std::endl;
42  failflag = true;
43  }
44  listNewChan.erase(cell); // fix 25.02.08
45  }
46  }
47 
48  if (!failflag)
49  std::cout << "These are identical to within deltaP" << std::endl;
50  if (failflag) {
51  // if changed, this creates the empty file changed.bool which the auto job uses as a flag
52  std::ofstream outStream3(outfile.c_str());
53  std::cout << "--- Pedestals changed! ---" << std::endl;
54  }
55 }
56 
T getUntrackedParameter(std::string const &, T const &) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool ev
const Item * getValues(DetId fId, bool throwOnFail=true) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< DetId > getAllChannels() const
void analyze(const edm::Event &ev, const edm::EventSetup &es) override
Definition: DetId.h:17
HcalAutoPedestalValidator(edm::ParameterSet const &ps)
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86