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.

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 }

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

◆ ~HtrXmlPatternTool()

HtrXmlPatternTool::~HtrXmlPatternTool ( )

Definition at line 39 of file HtrXmlPatternTool.cc.

39 { delete m_patternSet; }

References m_patternSet.

Member Function Documentation

◆ createHists()

void HtrXmlPatternTool::createHists ( )

Definition at line 194 of file HtrXmlPatternTool.cc.

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++) {
206  CrateData* cd = m_patternSet->getCrate(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 }

References hippyaddtobaddatafiles::cd(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, officialStyle::chan, gather_cfg::cout, 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, ChannelPattern::SAMPLES, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HtrXmlPattern::endJob().

◆ Fill() [1/3]

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

Definition at line 41 of file HtrXmlPatternTool.cc.

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 }

References hippyaddtobaddatafiles::cd(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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().

◆ 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.

19 { return m_patternSet; }

References m_patternSet.

Referenced by HtrXmlPattern::do_hand_fill().

◆ prepareDirs()

void HtrXmlPatternTool::prepareDirs ( )

Definition at line 110 of file HtrXmlPatternTool.cc.

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

References HtrXmlPatternToolParameters::m_output_directory, and m_params.

Referenced by HtrXmlPattern::endJob().

◆ writeXML()

void HtrXmlPatternTool::writeXML ( )

Definition at line 112 of file HtrXmlPatternTool.cc.

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++) {
128  CrateData* cd = m_patternSet->getCrate(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 }

References hippyaddtobaddatafiles::cd(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, gather_cfg::cout, 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, MillePedeFileConverter_cfg::out, AlCaHLTBitMon_QueryRunRegistry::string, pileupReCalc_HLTpaths::trunc, and HtrXmlPatternWriter::writePattern().

Referenced by HtrXmlPattern::endJob().

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

HtrXmlPatternToolParameters::m_show_errors
bool m_show_errors
Definition: HtrXmlPatternToolParameters.h:12
HalfHtrData::setDCC
void setDCC(int dcc)
Definition: HtrXmlPatternSet.h:54
mps_fire.i
i
Definition: mps_fire.py:428
ChannelPattern
Definition: HtrXmlPatternSet.h:8
HcalElectronicsId::readoutVMECrateId
constexpr int readoutVMECrateId() const
get the readout VME crate number
Definition: HcalElectronicsId.h:105
HtrXmlPatternToolParameters::m_file_tag
std::string m_file_tag
Definition: HtrXmlPatternToolParameters.h:17
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
HtrXmlPatternTool::m_params
HtrXmlPatternToolParameters * m_params
Definition: HtrXmlPatternTool.h:23
HalfHtrData
Definition: HtrXmlPatternSet.h:44
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalElectronicsId::htrSlot
constexpr int htrSlot() const
get the htr slot
Definition: HcalElectronicsId.h:97
hgcal_conditions::parameters
Definition: HGCConditions.h:86
HtrXmlPatternTool::m_xmlWriter
HtrXmlPatternWriter m_xmlWriter
Definition: HtrXmlPatternTool.h:24
HalfHtrData::getPattern
ChannelPattern * getPattern(int chan)
Definition: HtrXmlPatternSet.h:47
HtrXmlPatternSet
Definition: HtrXmlPatternSet.h:72
trackingPlots.hp
hp
Definition: trackingPlots.py:1230
ChannelPattern::SAMPLES
static const int SAMPLES
Definition: HtrXmlPatternSet.h:10
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
ChannelPattern::NUM_CRATES
static const int NUM_CRATES
Definition: HtrXmlPatternSet.h:11
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalElectronicsId::htrTopBottom
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
Definition: HcalElectronicsId.h:103
HtrXmlPatternTool::m_patternSet
HtrXmlPatternSet * m_patternSet
Definition: HtrXmlPatternTool.h:22
HalfHtrData::setSpigot
void setSpigot(int spigot)
Definition: HtrXmlPatternSet.h:53
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ChannelPattern::NUM_SLOTS
static const int NUM_SLOTS
Definition: HtrXmlPatternSet.h:13
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
HcalElectronicsId::spigot
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
Definition: HcalElectronicsId.h:93
HcalElectronicsId::dccid
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
Definition: HcalElectronicsId.h:95
HtrXmlPatternSet::getCrate
CrateData * getCrate(int crate)
Definition: HtrXmlPatternSet.cc:295
HtrXmlPatternWriter::writePattern
void writePattern(HalfHtrData *spigotData, int fiber, std::ostream &os, int level=0)
Definition: HtrXmlPatternWriter.cc:22
HcalElectronicsId::htrChanId
constexpr int htrChanId() const
get the HTR channel id (1-24)
Definition: HcalElectronicsId.h:87
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
pileupReCalc_HLTpaths.trunc
trunc
Definition: pileupReCalc_HLTpaths.py:144
HtrXmlPatternWriter::setTagName
void setTagName(std::string tn)
Definition: HtrXmlPatternWriter.h:10