CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMGenericTnPClient.cc
Go to the documentation of this file.
11 
13 
14 using namespace edm;
15 using namespace dqmTnP;
16 
18  public:
20  virtual ~DQMGenericTnPClient();
21  virtual void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {};
22  virtual void endRun(const edm::Run &run, const edm::EventSetup &setup);
23  void calculateEfficiency(const ParameterSet& pset);
24  private:
26  TFile * plots;
28  bool verbose;
32 };
33 
35  myDQMrootFolder( pset.getUntrackedParameter<string>("MyDQMrootFolder") ),
36  verbose( pset.getUntrackedParameter<bool>("Verbose",false) ),
37  efficiencies( pset.getUntrackedParameter<VParameterSet>("Efficiencies") )
38 {
39  TString savePlotsInRootFileName = pset.getUntrackedParameter<string>("SavePlotsInRootFileName","");
40  plots = savePlotsInRootFileName!="" ? new TFile(savePlotsInRootFileName,"recreate") : 0;
43 }
44 
47  if( !dqmStore ){
48  LogError("DQMGenericTnPClient")<<"Could not find DQMStore service\n";
49  return;
50  }
52  //loop over all efficiency tasks
53  for(VParameterSet::const_iterator pset = efficiencies.begin(); pset!=efficiencies.end(); pset++){
55  }
56 }
57 
59  //get hold of numerator and denominator histograms
60  string allMEname = myDQMrootFolder+"/"+pset.getUntrackedParameter<string>("DenominatorMEname");
61  string passMEname = myDQMrootFolder+"/"+pset.getUntrackedParameter<string>("NumeratorMEname");
62  MonitorElement *allME = dqmStore->get(allMEname);
63  MonitorElement *passME = dqmStore->get(passMEname);
64  if(allME==0 || passME==0){
65  LogDebug("DQMGenericTnPClient")<<"Could not find MEs: "<<allMEname<<" or "<<passMEname<<endl;
66  return;
67  }
68  TH1 *all = allME->getTH1();
69  TH1 *pass = passME->getTH1();
70  //setup the fitter
71  string fitFunction = pset.getUntrackedParameter<string>("FitFunction");
72  AbstractFitter *fitter = 0;
73  if(fitFunction=="GaussianPlusLinear"){
75  pset.getUntrackedParameter<double>("ExpectedMean"),
76  pset.getUntrackedParameter<double>("FitRangeLow"),
77  pset.getUntrackedParameter<double>("FitRangeHigh"),
78  pset.getUntrackedParameter<double>("ExpectedSigma")
79  );
80  fitter = GPLfitter;
81  }else if(fitFunction=="VoigtianPlusExponential"){
83  pset.getUntrackedParameter<double>("ExpectedMean"),
84  pset.getUntrackedParameter<double>("FitRangeLow"),
85  pset.getUntrackedParameter<double>("FitRangeHigh"),
86  pset.getUntrackedParameter<double>("ExpectedSigma"),
87  pset.getUntrackedParameter<double>("FixedWidth")
88  );
89  fitter = VPEfitter;
90  }else{
91  LogError("DQMGenericTnPClient")<<"Fit function: "<<fitFunction<<" does not exist"<<endl;
92  return;
93  }
94  //check dimensions
95  int dimensions = all->GetDimension();
96  int massDimension = pset.getUntrackedParameter<int>("MassDimension");
97  if(massDimension>dimensions){
98  LogError("DQMGenericTnPClient")<<"Monitoring Element "<<allMEname<<" has smaller dimension than "<<massDimension<<endl;
99  return;
100  }
101  //figure out directory and efficiency names
102  string effName = pset.getUntrackedParameter<string>("EfficiencyMEname");
103  string effDir = myDQMrootFolder;
104  string::size_type slashPos = effName.rfind('/');
105  if ( string::npos != slashPos ) {
106  effDir += "/"+effName.substr(0, slashPos);
107  effName.erase(0, slashPos+1);
108  }
109  dqmStore->setCurrentFolder(effDir);
110  TString prefix(effDir.c_str());
111  prefix.ReplaceAll('/','_');
112  //calculate and book efficiency
113  if(dimensions==2){
114  TProfile* eff = 0;
115  TProfile* effChi2 = 0;
116  TString error = fitter->calculateEfficiency((TH2*)pass, (TH2*)all, massDimension, eff, effChi2, plots?prefix+effName.c_str():"");
117  if(error!=""){
118  LogError("DQMGenericTnPClient")<<error<<endl;
119  return;
120  }
121  dqmStore->bookProfile(effName,eff);
122  dqmStore->bookProfile(effName+"Chi2",effChi2);
123  delete eff;
124  delete effChi2;
125  }else if(dimensions==3){
126  TProfile2D* eff = 0;
127  TProfile2D* effChi2 = 0;
128  TString error = fitter->calculateEfficiency((TH3*)pass, (TH3*)all, massDimension, eff, effChi2, plots?prefix+effName.c_str():"");
129  if(error!=""){
130  LogError("DQMGenericTnPClient")<<error<<endl;
131  return;
132  }
133  dqmStore->bookProfile2D(effName,eff);
134  dqmStore->bookProfile2D(effName+"Chi2",effChi2);
135  delete eff;
136  delete effChi2;
137  }
138 }
139 
141  delete GPLfitter;
142  if(plots){
143  plots->Close();
144  }
145 }
146 
147 //define this as a plug-in
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
GaussianPlusLinearFitter * GPLfitter
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:29
void calculateEfficiency(const ParameterSet &pset)
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_)
DQMGenericTnPClient(const edm::ParameterSet &pset)
VoigtianPlusExponentialFitter * VPEfitter
TH1 * getTH1(void) const
tuple pset
Definition: CrabTask.py:85
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:833
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1270
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual void endRun(const edm::Run &run, const edm::EventSetup &setup)
virtual void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
const VParameterSet efficiencies
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")
Definition: DQMStore.cc:977