CMS 3D CMS Logo

WriteL1TriggerObjectsTxt.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Test/WriteL1TriggerObjectsTxt
4 // Class: WriteL1TriggerObjectsTxt
5 //
13 //
14 // Original Author: Aleko Khukhunaishvili
15 // Created: Fri, 21 Jul 2017 08:25:18 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <fstream>
22 
23 // user include files
30 
38 
39 class WriteL1TriggerObjectsTxt : public edm::one::EDAnalyzer<edm::one::SharedResources> {
40 public:
42  ~WriteL1TriggerObjectsTxt() override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 private:
47  void analyze(const edm::Event&, const edm::EventSetup&) override;
48 
50 };
51 
53  : tagName_(iConfig.getParameter<std::string>("TagName")) {}
55 
57  using namespace edm;
58 
60  iSetup.get<HcalDbRecord>().get(conditions);
61 
62  const HcalLutMetadata* metadata = conditions->getHcalLutMetadata();
63  const HcalTopology* topo = metadata->topo();
64 
65  std::unique_ptr<HcalL1TriggerObjects> HcalL1TrigObjCol(new HcalL1TriggerObjects);
66 
67  for (const auto& id : metadata->getAllChannels()) {
68  if (not(id.det() == DetId::Hcal and topo->valid(id)))
69  continue;
70 
71  HcalDetId cell(id);
72  HcalSubdetector subdet = cell.subdet();
73  if (subdet != HcalBarrel and subdet != HcalEndcap and subdet != HcalForward)
74  continue;
75 
77 
78  float gain = 0.0;
79  float ped = 0.0;
80 
81  for (auto i : {0, 1, 2, 3}) {
82  gain += calibrations.LUTrespcorrgain(i);
83  ped += calibrations.effpedestal(i);
84  }
85 
86  gain /= 4.;
87  ped /= 4.;
88 
89  const HcalChannelStatus* channelStatus = conditions->getHcalChannelStatus(cell);
90  uint32_t status = channelStatus->getValue();
91  HcalL1TriggerObject l1object(cell, ped, gain, status);
92  HcalL1TrigObjCol->setTopo(topo);
93  HcalL1TrigObjCol->addValues(l1object);
94  }
95 
96  HcalL1TrigObjCol->setTagString(tagName_);
97  HcalL1TrigObjCol->setAlgoString("A 2-TS Peak Finder");
98  std::string outfilename = "Gen_L1TriggerObjects_";
99  outfilename += tagName_;
100  outfilename += ".txt";
101  std::ofstream of(outfilename.c_str());
102  HcalDbASCIIIO::dumpObject(of, *HcalL1TrigObjCol);
103 }
104 
107  desc.setUnknown();
108  descriptions.addDefault(desc);
109 }
110 
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool valid(const DetId &id) const override
void analyze(const edm::Event &, const edm::EventSetup &) override
const HcalChannelStatus * getHcalChannelStatus(const HcalGenericDetId &fId) const
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< DetId > getAllChannels() const
constexpr double effpedestal(int fCapId) const
get effective pedestal for capid=0..3
HcalSubdetector
Definition: HcalAssistant.h:31
const HcalLutMetadata * getHcalLutMetadata() const
constexpr double LUTrespcorrgain(int fCapId) const
get LUT corrected and response corrected gain for capid=0..3
HLT enums.
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
T get() const
Definition: EventSetup.h:73
WriteL1TriggerObjectsTxt(const edm::ParameterSet &)
uint32_t getValue() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
const HcalTopology * topo() const