CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
29 
37 
38 class WriteL1TriggerObjectsTxt : public edm::one::EDAnalyzer<edm::one::SharedResources> {
39 public:
41  ~WriteL1TriggerObjectsTxt() override;
42 
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
44 
45 private:
46  void analyze(const edm::Event&, const edm::EventSetup&) override;
47 
50 };
51 
53  : tagName_(iConfig.getParameter<std::string>("TagName")),
54  tok_dbservice_(esConsumes<HcalDbService, HcalDbRecord>()) {}
55 
57 
59  using namespace edm;
60 
62 
63  const HcalLutMetadata* metadata = conditions->getHcalLutMetadata();
64  const HcalTopology* topo = metadata->topo();
65 
66  std::unique_ptr<HcalL1TriggerObjects> HcalL1TrigObjCol(new HcalL1TriggerObjects);
67 
68  for (const auto& id : metadata->getAllChannels()) {
69  if (not(id.det() == DetId::Hcal and topo->valid(id)))
70  continue;
71 
72  HcalDetId cell(id);
73  HcalSubdetector subdet = cell.subdet();
74  if (subdet != HcalBarrel and subdet != HcalEndcap and subdet != HcalForward)
75  continue;
76 
77  HcalCalibrations calibrations = conditions->getHcalCalibrations(cell);
78 
79  float gain = 0.0;
80  float ped = 0.0;
81 
82  for (auto i : {0, 1, 2, 3}) {
83  gain += calibrations.LUTrespcorrgain(i);
84  ped += calibrations.effpedestal(i);
85  }
86 
87  gain /= 4.;
88  ped /= 4.;
89 
90  const HcalChannelStatus* channelStatus = conditions->getHcalChannelStatus(cell);
91  uint32_t status = channelStatus->getValue();
92  HcalL1TriggerObject l1object(cell, ped, gain, status);
93  HcalL1TrigObjCol->setTopo(topo);
94  HcalL1TrigObjCol->addValues(l1object);
95  }
96 
97  HcalL1TrigObjCol->setTagString(tagName_);
98  HcalL1TrigObjCol->setAlgoString("A 2-TS Peak Finder");
99  std::string outfilename = "Gen_L1TriggerObjects_";
101  outfilename += ".txt";
102  std::ofstream of(outfilename.c_str());
103  HcalDbASCIIIO::dumpObject(of, *HcalL1TrigObjCol);
104 }
105 
108  desc.setUnknown();
109  descriptions.addDefault(desc);
110 }
111 
edm::ESGetToken< HcalDbService, HcalDbRecord > tok_dbservice_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
list status
Definition: mps_update.py:107
bool getData(T &iHolder) const
Definition: EventSetup.h:128
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
tuple of
Definition: haddnano.py:40
constexpr double effpedestal(int fCapId) const
get effective pedestal for capid=0..3
HcalSubdetector
Definition: HcalAssistant.h:31
constexpr double LUTrespcorrgain(int fCapId) const
get LUT corrected and response corrected gain for capid=0..3
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
WriteL1TriggerObjectsTxt(const edm::ParameterSet &)
uint32_t getValue() const
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283