CMS 3D CMS Logo

HtrXmlPattern.cc
Go to the documentation of this file.
5 
8 
9 #include "HtrXmlPattern.h"
10 #include "HtrXmlPatternTool.h"
12 
14  m_filled = false;
15  m_fill_by_hand = iConfig.getUntrackedParameter<bool>("fill_by_hand");
16  m_hand_pattern_number = iConfig.getUntrackedParameter<int>("hand_pattern_number");
17  m_sets_to_show = iConfig.getUntrackedParameter<int>("sets_to_show");
18  m_write_root_file = iConfig.getUntrackedParameter<bool>("write_root_file");
19 
21  m_toolparameters->m_show_errors = iConfig.getUntrackedParameter<bool>("show_errors");
22  m_toolparameters->m_presamples_per_event = iConfig.getUntrackedParameter<int>("presamples_per_event");
23  m_toolparameters->m_samples_per_event = iConfig.getUntrackedParameter<int>("samples_per_event");
24 
25  m_toolparameters->m_XML_file_mode = iConfig.getUntrackedParameter<int>("XML_file_mode");
26  m_toolparameters->m_file_tag = iConfig.getUntrackedParameter<std::string>("file_tag");
27  m_toolparameters->m_user_output_directory = iConfig.getUntrackedParameter<std::string>("user_output_directory");
28 
29  std::string out_dir = m_toolparameters->m_user_output_directory;
30  while (out_dir.find_last_of('/') == out_dir.length() - 1)
31  out_dir.erase(out_dir.find_last_of('/'));
32  m_toolparameters->m_output_directory = out_dir + "/" + (m_toolparameters->m_file_tag) + "/";
33 
34  m_tool = new HtrXmlPatternTool(m_toolparameters);
35 }
36 
38  delete m_tool;
39  delete m_toolparameters;
40 }
41 
42 // ------------ method called to for each event ------------
44  using namespace std;
45 
46  if (m_filled)
47  return;
48 
50  iSetup.get<HcalDbRecord>().get(pSetup);
51  const HcalElectronicsMap* readoutMap = pSetup->getHcalMapping();
52 
53  if (m_fill_by_hand) {
54  do_hand_fill(readoutMap);
55  m_filled = true;
56  return;
57  }
58 
59  std::vector<edm::Handle<HBHEDigiCollection> > hbhe;
60  std::vector<edm::Handle<HODigiCollection> > ho;
61  std::vector<edm::Handle<HFDigiCollection> > hf;
62  std::vector<edm::Handle<ZDCDigiCollection> > zdc;
63  std::vector<edm::Handle<HcalCalibDigiCollection> > hc;
64  std::vector<edm::Handle<HcalTrigPrimDigiCollection> > htp;
65  std::vector<edm::Handle<HcalHistogramDigiCollection> > hh;
66 
67  iEvent.getManyByType(hbhe);
68  if (hbhe.empty()) {
69  cout << "No HB/HE Digis." << endl;
70  } else {
71  std::vector<edm::Handle<HBHEDigiCollection> >::iterator i;
72  for (i = hbhe.begin(); i != hbhe.end(); i++) {
73  const HBHEDigiCollection& c = *(*i);
74 
75  int count = 0;
76  for (HBHEDigiCollection::const_iterator j = c.begin(); j != c.end(); j++) {
77  const HcalElectronicsId HEID = readoutMap->lookup(j->id());
78  m_tool->Fill(HEID, j);
79 
80  if (count++ < m_sets_to_show || m_sets_to_show < 0) {
81  cout << *j << std::endl;
82  cout << HEID << endl;
83  cout << "count: " << count << endl;
84  }
85  }
86  if (m_sets_to_show != 0)
87  cout << "HB/HE count: " << count << endl;
88  }
89  }
90 
91  iEvent.getManyByType(hf);
92  if (hf.empty()) {
93  cout << "No HF Digis." << endl;
94  } else {
95  std::vector<edm::Handle<HFDigiCollection> >::iterator i;
96  for (i = hf.begin(); i != hf.end(); i++) {
97  const HFDigiCollection& c = *(*i);
98 
99  int count = 0;
100  for (HFDigiCollection::const_iterator j = c.begin(); j != c.end(); j++) {
101  const HcalElectronicsId HEID = readoutMap->lookup(j->id());
102  m_tool->Fill(HEID, j);
103 
104  if (count++ < m_sets_to_show || m_sets_to_show < 0) {
105  cout << *j << std::endl;
106  cout << HEID << endl;
107  cout << "count: " << count << endl;
108  }
109  }
110  if (m_sets_to_show != 0)
111  cout << "HF count: " << count << endl;
112  }
113  }
114 
115  iEvent.getManyByType(ho);
116  if (ho.empty()) {
117  cout << "No HO Digis." << endl;
118  } else {
119  std::vector<edm::Handle<HODigiCollection> >::iterator i;
120  for (i = ho.begin(); i != ho.end(); i++) {
121  const HODigiCollection& c = *(*i);
122 
123  int count = 0;
124  for (HODigiCollection::const_iterator j = c.begin(); j != c.end(); j++) {
125  const HcalElectronicsId HEID = readoutMap->lookup(j->id());
126  m_tool->Fill(HEID, j);
127 
128  if (count++ < m_sets_to_show || m_sets_to_show < 0) {
129  cout << *j << std::endl;
130  cout << HEID << endl;
131  cout << "count: " << count << endl;
132  }
133  }
134  if (m_sets_to_show != 0)
135  cout << "HO count: " << count << endl;
136  }
137  }
138 
139  cout << endl;
140 }
141 
144 
145  for (int iCrate = 0; iCrate < ChannelPattern::NUM_CRATES; iCrate++) {
146  CrateData* cd = hxps->getCrate(iCrate);
147  if (!cd)
148  continue;
149  for (int iSlot = 0; iSlot < ChannelPattern::NUM_SLOTS; iSlot++) {
150  for (int iTb = 0; iTb < 2; iTb++) {
151  HalfHtrData* hhd = cd->getHalfHtrData(iSlot, iTb);
152  if (!hhd)
153  continue;
154  for (int iChannel = 1; iChannel < 25; iChannel++) {
155  ChannelPattern* cp = hhd->getPattern(iChannel);
156  if (!cp)
157  continue;
159  }
160  }
161  }
162  }
163 }
164 
165 // ------------ method called once each job just after ending the event loop ------------
167  bool modeg0 = m_toolparameters->m_XML_file_mode > 0;
168  if (modeg0 || m_write_root_file)
169  m_tool->prepareDirs();
170  if (modeg0)
171  m_tool->writeXML();
172  if (m_write_root_file)
173  m_tool->createHists();
174 }
T getUntrackedParameter(std::string const &, T const &) const
void Fill_by_hand(const HcalElectronicsMap *, int)
HtrXmlPatternToolParameters * m_toolparameters
Definition: HtrXmlPattern.h:31
std::vector< T >::const_iterator const_iterator
~HtrXmlPattern() override
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: Event.h:508
void endJob() override
HtrXmlPattern(const edm::ParameterSet &)
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
Definition: HtrXmlPattern.h:33
bool m_write_root_file
Definition: HtrXmlPattern.h:36
static const int NUM_SLOTS
const_iterator end() const
void Fill(const HcalElectronicsId HEID, HBHEDigiCollection::const_iterator data)
HtrXmlPatternSet * GetPatternSet()
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
T get() const
Definition: EventSetup.h:71
susybsm::HSCParticleCollection hc
Definition: classes.h:25
const HcalElectronicsMap * getHcalMapping() const
virtual void do_hand_fill(const HcalElectronicsMap *)
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
const_iterator begin() const
HtrXmlPatternTool * m_tool
Definition: HtrXmlPattern.h:30