CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WriteL1TriggerObjetsXml.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: WriteL1TriggerObjetsXml
4 // Class: WriteL1TriggerObjetsXml
5 //
13 //
14 // Original Author: Ka Vang TSANG
15 // Created: Fri Jul 31 15:18:53 CEST 2009
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 #include <string>
23 
24 // user include files
27 
30 
32 
41 XERCES_CPP_NAMESPACE_USE
42 //
43 // class decleration
44 //
45 
46 class WriteL1TriggerObjetsXml : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
47 public:
50 
51 
52 private:
53  virtual void analyze(edm::Event const&, edm::EventSetup const&) override;
54  virtual void beginRun(edm::Run const&, edm::EventSetup const&) override {}
55  virtual void endRun(edm::Run const&, edm::EventSetup const&) override {}
56 
57  // ----------member data ---------------------------
59 };
60 
61 //
62 // constants, enums and typedefs
63 //
64 
65 //
66 // static data member definitions
67 //
68 
69 //
70 // constructors and destructor
71 //
72 WriteL1TriggerObjetsXml::WriteL1TriggerObjetsXml(const edm::ParameterSet& iConfig) : tagname_(iConfig.getParameter<std::string>("TagName"))
73 {
74  //now do what ever initialization is needed
75 
76 }
77 
78 
80 {
81 
82  // do anything here that needs to be done at desctruction time
83  // (e.g. close files, deallocate resources etc.)
84 
85 }
86 
87 
88 //
89 // member functions
90 //
91 
92 // ------------ method called to for each event ------------
93 void
95  edm::EventSetup const& iSetup) {
97  iSetup.get<HcalRecNumberingRecord>().get(htopo);
98  const HcalTopology* topo = htopo.product();
100  iSetup.get<HcalDbRecord>().get(conditions);
101 
103  std::string subDetName[3] = {"HB", "HE", "HF"};
104  int maxEta(0), maxPhi(72), maxDepth(0);
105  const HcalDDDRecConstants* hcons = topo->dddConstants();
106  for (int isub=0; isub<3; ++isub) {
107  if (hcons->getMaxDepth(isub) > maxDepth) maxDepth = hcons->getMaxDepth(isub);
108  if (hcons->getEtaRange(isub).second > maxEta)
109  maxEta = hcons->getEtaRange(isub).second;
110  if (hcons->getNPhi(isub) > maxPhi) maxPhi = hcons->getNPhi(isub);
111  }
112 
114  for (int isub = 0; isub < 3; ++isub){
115  for (int ieta = -maxEta; ieta <= maxEta; ++ieta){
116  for (int iphi = 1; iphi <=maxPhi; ++iphi){
117  for (int depth = 1; depth <= maxDepth; ++depth){
118  HcalDetId id(subDet[isub], ieta, iphi, depth);
119 
120  if (!topo->valid(id)) continue;
121  HcalCalibrations calibrations = conditions->getHcalCalibrations(id);
122  const HcalChannelStatus* channelStatus = conditions->getHcalChannelStatus(id);
123  uint32_t status = channelStatus->getValue();
124 
125  double gain = 0.0;
126  double ped = 0.0;
127 
128  for (int i=0; i<4; ++i) {
129  gain += calibrations.LUTrespcorrgain(i);
130  ped += calibrations.pedestal(i);
131  }
132  gain /= 4.;
133  ped /= 4.;
134 
135  xml.add_hcal_channel_dataset(ieta, iphi, depth, subDetName[isub], ped, gain, status);
136  }// for depth
137  }// for iphi
138  }// for ieta
139  }// for subdet
140 
141  std::string xmlOutputFileName(tagname_);
142  xmlOutputFileName += ".xml";
143  xml.write(xmlOutputFileName);
144 }
145 
146 //define this as a plug-in
int getNPhi(const int type) const
int i
Definition: DBlmapReader.cc:9
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:150
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:322
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double maxEta
double pedestal(int fCapId) const
get pedestal for capid=0..3
XERCES_CPP_NAMESPACE::DOMNode * add_hcal_channel_dataset(int ieta, int iphi, int depth, std::string subdetector, double ped, double gain, int flag)
int getMaxDepth(const int type) const
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:230
HcalSubdetector
Definition: HcalAssistant.h:31
double LUTrespcorrgain(int fCapId) const
get LUT corrected and response corrected gain for capid=0..3
WriteL1TriggerObjetsXml(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
virtual bool valid(const DetId &id) const
std::pair< int, int > getEtaRange(const int i) const
virtual void analyze(edm::Event const &, edm::EventSetup const &) override
uint32_t getValue() const
Definition: Run.h:42
tuple status
Definition: mps_update.py:57