CMS 3D CMS Logo

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