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");
28 
30  while (out_dir.find_last_of('/') == out_dir.length() - 1)
31  out_dir.erase(out_dir.find_last_of('/'));
33 
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;
158  cp->Fill_by_hand(emap, m_hand_pattern_number);
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 }
HcalElectronicsMap.h
HtrXmlPatternToolParameters::m_show_errors
bool m_show_errors
Definition: HtrXmlPatternToolParameters.h:12
HtrXmlPatternTool
Definition: HtrXmlPatternTool.h:9
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HtrXmlPattern::m_sets_to_show
int m_sets_to_show
Definition: HtrXmlPattern.h:32
ChannelPattern
Definition: HtrXmlPatternSet.h:8
HtrXmlPattern::m_toolparameters
HtrXmlPatternToolParameters * m_toolparameters
Definition: HtrXmlPattern.h:31
ESHandle.h
HtrXmlPatternTool::createHists
void createHists()
Definition: HtrXmlPatternTool.cc:194
HtrXmlPatternToolParameters::m_file_tag
std::string m_file_tag
Definition: HtrXmlPatternToolParameters.h:17
runGCPTkAlMap.out_dir
string out_dir
Definition: runGCPTkAlMap.py:49
HalfHtrData
Definition: HtrXmlPatternSet.h:44
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HtrXmlPatternToolParameters.h
edm::SortedCollection
Definition: SortedCollection.h:49
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
hgcal_conditions::parameters
Definition: HGCConditions.h:86
HtrXmlPatternTool::writeXML
void writeXML()
Definition: HtrXmlPatternTool.cc:112
HtrXmlPattern.h
HcalDbService::getHcalMapping
const HcalElectronicsMap * getHcalMapping() const
Definition: HcalDbService.cc:343
HalfHtrData::getPattern
ChannelPattern * getPattern(int chan)
Definition: HtrXmlPatternSet.h:47
HtrXmlPatternSet
Definition: HtrXmlPatternSet.h:72
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
HtrXmlPatternToolParameters::m_output_directory
std::string m_output_directory
Definition: HtrXmlPatternToolParameters.h:19
HtrXmlPatternToolParameters::m_XML_file_mode
int m_XML_file_mode
Definition: HtrXmlPatternToolParameters.h:16
CrateData
Definition: HtrXmlPatternSet.h:62
HcalDigiCollections.h
HtrXmlPattern::m_filled
bool m_filled
Definition: HtrXmlPattern.h:35
ChannelPattern::NUM_CRATES
static const int NUM_CRATES
Definition: HtrXmlPatternSet.h:11
edm::ESHandle< HcalDbService >
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
HcalDbRecord.h
HtrXmlPatternTool::prepareDirs
void prepareDirs()
Definition: HtrXmlPatternTool.cc:110
hh
const auto & hh
Definition: CAHitNtupletGeneratorKernelsImpl.h:552
HtrXmlPattern::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HtrXmlPattern.cc:43
edm::ParameterSet
Definition: ParameterSet.h:47
HtrXmlPattern::HtrXmlPattern
HtrXmlPattern(const edm::ParameterSet &)
Definition: HtrXmlPattern.cc:13
HtrXmlPatternTool::GetPatternSet
HtrXmlPatternSet * GetPatternSet()
Definition: HtrXmlPatternTool.h:19
iEvent
int iEvent
Definition: GenABIO.cc:224
HtrXmlPatternTool.h
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
edm::EventSetup
Definition: EventSetup.h:58
HtrXmlPatternToolParameters::m_presamples_per_event
int m_presamples_per_event
Definition: HtrXmlPatternToolParameters.h:13
get
#define get
HtrXmlPatternTool::Fill
void Fill(const HcalElectronicsId HEID, HBHEDigiCollection::const_iterator data)
Definition: HtrXmlPatternTool.cc:41
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalElectronicsMap
Definition: HcalElectronicsMap.h:31
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
hcalSimParameters_cfi.zdc
zdc
Definition: hcalSimParameters_cfi.py:97
HtrXmlPatternToolParameters::m_user_output_directory
std::string m_user_output_directory
Definition: HtrXmlPatternToolParameters.h:18
HtrXmlPattern::~HtrXmlPattern
~HtrXmlPattern() override
Definition: HtrXmlPattern.cc:37
std
Definition: JetResolutionObject.h:76
HcalElectronicsMap::lookup
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
Definition: HcalElectronicsMap.cc:70
HtrXmlPattern::endJob
void endJob() override
Definition: HtrXmlPattern.cc:166
HtrXmlPattern::do_hand_fill
virtual void do_hand_fill(const HcalElectronicsMap *)
Definition: HtrXmlPattern.cc:142
ChannelPattern::NUM_SLOTS
static const int NUM_SLOTS
Definition: HtrXmlPatternSet.h:13
HtrXmlPattern::m_tool
HtrXmlPatternTool * m_tool
Definition: HtrXmlPattern.h:30
HcalDbService.h
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40
HcalDbRecord
Definition: HcalDbRecord.h:30
HtrXmlPatternSet::getCrate
CrateData * getCrate(int crate)
Definition: HtrXmlPatternSet.cc:295
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
HtrXmlPatternToolParameters::m_samples_per_event
int m_samples_per_event
Definition: HtrXmlPatternToolParameters.h:14
HtrXmlPatternToolParameters
Definition: HtrXmlPatternToolParameters.h:6
HtrXmlPattern::m_write_root_file
bool m_write_root_file
Definition: HtrXmlPattern.h:36
HtrXmlPattern::m_hand_pattern_number
int m_hand_pattern_number
Definition: HtrXmlPattern.h:33
HtrXmlPattern::m_fill_by_hand
bool m_fill_by_hand
Definition: HtrXmlPattern.h:34