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 
76  HcalCalibrations calibrations = conditions->getHcalCalibrations(cell);
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_";
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 
EDAnalyzer.h
HcalCalibrations.h
mps_fire.i
i
Definition: mps_fire.py:428
ESHandle.h
mps_update.status
status
Definition: mps_update.py:69
HcalL1TriggerObjects.h
edm
HLT enums.
Definition: AlignableModifier.h:19
HcalTopology
Definition: HcalTopology.h:26
DetId::Hcal
Definition: DetId.h:28
HcalL1TriggerObject.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
WriteL1TriggerObjectsTxt::~WriteL1TriggerObjectsTxt
~WriteL1TriggerObjectsTxt() override
Definition: WriteL1TriggerObjectsTxt.cc:54
AlignmentProducer_cff.calibrations
calibrations
Definition: AlignmentProducer_cff.py:59
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
HcalBarrel
Definition: HcalAssistant.h:33
WriteL1TriggerObjectsTxt::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: WriteL1TriggerObjectsTxt.cc:56
MakerMacros.h
HcalL1TriggerObjects
Definition: HcalL1TriggerObjects.h:14
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripCommissioningSource_FromRAW_cfg.outfilename
outfilename
Definition: SiStripCommissioningSource_FromRAW_cfg.py:122
HcalChannelStatus
Definition: HcalChannelStatus.h:13
edm::ESHandle< HcalDbService >
HcalDbRecord.h
HcalCalibrations
Definition: HcalCalibrations.h:9
TrackingMonitor_cfi.metadata
metadata
Definition: TrackingMonitor_cfi.py:71
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalL1TriggerObject
Definition: HcalL1TriggerObject.h:13
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
WriteL1TriggerObjectsTxt::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: WriteL1TriggerObjectsTxt.cc:105
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
HcalDetId
Definition: HcalDetId.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
WriteL1TriggerObjectsTxt::WriteL1TriggerObjectsTxt
WriteL1TriggerObjectsTxt(const edm::ParameterSet &)
Definition: WriteL1TriggerObjectsTxt.cc:52
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
WriteL1TriggerObjectsTxt::tagName_
std::string tagName_
Definition: WriteL1TriggerObjectsTxt.cc:49
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
HcalTopology::valid
bool valid(const DetId &id) const override
Definition: HcalTopology.cc:225
HcalDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
HcalTopology.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
std
Definition: JetResolutionObject.h:76
HcalLutMetadata
Definition: HcalLutMetadata.h:15
HcalDbASCIIIO.h
HcalEndcap
Definition: HcalAssistant.h:34
Frameworkfwd.h
WriteL1TriggerObjectsTxt
Definition: WriteL1TriggerObjectsTxt.cc:39
HcalDbService.h
HcalDbRecord
Definition: HcalDbRecord.h:30
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99