CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HtrXmlPatternTool Class Reference

#include <HtrXmlPatternTool.h>

Public Member Functions

void createHists ()
 
void Fill (const HcalElectronicsId HEID, HBHEDigiCollection::const_iterator data)
 
void Fill (const HcalElectronicsId HEID, HFDigiCollection::const_iterator data)
 
void Fill (const HcalElectronicsId HEID, HODigiCollection::const_iterator data)
 
HtrXmlPatternSetGetPatternSet ()
 
 HtrXmlPatternTool (HtrXmlPatternToolParameters *m_params)
 
void prepareDirs ()
 
void writeXML ()
 
 ~HtrXmlPatternTool ()
 

Private Attributes

HtrXmlPatternToolParametersm_params
 
HtrXmlPatternSetm_patternSet
 
HtrXmlPatternWriter m_xmlWriter
 

Detailed Description

Definition at line 9 of file HtrXmlPatternTool.h.

Constructor & Destructor Documentation

HtrXmlPatternTool::HtrXmlPatternTool ( HtrXmlPatternToolParameters m_params)

Definition at line 11 of file HtrXmlPatternTool.cc.

References i, HtrXmlPatternToolParameters::m_file_tag, m_params, m_patternSet, m_xmlWriter, ChannelPattern::NUM_CRATES, ChannelPattern::NUM_SLOTS, and HtrXmlPatternWriter::setTagName().

11  {
12  m_params = params;
13 
14  //slotsOn array index corresponds to physical number (e.g., slotsOn[1] for slot 1)
15  int slotsOn [ChannelPattern::NUM_SLOTS];
16  int cratesOn[ChannelPattern::NUM_CRATES];
17 
18  //turn off all slots
19  for (int i=0; i<ChannelPattern::NUM_SLOTS; i++) slotsOn[i]=0;
20  //turn on slots 2,3,4,5,6,7,8
21  for (int i=2; i<9; i++) slotsOn[i]=1;
22  //turn on slots 13,14,15,16,17,18
23  for (int i=13; i<19; i++) slotsOn[i]=1;
24 
25  //turn on all crates
26  for (int i=0; i<ChannelPattern::NUM_CRATES; i++) cratesOn[i]=1;
27  //turn off two unused crates
28  cratesOn[ 8] = 0;
29  cratesOn[16] = 0;
30 
31  m_patternSet=new HtrXmlPatternSet(cratesOn,slotsOn);
33 
34 }
int i
Definition: DBlmapReader.cc:9
void setTagName(std::string tn)
static const int NUM_CRATES
HtrXmlPatternWriter m_xmlWriter
static const int NUM_SLOTS
HtrXmlPatternSet * m_patternSet
HtrXmlPatternTool::~HtrXmlPatternTool ( )

Definition at line 36 of file HtrXmlPatternTool.cc.

References m_patternSet.

36  {
37  delete m_patternSet;
38 }
HtrXmlPatternSet * m_patternSet

Member Function Documentation

void HtrXmlPatternTool::createHists ( )

Definition at line 198 of file HtrXmlPatternTool.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, CommonMethods::cp(), ChannelPattern::getCoded(), HtrXmlPatternSet::getCrate(), CrateData::getHalfHtrData(), HalfHtrData::getPattern(), ChannelPattern::getQuantized(), AnalysisDataFormats_SUSYBSMObjects::hp, i, HtrXmlPatternToolParameters::m_file_tag, HtrXmlPatternToolParameters::m_output_directory, m_params, m_patternSet, mergeVDriftHistosByStation::name, ChannelPattern::NUM_CRATES, ChannelPattern::NUM_SLOTS, ChannelPattern::SAMPLES, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HtrXmlPattern::endJob().

198  {
199  std::cout << "Writing root file..." << std::endl;
201  TFile of(name.c_str(),"RECREATE");
202  if (of.IsZombie()) {
203  std::cerr << "root output file " << name << " is bad." << std::endl;
204  return;
205  }
206 
207  of.mkdir("adc");
208 
209  for (int crate=0; crate<ChannelPattern::NUM_CRATES; crate++) {
210  CrateData* cd=m_patternSet->getCrate(crate);
211  if (cd==0) continue;
212  for (int slot=0; slot<ChannelPattern::NUM_SLOTS; slot++) {
213  for (int tb=0; tb<=1; tb++) {
214  HalfHtrData* hd=cd->getHalfHtrData(slot,tb);
215  if (hd==0) continue;
216  for (int chan=1; chan<=24; chan++) {
217  ChannelPattern* cp=hd->getPattern(chan);
218  char hname[128];
219  sprintf(hname,"Exact fC Cr%d,%d%s-%d",crate,slot,
220  ((tb==1)?("t"):("b")),chan);
221  TH1* hp=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5);
222  hp->SetDirectory(0);
223  sprintf(hname,"Quantized fC Cr%d,%d%s-%d",crate,slot,
224  ((tb==1)?("t"):("b")),chan);
225  TH1* hq=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5);
226  hp->SetDirectory(0);
227  sprintf(hname,"Encoded fC Cr%d,%d%s-%d",crate,slot,
228  ((tb==1)?("t"):("b")),chan);
229  TH1* ha=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5);
230  ha->SetDirectory(0);
231  for (int i=0; i<ChannelPattern::SAMPLES; i++) {
232  hp->Fill(i*1.0,(*cp)[i]);
233  hq->Fill(i*1.0,cp->getQuantized(i));
234  ha->Fill(i*1.0,cp->getCoded(i));
235  }
236  //of.cd("perfect"); hp->Write();
237  //of.cd("quantized"); hq->Write();
238  of.cd("adc"); ha->Write();
239  delete hp;
240  delete hq;
241  delete ha;
242  }
243  }
244  }
245  }
246  of.Close();
247 }
int i
Definition: DBlmapReader.cc:9
int getCoded(int bc) const
HtrXmlPatternToolParameters * m_params
static const int NUM_CRATES
static const int SAMPLES
ChannelPattern * getPattern(int chan)
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
static const int NUM_SLOTS
HtrXmlPatternSet * m_patternSet
double getQuantized(int bc) const
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
tuple cout
Definition: gather_cfg.py:121
void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HBHEDigiCollection::const_iterator  data 
)

Definition at line 40 of file HtrXmlPatternTool.cc.

References dtNoiseDBValidation_cfg::cerr, CommonMethods::cp(), HcalElectronicsId::dccid(), ChannelPattern::Fill(), HtrXmlPatternSet::getCrate(), CrateData::getHalfHtrData(), HalfHtrData::getPattern(), HcalElectronicsId::htrChanId(), HcalElectronicsId::htrSlot(), HcalElectronicsId::htrTopBottom(), m_params, m_patternSet, HtrXmlPatternToolParameters::m_show_errors, HcalElectronicsId::readoutVMECrateId(), HalfHtrData::setDCC(), HalfHtrData::setSpigot(), and HcalElectronicsId::spigot().

Referenced by HtrXmlPattern::analyze().

40  {
42  HalfHtrData* hd=0;
43  ChannelPattern* cp=0;
44 
45  if (cd) {
46  hd=cd->getHalfHtrData(HEID.htrSlot(),HEID.htrTopBottom());
47  if (hd) {
48  hd->setSpigot(HEID.spigot());
49  hd->setDCC(HEID.dccid());
50 
51  cp=hd->getPattern(HEID.htrChanId());
52  if (cp) cp->Fill(m_params,data);
53  else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot,channel): ("
54  << HEID.readoutVMECrateId() << ","
55  << HEID.htrSlot() << ","
56  << HEID.htrChanId() << ")" << std::endl;
57  }
58  else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot): ("
59  << HEID.readoutVMECrateId() << ","
60  << HEID.htrSlot() << ")" << std::endl;
61  }
62  else if(m_params->m_show_errors) std::cerr << "Bad (crate): (" << HEID.readoutVMECrateId() << ")" << std::endl;
63 }
int htrSlot() const
get the htr slot
HtrXmlPatternToolParameters * m_params
int readoutVMECrateId() const
get the readout VME crate number
void Fill(HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
ChannelPattern * getPattern(int chan)
int htrChanId() const
get the HTR channel id (1-24)
int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
HtrXmlPatternSet * m_patternSet
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
void setSpigot(int spigot)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void setDCC(int dcc)
void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HFDigiCollection::const_iterator  data 
)

Definition at line 65 of file HtrXmlPatternTool.cc.

References dtNoiseDBValidation_cfg::cerr, CommonMethods::cp(), HcalElectronicsId::dccid(), ChannelPattern::Fill(), HtrXmlPatternSet::getCrate(), CrateData::getHalfHtrData(), HalfHtrData::getPattern(), HcalElectronicsId::htrChanId(), HcalElectronicsId::htrSlot(), HcalElectronicsId::htrTopBottom(), m_params, m_patternSet, HtrXmlPatternToolParameters::m_show_errors, HcalElectronicsId::readoutVMECrateId(), HalfHtrData::setDCC(), HalfHtrData::setSpigot(), and HcalElectronicsId::spigot().

65  {
67  HalfHtrData* hd=0;
68  ChannelPattern* cp=0;
69 
70  if (cd) {
71  hd=cd->getHalfHtrData(HEID.htrSlot(),HEID.htrTopBottom());
72  if (hd) {
73  hd->setSpigot(HEID.spigot());
74  hd->setDCC(HEID.dccid());
75 
76  cp=hd->getPattern(HEID.htrChanId());
77  if (cp) cp->Fill(m_params,data);
78  else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot,channel): ("
79  << HEID.readoutVMECrateId() << ","
80  << HEID.htrSlot() << ","
81  << HEID.htrChanId() << ")" << std::endl;
82  }
83  else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot): ("
84  << HEID.readoutVMECrateId() << ","
85  << HEID.htrSlot() << ")" << std::endl;
86  }
87  else if(m_params->m_show_errors) std::cerr << "Bad (crate): (" << HEID.readoutVMECrateId() << ")" << std::endl;
88 }
int htrSlot() const
get the htr slot
HtrXmlPatternToolParameters * m_params
int readoutVMECrateId() const
get the readout VME crate number
void Fill(HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
ChannelPattern * getPattern(int chan)
int htrChanId() const
get the HTR channel id (1-24)
int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
HtrXmlPatternSet * m_patternSet
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
void setSpigot(int spigot)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void setDCC(int dcc)
void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HODigiCollection::const_iterator  data 
)

Definition at line 90 of file HtrXmlPatternTool.cc.

References dtNoiseDBValidation_cfg::cerr, CommonMethods::cp(), HcalElectronicsId::dccid(), ChannelPattern::Fill(), HtrXmlPatternSet::getCrate(), CrateData::getHalfHtrData(), HalfHtrData::getPattern(), HcalElectronicsId::htrChanId(), HcalElectronicsId::htrSlot(), HcalElectronicsId::htrTopBottom(), m_params, m_patternSet, HtrXmlPatternToolParameters::m_show_errors, HcalElectronicsId::readoutVMECrateId(), HalfHtrData::setDCC(), HalfHtrData::setSpigot(), and HcalElectronicsId::spigot().

90  {
92  HalfHtrData* hd=0;
93  ChannelPattern* cp=0;
94 
95  if (cd) {
96  hd=cd->getHalfHtrData(HEID.htrSlot(),HEID.htrTopBottom());
97  if (hd) {
98  hd->setSpigot(HEID.spigot());
99  hd->setDCC(HEID.dccid());
100 
101  cp=hd->getPattern(HEID.htrChanId());
102  if (cp) cp->Fill(m_params,data);
103  else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot,channel): ("
104  << HEID.readoutVMECrateId() << ","
105  << HEID.htrSlot() << ","
106  << HEID.htrChanId() << ")" << std::endl;
107  }
108  else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot): ("
109  << HEID.readoutVMECrateId() << ","
110  << HEID.htrSlot() << ")" << std::endl;
111  }
112  else if(m_params->m_show_errors) std::cerr << "Bad (crate): (" << HEID.readoutVMECrateId() << ")" << std::endl;
113 }
int htrSlot() const
get the htr slot
HtrXmlPatternToolParameters * m_params
int readoutVMECrateId() const
get the readout VME crate number
void Fill(HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
ChannelPattern * getPattern(int chan)
int htrChanId() const
get the HTR channel id (1-24)
int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
HtrXmlPatternSet * m_patternSet
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
void setSpigot(int spigot)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void setDCC(int dcc)
HtrXmlPatternSet* HtrXmlPatternTool::GetPatternSet ( )
inline

Definition at line 19 of file HtrXmlPatternTool.h.

References m_patternSet.

Referenced by HtrXmlPattern::do_hand_fill().

19 {return m_patternSet;}
HtrXmlPatternSet * m_patternSet
void HtrXmlPatternTool::prepareDirs ( )

Definition at line 115 of file HtrXmlPatternTool.cc.

References HtrXmlPatternToolParameters::m_output_directory, and m_params.

Referenced by HtrXmlPattern::endJob().

115  {
116  boost::filesystem::create_directory(m_params->m_output_directory);
117 }
HtrXmlPatternToolParameters * m_params
void HtrXmlPatternTool::writeXML ( )

Definition at line 119 of file HtrXmlPatternTool.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, HtrXmlPatternSet::getCrate(), CrateData::getHalfHtrData(), HtrXmlPatternToolParameters::m_file_tag, HtrXmlPatternToolParameters::m_output_directory, m_params, m_patternSet, HtrXmlPatternToolParameters::m_XML_file_mode, m_xmlWriter, mergeVDriftHistosByStation::name, ChannelPattern::NUM_CRATES, ChannelPattern::NUM_SLOTS, dbtoconf::out, AlCaHLTBitMon_QueryRunRegistry::string, estimatePileup_makeJSON::trunc, and HtrXmlPatternWriter::writePattern().

Referenced by HtrXmlPattern::endJob().

119  {
120  std::cout << "Writing XML..." << std::endl;
121  std::ofstream* of=0;
122 
123  if (m_params->m_XML_file_mode==1) {
125  of=new std::ofstream(name.c_str(),std::ios_base::out|std::ios_base::trunc);
126  if (!of->good()) {
127  std::cerr << "XML output file " << name << " is bad." << std::endl;
128  return;
129  }
130  (*of) << "<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
131  (*of) << "<CFGBrickSet name='" << m_params->m_file_tag << "'>" << std::endl;
132  }
133 
134  for (int crate=0; crate<ChannelPattern::NUM_CRATES; crate++) {
135  CrateData* cd=m_patternSet->getCrate(crate);
136  if (cd==0) continue;
137 
138  if (m_params->m_XML_file_mode==2) {
140  char cr_name[256];
141  snprintf(cr_name,256,"_crate_%d.xml",crate);
142  name += cr_name;
143  of=new std::ofstream(name.c_str(),std::ios_base::out|std::ios_base::trunc);
144  if (!of->good()) {
145  std::cerr << "XML output file " << name << " is bad." << std::endl;
146  return;
147  }
148  (*of) << "<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
149  (*of) << "<CFGBrickSet name='" << m_params->m_file_tag << "'>" << std::endl;
150  }
151 
152  for (int slot=0; slot<ChannelPattern::NUM_SLOTS; slot++) {
153  for (int tb=0; tb<=1; tb++) {
154  HalfHtrData* hd=cd->getHalfHtrData(slot,tb);
155  if (hd==0) continue;
156  for (int fiber=1; fiber<=8; fiber++) {
157 
158  if (m_params->m_XML_file_mode==3) {
160  char cr_name[256];
161  snprintf(cr_name,256,"_crate_%d_slot_%d_tb_%d_fiber_%d.xml",crate,slot,tb,fiber);
162  name += cr_name;
163  of=new std::ofstream(name.c_str(),std::ios_base::out|std::ios_base::trunc);
164  if (!of->good()) {
165  std::cerr << "XML output file " << name << " is bad." << std::endl;
166  return;
167  }
168  (*of) << "<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
169  }
170  m_xmlWriter.writePattern(hd,fiber,*of,1);
171  if (m_params->m_XML_file_mode==3) {
172  of->close();
173  delete of;
174  of=0;
175  }
176 
177  } //end fiber loop
178  } // end tb loop
179  } //end slot loop
180 
181  if (m_params->m_XML_file_mode==2) {
182  (*of) << "</CFGBrickSet>" << std::endl;
183  of->close();
184  delete of;
185  of=0;
186  }
187 
188  } //end crate loop
189 
190  if (m_params->m_XML_file_mode==1) {
191  (*of) << "</CFGBrickSet>" << std::endl;
192  of->close();
193  delete of;
194  of=0;
195  }
196 }
HtrXmlPatternToolParameters * m_params
static const int NUM_CRATES
HtrXmlPatternWriter m_xmlWriter
static const int NUM_SLOTS
HtrXmlPatternSet * m_patternSet
tuple out
Definition: dbtoconf.py:99
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
void writePattern(HalfHtrData *spigotData, int fiber, std::ostream &os, int level=0)
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

HtrXmlPatternToolParameters* HtrXmlPatternTool::m_params
private

Definition at line 22 of file HtrXmlPatternTool.h.

Referenced by createHists(), Fill(), HtrXmlPatternTool(), prepareDirs(), and writeXML().

HtrXmlPatternSet* HtrXmlPatternTool::m_patternSet
private
HtrXmlPatternWriter HtrXmlPatternTool::m_xmlWriter
private

Definition at line 23 of file HtrXmlPatternTool.h.

Referenced by HtrXmlPatternTool(), and writeXML().