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

Public Types | |
| typedef std::map< std::pair< int, int >, Select::Count > | KeyMap |
| typedef std::map< unsigned int, KeyMap > | CountMap |
Public Member Functions | |
| SelectCount () | |
| virtual | ~SelectCount () |
| bool | Run (Event &event, const Record &record, bool pass) |
| void | Config (const Registry ®) |
| void | Set (TDirectory *dir) |
| void | End (const DataBlock &block) |
Private Member Functions | |
| Select::Count & | GetCount (int iaction, Particle::Particle_t particle, int select, const std::string &opt="") |
| void | Print (int iaction, const std::string &opt, std::ostream &out) const |
Private Attributes | |
| TDirectory * | fDir |
| std::string | fDirName |
| std::string | fAlgName |
| Registry | fConfig |
| bool | fPrint |
| bool | fWeight |
| bool | fTotalOnlyNC |
| bool | fTotalOnlyNue |
| int | fRun |
| int | fSnarl |
| int | fIndex |
| unsigned int | fCount |
| unsigned int | fNameWidth |
| unsigned int | fNumbWidth |
| CountMap | fMap |
|
|
Definition at line 60 of file SelectCount.h. |
|
|
Definition at line 59 of file SelectCount.h. Referenced by End(), GetCount(), and Print(). |
|
|
Definition at line 51 of file SelectCount.cxx. References fConfig, and Registry::Set(). 00052 :fDir(0), 00053 fDirName(""), 00054 fAlgName(), 00055 fConfig(false), 00056 fPrint(true), 00057 fWeight(true), 00058 fTotalOnlyNC(true), 00059 fTotalOnlyNue(true), 00060 fRun(-1), 00061 fSnarl(-1), 00062 fIndex(-1), 00063 fCount(0), 00064 fNameWidth(0), 00065 fNumbWidth(0), 00066 fMap() 00067 { 00068 fConfig.Set("RunAlgEventPrint", "no"); 00069 }
|
|
|
Definition at line 72 of file SelectCount.cxx. 00073 {
00074 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 127 of file SelectCount.cxx. References fAlgName, fConfig, fDirName, fPrint, fTotalOnlyNC, fTotalOnlyNue, fWeight, Anp::GetString(), Registry::KeyExists(), Registry::Merge(), Anp::Read(), and reg. Referenced by GetCount(). 00128 {
00129 fConfig.Merge(reg);
00130
00131 pair<string, bool> result;
00132
00133 result = Anp::GetString("SelectCount", "DirName", reg);
00134 if(result.second)
00135 {
00136 fDirName = result.first;
00137 }
00138
00139 result = Anp::GetString("SelectCount", "AlgName", reg);
00140 if(result.second)
00141 {
00142 fAlgName = result.first;
00143 }
00144
00145 Anp::Read(reg, "SelectCountPrint", fPrint);
00146 Anp::Read(reg, "SelectCountWeight", fWeight);
00147
00148 if(reg.KeyExists("PrintConfig"))
00149 {
00150 cout << "SelectCount::Config" << endl
00151 << " DirName = " << fDirName << endl
00152 << " AlgName = " << fAlgName << endl
00153 << " Print = " << fPrint << endl
00154 << " Weight = " << fWeight << endl
00155 << " TotalOnlyNC = " << fTotalOnlyNC << endl
00156 << " TotalOnlyNue = " << fTotalOnlyNue << endl;
00157 }
00158 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 161 of file SelectCount.cxx. References Anp::AlgCaddy< T >::alg, count, Anp::Select::Count::fail, fMap, fNameWidth, fNumbWidth, KeyMap, Anp::NameWidth(), Anp::NumbWidth(), Anp::Select::Count::pass, Print(), and Anp::Handle< T >::valid(). 00162 {
00163 vector<AlgCaddy<AlgEvent> > avec;
00164
00165 for(CountMap::iterator cit = fMap.begin(); cit != fMap.end(); ++cit)
00166 {
00167 KeyMap &kmap = cit -> second;
00168
00169 for(KeyMap::iterator kit = kmap.begin(); kit != kmap.end(); ++kit)
00170 {
00171 Select::Count &count = kit -> second;
00172
00173 if(count.pass.alg.valid())
00174 {
00175 count.pass.alg -> End(block);
00176 }
00177 if(count.fail.alg.valid())
00178 {
00179 count.fail.alg -> End(block);
00180 }
00181
00182 avec.push_back(count.pass);
00183 avec.push_back(count.fail);
00184 }
00185 }
00186
00187 fNameWidth = Anp::NameWidth(avec);
00188 fNumbWidth = Anp::NumbWidth(avec);
00189
00190 avec.clear();
00191
00192 stringstream out;
00193
00194 out << "Printing number of passed events" << endl;
00195
00196 Print(-1, "pass", out); // all interactions types
00197 Print( 0, "pass", out); // NC interactions
00198 Print(+1, "pass", out); // CC interactions
00199
00200 out << "Printing number of failed events" << endl;
00201
00202 Print(-1, "fail", out); // all interactions types
00203 Print( 0, "fail", out); // NC interactions
00204 Print(+1, "fail", out); // CC interactions
00205
00206 if(fPrint)
00207 {
00208 cout << out.str();
00209 }
00210 }
|
|
||||||||||||||||||||
|
Definition at line 213 of file SelectCount.cxx. References Anp::AlgCaddy< T >::alg, Config(), count, Anp::Factory< T >::Create(), Anp::Select::Count::fail, fAlgName, fConfig, fMap, fTotalOnlyNue, Anp::GetDir(), Anp::Factory< T >::Instance(), KeyMap, Anp::AlgCaddy< T >::name, Particle::Name(), Anp::Select::Count::particle, Anp::Select::Count::pass, Set(), and Anp::Handle< T >::valid(). Referenced by Run(). 00217 {
00218 KeyMap &kmap = fMap[select];
00219
00220 // Combine nu_e and nu_e_bar together
00221 if(fTotalOnlyNue && particle == Particle::kNuE || particle == Particle::kNuEBar)
00222 {
00223 particle = Particle::kNuEAll;
00224 }
00225
00226 const pair<int, int> key(iaction, particle);
00227
00228 KeyMap::iterator cit = kmap.find(key);
00229 if(cit == kmap.end())
00230 {
00231 string name;
00232 Select::Count count;
00233 count.particle = particle;
00234
00235 if(name.empty())
00236 {
00237 Anp::Lock<Anp::Mutex> lock(Anp::GetMainMutex());
00238 const string name = Particle::Name(particle);
00239
00240 count.pass.name = name;
00241 count.fail.name = name;
00242 }
00243
00244 if(!fAlgName.empty() && opt.find("alg") != string::npos)
00245 {
00246 Handle<AlgEvent> pass;
00247 Handle<AlgEvent> fail;
00248
00249 if(!pass.valid() && !fail.valid())
00250 {
00251 Anp::Lock<Anp::Mutex> lock(Anp::GetMainMutex());
00252 pass = Anp::Factory<AlgEvent>::Instance().Create(fAlgName);
00253 fail = Anp::Factory<AlgEvent>::Instance().Create(fAlgName);
00254 }
00255
00256 if(pass.valid())
00257 {
00258 stringstream dname_pass;
00259 dname_pass << "pass_" << select;
00260
00261 TDirectory *dir = Anp::GetDir(dname_pass.str(), fDir);
00262
00263 pass -> Config(fConfig);
00264 pass -> Set(dir);
00265 count.pass.alg = pass;
00266 }
00267
00268 if(fail.valid())
00269 {
00270 stringstream dname_fail;
00271 dname_fail << "fail_" << select;
00272
00273 TDirectory *dir = Anp::GetDir(dname_fail.str(), fDir);
00274
00275 fail -> Config(fConfig);
00276 fail -> Set(dir);
00277 count.fail.alg = fail;
00278 }
00279 }
00280
00281 cit = kmap.insert(KeyMap::value_type(key, count)).first;
00282 }
00283
00284 return cit -> second;
00285 }
|
|
||||||||||||||||
|
Definition at line 288 of file SelectCount.cxx. References count, Anp::Select::Count::fail, fMap, fNameWidth, fNumbWidth, fTotalOnlyNC, KeyMap, Anp::Select::Count::particle, Anp::Select::Count::pass, and Anp::AlgCaddy< T >::Print(). Referenced by End(). 00289 {
00290 short iflag = -1;
00291 if(opt.find("pass") != string::npos)
00292 {
00293 iflag = 1;
00294 }
00295 else if(opt.find("fail") != string::npos)
00296 {
00297 iflag = 0;
00298 }
00299 else
00300 {
00301 return;
00302 }
00303
00304 unsigned int gcount = 0;
00305 for(CountMap::const_iterator cit = fMap.begin(); cit != fMap.end(); ++cit)
00306 {
00307 const KeyMap &kmap = cit -> second;
00308
00309 unsigned int icount = 0;
00310 for(KeyMap::const_iterator kit = kmap.begin(); kit != kmap.end(); ++kit)
00311 {
00312 const Select::Count &count = kit -> second;
00313
00314 if(iaction != kit -> first.first)
00315 {
00316 continue;
00317 }
00318
00319 string iaction_name;
00320 if(iaction == -1)
00321 {
00322 iaction_name = " any ";
00323 }
00324 else if(iaction == 0)
00325 {
00326 iaction_name = " nc ";
00327
00328 if(fTotalOnlyNC && count.particle != Particle::kAll)
00329 {
00330 continue;
00331 }
00332 }
00333 else if(iaction == 1)
00334 {
00335 iaction_name = " cc ";
00336 }
00337 else
00338 {
00339 cerr << "SelectCount::End - unknown key" << endl;
00340 continue;
00341 }
00342
00343 ++icount;
00344
00345 out << "#" << cit -> first << ":" << iaction_name;
00346
00347 if(iflag == 1)
00348 {
00349 if(fWeight)
00350 {
00351 count.pass.Print(fNameWidth, fNumbWidth, "weight", out);
00352 }
00353 else
00354 {
00355 count.pass.Print(fNameWidth, fNumbWidth, "event", out);
00356 }
00357 }
00358 else if(iflag == 0)
00359 {
00360 if(fWeight)
00361 {
00362 count.fail.Print(fNameWidth, fNumbWidth, "weight", out);
00363 }
00364 else
00365 {
00366 count.fail.Print(fNameWidth, fNumbWidth, "event", out);
00367 }
00368 }
00369 }
00370
00371 if(icount > 1)
00372 {
00373 out << endl;
00374 }
00375 else if(icount > 0)
00376 {
00377 ++gcount;
00378 }
00379 }
00380
00381 if(gcount > 0)
00382 {
00383 out << endl;
00384 }
00385 }
|
|
||||||||||||||||
|
Implements Anp::AlgEvent. Definition at line 77 of file SelectCount.cxx. References Anp::Event::EventIndex(), fCount, Anp::Select::Count::Fill(), fIndex, Anp::Record::FindTruth(), fRun, fSnarl, GetCount(), Anp::Record::GetHeader(), Anp::Header::Run(), Anp::Header::Snarl(), Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::TruthIter. 00078 {
00079 if(fRun != record.GetHeader().Run() || fSnarl != record.GetHeader().Snarl())
00080 {
00081 fRun = record.GetHeader().Run();
00082 fSnarl = record.GetHeader().Snarl();
00083 fIndex = event.EventIndex();
00084 fCount = 0;
00085 }
00086 else if(fIndex != event.EventIndex())
00087 {
00088 fIndex = event.EventIndex();
00089 fCount = 0;
00090 }
00091 else
00092 {
00093 ++fCount;
00094 }
00095
00096 GetCount(-1, Particle::kAll, fCount, "alg").Fill(event, record, pass);
00097
00098 if(record.TruthBeg() == record.TruthEnd())
00099 {
00100 return true;
00101 }
00102
00103 const TruthIter itruth = record.FindTruth(event);
00104 if(itruth == record.TruthEnd())
00105 {
00106 return false;
00107 }
00108
00109 GetCount(itruth -> Interaction(), Particle::kAll, fCount).Fill(event, record, pass);
00110 GetCount(itruth -> Interaction(), itruth -> Particle(), fCount).Fill(event, record, pass);
00111
00112 return true;
00113 }
|
|
|
Reimplemented from Anp::AlgEvent. Definition at line 116 of file SelectCount.cxx. References fDir, fDirName, and Anp::GetDir(). Referenced by GetCount(). 00117 {
00118 if(!dir)
00119 {
00120 return;
00121 }
00122
00123 fDir = Anp::GetDir(fDirName, dir);
00124 }
|
|
|
Definition at line 74 of file SelectCount.h. Referenced by Config(), and GetCount(). |
|
|
Definition at line 76 of file SelectCount.h. Referenced by Config(), GetCount(), and SelectCount(). |
|
|
Reimplemented from Anp::Base. Definition at line 87 of file SelectCount.h. Referenced by Run(). |
|
|
Definition at line 71 of file SelectCount.h. Referenced by Set(). |
|
|
Definition at line 73 of file SelectCount.h. |
|
|
Definition at line 85 of file SelectCount.h. Referenced by Run(). |
|
|
Definition at line 92 of file SelectCount.h. Referenced by End(), GetCount(), and Print(). |
|
|
Definition at line 89 of file SelectCount.h. |
|
|
Definition at line 90 of file SelectCount.h. |
|
|
Definition at line 78 of file SelectCount.h. Referenced by Config(). |
|
|
Definition at line 83 of file SelectCount.h. Referenced by Run(). |
|
|
Definition at line 84 of file SelectCount.h. Referenced by Run(). |
|
|
Definition at line 80 of file SelectCount.h. |
|
|
Definition at line 81 of file SelectCount.h. Referenced by Config(), and GetCount(). |
|
|
Definition at line 79 of file SelectCount.h. Referenced by Config(). |
1.3.9.1