#include <PlotEff.h>
Inheritance diagram for Anp::PlotEff:

Public Member Functions | |
| PlotEff () | |
| virtual | ~PlotEff () |
| bool | Run (Record &record) |
| bool | Run (Event &event, const Record &record, bool pass) |
| void | Config (const Registry ®) |
| void | Set (TDirectory *dir) |
| void | End (const DataBlock &) |
Private Types | |
| typedef std::vector< Handle< CountHist > > | EffVec |
Private Member Functions | |
| bool | Add (EffVec &evec, int action, int reson, Particle::Particle_t particle, const std::string &opt) |
| TH1 * | GetTH1 (TDirectory *dir, const std::string &key, const std::string &name, const std::string &xtitle, const std::string &ytitle) |
| bool | IsMatch (Handle< CountHist > &hist, const Truth &truth) const |
Private Attributes | |
| TDirectory * | fDir |
| std::string | fDirName |
| std::string | fTH1Name |
| bool | fInit |
| bool | fTrueFid |
| bool | fVerbose |
| double | fMinCom |
| double | fNMerge |
| EffVec | fTrueEff |
| EffVec | fRecoEff |
| double | fTruthAll |
| double | fTruthFid |
| double | fTruthRec |
|
|
|
|
|
Definition at line 27 of file PlotEff.cxx. 00028 :fDir(0), 00029 fDirName("eff"), 00030 fTH1Name("energy"), 00031 fInit(false), 00032 fTrueFid(true), 00033 fVerbose(false), 00034 fMinCom(0.0), 00035 fNMerge(100.0), 00036 fTruthAll(0.0), 00037 fTruthFid(0.0), 00038 fTruthRec(0.0) 00039 { 00040 }
|
|
|
Definition at line 43 of file PlotEff.cxx. 00044 {
00045 }
|
|
||||||||||||||||||||||||
|
Definition at line 284 of file PlotEff.cxx. References fDir, find(), fTH1Name, Anp::GetDir(), and Particle::Name(). Referenced by Set(). 00286 {
00287 if(!fDir)
00288 {
00289 return false;
00290 }
00291
00292 Handle<CountHist> hist(new CountHist(action, reson, particle));
00293
00294 if(std::find(evec.begin(), evec.end(), hist) != evec.end())
00295 {
00296 cerr << "PlotEff::Create - key already exists" << endl;
00297 return false;
00298 }
00299
00300 string name, title;
00301
00302 if (action == 1) name = "cc";
00303 else if(action == 0) name = "nc";
00304 else if(action < 0) name = "all";
00305 else
00306 {
00307 return false;
00308 }
00309
00310 if(true)
00311 {
00312 Anp::Lock<Mutex> lock(Anp::GetMainMutex());
00313 name = name + "_" + Particle::Name(particle);
00314 }
00315
00316 if (reson == 1001) name = name + "_qes";
00317 else if(reson == 1002) name = name + "_res";
00318 else if(reson == 1003) name = name + "_dis";
00319
00320 TDirectory *dir = 0;
00321
00322 if(opt.find("reco") != string::npos)
00323 {
00324 title = "reconstructed E_{#nu} (GeV)";
00325 dir = Anp::GetDir("reco", fDir);
00326 }
00327 else if(opt.find("true") != string::npos)
00328 {
00329 title = "true E_{#nu} (GeV)";
00330 dir = Anp::GetDir("true", fDir);
00331 }
00332 else
00333 {
00334 return false;
00335 }
00336
00337 const string name1 = "all_" + name;
00338 const string name2 = "sel_" + name;
00339 const string name3 = "eff_" + name;
00340
00341 hist -> nmin = fNMerge;
00342 hist -> hall = PlotEff::GetTH1(dir, fTH1Name, name1, title, "all events");
00343 hist -> hsel = PlotEff::GetTH1(dir, fTH1Name, name2, title, "selected events");
00344 hist -> hrat = PlotEff::GetTH1(dir, fTH1Name, name3, title, "efficiency");
00345 hist -> verbose = fVerbose;
00346
00347 if(hist -> Valid())
00348 {
00349 evec.push_back(hist);
00350 }
00351 else
00352 {
00353 return false;
00354 }
00355
00356 return true;
00357 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 167 of file PlotEff.cxx. References fDirName, fMinCom, fNMerge, fTH1Name, fTrueFid, fVerbose, Registry::Get(), Registry::KeyExists(), Anp::Read(), and reg. 00168 {
00169 const char *value_char = 0;
00170 if(reg.Get("PlotEffDirName", value_char) && value_char)
00171 {
00172 fDirName = value_char;
00173 }
00174
00175 value_char = 0;
00176 if(reg.Get("PlotEffTH1Name", value_char) && value_char)
00177 {
00178 fTH1Name = value_char;
00179 }
00180
00181 Anp::Read(reg, "PlotEffTrueFid", fTrueFid);
00182 Anp::Read(reg, "PlotEffVerbose", fVerbose);
00183
00184 reg.Get("PlotPurNMerge", fNMerge);
00185 reg.Get("PlotPurMinCom", fMinCom);
00186
00187 if(reg.KeyExists("PrintConfig"))
00188 {
00189 cout << "PlotEff::Config" << endl
00190 << " DirName = " << fDirName << endl
00191 << " TH1Name = " << fTH1Name << endl
00192 << " MinCom = " << fMinCom << endl
00193 << " NMerge = " << fNMerge << endl
00194 << " TrueFid = " << fTrueFid << endl
00195 << " Verbose = " << fVerbose << endl;
00196 }
00197 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 232 of file PlotEff.cxx. References fNMerge, fRecoEff, fTrueEff, fTruthAll, fTruthFid, fTruthRec, and Anp::Handle< T >::valid(). 00233 {
00234 for(EffVec::iterator it = fTrueEff.begin(); it != fTrueEff.end(); ++it)
00235 {
00236 Handle<CountHist> &hist = *it;
00237
00238 if(!hist.valid() || !hist -> Valid())
00239 {
00240 continue;
00241 }
00242
00243 if(fNMerge > 0.0)
00244 {
00245 hist -> ComputeRatio("merge");
00246 }
00247 else
00248 {
00249 hist -> ComputeRatio();
00250 }
00251 }
00252 for(EffVec::iterator it = fRecoEff.begin(); it != fRecoEff.end(); ++it)
00253 {
00254 Handle<CountHist> &hist = *it;
00255
00256 if(!hist.valid() || !hist -> Valid())
00257 {
00258 continue;
00259 }
00260
00261 if(fNMerge > 0.0)
00262 {
00263 hist -> ComputeRatio("merge");
00264 }
00265 else
00266 {
00267 hist -> ComputeRatio();
00268 }
00269 }
00270
00271 fTrueEff.clear();
00272 fRecoEff.clear();
00273
00274 if(fVerbose)
00275 {
00276 cout << "PlotEff::End " << endl
00277 << " TruthAll = " << fTruthAll << endl
00278 << " TruthFid = " << fTruthFid << endl
00279 << " TruthRec = " << fTruthRec << endl;
00280 }
00281 }
|
|
||||||||||||||||||||||||
|
Definition at line 360 of file PlotEff.cxx. References Anp::SetDir(). 00364 {
00365 if(!dir)
00366 {
00367 return 0;
00368 }
00369
00370 TH1 *h = HistMan::Instance().CreateTH1(key, "eff");
00371 if(h)
00372 {
00373 h -> GetXaxis() -> SetTitle(xtitle.c_str());
00374 h -> GetYaxis() -> SetTitle(ytitle.c_str());
00375 h -> GetXaxis() -> CenterTitle();
00376 h -> GetYaxis() -> CenterTitle();
00377 Anp::SetDir(h, dir, name);
00378 }
00379
00380 return h;
00381 }
|
|
||||||||||||
|
Definition at line 384 of file PlotEff.cxx. References Anp::Truth::Interaction(), Particle::Overlap(), Anp::Truth::Particle(), Anp::Truth::Resonance(), and Anp::Handle< T >::valid(). 00385 {
00386 if(!hist.valid() || !(hist -> Valid()))
00387 {
00388 return false;
00389 }
00390
00391 if(hist -> GetReson() > 0 &&
00392 hist -> GetReson() != truth.Resonance())
00393 {
00394 return false;
00395 }
00396
00397 if(hist -> GetInteraction() >= 0 &&
00398 hist -> GetInteraction() != truth.Interaction())
00399 {
00400 return false;
00401 }
00402
00403 if(!Particle::Overlap(hist -> GetParticle(), truth.Particle()))
00404 {
00405 return false;
00406 }
00407
00408 return true;
00409 }
|
|
||||||||||||||||
|
Implements Anp::AlgEvent. Definition at line 111 of file PlotEff.cxx. References Anp::RecoNu::ENeu(), fDir, Anp::Record::FindTruth(), fRecoEff, fTrueEff, Anp::Record::GetHeader(), Anp::Event::GetNu(), Anp::Header::IsData(), Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), Anp::TruthIter, and Anp::Event::Weight(). 00112 {
00113 if(!fDir || record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00114 {
00115 return true;
00116 }
00117
00118 const TruthIter itruth = record.FindTruth(event);
00119 if(itruth == record.TruthEnd())
00120 {
00121 return true;
00122 }
00123
00124 for(EffVec::iterator it = fRecoEff.begin(); it != fRecoEff.end(); ++it)
00125 {
00126 Handle<CountHist> &hist = *it;
00127
00128 if(!PlotEff::IsMatch(hist, *itruth))
00129 {
00130 continue;
00131 }
00132
00133 if(pass)
00134 {
00135 hist -> Fill(event.GetNu().ENeu(), event.Weight(), event.Weight());
00136 }
00137 else
00138 {
00139 hist -> Fill(event.GetNu().ENeu(), event.Weight(), 0.0);
00140 }
00141 }
00142
00143 for(EffVec::iterator it = fTrueEff.begin(); it != fTrueEff.end(); ++it)
00144 {
00145 Handle<CountHist> &hist = *it;
00146
00147 if(!PlotEff::IsMatch(hist, *itruth))
00148 {
00149 continue;
00150 }
00151
00152 if(pass)
00153 {
00154 hist -> Fill(itruth -> ENeu(), itruth -> Weight(), itruth -> Weight());
00155 }
00156 else
00157 {
00158 hist -> Fill(itruth -> ENeu(), itruth -> Weight(), 0.0);
00159 }
00160 }
00161
00162
00163 return true;
00164 }
|
|
|
Implements Anp::AlgSnarl. Definition at line 48 of file PlotEff.cxx. References Anp::Record::EventBeg(), Anp::Record::EventEnd(), fDir, find(), fTrueEff, fTrueFid, fTruthAll, fTruthFid, fTruthRec, Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), Anp::TruthIter, and Anp::TruthRecoIter. 00049 {
00050 if(!fDir || record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00051 {
00052 return true;
00053 }
00054
00055 for(TruthIter itruth = record.TruthBeg(); itruth != record.TruthEnd(); ++itruth)
00056 {
00057 //
00058 // True fiducial vertex?
00059 //
00060 double weight_all = 0.0;
00061 if(fTrueFid && itruth -> GetVtx().IsFiducial())
00062 {
00063 weight_all = itruth -> Weight();
00064
00065 }
00066 fTruthAll += itruth -> Weight();
00067 fTruthFid += weight_all;
00068
00069 for(EffVec::iterator it = fTrueEff.begin(); it != fTrueEff.end(); ++it)
00070 {
00071 Handle<CountHist> &hist = *it;
00072
00073 if(!PlotEff::IsMatch(hist, *itruth))
00074 {
00075 continue;
00076 }
00077
00078 double weight_sel = 0.0;
00079
00080 for(TruthRecoIter ireco = itruth -> RecoBeg(); ireco != itruth -> RecoEnd(); ++ireco)
00081 {
00082 if(!(ireco -> IsEvent()) || ireco -> ComplAll() < fMinCom)
00083 {
00084 continue;
00085 }
00086
00087 if(std::find(record.EventBeg(), record.EventEnd(), ireco->RecoIndex()) != record.EventEnd())
00088 {
00089 weight_sel += itruth -> Weight();
00090 }
00091 }
00092
00093 hist -> Fill(itruth -> ENeu(), weight_all, weight_sel);
00094 }
00095
00096 for(TruthRecoIter ireco = itruth -> RecoBeg(); ireco != itruth -> RecoEnd(); ++ireco)
00097 {
00098 if(!(ireco -> IsEvent()) || ireco -> ComplAll() < fMinCom)
00099 {
00100 continue;
00101 }
00102
00103 fTruthRec += itruth -> Weight();
00104 }
00105 }
00106
00107 return true;
00108 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 200 of file PlotEff.cxx. References Add(), fDir, fDirName, fRecoEff, fTrueEff, and Anp::GetDir(). 00201 {
00202 if(!dir)
00203 {
00204 return;
00205 }
00206
00207 fDir = Anp::GetDir(fDirName, dir);
00208
00209 //
00210 // Create histograms
00211 //
00212 Add(fTrueEff, 1, 0, Particle::kNuM, "true");
00213 Add(fTrueEff, 1, 0, Particle::kNuMBar, "true");
00214 Add(fTrueEff, 1, 0, Particle::kNuMAny, "true");
00215 Add(fTrueEff, 0, 0, Particle::kAll, "true");
00216
00217 Add(fTrueEff, 1, 1001, Particle::kNuM, "true");
00218 Add(fTrueEff, 1, 1002, Particle::kNuM, "true");
00219 Add(fTrueEff, 1, 1003, Particle::kNuM, "true");
00220
00221 Add(fRecoEff, 1, 0, Particle::kNuM, "reco");
00222 Add(fRecoEff, 1, 0, Particle::kNuMBar, "reco");
00223 Add(fRecoEff, 1, 0, Particle::kNuMAny, "reco");
00224 Add(fRecoEff, 0, 0, Particle::kAll, "reco");
00225
00226 Add(fRecoEff, 1, 1001, Particle::kNuM, "reco");
00227 Add(fRecoEff, 1, 1002, Particle::kNuM, "reco");
00228 Add(fRecoEff, 1, 1003, Particle::kNuM, "reco");
00229 }
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 69 of file PlotEff.h. Referenced by Config(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 67 of file PlotEff.h. Referenced by Config(). |
1.3.9.1