CMS 3D CMS Logo

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 mps_fire::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 }
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 200 of file HtrXmlPatternTool.cc.

References MessageLogger_cfi::cerr, officialStyle::chan, gather_cfg::cout, SimDataFormats::CaloAnalysis::cp, ChannelPattern::getCoded(), HtrXmlPatternSet::getCrate(), CrateData::getHalfHtrData(), HalfHtrData::getPattern(), ChannelPattern::getQuantized(), AnalysisDataFormats_SUSYBSMObjects::hp, mps_fire::i, HtrXmlPatternToolParameters::m_file_tag, HtrXmlPatternToolParameters::m_output_directory, m_params, m_patternSet, dataset::name, ChannelPattern::NUM_CRATES, ChannelPattern::NUM_SLOTS, ChannelPattern::SAMPLES, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HtrXmlPattern::endJob().

200  {
201  std::cout << "Writing root file..." << std::endl;
203  TFile of(name.c_str(),"RECREATE");
204  if (of.IsZombie()) {
205  std::cerr << "root output file " << name << " is bad." << std::endl;
206  return;
207  }
208 
209  of.mkdir("adc");
210 
211  for (int crate=0; crate<ChannelPattern::NUM_CRATES; crate++) {
212  CrateData* cd=m_patternSet->getCrate(crate);
213  if (cd==nullptr) continue;
214  for (int slot=0; slot<ChannelPattern::NUM_SLOTS; slot++) {
215  for (int tb=0; tb<=1; tb++) {
216  HalfHtrData* hd=cd->getHalfHtrData(slot,tb);
217  if (hd==nullptr) continue;
218  for (int chan=1; chan<=24; chan++) {
220  char hname[128];
221  sprintf(hname,"Exact fC Cr%d,%d%s-%d",crate,slot,
222  ((tb==1)?("t"):("b")),chan);
223  TH1* hp=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5);
224  hp->SetDirectory(nullptr);
225  sprintf(hname,"Quantized fC Cr%d,%d%s-%d",crate,slot,
226  ((tb==1)?("t"):("b")),chan);
227  TH1* hq=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5);
228  hp->SetDirectory(nullptr);
229  sprintf(hname,"Encoded fC Cr%d,%d%s-%d",crate,slot,
230  ((tb==1)?("t"):("b")),chan);
231  TH1* ha=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5);
232  ha->SetDirectory(nullptr);
233  for (int i=0; i<ChannelPattern::SAMPLES; i++) {
234  hp->Fill(i*1.0,(*cp)[i]);
235  hq->Fill(i*1.0,cp->getQuantized(i));
236  ha->Fill(i*1.0,cp->getCoded(i));
237  }
238  //of.cd("perfect"); hp->Write();
239  //of.cd("quantized"); hq->Write();
240  of.cd("adc"); ha->Write();
241  delete hp;
242  delete hq;
243  delete ha;
244  }
245  }
246  }
247  }
248  of.Close();
249 }
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)
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HBHEDigiCollection::const_iterator  data 
)

Definition at line 40 of file HtrXmlPatternTool.cc.

References MessageLogger_cfi::cerr, SimDataFormats::CaloAnalysis::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=nullptr;
43  ChannelPattern* cp=nullptr;
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 }
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
HtrXmlPatternToolParameters * m_params
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
void Fill(HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
ChannelPattern * getPattern(int chan)
constexpr int htrSlot() const
get the htr slot
constexpr int readoutVMECrateId() const
get the readout VME crate number
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
HtrXmlPatternSet * m_patternSet
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
constexpr int htrChanId() const
get the HTR channel id (1-24)
void setDCC(int dcc)
void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HFDigiCollection::const_iterator  data 
)

Definition at line 65 of file HtrXmlPatternTool.cc.

References MessageLogger_cfi::cerr, SimDataFormats::CaloAnalysis::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=nullptr;
68  ChannelPattern* cp=nullptr;
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 }
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
HtrXmlPatternToolParameters * m_params
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
void Fill(HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
ChannelPattern * getPattern(int chan)
constexpr int htrSlot() const
get the htr slot
constexpr int readoutVMECrateId() const
get the readout VME crate number
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
HtrXmlPatternSet * m_patternSet
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
constexpr int htrChanId() const
get the HTR channel id (1-24)
void setDCC(int dcc)
void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HODigiCollection::const_iterator  data 
)

Definition at line 90 of file HtrXmlPatternTool.cc.

References MessageLogger_cfi::cerr, SimDataFormats::CaloAnalysis::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=nullptr;
93  ChannelPattern* cp=nullptr;
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 }
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
HtrXmlPatternToolParameters * m_params
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
void Fill(HtrXmlPatternToolParameters *params, HBHEDigiCollection::const_iterator data)
ChannelPattern * getPattern(int chan)
constexpr int htrSlot() const
get the htr slot
constexpr int readoutVMECrateId() const
get the readout VME crate number
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
HtrXmlPatternSet * m_patternSet
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
constexpr int htrChanId() const
get the HTR channel id (1-24)
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 MessageLogger_cfi::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, dataset::name, ChannelPattern::NUM_CRATES, ChannelPattern::NUM_SLOTS, MillePedeFileConverter_cfg::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=nullptr;
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==nullptr) 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  delete of;
147  return;
148  }
149  (*of) << "<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
150  (*of) << "<CFGBrickSet name='" << m_params->m_file_tag << "'>" << std::endl;
151  }
152 
153  for (int slot=0; slot<ChannelPattern::NUM_SLOTS; slot++) {
154  for (int tb=0; tb<=1; tb++) {
155  HalfHtrData* hd=cd->getHalfHtrData(slot,tb);
156  if (hd==nullptr) continue;
157  for (int fiber=1; fiber<=8; fiber++) {
158 
159  if (m_params->m_XML_file_mode==3) {
161  char cr_name[256];
162  snprintf(cr_name,256,"_crate_%d_slot_%d_tb_%d_fiber_%d.xml",crate,slot,tb,fiber);
163  name += cr_name;
164  of=new std::ofstream(name.c_str(),std::ios_base::out|std::ios_base::trunc);
165  if (!of->good()) {
166  std::cerr << "XML output file " << name << " is bad." << std::endl;
167  delete of;
168  return;
169  }
170  (*of) << "<?xml version='1.0' encoding='UTF-8'?>" << std::endl;
171  }
172  m_xmlWriter.writePattern(hd,fiber,*of,1);
173  if (m_params->m_XML_file_mode==3) {
174  of->close();
175  delete of;
176  of=nullptr;
177  }
178 
179  } //end fiber loop
180  } // end tb loop
181  } //end slot loop
182 
183  if (m_params->m_XML_file_mode==2) {
184  (*of) << "</CFGBrickSet>" << std::endl;
185  of->close();
186  delete of;
187  of=nullptr;
188  }
189 
190  } //end crate loop
191 
192  if (m_params->m_XML_file_mode==1) {
193  (*of) << "</CFGBrickSet>" << std::endl;
194  of->close();
195  delete of;
196  of=nullptr;
197  }
198 }
HtrXmlPatternToolParameters * m_params
static const int NUM_CRATES
HtrXmlPatternWriter m_xmlWriter
static const int NUM_SLOTS
HtrXmlPatternSet * m_patternSet
HalfHtrData * getHalfHtrData(int slot, int one_two_tb)
CrateData * getCrate(int crate)
void writePattern(HalfHtrData *spigotData, int fiber, std::ostream &os, int level=0)

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().