CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
DQMGenericTnPClient Class Reference
Inheritance diagram for DQMGenericTnPClient:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
void calculateEfficiency (std::string dirName, const ParameterSet &pset)
 
 DQMGenericTnPClient (const edm::ParameterSet &pset)
 
virtual void endRun (const edm::Run &run, const edm::EventSetup &setup) override
 
void findAllSubdirectories (std::string dir, std::set< std::string > *myList, TString pattern)
 
virtual ~DQMGenericTnPClient ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

DQMStoredqmStore
 
const VParameterSet efficiencies
 
GaussianPlusLinearFitterGPLfitter
 
std::string myDQMrootFolder
 
TFile * plots
 
vstring subDirs
 
bool verbose
 
VoigtianPlusExponentialFitterVPEfitter
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 24 of file DQMGenericTnPClient.cc.

Constructor & Destructor Documentation

DQMGenericTnPClient::DQMGenericTnPClient ( const edm::ParameterSet pset)

Definition at line 43 of file DQMGenericTnPClient.cc.

References edm::ParameterSet::getUntrackedParameter(), GPLfitter, plots, and VPEfitter.

43  :
44  subDirs( pset.getUntrackedParameter<vstring>("subDirs", vstring()) ),
45  myDQMrootFolder( pset.getUntrackedParameter<std::string>("MyDQMrootFolder", "") ),
46  verbose( pset.getUntrackedParameter<bool>("Verbose",false) ),
47  efficiencies( pset.getUntrackedParameter<VParameterSet>("Efficiencies") )
48 {
49  TString savePlotsInRootFileName = pset.getUntrackedParameter<string>("SavePlotsInRootFileName","");
50  plots = savePlotsInRootFileName!="" ? new TFile(savePlotsInRootFileName,"recreate") : 0;
53 }
T getUntrackedParameter(std::string const &, T const &) const
GaussianPlusLinearFitter * GPLfitter
vector< string > vstring
Definition: ExoticaDQM.cc:75
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
VoigtianPlusExponentialFitter * VPEfitter
const VParameterSet efficiencies
DQMGenericTnPClient::~DQMGenericTnPClient ( )
virtual

Definition at line 180 of file DQMGenericTnPClient.cc.

References GPLfitter, and plots.

180  {
181  delete GPLfitter;
182  if(plots){
183  plots->Close();
184  }
185 }
GaussianPlusLinearFitter * GPLfitter

Member Function Documentation

virtual void DQMGenericTnPClient::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
inlineoverridevirtual

Implements edm::EDAnalyzer.

Definition at line 28 of file DQMGenericTnPClient.cc.

28 {};
void DQMGenericTnPClient::calculateEfficiency ( std::string  dirName,
const ParameterSet pset 
)

Definition at line 98 of file DQMGenericTnPClient.cc.

References cond::ecalcond::all, TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, relativeConstraints::error, MonitorElement::getTH1(), edm::ParameterSet::getUntrackedParameter(), GPLfitter, LogDebug, plots, prof2calltree::prefix, dqmTnP::AbstractFitter::setup(), dqmTnP::VoigtianPlusExponentialFitter::setup(), and VPEfitter.

Referenced by endRun().

98  {
99  //get hold of numerator and denominator histograms
100  string allMEname = dirName+"/"+pset.getUntrackedParameter<string>("DenominatorMEname");
101  string passMEname = dirName+"/"+pset.getUntrackedParameter<string>("NumeratorMEname");
102  MonitorElement *allME = dqmStore->get(allMEname);
103  MonitorElement *passME = dqmStore->get(passMEname);
104  if(allME==0 || passME==0){
105  LogDebug("DQMGenericTnPClient")<<"Could not find MEs: "<<allMEname<<" or "<<passMEname<<endl;
106  return;
107  }
108  TH1 *all = allME->getTH1();
109  TH1 *pass = passME->getTH1();
110  //setup the fitter
111  string fitFunction = pset.getUntrackedParameter<string>("FitFunction");
112  AbstractFitter *fitter = 0;
113  if(fitFunction=="GaussianPlusLinear"){
114  GPLfitter->setup(
115  pset.getUntrackedParameter<double>("ExpectedMean"),
116  pset.getUntrackedParameter<double>("FitRangeLow"),
117  pset.getUntrackedParameter<double>("FitRangeHigh"),
118  pset.getUntrackedParameter<double>("ExpectedSigma")
119  );
120  fitter = GPLfitter;
121  }else if(fitFunction=="VoigtianPlusExponential"){
122  VPEfitter->setup(
123  pset.getUntrackedParameter<double>("ExpectedMean"),
124  pset.getUntrackedParameter<double>("FitRangeLow"),
125  pset.getUntrackedParameter<double>("FitRangeHigh"),
126  pset.getUntrackedParameter<double>("ExpectedSigma"),
127  pset.getUntrackedParameter<double>("FixedWidth")
128  );
129  fitter = VPEfitter;
130  }else{
131  LogError("DQMGenericTnPClient")<<"Fit function: "<<fitFunction<<" does not exist"<<endl;
132  return;
133  }
134  //check dimensions
135  int dimensions = all->GetDimension();
136  int massDimension = pset.getUntrackedParameter<int>("MassDimension");
137  if(massDimension>dimensions){
138  LogError("DQMGenericTnPClient")<<"Monitoring Element "<<allMEname<<" has smaller dimension than "<<massDimension<<endl;
139  return;
140  }
141  //figure out directory and efficiency names
142  string effName = pset.getUntrackedParameter<string>("EfficiencyMEname");
143  string effDir = dirName;
144  string::size_type slashPos = effName.rfind('/');
145  if ( string::npos != slashPos ) {
146  effDir += "/"+effName.substr(0, slashPos);
147  effName.erase(0, slashPos+1);
148  }
149  dqmStore->setCurrentFolder(effDir);
150  TString prefix(effDir.c_str());
151  prefix.ReplaceAll('/','_');
152  //calculate and book efficiency
153  if(dimensions==2){
154  TProfile* eff = 0;
155  TProfile* effChi2 = 0;
156  TString error = fitter->calculateEfficiency((TH2*)pass, (TH2*)all, massDimension, eff, effChi2, plots?prefix+effName.c_str():"");
157  if(error!=""){
158  LogError("DQMGenericTnPClient")<<error<<endl;
159  return;
160  }
161  dqmStore->bookProfile(effName,eff);
162  dqmStore->bookProfile(effName+"Chi2",effChi2);
163  delete eff;
164  delete effChi2;
165  }else if(dimensions==3){
166  TProfile2D* eff = 0;
167  TProfile2D* effChi2 = 0;
168  TString error = fitter->calculateEfficiency((TH3*)pass, (TH3*)all, massDimension, eff, effChi2, plots?prefix+effName.c_str():"");
169  if(error!=""){
170  LogError("DQMGenericTnPClient")<<error<<endl;
171  return;
172  }
173  dqmStore->bookProfile2D(effName,eff);
174  dqmStore->bookProfile2D(effName+"Chi2",effChi2);
175  delete eff;
176  delete effChi2;
177  }
178 }
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
GaussianPlusLinearFitter * GPLfitter
void setup(double expectedMean_, double massLow, double massHigh, double expectedSigma_)
uint16_t size_type
void setup(double expectedMean_, double massLow, double massHigh, double expectedSigma_, double width_)
VoigtianPlusExponentialFitter * VPEfitter
TH1 * getTH1(void) const
void DQMGenericTnPClient::endRun ( const edm::Run run,
const edm::EventSetup setup 
)
overridevirtual

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, AlCaHLTBitMon_QueryRunRegistry::string, and subDirs.

55  {
56 
57  TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
58 
60  if( !dqmStore ){
61  LogError("DQMGenericTnPClient")<<"Could not find DQMStore service\n";
62  return;
63  }
64  dqmStore->setCurrentFolder(myDQMrootFolder);
65 
66  set<std::string> subDirSet;
67 
68  if (myDQMrootFolder != "")
69  subDirSet.insert(myDQMrootFolder);
70  else {
71  for(vstring::const_iterator iSubDir = subDirs.begin();
72  iSubDir != subDirs.end(); ++iSubDir) {
73  std::string subDir = *iSubDir;
74  if ( subDir[subDir.size()-1] == '/' ) subDir.erase(subDir.size()-1);
75  if ( TString(subDir).Contains(metacharacters) ) {
76  const string::size_type shiftPos = subDir.rfind('/');
77  const string searchPath = subDir.substr(0, shiftPos);
78  const string pattern = subDir.substr(shiftPos + 1, subDir.length());
79  findAllSubdirectories (searchPath, &subDirSet, pattern);
80  }
81  else {
82  subDirSet.insert(subDir);
83  }
84  }
85  }
86 
87  for(set<string>::const_iterator iSubDir = subDirSet.begin();
88  iSubDir != subDirSet.end(); ++iSubDir) {
89  const string& dirName = *iSubDir;
90  for(VParameterSet::const_iterator pset = efficiencies.begin();
91  pset != efficiencies.end(); ++pset) {
92  calculateEfficiency(dirName, *pset);
93  }
94  }
95 
96 }
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
uint16_t size_type
void calculateEfficiency(std::string dirName, const ParameterSet &pset)
const VParameterSet efficiencies
void findAllSubdirectories(std::string dir, std::set< std::string > *myList, TString pattern)
void DQMGenericTnPClient::findAllSubdirectories ( std::string  dir,
std::set< std::string > *  myList,
TString  pattern = "" 
)

Definition at line 187 of file DQMGenericTnPClient.cc.

References TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, nonPerlWildcard(), and listBenchmarks::pattern.

Referenced by endRun().

187  {
188  if (!dqmStore->dirExists(dir)) {
189  LogError("DQMGenericTnPClient") << " DQMGenericTnPClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
190  return;
191  }
192  TPRegexp nonPerlWildcard("\\w\\*|^\\*");
193  if (pattern != "") {
194  if (pattern.Contains(nonPerlWildcard)) pattern.ReplaceAll("*",".*");
195  TPRegexp regexp(pattern);
196  dqmStore->cd(dir);
197  vector <string> foundDirs = dqmStore->getSubdirs();
198  for(vector<string>::const_iterator iDir = foundDirs.begin();
199  iDir != foundDirs.end(); ++iDir) {
200  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
201  if (dirName.Contains(regexp))
202  findAllSubdirectories ( *iDir, myList);
203  }
204  }
205  else if (dqmStore->dirExists(dir)){
206  myList->insert(dir);
207  dqmStore->cd(dir);
209  } else {
210 
211  LogInfo ("DQMGenericClient") << "Trying to find sub-directories of " << dir
212  << " failed because " << dir << " does not exist";
213 
214  }
215  return;
216 }
TPRegexp nonPerlWildcard("\\w\\*|^\\*")
dbl *** dir
Definition: mlp_gen.cc:35
void findAllSubdirectories(std::string dir, std::set< std::string > *myList, TString pattern)

Member Data Documentation

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

GaussianPlusLinearFitter* DQMGenericTnPClient::GPLfitter
private
std::string DQMGenericTnPClient::myDQMrootFolder
private

Definition at line 36 of file DQMGenericTnPClient.cc.

Referenced by endRun().

TFile* DQMGenericTnPClient::plots
private
vstring DQMGenericTnPClient::subDirs
private

Definition at line 35 of file DQMGenericTnPClient.cc.

Referenced by endRun().

bool DQMGenericTnPClient::verbose
private
VoigtianPlusExponentialFitter* DQMGenericTnPClient::VPEfitter
private

Definition at line 40 of file DQMGenericTnPClient.cc.

Referenced by calculateEfficiency(), and DQMGenericTnPClient().