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