Public Member Functions | |
virtual void | analyze (const edm::Event &event, const edm::EventSetup &eventSetup) |
void | calculateEfficiency (std::string dirName, const ParameterSet &pset) |
DQMGenericTnPClient (const edm::ParameterSet &pset) | |
virtual void | endRun (const edm::Run &run, const edm::EventSetup &setup) |
void | findAllSubdirectories (std::string dir, std::set< std::string > *myList, TString pattern) |
virtual | ~DQMGenericTnPClient () |
Private Attributes | |
DQMStore * | dqmStore |
const VParameterSet | efficiencies |
GaussianPlusLinearFitter * | GPLfitter |
std::string | myDQMrootFolder |
TFile * | plots |
vstring | subDirs |
bool | verbose |
VoigtianPlusExponentialFitter * | VPEfitter |
Definition at line 24 of file DQMGenericTnPClient.cc.
DQMGenericTnPClient::DQMGenericTnPClient | ( | const edm::ParameterSet & | pset | ) |
Definition at line 43 of file DQMGenericTnPClient.cc.
References edm::ParameterSet::getUntrackedParameter(), GPLfitter, plots, and VPEfitter.
: subDirs( pset.getUntrackedParameter<vstring>("subDirs", vstring()) ), myDQMrootFolder( pset.getUntrackedParameter<std::string>("MyDQMrootFolder", "") ), verbose( pset.getUntrackedParameter<bool>("Verbose",false) ), efficiencies( pset.getUntrackedParameter<VParameterSet>("Efficiencies") ) { TString savePlotsInRootFileName = pset.getUntrackedParameter<string>("SavePlotsInRootFileName",""); plots = savePlotsInRootFileName!="" ? new TFile(savePlotsInRootFileName,"recreate") : 0; GPLfitter = new GaussianPlusLinearFitter(verbose); VPEfitter = new VoigtianPlusExponentialFitter(verbose); }
DQMGenericTnPClient::~DQMGenericTnPClient | ( | ) | [virtual] |
virtual void DQMGenericTnPClient::analyze | ( | const edm::Event & | event, |
const edm::EventSetup & | eventSetup | ||
) | [inline, virtual] |
void DQMGenericTnPClient::calculateEfficiency | ( | std::string | dirName, |
const ParameterSet & | pset | ||
) |
Definition at line 98 of file DQMGenericTnPClient.cc.
References cond::ecalcond::all, DQMStore::bookProfile(), DQMStore::bookProfile2D(), TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, interpolateCardsSimple::eff, error, DQMStore::get(), MonitorElement::getTH1(), edm::ParameterSet::getUntrackedParameter(), GPLfitter, LogDebug, plots, prof2calltree::prefix, DQMStore::setCurrentFolder(), dqmTnP::VoigtianPlusExponentialFitter::setup(), dqmTnP::AbstractFitter::setup(), and VPEfitter.
Referenced by endRun().
{ //get hold of numerator and denominator histograms string allMEname = dirName+"/"+pset.getUntrackedParameter<string>("DenominatorMEname"); string passMEname = dirName+"/"+pset.getUntrackedParameter<string>("NumeratorMEname"); MonitorElement *allME = dqmStore->get(allMEname); MonitorElement *passME = dqmStore->get(passMEname); if(allME==0 || passME==0){ LogDebug("DQMGenericTnPClient")<<"Could not find MEs: "<<allMEname<<" or "<<passMEname<<endl; return; } TH1 *all = allME->getTH1(); TH1 *pass = passME->getTH1(); //setup the fitter string fitFunction = pset.getUntrackedParameter<string>("FitFunction"); AbstractFitter *fitter = 0; if(fitFunction=="GaussianPlusLinear"){ GPLfitter->setup( pset.getUntrackedParameter<double>("ExpectedMean"), pset.getUntrackedParameter<double>("FitRangeLow"), pset.getUntrackedParameter<double>("FitRangeHigh"), pset.getUntrackedParameter<double>("ExpectedSigma") ); fitter = GPLfitter; }else if(fitFunction=="VoigtianPlusExponential"){ VPEfitter->setup( pset.getUntrackedParameter<double>("ExpectedMean"), pset.getUntrackedParameter<double>("FitRangeLow"), pset.getUntrackedParameter<double>("FitRangeHigh"), pset.getUntrackedParameter<double>("ExpectedSigma"), pset.getUntrackedParameter<double>("FixedWidth") ); fitter = VPEfitter; }else{ LogError("DQMGenericTnPClient")<<"Fit function: "<<fitFunction<<" does not exist"<<endl; return; } //check dimensions int dimensions = all->GetDimension(); int massDimension = pset.getUntrackedParameter<int>("MassDimension"); if(massDimension>dimensions){ LogError("DQMGenericTnPClient")<<"Monitoring Element "<<allMEname<<" has smaller dimension than "<<massDimension<<endl; return; } //figure out directory and efficiency names string effName = pset.getUntrackedParameter<string>("EfficiencyMEname"); string effDir = dirName; string::size_type slashPos = effName.rfind('/'); if ( string::npos != slashPos ) { effDir += "/"+effName.substr(0, slashPos); effName.erase(0, slashPos+1); } dqmStore->setCurrentFolder(effDir); TString prefix(effDir.c_str()); prefix.ReplaceAll('/','_'); //calculate and book efficiency if(dimensions==2){ TProfile* eff = 0; TProfile* effChi2 = 0; TString error = fitter->calculateEfficiency((TH2*)pass, (TH2*)all, massDimension, eff, effChi2, plots?prefix+effName.c_str():""); if(error!=""){ LogError("DQMGenericTnPClient")<<error<<endl; return; } dqmStore->bookProfile(effName,eff); dqmStore->bookProfile(effName+"Chi2",effChi2); delete eff; delete effChi2; }else if(dimensions==3){ TProfile2D* eff = 0; TProfile2D* effChi2 = 0; TString error = fitter->calculateEfficiency((TH3*)pass, (TH3*)all, massDimension, eff, effChi2, plots?prefix+effName.c_str():""); if(error!=""){ LogError("DQMGenericTnPClient")<<error<<endl; return; } dqmStore->bookProfile2D(effName,eff); dqmStore->bookProfile2D(effName+"Chi2",effChi2); delete eff; delete effChi2; } }
void DQMGenericTnPClient::endRun | ( | const edm::Run & | run, |
const edm::EventSetup & | setup | ||
) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 55 of file DQMGenericTnPClient.cc.
References calculateEfficiency(), TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, efficiencies, findAllSubdirectories(), metacharacters(), myDQMrootFolder, cppFunctionSkipper::operator, listBenchmarks::pattern, DQMStore::setCurrentFolder(), and subDirs.
{ TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]"); dqmStore = Service<DQMStore>().operator->(); if( !dqmStore ){ LogError("DQMGenericTnPClient")<<"Could not find DQMStore service\n"; return; } dqmStore->setCurrentFolder(myDQMrootFolder); set<std::string> subDirSet; if (myDQMrootFolder != "") subDirSet.insert(myDQMrootFolder); else { for(vstring::const_iterator iSubDir = subDirs.begin(); iSubDir != subDirs.end(); ++iSubDir) { std::string subDir = *iSubDir; if ( subDir[subDir.size()-1] == '/' ) subDir.erase(subDir.size()-1); if ( TString(subDir).Contains(metacharacters) ) { const string::size_type shiftPos = subDir.rfind('/'); const string searchPath = subDir.substr(0, shiftPos); const string pattern = subDir.substr(shiftPos + 1, subDir.length()); findAllSubdirectories (searchPath, &subDirSet, pattern); } else { subDirSet.insert(subDir); } } } for(set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) { const string& dirName = *iSubDir; for(VParameterSet::const_iterator pset = efficiencies.begin(); pset != efficiencies.end(); ++pset) { calculateEfficiency(dirName, *pset); } } }
void DQMGenericTnPClient::findAllSubdirectories | ( | std::string | dir, |
std::set< std::string > * | myList, | ||
TString | pattern = "" |
||
) |
Definition at line 187 of file DQMGenericTnPClient.cc.
References DQMStore::cd(), DQMStore::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, DQMStore::getSubdirs(), nonPerlWildcard(), and listBenchmarks::pattern.
Referenced by endRun().
{ if (!dqmStore->dirExists(dir)) { LogError("DQMGenericTnPClient") << " DQMGenericTnPClient::findAllSubdirectories ==> Missing folder " << dir << " !!!"; return; } TPRegexp nonPerlWildcard("\\w\\*|^\\*"); if (pattern != "") { if (pattern.Contains(nonPerlWildcard)) pattern.ReplaceAll("*",".*"); TPRegexp regexp(pattern); dqmStore->cd(dir); vector <string> foundDirs = dqmStore->getSubdirs(); for(vector<string>::const_iterator iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) { TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length()); if (dirName.Contains(regexp)) findAllSubdirectories ( *iDir, myList); } } else if (dqmStore->dirExists(dir)){ myList->insert(dir); dqmStore->cd(dir); findAllSubdirectories (dir, myList, "*"); } else { LogInfo ("DQMGenericClient") << "Trying to find sub-directories of " << dir << " failed because " << dir << " does not exist"; } return; }
DQMStore* DQMGenericTnPClient::dqmStore [private] |
Definition at line 33 of file DQMGenericTnPClient.cc.
Referenced by calculateEfficiency(), endRun(), and findAllSubdirectories().
const VParameterSet DQMGenericTnPClient::efficiencies [private] |
Definition at line 38 of file DQMGenericTnPClient.cc.
Referenced by endRun().
Definition at line 39 of file DQMGenericTnPClient.cc.
Referenced by calculateEfficiency(), DQMGenericTnPClient(), and ~DQMGenericTnPClient().
std::string DQMGenericTnPClient::myDQMrootFolder [private] |
Definition at line 36 of file DQMGenericTnPClient.cc.
Referenced by endRun().
TFile* DQMGenericTnPClient::plots [private] |
Definition at line 34 of file DQMGenericTnPClient.cc.
Referenced by calculateEfficiency(), DQMGenericTnPClient(), and ~DQMGenericTnPClient().
vstring DQMGenericTnPClient::subDirs [private] |
Definition at line 35 of file DQMGenericTnPClient.cc.
Referenced by endRun().
bool DQMGenericTnPClient::verbose [private] |
Definition at line 37 of file DQMGenericTnPClient.cc.
Definition at line 40 of file DQMGenericTnPClient.cc.
Referenced by calculateEfficiency(), and DQMGenericTnPClient().