#include <HtrXmlPatternTool.h>
Public Member Functions | |
void | createHists () |
void | Fill (const HcalElectronicsId HEID, HFDigiCollection::const_iterator data) |
void | Fill (const HcalElectronicsId HEID, HODigiCollection::const_iterator data) |
void | Fill (const HcalElectronicsId HEID, HBHEDigiCollection::const_iterator data) |
HtrXmlPatternSet * | GetPatternSet () |
HtrXmlPatternTool (HtrXmlPatternToolParameters *m_params) | |
void | prepareDirs () |
void | writeXML () |
~HtrXmlPatternTool () | |
Private Attributes | |
HtrXmlPatternToolParameters * | m_params |
HtrXmlPatternSet * | m_patternSet |
HtrXmlPatternWriter | m_xmlWriter |
Definition at line 9 of file HtrXmlPatternTool.h.
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().
{ m_params = params; //slotsOn array index corresponds to physical number (e.g., slotsOn[1] for slot 1) int slotsOn [ChannelPattern::NUM_SLOTS]; int cratesOn[ChannelPattern::NUM_CRATES]; //turn off all slots for (int i=0; i<ChannelPattern::NUM_SLOTS; i++) slotsOn[i]=0; //turn on slots 2,3,4,5,6,7,8 for (int i=2; i<9; i++) slotsOn[i]=1; //turn on slots 13,14,15,16,17,18 for (int i=13; i<19; i++) slotsOn[i]=1; //turn on all crates for (int i=0; i<ChannelPattern::NUM_CRATES; i++) cratesOn[i]=1; //turn off two unused crates cratesOn[ 8] = 0; cratesOn[16] = 0; m_patternSet=new HtrXmlPatternSet(cratesOn,slotsOn); m_xmlWriter.setTagName(m_params->m_file_tag); }
HtrXmlPatternTool::~HtrXmlPatternTool | ( | ) |
Definition at line 36 of file HtrXmlPatternTool.cc.
References m_patternSet.
{ delete m_patternSet; }
void HtrXmlPatternTool::createHists | ( | ) |
Definition at line 198 of file HtrXmlPatternTool.cc.
References benchmark_cfg::cerr, gather_cfg::cout, ChannelPattern::getCoded(), HtrXmlPatternSet::getCrate(), CrateData::getHalfHtrData(), HalfHtrData::getPattern(), ChannelPattern::getQuantized(), i, HtrXmlPatternToolParameters::m_file_tag, HtrXmlPatternToolParameters::m_output_directory, m_params, m_patternSet, and ChannelPattern::SAMPLES.
Referenced by HtrXmlPattern::endJob().
{ std::cout << "Writing root file..." << std::endl; std::string name=m_params->m_output_directory+"/"+(m_params->m_file_tag)+".root"; TFile of(name.c_str(),"RECREATE"); if (of.IsZombie()) { std::cerr << "root output file " << name << " is bad." << std::endl; return; } of.mkdir("adc"); for (int crate=0; crate<ChannelPattern::NUM_CRATES; crate++) { CrateData* cd=m_patternSet->getCrate(crate); if (cd==0) continue; for (int slot=0; slot<ChannelPattern::NUM_SLOTS; slot++) { for (int tb=0; tb<=1; tb++) { HalfHtrData* hd=cd->getHalfHtrData(slot,tb); if (hd==0) continue; for (int chan=1; chan<=24; chan++) { ChannelPattern* cp=hd->getPattern(chan); char hname[128]; sprintf(hname,"Exact fC Cr%d,%d%s-%d",crate,slot, ((tb==1)?("t"):("b")),chan); TH1* hp=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5); hp->SetDirectory(0); sprintf(hname,"Quantized fC Cr%d,%d%s-%d",crate,slot, ((tb==1)?("t"):("b")),chan); TH1* hq=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5); hp->SetDirectory(0); sprintf(hname,"Encoded fC Cr%d,%d%s-%d",crate,slot, ((tb==1)?("t"):("b")),chan); TH1* ha=new TH1F(hname,hname,ChannelPattern::SAMPLES,-0.5,ChannelPattern::SAMPLES-0.5); ha->SetDirectory(0); for (int i=0; i<ChannelPattern::SAMPLES; i++) { hp->Fill(i*1.0,(*cp)[i]); hq->Fill(i*1.0,cp->getQuantized(i)); ha->Fill(i*1.0,cp->getCoded(i)); } //of.cd("perfect"); hp->Write(); //of.cd("quantized"); hq->Write(); of.cd("adc"); ha->Write(); delete hp; delete hq; delete ha; } } } } of.Close(); }
void HtrXmlPatternTool::Fill | ( | const HcalElectronicsId | HEID, |
HBHEDigiCollection::const_iterator | data | ||
) |
Definition at line 40 of file HtrXmlPatternTool.cc.
References benchmark_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().
{ CrateData* cd=m_patternSet->getCrate(HEID.readoutVMECrateId()); HalfHtrData* hd=0; ChannelPattern* cp=0; if (cd) { hd=cd->getHalfHtrData(HEID.htrSlot(),HEID.htrTopBottom()); if (hd) { hd->setSpigot(HEID.spigot()); hd->setDCC(HEID.dccid()); cp=hd->getPattern(HEID.htrChanId()); if (cp) cp->Fill(m_params,data); else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot,channel): (" << HEID.readoutVMECrateId() << "," << HEID.htrSlot() << "," << HEID.htrChanId() << ")" << std::endl; } else if(m_params->m_show_errors) std::cerr << "Bad (crate,slot): (" << HEID.readoutVMECrateId() << "," << HEID.htrSlot() << ")" << std::endl; } else if(m_params->m_show_errors) std::cerr << "Bad (crate): (" << HEID.readoutVMECrateId() << ")" << std::endl; }
void HtrXmlPatternTool::Fill | ( | const HcalElectronicsId | HEID, |
HFDigiCollection::const_iterator | data | ||
) |
void HtrXmlPatternTool::Fill | ( | const HcalElectronicsId | HEID, |
HODigiCollection::const_iterator | data | ||
) |
HtrXmlPatternSet* HtrXmlPatternTool::GetPatternSet | ( | ) | [inline] |
Definition at line 19 of file HtrXmlPatternTool.h.
References m_patternSet.
Referenced by HtrXmlPattern::do_hand_fill().
{return 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().
{ boost::filesystem::create_directory(m_params->m_output_directory); }
void HtrXmlPatternTool::writeXML | ( | ) |
Definition at line 28 of file HcalConstantsXMLWriter.cc.
References gather_cfg::cout, benchmark_cfg::fb, i, runonSM::newfile, dbtoconf::out, and dbtoconf::root.
Referenced by HtrXmlPattern::endJob().
{ int nn = newfile0.size(); char newfile[99]; for (int i = 0; i < nn; i++) { newfile[i]=newfile0[i]; } char const* fend="\0"; newfile[nn] = *fend; cout<<" New file "<<newfile<<endl; filebuf fb; fb.open (newfile,ios::out); ostream fOut(&fb); XMLCh tempStr[100]; XMLString::transcode ("Core",tempStr,99); mDom = DOMImplementationRegistry::getDOMImplementation (tempStr); XMLString::transcode("CalibrationConstants", tempStr, 99); mDoc = mDom->createDocument( 0, // root element namespace URI. tempStr, // root element name 0); // document type object (DTD). StreamOutFormatTarget formTarget (fOut); DOMWriter* domWriter = mDom->createDOMWriter(); domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true); DOMElement* root = mDoc->getDocumentElement(); XMLString::transcode("Hcal", tempStr, 99); DOMElement* rootelem = mDoc->createElement (tempStr); root->appendChild(rootelem); XMLString::transcode("Cell", tempStr, 99); vector<DOMElement*> theDOMVec; for(unsigned int i=0; i<detvec.size();i++) { theDOMVec.push_back(mDoc->createElement (tempStr)); newCellLine(theDOMVec[i],detvec[i],etavec[i],phivec[i],depthvec[i],scalevec[i]); rootelem->appendChild(theDOMVec[i]); } cout<<" Write Doc "<<theDOMVec.size()<<endl; domWriter->writeNode (&formTarget, *mDoc); cout<<" End of Writting "<<endl; mDoc->release (); }
Definition at line 22 of file HtrXmlPatternTool.h.
Referenced by createHists(), Fill(), HtrXmlPatternTool(), and prepareDirs().
HtrXmlPatternSet* HtrXmlPatternTool::m_patternSet [private] |
Definition at line 21 of file HtrXmlPatternTool.h.
Referenced by createHists(), Fill(), GetPatternSet(), HtrXmlPatternTool(), and ~HtrXmlPatternTool().
Definition at line 23 of file HtrXmlPatternTool.h.
Referenced by HtrXmlPatternTool().