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::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, submitPVValidationJobs::params, 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++)
20  slotsOn[i] = 0;
21  //turn on slots 2,3,4,5,6,7,8
22  for (int i = 2; i < 9; i++)
23  slotsOn[i] = 1;
24  //turn on slots 13,14,15,16,17,18
25  for (int i = 13; i < 19; i++)
26  slotsOn[i] = 1;
27 
28  //turn on all crates
29  for (int i = 0; i < ChannelPattern::NUM_CRATES; i++)
30  cratesOn[i] = 1;
31  //turn off two unused crates
32  cratesOn[8] = 0;
33  cratesOn[16] = 0;
34 
35  m_patternSet = new HtrXmlPatternSet(cratesOn, slotsOn);
37 }
void setTagName(std::string tn)
HtrXmlPatternToolParameters * m_params
static const int NUM_CRATES
HtrXmlPatternWriter m_xmlWriter
static const int NUM_SLOTS
HtrXmlPatternSet * m_patternSet

◆ ~HtrXmlPatternTool()

HtrXmlPatternTool::~HtrXmlPatternTool ( )

Definition at line 39 of file HtrXmlPatternTool.cc.

References m_patternSet.

39 { delete m_patternSet; }
HtrXmlPatternSet * m_patternSet

Member Function Documentation

◆ createHists()

void HtrXmlPatternTool::createHists ( )

Definition at line 194 of file HtrXmlPatternTool.cc.

References hippyaddtobaddatafiles::cd(), DMR_cfg::cerr, officialStyle::chan, gather_cfg::cout, FCDTask_cfi::crate, HtrXmlPatternSet::getCrate(), HalfHtrData::getPattern(), trackingPlots::hp, mps_fire::i, HtrXmlPatternToolParameters::m_file_tag, HtrXmlPatternToolParameters::m_output_directory, m_params, m_patternSet, Skims_PA_cff::name, ChannelPattern::NUM_CRATES, ChannelPattern::NUM_SLOTS, haddnano::of, ChannelPattern::SAMPLES, FCDTask_cfi::slot, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HtrXmlPattern::endJob().

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

◆ Fill() [1/3]

void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HBHEDigiCollection::const_iterator  data 
)

Definition at line 41 of file HtrXmlPatternTool.cc.

References hippyaddtobaddatafiles::cd(), DMR_cfg::cerr, data, HcalElectronicsId::dccid(), HtrXmlPatternSet::getCrate(), 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().

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

◆ Fill() [2/3]

void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HFDigiCollection::const_iterator  data 
)

◆ Fill() [3/3]

void HtrXmlPatternTool::Fill ( const HcalElectronicsId  HEID,
HODigiCollection::const_iterator  data 
)

◆ GetPatternSet()

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

◆ prepareDirs()

void HtrXmlPatternTool::prepareDirs ( )

Definition at line 110 of file HtrXmlPatternTool.cc.

References HtrXmlPatternToolParameters::m_output_directory, and m_params.

Referenced by HtrXmlPattern::endJob().

110 { std::filesystem::create_directory(m_params->m_output_directory); }
HtrXmlPatternToolParameters * m_params

◆ writeXML()

void HtrXmlPatternTool::writeXML ( )

Definition at line 112 of file HtrXmlPatternTool.cc.

References hippyaddtobaddatafiles::cd(), DMR_cfg::cerr, gather_cfg::cout, FCDTask_cfi::crate, FCDTask_cfi::fiber, HtrXmlPatternSet::getCrate(), HtrXmlPatternToolParameters::m_file_tag, HtrXmlPatternToolParameters::m_output_directory, m_params, m_patternSet, HtrXmlPatternToolParameters::m_XML_file_mode, m_xmlWriter, Skims_PA_cff::name, ChannelPattern::NUM_CRATES, ChannelPattern::NUM_SLOTS, haddnano::of, MillePedeFileConverter_cfg::out, FCDTask_cfi::slot, AlCaHLTBitMon_QueryRunRegistry::string, pileupReCalc_HLTpaths::trunc, and HtrXmlPatternWriter::writePattern().

Referenced by HtrXmlPattern::endJob().

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

Member Data Documentation

◆ m_params

HtrXmlPatternToolParameters* HtrXmlPatternTool::m_params
private

Definition at line 23 of file HtrXmlPatternTool.h.

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

◆ m_patternSet

HtrXmlPatternSet* HtrXmlPatternTool::m_patternSet
private

◆ m_xmlWriter

HtrXmlPatternWriter HtrXmlPatternTool::m_xmlWriter
private

Definition at line 24 of file HtrXmlPatternTool.h.

Referenced by HtrXmlPatternTool(), and writeXML().