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

Public Member Functions | |
| PlotShortSelect () | |
| virtual | ~PlotShortSelect () |
| bool | Run (Record &record) |
| void | Set (TDirectory *dir) |
| void | Config (const Registry ®) |
Private Types | |
| typedef std::map< std::string, TH1 * > | MapTH1 |
| typedef std::map< std::string, TH2 * > | MapTH2 |
Private Member Functions | |
| bool | Plot (const TruthIter truth, const Record &record) |
| TH1 * | GetTH1 (const std::string &key, const std::string &name="", TDirectory *dir=0) |
| TH2 * | GetTH2 (const std::string &key, const std::string &name="", TDirectory *dir=0, const std::string &plottype="unknown") |
| Particle::Particle_t | Particle (const Track &track, const Record &record) const |
Private Attributes | |
| std::string | fDirName |
| TDirectory * | fDir |
| int | fPid |
| int | fLowPid |
| int | fSelector |
| double | fPidCut |
| double | fLowCut |
| double | fSelCut |
| double | fMinCom |
| bool | fErase |
| bool | fPlot |
| bool | fTrueFid |
| int | fNMiss |
| std::vector< int > | fKeys |
| std::map< std::string, TH1 * > | fMapTH1 |
| std::map< std::string, TH2 * > | fMapTH2 |
|
|
Definition at line 50 of file PlotShortSelect.h. |
|
|
Definition at line 51 of file PlotShortSelect.h. |
|
|
Definition at line 27 of file PlotShortSelect.cxx. 00028 :fDirName("shorteff"), 00029 fDir(0), 00030 fPid(4280), 00031 fLowPid(2695), 00032 fSelector(19480), 00033 fPidCut(0.4), 00034 fLowCut(0.3), 00035 fSelCut(0.8), 00036 fMinCom(0.9), 00037 fErase(false), 00038 fPlot(true), 00039 fTrueFid(true), 00040 fNMiss(0) 00041 { 00042 }
|
|
|
Definition at line 45 of file PlotShortSelect.cxx. 00046 {
00047 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 85 of file PlotShortSelect.cxx. References fDirName, fLowCut, fLowPid, fPid, fPidCut, fSelCut, fSelector, fTrueFid, Registry::Get(), Registry::KeyExists(), Anp::Read(), and reg. 00086 {
00087 //
00088 // Read string configurations
00089 //
00090 Anp::Read(reg,"PlotShortSelectDirName", fDirName);
00091 reg.Get("PlotShortSelectPid",fPid);
00092 reg.Get("PlotShortSelectLowPid",fLowPid);
00093 reg.Get("PlotShortSelectSelector", fSelector);
00094 reg.Get("PlotShortSelectPidCut",fPidCut);
00095 reg.Get("PlotShortSelectLowPidCut",fLowCut);
00096 reg.Get("PlotShortSelectSelCut", fSelCut);
00097 Anp::Read(reg, "PlotShortSelectFiducial", fTrueFid) ;
00098 if(reg.KeyExists("PrintConfig"))
00099 {
00100 cout << "PlotShortSelect::Config" << endl
00101 << " DirName = " << fDirName << endl
00102 << " Pid = "<<fPid<<endl
00103 << " LowPid = "<<fLowPid<<endl
00104 << " Selector = "<<fSelector<<endl
00105 << " PidCut ="<< fPidCut<< endl
00106 << " LowPidCut="<<fLowCut<< endl
00107 << " SelectorCut="<<fSelCut<<endl
00108 << " TrueFiducial = " <<fTrueFid<<endl;
00109 }
00110 }
|
|
||||||||||||||||
|
Definition at line 251 of file PlotShortSelect.cxx. References fMapTH1, and Anp::SetDir(). 00252 {
00253 stringstream pathss;
00254 pathss<<dir->GetPath()<<"/"<<key;
00255 string path = pathss.str();
00256 MapTH1::iterator hit = fMapTH1.find(path);
00257 if( hit==fMapTH1.end())
00258 {
00259 TH1 *h = HistMan::Instance().CreateTH1(key, "short_passed");
00260 if(h)
00261 {
00262 Anp::SetDir(h, dir, name);
00263 }
00264 else
00265 {
00266 ++fNMiss;
00267 }
00268 hit = fMapTH1.insert(MapTH1::value_type(path, h)).first;
00269 }
00270 return hit->second;
00271 }
|
|
||||||||||||||||||||
|
Definition at line 274 of file PlotShortSelect.cxx. References fMapTH2, and Anp::SetDir(). 00275 {
00276 MapTH2::iterator hit = fMapTH2.find(key);
00277 if(hit == fMapTH2.end())
00278 {
00279 TH2* h = HistMan::Instance().CreateTH2(key,plottype);
00280 if(h)
00281 {
00282 Anp::SetDir(h, dir, name);
00283 }
00284 else
00285 {
00286 ++fNMiss;
00287 }
00288 hit = fMapTH2.insert(MapTH2::value_type(key, h)).first;
00289 }
00290
00291 return hit -> second;
00292 }
|
|
||||||||||||
|
Definition at line 295 of file PlotShortSelect.cxx. References Anp::Record::FindStdHep(), Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Record::StdHepBeg(), Anp::Record::StdHepEnd(), and Anp::StdHepIter. 00296 {
00297 if(record.GetHeader().IsData())
00298 {
00299 return Particle::kUnknown;
00300 }
00301
00302 if(record.StdHepBeg() != record.StdHepEnd())
00303 {
00304 const StdHepIter stdhep = record.FindStdHep(track);
00305 if(stdhep == record.StdHepEnd())
00306 {
00307 return Particle::kUnknown;
00308 }
00309
00310 if(stdhep -> Particle() == Particle::kMuonPos ||
00311 stdhep -> Particle() == Particle::kMuonNeg)
00312 {
00313 return Particle::kMuon;
00314 }
00315 else
00316 {
00317
00318 return Particle::kNotMuon;
00319 }
00320 }
00321
00322 return Particle::kUnknown;
00323 }
|
|
||||||||||||
|
Definition at line 114 of file PlotShortSelect.cxx. References Anp::Event::DataAt(), Anp::Record::EventBeg(), Anp::Record::EventEnd(), Anp::EventIter, fDir, find(), Anp::Record::FindEvent(), fLowPid, fPid, fSelector, fTrueFid, Anp::GetDir(), Anp::Event::GetRecoNu(), Anp::Event::KeyExists(), Anp::LongestTrack(), Anp::Record::TrackEnd(), Anp::TrackIter, Anp::TruthRecoIter, and Anp::RecoNu::Y(). 00115 {
00116 double weight_all = 1.0;
00117
00118 if(fTrueFid && truth->GetVtx().IsFiducial())
00119 {
00120 weight_all = truth->Weight();
00121 }
00122 if(!fDir || !fPlot)
00123 {
00124 return false;
00125 }
00126 EventIter event = record.EventEnd();
00127 std::map<std::string, double> hist_map;
00128 bool withtrack =false;
00129 bool pid1pass=false;
00130 bool pid2pass=false;
00131 bool pid3pass=false;
00132 double weight_sel= 0.0;
00133 double weight_evt = 0.0;
00134 for(TruthRecoIter ireco = truth->RecoBeg(); ireco !=truth->RecoEnd(); ++ireco)
00135 {
00136 if(!(ireco -> IsEvent()) || ireco -> ComplAll() < fMinCom)
00137 {
00138 continue;
00139 }
00140
00141 if(std::find(record.EventBeg(), record.EventEnd(), ireco->RecoIndex()) != record.EventEnd())
00142 {
00143 weight_sel += truth->Weight();
00144
00145 event = record.FindEvent(ireco->RecoIndex());
00146 weight_evt += event->Weight();
00147 }
00148 }
00149
00150 const TrackIter track = Anp::LongestTrack((*event),record);
00151 string eventdir = "unknown";
00152 if(truth->IsCC()){
00153 eventdir = "cc";
00154 hist_map["iaction"] =1;
00155 }
00156 else if(truth->IsNC()){
00157 eventdir = "nc";
00158 hist_map["iaction"]=0;
00159 }
00160 else{
00161 eventdir="other";
00162 hist_map["iaction"]=2;
00163 }
00164
00165 TDirectory* evtdir = Anp::GetDir(eventdir,fDir); // cc or nc (or other)
00166
00167 TH1* recoE =(TH1*) PlotShortSelect::GetTH1("reco_enu_base","reco_enu_base", evtdir);
00168 if(recoE && event!=record.EventEnd())recoE->Fill(event->Gev(), weight_all);
00169
00170 TH1* trueE =(TH1*) PlotShortSelect::GetTH1("true_enu_base","true_enu_base", evtdir);
00171 if(trueE) trueE->Fill(truth->Energy(), weight_all);
00172
00173 TH1* recoY =(TH1*) PlotShortSelect::GetTH1("reco_y_base","reco_y_base", evtdir);
00174 Event evt = *event;
00175 RecoNu &rnu = (evt).GetRecoNu();
00176 if(recoY) recoY->Fill(rnu.Y(), weight_all);
00177
00178 //
00179 // Get Event base quantities
00180 //
00181
00182 hist_map["reco_enu"] = event->Gev();
00183 hist_map["true_enu"] = truth->Energy();
00184 hist_map["reco_y"] = (evt.GetRecoNu()).Y();
00185
00186
00187 if(track==(record.TrackEnd()))
00188 {
00189 if(evt.KeyExists(fSelector) && evt.DataAt(fSelector) > fSelCut) pid3pass=true;
00190 }
00191 else
00192 {
00193 //
00194 // event has a track, see if it passes rustem's or lowE kNN
00195 //
00196 withtrack=true;
00197 const Particle::Particle_t particle = PlotShortSelect::Particle(*track, record);
00198 if(!track->KeyExists(fPid) && !track->KeyExists(fLowPid)) return false;
00199
00200 if(track->KeyExists(fPid) && track->DataAt(fPid) > fPidCut) pid1pass =true;
00201 if(track->KeyExists(fLowPid) && track->DataAt(fLowPid) >fLowCut)pid2pass =true;
00202 if(!pid1pass && !pid2pass) return false;
00203
00204 if(particle == Particle::kMuonPos || particle== Particle::kMuonNeg)hist_map["track_id"] = 1;
00205 else hist_map["track_id"] =0;
00206 }
00207
00208 //
00209 // Fill Histograms
00210 //
00211
00212 string passdir = "unknown";
00213 if(track==record.TrackEnd()) passdir = "no-track";
00214 else passdir = "track";
00215
00216 //
00217 //
00218 //
00219
00220 TDirectory* pasdir =Anp::GetDir(passdir,evtdir); // track or no-track event
00221 TDirectory* pid1dir =Anp::GetDir("firstpass",evtdir); // passed pid1
00222 TDirectory* pid2dir =Anp::GetDir("secondpass",evtdir); // passed pid2 but not pid1
00223 TDirectory* pid3dir =Anp::GetDir("thirdpass",evtdir); // passed pid3 but not pid2 or pid1
00224 for( std::map<std::string, double>::iterator it = hist_map.begin(); it!=hist_map.end(); it++)
00225 {
00226 TH1* h =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, evtdir);
00227 if(h)h->Fill(it->second, weight_sel);
00228
00229 TH1* j =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pasdir);
00230 if(j)j->Fill(it->second, weight_sel);
00231
00232 if(pid1pass) {
00233 TH1* k =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pid1dir);
00234 if(k)k->Fill(it->second, weight_sel);
00235 }
00236 else if(pid2pass) {
00237 TH1* l =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pid2dir);
00238 if(l)l->Fill(it->second, weight_sel);
00239 }
00240 else if(pid3pass) {
00241 TH1* m =(TH1*) PlotShortSelect::GetTH1(it->first,it->first, pid3dir);
00242 if(m)m->Fill(it->second, weight_sel);
00243 }
00244
00245 }
00246
00247 return true;
00248 }
|
|
|
Implements Anp::AlgSnarl. Definition at line 50 of file PlotShortSelect.cxx. References Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::TruthIter. 00051 {
00052 if( record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd()) return true;
00053 for(TruthIter itruth = record.TruthBeg(); itruth != record.TruthEnd(); ++itruth)
00054 {
00055 if(!PlotShortSelect::Plot(itruth, record) && fErase)
00056 {
00057 // ievent= record.Erase(ievent);
00058 }
00059 }
00060 return true;
00061 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 64 of file PlotShortSelect.cxx. References fDir, fDirName, fNMiss, fPlot, and Anp::GetDir(). 00065 {
00066
00067 if(!dir)
00068 {
00069 return;
00070 }
00071
00072 fDir = Anp::GetDir(fDirName, dir);
00073
00074 if(fNMiss == 0)
00075 {
00076 fPlot = true;
00077 }
00078 else
00079 {
00080 cerr << "PlotShortSelect::Set - missed " << fNMiss << " histograms" << endl;
00081 }
00082 }
|
|
|
Definition at line 56 of file PlotShortSelect.h. |
|
|
Definition at line 55 of file PlotShortSelect.h. |
|
|
Definition at line 65 of file PlotShortSelect.h. |
|
|
Definition at line 70 of file PlotShortSelect.h. |
|
|
Definition at line 62 of file PlotShortSelect.h. Referenced by Config(). |
|
|
Definition at line 59 of file PlotShortSelect.h. |
|
|
Definition at line 72 of file PlotShortSelect.h. Referenced by GetTH1(). |
|
|
Definition at line 73 of file PlotShortSelect.h. Referenced by GetTH2(). |
|
|
Definition at line 64 of file PlotShortSelect.h. |
|
|
Definition at line 68 of file PlotShortSelect.h. Referenced by Set(). |
|
|
Definition at line 58 of file PlotShortSelect.h. |
|
|
Definition at line 61 of file PlotShortSelect.h. Referenced by Config(). |
|
|
Definition at line 66 of file PlotShortSelect.h. Referenced by Set(). |
|
|
Definition at line 63 of file PlotShortSelect.h. Referenced by Config(). |
|
|
Definition at line 60 of file PlotShortSelect.h. |
|
|
Definition at line 67 of file PlotShortSelect.h. |
1.3.9.1