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

Public Types | |
| typedef Handle< Plot::Data > | PlotHandle |
Public Member Functions | |
| PlotData () | |
| virtual | ~PlotData () |
| bool | Run (Record &record) |
| bool | Run (Event &event, const Record &record, const bool pass) |
| void | Config (const Registry ®) |
| void | Set (TDirectory *dir) |
Private Member Functions | |
| void | Plot (const Event &event, const Record &record, double weight) |
| void | Plot (const Track &track, const Record &record, double weight) |
| PlotHandle | Get (const std::string &option) |
| Particle::Particle_t | Particle (const Track &track, const Record &record, int booltype) const |
Private Attributes | |
| TDirectory * | fDir |
| std::string | fDirName |
| bool | fPlot1d |
| bool | fPlot2d |
| bool | fPlotAll |
| bool | fPlotEvent |
| bool | fPlotReson |
| bool | fPlotSign |
| bool | fPlotTrack |
| bool | fPlotTruth |
| bool | fTakeTrack |
| bool | fUseWeight |
| unsigned int | fCorrSize |
| unsigned int | fFillFrac |
| unsigned int | fFillNbin |
| unsigned int | fFillSize |
| int | fMuonKey |
| int | fPass |
| std::vector< int > | fKeys |
| std::map< std::string, PlotHandle > | fPlot |
|
|
Definition at line 39 of file PlotData.h. Referenced by Get(). |
|
|
Definition at line 29 of file PlotData.cxx. 00030 :fDir(0), 00031 fDirName("data"), 00032 fPlot1d(true), 00033 fPlot2d(false), 00034 fPlotAll(false), 00035 fPlotEvent(true), 00036 fPlotReson(false), 00037 fPlotSign(false), 00038 fPlotTrack(false), 00039 fPlotTruth(true), 00040 fTakeTrack(false), 00041 fUseWeight(true), 00042 fCorrSize(0), 00043 fFillFrac(1), 00044 fFillNbin(200), 00045 fFillSize(800), 00046 fMuonKey(7000), 00047 fPass(-1) 00048 { 00049 }
|
|
|
Definition at line 52 of file PlotData.cxx. 00053 {
00054 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 149 of file PlotData.cxx. References fCorrSize, fDirName, fFillFrac, fFillNbin, fFillSize, fKeys, fMuonKey, fPass, fPlot1d, fPlot2d, fPlotAll, fPlotEvent, fPlotReson, fPlotSign, fPlotTrack, fPlotTruth, fTakeTrack, fUseWeight, Registry::Get(), Registry::KeyExists(), Anp::Read(), reg, and UtilString::StringTok(). 00150 {
00151 //
00152 // Configure self
00153 //
00154
00155 reg.Get("PlotDataPass", fPass);
00156 Anp::Read(reg, "PlotData1d", fPlot1d);
00157 Anp::Read(reg, "PlotData2d", fPlot2d);
00158 Anp::Read(reg, "PlotDataAll", fPlotAll);
00159 Anp::Read(reg, "PlotDataEvent", fPlotEvent);
00160 Anp::Read(reg, "PlotDataReson", fPlotReson);
00161 Anp::Read(reg, "PlotDataSign", fPlotSign);
00162 Anp::Read(reg, "PlotDataTrack", fPlotTrack);
00163 Anp::Read(reg, "PlotDataTruth", fPlotTruth);
00164 Anp::Read(reg, "PlotDataTakeTrack", fTakeTrack);
00165 Anp::Read(reg, "PlotDataWeight", fUseWeight);
00166
00167 int value_int = -1;
00168 if(reg.Get("PlotDataCorrSize", value_int) && value_int >= 0)
00169 {
00170 fCorrSize = static_cast<unsigned int>(value_int);
00171 }
00172
00173 value_int = -1;
00174 if(reg.Get("PlotDataFillFrac", value_int) && value_int >= 0 && value_int < 100)
00175 {
00176 fFillFrac = static_cast<unsigned int>(value_int);
00177 }
00178
00179 value_int = -1;
00180 if(reg.Get("PlotDataFillNbin", value_int) && value_int >= 2)
00181 {
00182 fFillNbin = static_cast<unsigned int>(value_int);
00183 }
00184
00185 value_int = -1;
00186 if(reg.Get("PlotDataFillSize", value_int) && value_int >= 100)
00187 {
00188 fFillSize = static_cast<unsigned int>(value_int);
00189 }
00190
00191 const char *value_char = 0;
00192 if(reg.Get("PlotDataDirName", value_char))
00193 {
00194 fDirName = value_char;
00195 }
00196
00197 value_char = 0;
00198 if(reg.Get("PlotDataKeys", value_char))
00199 {
00200 vector<string> svec;
00201 UtilString::StringTok(svec, value_char, ", ");
00202 for(vector<string>::const_iterator sit = svec.begin(); sit != svec.end(); ++sit)
00203 {
00204 const short key = std::atoi(sit -> c_str());
00205 if(key != 0)
00206 {
00207 fKeys.push_back(key);
00208 }
00209 }
00210
00211 std::sort(fKeys.begin(), fKeys.end());
00212 }
00213
00214 if(reg.KeyExists("PrintConfig"))
00215 {
00216 cout << "PlotData::Config" << endl
00217 << " DirName = " << fDirName << endl
00218 << " Plot1d = " << fPlot1d << endl
00219 << " Plot2d = " << fPlot2d << endl
00220 << " PlotAll = " << fPlotAll << endl
00221 << " PlotEvent = " << fPlotEvent << endl
00222 << " PlotReson = " << fPlotReson << endl
00223 << " PlotSign = " << fPlotSign << endl
00224 << " PlotTrack = " << fPlotTrack << endl
00225 << " PlotTruth = " << fPlotTruth << endl
00226 << " TakeTrack = " << fTakeTrack << endl
00227 << " UseWeight = " << fUseWeight << endl
00228 << " CorrSize = " << fCorrSize << endl
00229 << " FillFrac = " << fFillFrac << endl
00230 << " FillNbin = " << fFillNbin << endl
00231 << " FillSize = " << fFillSize << endl
00232 << " MuonKey = " << fMuonKey << endl
00233 << " Added " << fKeys.size() << " keys" << endl;
00234 }
00235 }
|
|
|
Definition at line 429 of file PlotData.cxx. References fCorrSize, fDir, fFillFrac, fFillNbin, fFillSize, fPlot, fPlot1d, fPlot2d, fPlotAll, Anp::GetDir(), PlotHandle, and Set(). Referenced by Plot(), and Set(). 00430 {
00431 //
00432 // Find (create first time) and return plot object
00433 //
00434
00435 map<string, PlotHandle>::iterator pit = fPlot.find(path);
00436 if(pit == fPlot.end())
00437 {
00438 TDirectory *dir = Anp::GetDir(path, fDir);
00439
00440 PlotHandle plot(new Plot::Data());
00441
00442 plot -> Set("CorrSize", fCorrSize);
00443 plot -> Set("FillFrac", fFillFrac);
00444 plot -> Set("FillNbin", fFillNbin);
00445 plot -> Set("FillSize", fFillSize);
00446 plot -> Set("Plot1d", fPlot1d);
00447 plot -> Set("Plot2d", fPlot2d);
00448 plot -> Set("PlotAll", fPlotAll);
00449 plot -> Set(dir);
00450
00451 pit = fPlot.insert(map<string, PlotHandle>::value_type(path, plot)).first;
00452 }
00453
00454 return pit -> second;
00455 }
|
|
||||||||||||||||
|
Definition at line 458 of file PlotData.cxx. References Anp::Record::FindStdHep(), fMuonKey, Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Track::KeyExists(), Anp::Record::StdHepBeg(), Anp::Record::StdHepEnd(), and Anp::StdHepIter. Referenced by Plot(). 00459 {
00460 if(record.GetHeader().IsData())
00461 {
00462 return Particle::kUnknown;
00463 }
00464
00465 if(record.StdHepBeg() != record.StdHepEnd())
00466 {
00467 const StdHepIter stdhep = record.FindStdHep(track);
00468 if(stdhep == record.StdHepEnd())
00469 {
00470 return Particle::kUnknown;
00471 }
00472
00473 if(stdhep -> Particle() == Particle::kMuonPos ||
00474 stdhep -> Particle() == Particle::kMuonNeg)
00475 {
00476 return Particle::kMuon;
00477 }
00478 else if(booltype==1)
00479 {
00480 // Made to give particle type
00481 return stdhep->Particle();
00482 }
00483 else
00484 {
00485 // If you want a boolean-like answer is/not muon (default)
00486 return Particle::kNotMuon;
00487 }
00488 }
00489 else if(track.KeyExists(fMuonKey))
00490 {
00491 const float muon = track[fMuonKey];
00492
00493 if (muon > +0.9 && muon < +1.1) return Particle::kMuon;
00494 else if(muon > -0.1 && muon < +0.1) return Particle::kNotMuon;
00495 }
00496
00497 return Particle::kUnknown;
00498 }
|
|
||||||||||||||||
|
Definition at line 366 of file PlotData.cxx. References Anp::Track::DataBeg(), Anp::Track::DataEnd(), Anp::Record::FindStdHep(), fPlotTruth, Get(), Anp::Record::GetHeader(), Anp::Header::IsData(), Particle(), Anp::Record::StdHepEnd(), and Anp::StdHepIter. 00367 {
00368 //
00369 // Plot Track data
00370 //
00371 if(track.DataBeg() == track.DataEnd())
00372 {
00373 return;
00374 }
00375
00376 Get("track_all") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00377
00378 if(fPlotTruth && !record.GetHeader().IsData())
00379 {
00380 const Particle::Particle_t particle = PlotData::Particle(track, record,0);
00381
00382 if(particle == Particle::kMuon)
00383 {
00384 Get("track_muon") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00385 }
00386 else if(particle == Particle::kNotMuon)
00387 {
00388 Get("track_other") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00389 //
00390 // Added to give more distinctions to track plots
00391 // need to define partitype
00392 const Particle::Particle_t partitype = PlotData::Particle(track,record,1);
00393 if(partitype == Particle::kProton){
00394 Get("track_proton") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00395 }
00396 else if(partitype== Particle:: kPiPlus || partitype==Particle::kPiMinus){
00397 Get("track_pion") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00398 }
00399 else if(partitype== Particle:: kPi0){
00400 Get("track_pi0") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00401 }
00402
00403 //
00404 }
00405 else
00406 {
00407 Get("track_unknown") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00408 }
00409
00410 if(fPlotSign)
00411 {
00412 const StdHepIter stdhep = record.FindStdHep(track);
00413 if(stdhep != record.StdHepEnd())
00414 {
00415 if(stdhep -> Particle() == Particle::kMuonPos)
00416 {
00417 Get("track_mupos") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00418 }
00419 else if(stdhep -> Particle() == Particle::kMuonNeg)
00420 {
00421 Get("track_muneg") -> Fill(track.DataBeg(), track.DataEnd(), weight);
00422 }
00423 }
00424 }
00425 }
00426 }
|
|
||||||||||||||||
|
Definition at line 255 of file PlotData.cxx. References Anp::Event::DataBeg(), Anp::Event::DataEnd(), Anp::Record::FindTruth(), fPlotReson, fPlotTruth, fTakeTrack, Get(), Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::LongestTrack(), Particle(), Anp::Record::TrackEnd(), Anp::TrackIter, Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::TruthIter. 00256 {
00257 //
00258 // Make plots for Event and Track (optional) data
00259 //
00260
00261 const TrackIter itrack = Anp::LongestTrack(event, record);
00262 if(fTakeTrack && itrack != record.TrackEnd())
00263 {
00264 Get("all/track") -> Fill(itrack -> DataBeg(), itrack -> DataEnd(), weight);
00265 }
00266
00267 Get("all") -> Fill(event.DataBeg(), event.DataEnd(), weight);
00268
00269 //
00270 // Make separate plots for different truth categories
00271 //
00272 if(!fPlotTruth || record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00273 {
00274 return;
00275 }
00276
00277 const TruthIter truth = record.FindTruth(event);
00278 if(truth == record.TruthEnd())
00279 {
00280 return;
00281 }
00282
00283 string ipath = "unknown";
00284 if(truth -> IsCC())
00285 {
00286 ipath = "cc";
00287 }
00288 else if(truth -> IsNC())
00289 {
00290 ipath = "nc";
00291 }
00292
00293 Get(ipath) -> Fill(event.DataBeg(), event.DataEnd(), weight);
00294
00295 if(fTakeTrack && itrack != record.TrackEnd())
00296 {
00297 Get(ipath + "/track") -> Fill(itrack -> DataBeg(), itrack -> DataEnd(), weight);
00298 }
00299
00300 if(itrack != record.TrackEnd())
00301 {
00302 const Particle::Particle_t particle = Particle(*itrack, record,0);
00303
00304 string spath;
00305 if(particle == Particle::kMuon)
00306 {
00307 spath = "muon";
00308 }
00309 else if(particle == Particle::kNotMuon)
00310 {
00311 spath = "other";
00312 }
00313 else
00314 {
00315 spath = "unknown";
00316 }
00317
00318 Get(spath) -> Fill(event.DataBeg(), event.DataEnd(), weight);
00319
00320 if(fTakeTrack)
00321 {
00322 Get(spath + "/track") -> Fill(itrack -> DataBeg(), itrack -> DataEnd(), weight);
00323 }
00324
00325 if(truth -> IsCC())
00326 {
00327 spath = "cc_" + spath;
00328 Get(spath) -> Fill(event.DataBeg(), event.DataEnd(), weight);
00329
00330 if(fTakeTrack)
00331 {
00332 Get(spath + "/track") -> Fill(itrack -> DataBeg(), itrack -> DataEnd(), weight);
00333 }
00334 }
00335 }
00336
00337 if(fPlotReson && truth -> IsCC())
00338 {
00339 string rpath;
00340 if(truth -> Resonance() == 1001)
00341 {
00342 rpath = "cc_qes";
00343 }
00344 else if(truth -> Resonance() == 1002)
00345 {
00346 rpath = "cc_res";
00347 }
00348 else if(truth -> Resonance() == 1003)
00349 {
00350 rpath = "cc_dis";
00351 }
00352
00353 if(!rpath.empty())
00354 {
00355 Get(rpath) -> Fill(event.DataBeg(), event.DataEnd(), weight);
00356
00357 if(fTakeTrack && itrack != record.TrackEnd())
00358 {
00359 Get(rpath + "/track") -> Fill(itrack -> DataBeg(), itrack -> DataEnd(), weight);
00360 }
00361 }
00362 }
00363 }
|
|
||||||||||||||||
|
Implements Anp::AlgEvent. Definition at line 115 of file PlotData.cxx. References Anp::Event::MatchTrack(), Anp::Record::TrackBeg(), Anp::Record::TrackEnd(), Anp::TrackIter, and Anp::Event::Weight(). 00116 {
00117 //
00118 // Plot DataItem objects from track and event,
00119 // for each pair (key, data) plot all data at fixed key.
00120 //
00121 if(!pass || !fDir) return true;
00122
00123 //
00124 // Use Event weight?
00125 //
00126 double weight = 1.0;
00127 if(fUseWeight) weight = event.Weight();
00128
00129 if(fPlotEvent)
00130 {
00131 PlotData::Plot(event, record, weight);
00132 }
00133
00134 if(fPlotTrack)
00135 {
00136 for(TrackIter itrack = record.TrackBeg(); itrack != record.TrackEnd(); ++itrack)
00137 {
00138 if(event.MatchTrack(itrack -> TrackIndex()))
00139 {
00140 PlotData::Plot(*itrack, record, weight);
00141 }
00142 }
00143 }
00144
00145 return true;
00146 }
|
|
|
Implements Anp::AlgSnarl. Definition at line 57 of file PlotData.cxx. References Anp::Record::EventBeg(), Anp::Record::EventEnd(), Anp::EventIter, fPass, Anp::Record::TrackBeg(), Anp::Record::TrackEnd(), and Anp::TrackIter. 00058 {
00059 //
00060 // Plot DataItem objects from track and event,
00061 // for each pair (key, data) plot all data at fixed key.
00062 //
00063 if(!fDir) return true;
00064
00065 if(fPlotEvent)
00066 {
00067 for(EventIter ievent = record.EventBeg(); ievent != record.EventEnd(); ++ievent)
00068 {
00069 if(fPass>0)
00070 {
00071 if(!ievent->KeyExists(fPass)){
00072 cerr<<" PlotData::Run - asking for pass key but does not exist"<<endl;
00073 }
00074 else if(ievent->DataAt(fPass)<=0) continue;
00075 }
00076
00077 if(fUseWeight)
00078 {
00079 PlotData::Plot(*ievent, record, ievent -> Weight());
00080 }
00081 else
00082 {
00083 PlotData::Plot(*ievent, record, 1.0);
00084 }
00085 }
00086 }
00087
00088 if(fPlotTrack)
00089 {
00090 for(TrackIter itrack = record.TrackBeg(); itrack != record.TrackEnd(); ++itrack)
00091 {
00092 if(fPass>0)
00093 {
00094 if(!itrack->KeyExists(fPass)){
00095 cerr<<" PlotData::Run - asking for pass key but does not exist"<<endl;
00096 }
00097 else if(itrack->DataAt(fPass)<=0) continue;
00098 }
00099
00100 if(fUseWeight)
00101 {
00102 PlotData::Plot(*itrack, record, itrack -> Weight());
00103 }
00104 else
00105 {
00106 PlotData::Plot(*itrack, record, 1.0);
00107 }
00108 }
00109 }
00110
00111 return true;
00112 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 238 of file PlotData.cxx. References fDir, fDirName, Get(), and Anp::GetDir(). Referenced by Get(). 00239 {
00240 //
00241 // Get pointer to TDirectory where histograms will be saved
00242 //
00243 if(!dir) return;
00244
00245 if(dir -> Get(fDirName.c_str()))
00246 {
00247 cerr << "PlotData::Set - TDirectory already exists: " << fDirName << endl;
00248 return;
00249 }
00250
00251 fDir = Anp::GetDir(fDirName.c_str(), dir);
00252 }
|
|
|
Definition at line 67 of file PlotData.h. |
|
|
Definition at line 52 of file PlotData.h. |
|
|
Definition at line 54 of file PlotData.h. |
|
|
Definition at line 68 of file PlotData.h. |
|
|
Definition at line 69 of file PlotData.h. |
|
|
Definition at line 70 of file PlotData.h. |
|
|
Definition at line 74 of file PlotData.h. Referenced by Config(). |
|
|
Definition at line 72 of file PlotData.h. Referenced by Config(), and Particle(). |
|
|
Definition at line 73 of file PlotData.h. |
|
|
Definition at line 76 of file PlotData.h. Referenced by Get(). |
|
|
Definition at line 56 of file PlotData.h. |
|
|
Definition at line 57 of file PlotData.h. |
|
|
Definition at line 58 of file PlotData.h. |
|
|
Definition at line 59 of file PlotData.h. Referenced by Config(). |
|
|
Definition at line 60 of file PlotData.h. |
|
|
Definition at line 61 of file PlotData.h. Referenced by Config(). |
|
|
Definition at line 62 of file PlotData.h. Referenced by Config(). |
|
|
Definition at line 63 of file PlotData.h. |
|
|
Definition at line 64 of file PlotData.h. |
|
|
Definition at line 65 of file PlotData.h. Referenced by Config(). |
1.3.9.1