CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DQMGenericTnPClient Class Reference
Inheritance diagram for DQMGenericTnPClient:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
void calculateEfficiency (const std::string &dirName, const ParameterSet &pset)
 
 DQMGenericTnPClient (const edm::ParameterSet &pset)
 
void endRun (const edm::Run &run, const edm::EventSetup &setup) override
 
void findAllSubdirectories (const std::string &dir, std::set< std::string > *myList, TString pattern)
 
 ~DQMGenericTnPClient () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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") : nullptr;
53 }
T getUntrackedParameter(std::string const &, T const &) const
GaussianPlusLinearFitter * GPLfitter
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
#define nullptr
VoigtianPlusExponentialFitter * VPEfitter
const VParameterSet efficiencies
DQMGenericTnPClient::~DQMGenericTnPClient ( )
override

Definition at line 177 of file DQMGenericTnPClient.cc.

References GPLfitter, and plots.

177  {
178  delete GPLfitter;
179  if(plots){
180  plots->Close();
181  }
182 }
GaussianPlusLinearFitter * GPLfitter

Member Function Documentation

void DQMGenericTnPClient::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
inlineoverride
void DQMGenericTnPClient::calculateEfficiency ( const std::string &  dirName,
const ParameterSet pset 
)

Definition at line 95 of file DQMGenericTnPClient.cc.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor::all(), SiPixelPhase1DigisV_cfi::dimensions, TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, relativeConstraints::error, MonitorElement::getTH1(), edm::ParameterSet::getUntrackedParameter(), GPLfitter, LogDebug, plots, tablePrinter::prefix, dqmTnP::AbstractFitter::setup(), dqmTnP::VoigtianPlusExponentialFitter::setup(), and VPEfitter.

Referenced by endRun().

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

Definition at line 55 of file DQMGenericTnPClient.cc.

References calculateEfficiency(), TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, efficiencies, findAllSubdirectories(), metacharacters(), myDQMrootFolder, Utilities::operator, listBenchmarks::pattern, AlCaHLTBitMon_QueryRunRegistry::string, RecoMuonValidator_cff::subDir, 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(auto 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(auto const & dirName : subDirSet) {
88  for(auto const & efficiencie : efficiencies) {
89  calculateEfficiency(dirName, efficiencie);
90  }
91  }
92 
93 }
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
void calculateEfficiency(const std::string &dirName, const ParameterSet &pset)
uint16_t size_type
void findAllSubdirectories(const std::string &dir, std::set< std::string > *myList, TString pattern)
const VParameterSet efficiencies
void DQMGenericTnPClient::findAllSubdirectories ( const std::string &  dir,
std::set< std::string > *  myList,
TString  pattern = "" 
)

Definition at line 184 of file DQMGenericTnPClient.cc.

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

Referenced by endRun().

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

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