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 
20 // system include files
21 #include <memory>
22 #include <fstream>
23 
24 // user include files
31 
39 
40 class WriteL1TriggerObjectsTxt : public edm::one::EDAnalyzer<edm::one::SharedResources> {
41  public:
43  ~WriteL1TriggerObjectsTxt() override;
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47 
48  private:
49  void analyze(const edm::Event&, const edm::EventSetup&) override;
50 
52 };
53 
55  tagName_(iConfig.getParameter<std::string>("TagName"))
56 {
57 }
59 
60 
61 void
63 {
64  using namespace edm;
65 
67  iSetup.get<HcalDbRecord>().get(conditions);
68 
69  const HcalLutMetadata *metadata = conditions->getHcalLutMetadata();
70  const HcalTopology *topo = metadata->topo();
71 
72  std::unique_ptr<HcalL1TriggerObjects> HcalL1TrigObjCol(new HcalL1TriggerObjects);
73 
74  for (const auto& id: metadata->getAllChannels()) {
75  if (not (id.det() == DetId::Hcal and topo->valid(id))) continue;
76 
77  HcalDetId cell(id);
78  HcalSubdetector subdet = cell.subdet();
79  if (subdet != HcalBarrel and subdet != HcalEndcap and subdet != HcalForward) continue;
80 
82 
83  float gain = 0.0;
84  float ped = 0.0;
85 
86  for (auto i : {0,1,2,3}){
87  gain += calibrations.LUTrespcorrgain(i);
88  ped += calibrations.pedestal(i);
89  }
90 
91  gain /= 4.;
92  ped /= 4.;
93 
94  const HcalChannelStatus* channelStatus = conditions->getHcalChannelStatus(cell);
95  uint32_t status = channelStatus->getValue();
96  HcalL1TriggerObject l1object(cell, ped, gain, status);
97  HcalL1TrigObjCol->setTopo(topo);
98  HcalL1TrigObjCol->addValues(l1object);
99  }
100 
101 
102  HcalL1TrigObjCol->setTagString(tagName_);
103  HcalL1TrigObjCol->setAlgoString("A 2-TS Peak Finder");
104  std::string outfilename = "Gen_L1TriggerObjects_";
105  outfilename += tagName_;
106  outfilename += ".txt";
107  std::ofstream of(outfilename.c_str());
108  HcalDbASCIIIO::dumpObject(of, *HcalL1TrigObjCol);
109 }
110 
111 void
114  desc.setUnknown();
115  descriptions.addDefault(desc);
116 }
117 
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool valid(const DetId &id) const override
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const HcalChannelStatus * getHcalChannelStatus(const HcalGenericDetId &fId) const
double pedestal(int fCapId) const
get pedestal for capid=0..3
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< DetId > getAllChannels() const
HcalSubdetector
Definition: HcalAssistant.h:31
const HcalLutMetadata * getHcalLutMetadata() const
double LUTrespcorrgain(int fCapId) const
get LUT corrected and response corrected gain for capid=0..3
const T & get() const
Definition: EventSetup.h:58
HLT enums.
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
WriteL1TriggerObjectsTxt(const edm::ParameterSet &)
uint32_t getValue() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
const HcalTopology * topo() const