CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 
48  template <typename T>
49  void fillL1TrgObjsCollection(std::unique_ptr<HcalL1TriggerObjects>& l1TrgObjsCol,
51  const HcalTopology* topo,
52  T cell);
53 
56 };
57 
59  : tagName_(iConfig.getParameter<std::string>("TagName")),
60  tok_dbservice_(esConsumes<HcalDbService, HcalDbRecord>()) {}
61 
63 
64 template <typename T>
65 void WriteL1TriggerObjectsTxt::fillL1TrgObjsCollection(std::unique_ptr<HcalL1TriggerObjects>& l1TrgObjsCol,
67  const HcalTopology* topo,
68  T cell) {
69  const HcalCalibrations calibrations = conditions->getHcalCalibrations(cell);
70 
71  float gain = 0.0;
72  float ped = 0.0;
73 
74  for (auto i : {0, 1, 2, 3}) {
75  gain += calibrations.LUTrespcorrgain(i);
76  ped += calibrations.effpedestal(i);
77  }
78 
79  gain /= 4.;
80  ped /= 4.;
81 
82  const HcalChannelStatus* channelStatus = conditions->getHcalChannelStatus(cell);
83  uint32_t status = channelStatus->getValue();
84  HcalL1TriggerObject l1object(cell, ped, gain, status);
85  l1TrgObjsCol->setTopo(topo);
86  l1TrgObjsCol->addValues(l1object);
87 }
88 
90  using namespace edm;
91 
93 
94  const HcalLutMetadata* metadata = conditions->getHcalLutMetadata();
95  const HcalTopology* topo = metadata->topo();
96 
97  std::unique_ptr<HcalL1TriggerObjects> HcalL1TrigObjCol(new HcalL1TriggerObjects);
98 
99  for (const auto& id : metadata->getAllChannels()) {
100  if (id.det() == DetId::Hcal and topo->valid(id)) {
101  HcalDetId cell(id);
102  HcalSubdetector subdet = cell.subdet();
103  if (subdet != HcalBarrel and subdet != HcalEndcap and subdet != HcalForward)
104  continue;
105 
106  fillL1TrgObjsCollection(HcalL1TrigObjCol, conditions, topo, cell);
107 
108  } else if (id.det() == DetId::Calo && id.subdetId() == HcalZDCDetId::SubdetectorId) {
109  HcalZDCDetId cell(id.rawId());
110 
111  if (cell.section() != HcalZDCDetId::EM && cell.section() != HcalZDCDetId::HAD &&
112  cell.section() != HcalZDCDetId::LUM)
113  continue;
114 
115  fillL1TrgObjsCollection(HcalL1TrigObjCol, conditions, topo, cell);
116  }
117  }
118 
119  HcalL1TrigObjCol->setTagString(tagName_);
120  HcalL1TrigObjCol->setAlgoString("TP algo determined by HcalTPChannelParameter auxi params");
121  std::string outfilename = "Gen_L1TriggerObjects_";
123  outfilename += ".txt";
124  std::ofstream of(outfilename.c_str());
125  HcalDbASCIIIO::dumpObject(of, *HcalL1TrigObjCol);
126 }
127 
130  desc.setUnknown();
131  descriptions.addDefault(desc);
132 }
133 
edm::ESGetToken< HcalDbService, HcalDbRecord > tok_dbservice_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void fillL1TrgObjsCollection(std::unique_ptr< HcalL1TriggerObjects > &l1TrgObjsCol, const HcalDbService *conditions, const HcalTopology *topo, T cell)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void analyze(const edm::Event &, const edm::EventSetup &) override
bool valid(const DetId &id) const override
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
HcalSubdetector
Definition: HcalAssistant.h:31
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
uint32_t getValue() const
constexpr Section section() const
get the section
Definition: HcalZDCDetId.h:92
HLT enums.
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
static constexpr int32_t SubdetectorId
Definition: HcalZDCDetId.h:35
WriteL1TriggerObjectsTxt(const edm::ParameterSet &)
long double T