CMS 3D CMS Logo

HtrXmlPattern.cc
Go to the documentation of this file.
4 
7 
8 #include "HtrXmlPatternTool.h"
10 
11 // system include files
12 #include <memory>
13 
14 // default include files
17 
20 
24 
26 public:
27  explicit HtrXmlPattern(const edm::ParameterSet&);
28  ~HtrXmlPattern() override;
29 
30 private:
31  void analyze(const edm::Event&, const edm::EventSetup&) override;
32  void endJob() override;
33  virtual void do_hand_fill(const HcalElectronicsMap*);
39  bool m_filled;
41 
43 };
44 
46  m_filled = false;
47  m_fill_by_hand = iConfig.getUntrackedParameter<bool>("fill_by_hand");
48  m_hand_pattern_number = iConfig.getUntrackedParameter<int>("hand_pattern_number");
49  m_sets_to_show = iConfig.getUntrackedParameter<int>("sets_to_show");
50  m_write_root_file = iConfig.getUntrackedParameter<bool>("write_root_file");
51 
53  m_toolparameters->m_show_errors = iConfig.getUntrackedParameter<bool>("show_errors");
54  m_toolparameters->m_presamples_per_event = iConfig.getUntrackedParameter<int>("presamples_per_event");
55  m_toolparameters->m_samples_per_event = iConfig.getUntrackedParameter<int>("samples_per_event");
56 
57  m_toolparameters->m_XML_file_mode = iConfig.getUntrackedParameter<int>("XML_file_mode");
60 
62  while (out_dir.find_last_of('/') == out_dir.length() - 1)
63  out_dir.erase(out_dir.find_last_of('/'));
65 
67 }
68 
70  delete m_tool;
71  delete m_toolparameters;
72 }
73 
74 // ------------ method called to for each event ------------
76  using namespace std;
77 
78  if (m_filled)
79  return;
80 
81  // Get the HCAL Electronics Map from the Event setup
82  const auto pSetup = iSetup.getHandle(m_hcalElectronicsMapToken);
83  const HcalElectronicsMap* readoutMap = pSetup->getHcalMapping();
84 
85  if (m_fill_by_hand) {
86  do_hand_fill(readoutMap);
87  m_filled = true;
88  return;
89  }
90 
91  std::vector<edm::Handle<HBHEDigiCollection> > hbhe;
92  std::vector<edm::Handle<HODigiCollection> > ho;
93  std::vector<edm::Handle<HFDigiCollection> > hf;
94  std::vector<edm::Handle<ZDCDigiCollection> > zdc;
95  std::vector<edm::Handle<HcalCalibDigiCollection> > hc;
96  std::vector<edm::Handle<HcalTrigPrimDigiCollection> > htp;
97  std::vector<edm::Handle<HcalHistogramDigiCollection> > hh;
98 
99  //iEvent.getManyByType(hbhe);
100  throw cms::Exception("UnsupportedFunction") << "HtrXmlPattern::analyze: "
101  << "getManyByType has not been supported by the Framework since 2015. "
102  << "This module has been broken since then. Maybe it should be deleted. "
103  << "Another possibility is to upgrade to use GetterOfProducts instead.";
104 
105  if (hbhe.empty()) {
106  edm::LogPrint("HtrXmlPattern") << "No HB/HE Digis.";
107  } else {
108  std::vector<edm::Handle<HBHEDigiCollection> >::iterator i;
109  for (i = hbhe.begin(); i != hbhe.end(); i++) {
110  const HBHEDigiCollection& c = *(*i);
111 
112  int count = 0;
113  for (HBHEDigiCollection::const_iterator j = c.begin(); j != c.end(); j++) {
114  const HcalElectronicsId HEID = readoutMap->lookup(j->id());
115  m_tool->Fill(HEID, j);
116 
117  if (count++ < m_sets_to_show || m_sets_to_show < 0) {
118  edm::LogPrint("HtrXmlPattern") << *j;
119  edm::LogPrint("HtrXmlPattern") << HEID;
120  edm::LogPrint("HtrXmlPattern") << "count: " << count;
121  }
122  }
123  if (m_sets_to_show != 0)
124  edm::LogPrint("HtrXmlPattern") << "HB/HE count: " << count;
125  }
126  }
127 
128  //iEvent.getManyByType(hf);
129  throw cms::Exception("UnsupportedFunction") << "HtrXmlPattern::analyze: "
130  << "getManyByType has not been supported by the Framework since 2015. "
131  << "This module has been broken since then. Maybe it should be deleted. "
132  << "Another possibility is to upgrade to use GetterOfProducts instead.";
133 
134  if (hf.empty()) {
135  edm::LogPrint("HtrXmlPattern") << "No HF Digis.";
136  } else {
137  std::vector<edm::Handle<HFDigiCollection> >::iterator i;
138  for (i = hf.begin(); i != hf.end(); i++) {
139  const HFDigiCollection& c = *(*i);
140 
141  int count = 0;
142  for (HFDigiCollection::const_iterator j = c.begin(); j != c.end(); j++) {
143  const HcalElectronicsId HEID = readoutMap->lookup(j->id());
144  m_tool->Fill(HEID, j);
145 
146  if (count++ < m_sets_to_show || m_sets_to_show < 0) {
147  edm::LogPrint("HtrXmlPattern") << *j;
148  edm::LogPrint("HtrXmlPattern") << HEID;
149  edm::LogPrint("HtrXmlPattern") << "count: " << count;
150  }
151  }
152  if (m_sets_to_show != 0)
153  edm::LogPrint("HtrXmlPattern") << "HF count: " << count;
154  }
155  }
156 
157  //iEvent.getManyByType(ho);
158  throw cms::Exception("UnsupportedFunction") << "HtrXmlPattern::analyze: "
159  << "getManyByType has not been supported by the Framework since 2015. "
160  << "This module has been broken since then. Maybe it should be deleted. "
161  << "Another possibility is to upgrade to use GetterOfProducts instead.";
162 
163  if (ho.empty()) {
164  edm::LogPrint("HtrXmlPattern") << "No HO Digis.";
165  } else {
166  std::vector<edm::Handle<HODigiCollection> >::iterator i;
167  for (i = ho.begin(); i != ho.end(); i++) {
168  const HODigiCollection& c = *(*i);
169 
170  int count = 0;
171  for (HODigiCollection::const_iterator j = c.begin(); j != c.end(); j++) {
172  const HcalElectronicsId HEID = readoutMap->lookup(j->id());
173  m_tool->Fill(HEID, j);
174 
175  if (count++ < m_sets_to_show || m_sets_to_show < 0) {
176  edm::LogPrint("HtrXmlPattern") << *j;
177  edm::LogPrint("HtrXmlPattern") << HEID;
178  edm::LogPrint("HtrXmlPattern") << "count: " << count;
179  }
180  }
181  if (m_sets_to_show != 0)
182  edm::LogPrint("HtrXmlPattern") << "HO count: " << count;
183  }
184  }
185 
186  edm::LogPrint("HtrXmlPattern");
187 }
188 
191 
192  for (int iCrate = 0; iCrate < ChannelPattern::NUM_CRATES; iCrate++) {
193  CrateData* cd = hxps->getCrate(iCrate);
194  if (!cd)
195  continue;
196  for (int iSlot = 0; iSlot < ChannelPattern::NUM_SLOTS; iSlot++) {
197  for (int iTb = 0; iTb < 2; iTb++) {
198  HalfHtrData* hhd = cd->getHalfHtrData(iSlot, iTb);
199  if (!hhd)
200  continue;
201  for (int iChannel = 1; iChannel < 25; iChannel++) {
202  ChannelPattern* cp = hhd->getPattern(iChannel);
203  if (!cp)
204  continue;
205  cp->Fill_by_hand(emap, m_hand_pattern_number);
206  }
207  }
208  }
209  }
210 }
211 
212 // ------------ method called once each job just after ending the event loop ------------
214  bool modeg0 = m_toolparameters->m_XML_file_mode > 0;
215  if (modeg0 || m_write_root_file)
216  m_tool->prepareDirs();
217  if (modeg0)
218  m_tool->writeXML();
219  if (m_write_root_file)
220  m_tool->createHists();
221 }
222 
const edm::ESGetToken< HcalDbService, HcalDbRecord > m_hcalElectronicsMapToken
HtrXmlPatternToolParameters * m_toolparameters
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
std::vector< T >::const_iterator const_iterator
~HtrXmlPattern() override
void endJob() override
HtrXmlPattern(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
static const int NUM_CRATES
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
ChannelPattern * getPattern(int chan)
int m_hand_pattern_number
bool m_write_root_file
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static const int NUM_SLOTS
ALPAKA_FN_ACC ALPAKA_FN_INLINE void uint32_t const uint32_t CACellT< TrackerTraits > uint32_t CellNeighborsVector< TrackerTraits > CellTracksVector< TrackerTraits > HitsConstView< TrackerTraits > hh
Log< level::Warning, true > LogPrint
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
void Fill(const HcalElectronicsId HEID, HBHEDigiCollection::const_iterator data)
HtrXmlPatternSet * GetPatternSet()
CrateData * getCrate(int crate)
virtual void do_hand_fill(const HcalElectronicsMap *)
Readout chain identification for Hcal.
HtrXmlPatternTool * m_tool