#include <MeasureLA.h>
Public Member Functions | |
MeasureLA (const edm::ParameterSet &) | |
boost::shared_ptr < SiStripLorentzAngle > | produce (const SiStripLorentzAngleRcd &) |
Private Types | |
enum | GRANULARITY { LAYER = 0, MODULE = 1, MODULESUMMARY = 2 } |
Private Member Functions | |
void | calibrate (const std::pair< unsigned, LA_Filler_Fitter::Method >, LA_Filler_Fitter::Result &) const |
void | process_reports () const |
void | store_calibrations () |
void | store_methods_and_granularity (const edm::VParameterSet &) |
void | summarize_module_muH_byLayer () |
void | write_report_plots (const std::string, const LA_Filler_Fitter::Method, const GRANULARITY) const |
template<class T > | |
void | write_report_text (const std::string, const LA_Filler_Fitter::Method, const std::map< T, LA_Filler_Fitter::Result >) const |
void | write_report_text_ms (const std::string, const LA_Filler_Fitter::Method) const |
Static Private Member Functions | |
static std::pair< unsigned, LA_Filler_Fitter::Method > | calibration_key (const std::string layer, const LA_Filler_Fitter::Method) |
static std::pair< unsigned, LA_Filler_Fitter::Method > | calibration_key (const uint32_t detid, const LA_Filler_Fitter::Method) |
static std::string | granularity (int32_t g) |
Private Attributes | |
Book | book |
bool | byLayer |
bool | byModule |
const edm::VParameterSet | calibrations |
std::map< std::pair< uint32_t, LA_Filler_Fitter::Method > , float > | error_scaling |
const edm::FileInPath | fp_ |
const std::string | inFileLocation |
const std::vector< std::string > | inputFiles |
const float | localybin |
const unsigned | maxEvents |
const edm::VParameterSet | measurementPreferences |
int32_t | methods |
std::map< std::pair< uint32_t, LA_Filler_Fitter::Method > , float > | offset |
const edm::VParameterSet | reports |
std::map< std::pair< uint32_t, LA_Filler_Fitter::Method > , float > | slope |
const unsigned | stripsperbin |
Definition at line 14 of file MeasureLA.h.
enum sistrip::MeasureLA::GRANULARITY [private] |
Definition at line 23 of file MeasureLA.h.
{LAYER=0, MODULE=1, MODULESUMMARY=2};
sistrip::MeasureLA::MeasureLA | ( | const edm::ParameterSet & | conf | ) | [explicit] |
Definition at line 19 of file MeasureLA.cc.
References book, byLayer, byModule, dbtoweb::file, LA_Filler_Fitter::fill(), LA_Filler_Fitter::fit(), inFileLocation, inputFiles, localybin, maxEvents, measurementPreferences, methods, process_reports(), produce(), reports, edm::ESProducer::setWhatProduced(), store_calibrations(), store_methods_and_granularity(), stripsperbin, and summarize_module_muH_byLayer().
: inputFiles( conf.getParameter<std::vector<std::string> >("InputFiles") ), inFileLocation( conf.getParameter<std::string>("InFileLocation")), fp_(conf.getParameter<edm::FileInPath>("SiStripDetInfo") ), reports( conf.getParameter<edm::VParameterSet>("Reports")), measurementPreferences( conf.getParameter<edm::VParameterSet>("MeasurementPreferences")), calibrations(conf.getParameter<edm::VParameterSet>("Calibrations")), methods(0), byModule(false), byLayer(false), localybin(conf.getUntrackedParameter<double>("LocalYBin",0.0)), stripsperbin(conf.getUntrackedParameter<unsigned>("StripsPerBin",0)), maxEvents( conf.getUntrackedParameter<unsigned>("MaxEvents",0)) { store_methods_and_granularity( reports ); store_methods_and_granularity( measurementPreferences ); store_calibrations(); TChain*const chain = new TChain("la_data"); BOOST_FOREACH(const std::string file, inputFiles) chain->Add((file+inFileLocation).c_str()); LA_Filler_Fitter laff(methods, byLayer, byModule, localybin, stripsperbin, maxEvents); laff.fill(chain, book); laff.fit(book); summarize_module_muH_byLayer(); process_reports(); setWhatProduced(this,&MeasureLA::produce); }
void sistrip::MeasureLA::calibrate | ( | const std::pair< unsigned, LA_Filler_Fitter::Method > | key, |
LA_Filler_Fitter::Result & | result | ||
) | const [inline, private] |
Definition at line 163 of file MeasureLA.cc.
References LA_Filler_Fitter::Result::calMeasured, error_scaling, LA_Filler_Fitter::Result::measured, offset, and slope.
Referenced by summarize_module_muH_byLayer(), and write_report_text().
std::pair< uint32_t, LA_Filler_Fitter::Method > sistrip::MeasureLA::calibration_key | ( | const std::string | layer, |
const LA_Filler_Fitter::Method | method | ||
) | [static, private] |
Definition at line 169 of file MeasureLA.cc.
References diffTreeTool::format(), LA_Filler_Fitter::layer_index(), and sistrip::TIB.
Referenced by summarize_module_muH_byLayer(), and write_report_text().
{ boost::regex format(".*(T[IO]B)_layer(\\d)([as]).*"); const bool TIB = "TIB" == boost::regex_replace(layer, format, "\\1"); const bool stereo = "s" == boost::regex_replace(layer, format, "\\3"); const unsigned layerNum = boost::lexical_cast<unsigned>(boost::regex_replace(layer, format, "\\2")); return std::make_pair(LA_Filler_Fitter::layer_index(TIB,stereo,layerNum),method); }
std::pair< uint32_t, LA_Filler_Fitter::Method > sistrip::MeasureLA::calibration_key | ( | const uint32_t | detid, |
const LA_Filler_Fitter::Method | method | ||
) | [static, private] |
Definition at line 178 of file MeasureLA.cc.
References TIBDetId::layer(), TOBDetId::layer(), LA_Filler_Fitter::layer_index(), SiStripDetId::stereo(), SiStripDetId::subDetector(), and sistrip::TIB.
{ const bool TIB = SiStripDetId(detid).subDetector() == SiStripDetId::TIB; const bool stereo = TIB ? TIBDetId(detid).stereo() : TOBDetId(detid).stereo(); const unsigned layer = TIB ? TIBDetId(detid).layer() : TOBDetId(detid).layer(); return std::make_pair(LA_Filler_Fitter::layer_index(TIB,stereo,layer),method); }
static std::string sistrip::MeasureLA::granularity | ( | int32_t | g | ) | [inline, static, private] |
Definition at line 24 of file MeasureLA.h.
References LAYER, MODULE, and MODULESUMMARY.
Referenced by summarize_module_muH_byLayer(), write_report_plots(), and write_report_text_ms().
{ switch(g) { case LAYER: return "_layer"; case MODULE: return "_module"; case MODULESUMMARY: return "_moduleSummary"; } return "";};
void sistrip::MeasureLA::process_reports | ( | ) | const [private] |
Definition at line 87 of file MeasureLA.cc.
References Book::begin(), book, Book::end(), edm::ParameterSet::getParameter(), LAYER, LA_Filler_Fitter::layer_results(), MODULE, LA_Filler_Fitter::module_results(), MODULESUMMARY, AlCaRecoCosmics_cfg::name, L1TEmulatorMonitor_cff::p, reports, write_report_plots(), write_report_text(), and write_report_text_ms().
Referenced by MeasureLA().
{ BOOST_FOREACH(edm::ParameterSet p, reports) { const GRANULARITY gran = (GRANULARITY) p.getParameter<int32_t>("Granularity"); const std::string name = p.getParameter<std::string>("ReportName"); const LA_Filler_Fitter::Method method = (LA_Filler_Fitter::Method) p.getParameter<int32_t>("Method"); write_report_plots( name, method, gran); switch(gran) { case LAYER: write_report_text( name, method, LA_Filler_Fitter::layer_results(book, method) ); break; case MODULE: write_report_text( name, method, LA_Filler_Fitter::module_results(book, method)); break; case MODULESUMMARY: write_report_text_ms( name, method); break; } } { TFile widthsFile("widths.root","RECREATE"); for(Book::const_iterator it = book.begin(".*_width"); it!=book.end(); it++) if(it->second) it->second->Write(); widthsFile.Close();} }
boost::shared_ptr< SiStripLorentzAngle > sistrip::MeasureLA::produce | ( | const SiStripLorentzAngleRcd & | ) |
Definition at line 49 of file MeasureLA.cc.
References redigi_cff::SiStripLorentzAngle.
Referenced by MeasureLA().
{ boost::shared_ptr<SiStripLorentzAngle> lorentzAngle(new SiStripLorentzAngle()); /* std::map<uint32_t,LA_Filler_Fitter::Result> module_results = LA_Filler_Fitter::module_results(book, LA_Filler_Fitter::SQRTVAR); BOOST_FOREACH(const uint32_t& detid, SiStripDetInfoFileReader(fp_.fullPath()).getAllDetIds()) { float la = module_results[detid].measure / module_results[detid].field ; lorentzAngle->putLorentzAngle( detid, la ); } */ return lorentzAngle; }
void sistrip::MeasureLA::store_calibrations | ( | ) | [private] |
Definition at line 145 of file MeasureLA.cc.
References calibrations, error_scaling, edm::ParameterSet::getParameter(), i, combine::key, offset, L1TEmulatorMonitor_cff::p, and slope.
Referenced by MeasureLA().
{ BOOST_FOREACH(edm::ParameterSet p, calibrations) { LA_Filler_Fitter::Method method = (LA_Filler_Fitter::Method) p.getParameter<int32_t>("Method"); std::vector<double> slopes(p.getParameter<std::vector<double> >("Slopes")); assert(slopes.size()==14); std::vector<double> offsets(p.getParameter<std::vector<double> >("Offsets")); assert(offsets.size()==14); std::vector<double> pulls(p.getParameter<std::vector<double> >("Pulls")); assert(pulls.size()==14); for(unsigned i=0; i<14; i++) { const std::pair<unsigned,LA_Filler_Fitter::Method> key( i, method); offset[key] = offsets[i]; slope[key] = slopes[i]; error_scaling[key] = pulls[i]; } } }
void sistrip::MeasureLA::store_methods_and_granularity | ( | const edm::VParameterSet & | vpset | ) | [private] |
Definition at line 11 of file MeasureLA.cc.
References byLayer, byModule, edm::ParameterSet::getParameter(), methods, and L1TEmulatorMonitor_cff::p.
Referenced by MeasureLA().
{ BOOST_FOREACH(edm::ParameterSet p, vpset) { methods |= p.getParameter<int32_t>("Method"); byModule = byModule || p.getParameter<int32_t>("Granularity"); byLayer = byLayer || !p.getParameter<int32_t>("Granularity"); } }
void sistrip::MeasureLA::summarize_module_muH_byLayer | ( | ) | [private] |
Definition at line 64 of file MeasureLA.cc.
References Book::begin(), book, calibrate(), calibration_key(), Book::end(), Book::fill(), LA_Filler_Fitter::FIRST_METHOD, granularity(), label, LA_Filler_Fitter::LAST_METHOD, LA_Filler_Fitter::layerLabel(), m, LA_Filler_Fitter::method(), LA_Filler_Fitter::module_results(), MODULESUMMARY, funct::pow(), query::result, and CommonMethods::weight().
Referenced by MeasureLA().
{ for(int m = LA_Filler_Fitter::FIRST_METHOD; m <= LA_Filler_Fitter::LAST_METHOD; m<<=1) { const LA_Filler_Fitter::Method method = (LA_Filler_Fitter::Method)m; std::pair<uint32_t,LA_Filler_Fitter::Result> result; BOOST_FOREACH(result, LA_Filler_Fitter::module_results(book, method)) { calibrate( calibration_key(result.first,method), result.second); std::string label = LA_Filler_Fitter::layerLabel(result.first) + granularity(MODULESUMMARY) + LA_Filler_Fitter::method(method); label = boost::regex_replace(label,boost::regex("layer"),""); const double mu_H = -result.second.calMeasured.first / result.second.field; const double sigma_mu_H = result.second.calMeasured.second / result.second.field; const double weight = pow(1./sigma_mu_H, 2); book.fill(mu_H, label, 150,-0.05,0.1, weight); } for(Book::iterator it = book.begin(".*"+granularity(MODULESUMMARY)+".*"); it!=book.end(); ++it) { if(it->second->GetEntries()) it->second->Fit("gaus","LLQ"); } } }
void sistrip::MeasureLA::write_report_plots | ( | const std::string | name, |
const LA_Filler_Fitter::Method | method, | ||
const GRANULARITY | gran | ||
) | const [private] |
Definition at line 107 of file MeasureLA.cc.
References Book::begin(), book, Book::end(), dbtoweb::file, granularity(), estimatePileup::hist, combine::key, and LA_Filler_Fitter::method().
Referenced by process_reports().
{ TFile file((name+".root").c_str(),"RECREATE"); const std::string key = ".*" + granularity(gran) + ".*("+LA_Filler_Fitter::method(method)+"|"+LA_Filler_Fitter::method(method,0)+".*)"; for(Book::const_iterator hist = book.begin(key); hist!=book.end(); ++hist) if(hist->second) hist->second->Write(); file.Close(); }
void sistrip::MeasureLA::write_report_text | ( | const std::string | name, |
const LA_Filler_Fitter::Method | method, | ||
const std::map< T, LA_Filler_Fitter::Result > | results | ||
) | const [private] |
Definition at line 117 of file MeasureLA.cc.
References calibrate(), calibration_key(), dbtoweb::file, dbtoconf::out, and query::result.
Referenced by process_reports().
{ fstream file((name+".dat").c_str(),std::ios::out); std::pair<T,LA_Filler_Fitter::Result> result; BOOST_FOREACH(result, results) { calibrate( calibration_key(result.first,method), result.second); file << result.first << "\t" << result.second << std::endl; } file.close(); }
void sistrip::MeasureLA::write_report_text_ms | ( | const std::string | name, |
const LA_Filler_Fitter::Method | method | ||
) | const [private] |
Definition at line 128 of file MeasureLA.cc.
References Book::begin(), book, Book::end(), f, dbtoweb::file, granularity(), combine::key, LA_Filler_Fitter::method(), MODULESUMMARY, and dbtoconf::out.
Referenced by process_reports().
{ fstream file((name+".dat").c_str(),std::ios::out); const std::string key = ".*"+granularity(MODULESUMMARY)+LA_Filler_Fitter::method(method); for(Book::const_iterator it = book.begin(key); it!=book.end(); ++it) { const TF1*const f = it->second->GetFunction("gaus"); if(f) { file << it->first << "\t" << f->GetParameter(1) << "\t" << f->GetParError(1) << "\t" << f->GetParameter(2) << "\t" << f->GetParError(2) << std::endl; } } file.close(); }
Book sistrip::MeasureLA::book [private] |
Definition at line 53 of file MeasureLA.h.
Referenced by MeasureLA(), process_reports(), summarize_module_muH_byLayer(), write_report_plots(), and write_report_text_ms().
bool sistrip::MeasureLA::byLayer [private] |
Definition at line 50 of file MeasureLA.h.
Referenced by MeasureLA(), and store_methods_and_granularity().
bool sistrip::MeasureLA::byModule [private] |
Definition at line 50 of file MeasureLA.h.
Referenced by MeasureLA(), and store_methods_and_granularity().
const edm::VParameterSet sistrip::MeasureLA::calibrations [private] |
Definition at line 47 of file MeasureLA.h.
Referenced by store_calibrations().
std::map<std::pair<uint32_t,LA_Filler_Fitter::Method>,float> sistrip::MeasureLA::error_scaling [private] |
Definition at line 48 of file MeasureLA.h.
Referenced by calibrate(), and store_calibrations().
const edm::FileInPath sistrip::MeasureLA::fp_ [private] |
Definition at line 46 of file MeasureLA.h.
const std::string sistrip::MeasureLA::inFileLocation [private] |
Definition at line 45 of file MeasureLA.h.
Referenced by MeasureLA().
const std::vector<std::string> sistrip::MeasureLA::inputFiles [private] |
Definition at line 44 of file MeasureLA.h.
Referenced by MeasureLA().
const float sistrip::MeasureLA::localybin [private] |
Definition at line 51 of file MeasureLA.h.
Referenced by MeasureLA().
const unsigned sistrip::MeasureLA::maxEvents [private] |
Definition at line 52 of file MeasureLA.h.
Referenced by MeasureLA().
const edm::VParameterSet sistrip::MeasureLA::measurementPreferences [private] |
Definition at line 47 of file MeasureLA.h.
Referenced by MeasureLA().
int32_t sistrip::MeasureLA::methods [private] |
Definition at line 49 of file MeasureLA.h.
Referenced by MeasureLA(), and store_methods_and_granularity().
std::map<std::pair<uint32_t,LA_Filler_Fitter::Method>,float> sistrip::MeasureLA::offset [private] |
Definition at line 48 of file MeasureLA.h.
Referenced by calibrate(), and store_calibrations().
const edm::VParameterSet sistrip::MeasureLA::reports [private] |
Definition at line 47 of file MeasureLA.h.
Referenced by MeasureLA(), and process_reports().
std::map<std::pair<uint32_t,LA_Filler_Fitter::Method>,float> sistrip::MeasureLA::slope [private] |
Definition at line 48 of file MeasureLA.h.
Referenced by calibrate(), and store_calibrations().
const unsigned sistrip::MeasureLA::stripsperbin [private] |
Definition at line 52 of file MeasureLA.h.
Referenced by MeasureLA().