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

Public Member Functions | |
| SelectTrue () | |
| virtual | ~SelectTrue () |
| bool | Run (Record &record) |
| void | Config (const Registry ®) |
| void | Set (TDirectory *dir) |
| bool | Init (const Header &header) |
| void | End (const DataBlock &block) |
Private Types | |
| enum | Selection { kAll = -1, kNC = 0, kCC = 1, kCCPos = 2, kCCNeg = 3, kBad = 5, kQES = 1001, kRES = 1002, kDIS = 1003 } |
Private Member Functions | |
| AlgSnarlPtr | GetAlg (const std::string &key) |
| bool | Select (Event &event, const Record &record, const std::string &option) const |
| Selection | GetSelection (const std::string &key) const |
| void | AddData (Event &event, const Record &record, const Selection select) const |
Private Attributes | |
| TDirectory * | fDir |
| std::string | fAlgList |
| std::string | fAlgName |
| std::string | fDirName |
| Registry | fConfig |
| Header | fHeader |
| Record | fRecord |
| int | fNeuKey |
| int | fDISKey |
| int | fQESKey |
| double | fDISCut |
| double | fQESCut |
| double | fEHCut |
| double | fW2Cut |
| std::vector< std::string > | fKeys |
| std::map< std::string, AlgSnarlPtr > | fAlgMap |
|
|
Definition at line 39 of file SelectTrue.h. Referenced by Config(), GetSelection(), and Select(). 00040 {
00041 kAll=-1, kNC=0, kCC=1, kCCPos=2, kCCNeg=3, kBad=5, kQES=1001, kRES=1002, kDIS=1003
00042 };
|
|
|
Definition at line 31 of file SelectTrue.cxx. 00032 :fDir(0), 00033 fAlgList(""), 00034 fAlgName(""), 00035 fDirName(""), 00036 fConfig(false), 00037 fHeader(), 00038 fRecord(), 00039 fNeuKey(1), 00040 fDISKey(1523), 00041 fQESKey(1521), 00042 fDISCut(0.25), 00043 fQESCut(0.75), 00044 fEHCut(0.15), 00045 fW2Cut(4.0) 00046 { 00047 }
|
|
|
Definition at line 50 of file SelectTrue.cxx. 00051 {
00052 }
|
|
||||||||||||||||
|
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 109 of file SelectTrue.cxx. References fAlgList, fAlgName, fConfig, fDirName, fKeys, Registry::Get(), Registry::KeyExists(), Registry::Merge(), reg, Selection, Registry::Set(), and UtilString::StringTok(). Referenced by GetAlg(). 00110 {
00111 const char *value_char = 0;
00112 if(reg.Get("SelectTrueAlgName", value_char) && value_char)
00113 {
00114 fAlgName = value_char;
00115 }
00116
00117 value_char = 0;
00118 if(reg.Get("SelectTrueDirName", value_char) && value_char)
00119 {
00120 fDirName = value_char;
00121 }
00122
00123 //
00124 // Merge main registry and reset some keys used by RunAlgSnarl
00125 //
00126 fConfig.Merge(reg);
00127 fConfig.Set("AlgEventList", "");
00128 fConfig.Set("AlgSnarlList", "");
00129 fConfig.Set("AlgSnarlDirName", "");
00130 fConfig.Set("AlgSnarlDoThread", "no");
00131 fConfig.Set("AlgSnarlMakeCopy", "no");
00132 fConfig.Set("AlgSnarlPrintEnd", "no");
00133
00134 // read list of algorithms from SelectTrueList key and set
00135 // AlgSnarlList key with this list. If SelectTrueList key
00136 // does not exist then erase AlgSnarlList key.
00137 const char *value_list = 0;
00138 if(reg.Get("SelectTrueList", value_list) && value_list)
00139 {
00140 const string alist = value_list;
00141 if(alist.find("SelectTrue") == string::npos)
00142 {
00143 fAlgList = alist;
00144 if (fAlgName.find("Event") != string::npos) fConfig.Set("AlgEventList", alist.c_str());
00145 else if(fAlgName.find("Snarl") != string::npos) fConfig.Set("AlgSnarlList", alist.c_str());
00146 }
00147 else
00148 {
00149 cerr << "SelectTrue::Config - algorithm list should not include self" << endl;
00150 }
00151 }
00152
00153 const char *value_true = 0;
00154 if(reg.Get("SelectTrue", value_true) && value_true)
00155 {
00156 vector<string> svec;
00157
00158 UtilString::StringTok(svec, string(value_true), ", ");
00159
00160 for(vector<string>::const_iterator sit = svec.begin(); sit != svec.end(); ++sit)
00161 {
00162 const string &key = *sit;
00163
00164 const Selection select = SelectTrue::GetSelection(key);
00165 if(select != kBad)
00166 {
00167 fKeys.push_back(key);
00168 continue;
00169 }
00170
00171 cerr << "SelectTrue::Config - ignoring unknown key: " << key << endl;
00172 }
00173
00174 std::sort(fKeys.begin(), fKeys.end());
00175 }
00176
00177 if(fConfig.KeyExists("PrintConfig") || fConfig.KeyExists("PrintKinem"))
00178 {
00179 cout << "SelectTrue::Config" << endl
00180 << " AlgList = " << fAlgList << endl
00181 << " AlgName = " << fAlgName << endl
00182 << " DirName = " << fDirName << endl
00183 << " Added " << fKeys.size() << " keys" << endl;
00184
00185 for(vector<string>::const_iterator it = fKeys.begin(); it != fKeys.end(); ++it)
00186 {
00187 if(it == fKeys.begin())
00188 {
00189 cout << " " << *it;
00190 }
00191 else if(it + 1 == fKeys.end())
00192 {
00193 cout << " " << *it << endl;
00194 }
00195 else
00196 {
00197 cout << " " << *it;
00198 }
00199 }
00200 }
00201 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 229 of file SelectTrue.cxx. References Anp::AlgSnarlPtr, fAlgMap, and Anp::Handle< T >::valid(). 00230 {
00231 for(map<string, AlgSnarlPtr>::iterator ialg = fAlgMap.begin(); ialg != fAlgMap.end(); ++ialg)
00232 {
00233 AlgSnarlPtr alg = ialg -> second;
00234
00235 if(alg.valid())
00236 {
00237 alg -> End(block);
00238 }
00239 }
00240
00241 fAlgMap.clear();
00242 }
|
|
|
Definition at line 301 of file SelectTrue.cxx. References Anp::AlgSnarlPtr, Config(), Anp::Factory< T >::Create(), fAlgMap, fAlgName, fConfig, fDir, fHeader, Init(), Anp::Factory< T >::Instance(), Anp::AlgSnarl::Name(), Set(), and Anp::Handle< T >::valid(). Referenced by Run(). 00302 {
00303 //
00304 // Create child algorithm
00305 //
00306
00307 map<string, AlgSnarlPtr>::iterator fit = fAlgMap.find(key);
00308 if(fit == fAlgMap.end())
00309 {
00310 Handle<AlgSnarl> alg;
00311
00312 if(!alg.valid())
00313 {
00314 Anp::Lock<Mutex> lock(Anp::GetMainMutex());
00315 alg = Anp::Factory<AlgSnarl>::Instance().Create(fAlgName);
00316 }
00317
00318 if(alg.valid())
00319 {
00320 alg -> Name(fAlgName + "-" + key);
00321 alg -> Config(fConfig);
00322
00323 if(key == "all")
00324 {
00325 alg -> Set(fDir);
00326 }
00327 else
00328 {
00329 alg -> Set(Anp::GetDir(key, fDir));
00330 }
00331
00332 alg -> Init(fHeader);
00333 }
00334
00335 fit = fAlgMap.insert(map<string, AlgSnarlPtr>::value_type(key, alg)).first;
00336 }
00337
00338 return fit -> second;
00339 }
|
|
|
Definition at line 343 of file SelectTrue.cxx. References Selection. 00344 {
00345 //
00346 // Extract kinematics option
00347 //
00348 if(key == "all") return kAll;
00349
00350 if (key.find("true") == string::npos) return kBad;
00351 if (key.find("qes") != string::npos) return kQES;
00352 else if(key.find("dis") != string::npos) return kDIS;
00353 else if(key.find("res") != string::npos) return kRES;
00354 else if(key.find("ccpos") != string::npos) return kCCPos;
00355 else if(key.find("ccneg") != string::npos) return kCCNeg;
00356 else if(key.find("cc") != string::npos) return kCC;
00357 else if(key.find("nc") != string::npos) return kNC;
00358
00359 cerr << "SelectTrue::GetSelection - uknown selection key: " << key << endl;
00360
00361 return kBad;
00362 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 215 of file SelectTrue.cxx. References fHeader, and Anp::Header::IsValid(). Referenced by GetAlg(). 00216 {
00217 //
00218 // Configure self and save copy of Header
00219 //
00220
00221 assert(!fHeader.IsValid() && "SelectTrue already has valid header - logic errror");
00222
00223 fHeader = header;
00224
00225 return fHeader.IsValid();
00226 }
|
|
|
Implements Anp::AlgSnarl. Definition at line 55 of file SelectTrue.cxx. References Anp::AlgSnarlPtr, Anp::CleanRecord(), Anp::Record::Erase(), Anp::Record::EventBeg(), Anp::Record::EventBegIterator(), Anp::Record::EventEnd(), Anp::Record::EventEndIterator(), Anp::EventIterator, fKeys, fRecord, GetAlg(), Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::Handle< T >::valid(). 00056 {
00057 //
00058 // Create empty Record class, code runs faster when this is outside loop.
00059 //
00060
00061 for(vector<string>::const_iterator kit = fKeys.begin(); kit != fKeys.end(); ++kit)
00062 {
00063 const string &key = *kit;
00064
00065 AlgSnarlPtr alg = GetAlg(key);
00066 if(!alg.valid())
00067 {
00068 continue;
00069 }
00070
00071 if(key != "all" && (record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd()))
00072 {
00073 return true;
00074 }
00075
00076 //
00077 // Fill copy with Record content
00078 //
00079 fRecord = record;
00080
00081 //
00082 // Remove events that do not pass current selection
00083 //
00084 EventIterator ievent = fRecord.EventBegIterator();
00085 while(ievent != fRecord.EventEndIterator())
00086 {
00087 if(SelectTrue::Select(*ievent, fRecord, key))
00088 {
00089 ++ievent;
00090 }
00091 else
00092 {
00093 ievent = fRecord.Erase(ievent);
00094 }
00095 }
00096
00097 //
00098 // Remove tracks and showers that do not match selected events
00099 //
00100 Anp::CleanRecord(fRecord.EventBeg(), fRecord.EventEnd(), fRecord);
00101
00102 alg -> Run(fRecord);
00103 }
00104
00105 return true;
00106 }
|
|
||||||||||||||||
|
Definition at line 245 of file SelectTrue.cxx. References Anp::Record::FindTruth(), kDIS, kQES, kRES, Selection, Anp::Record::TruthEnd(), and Anp::TruthIter. 00246 {
00247 //
00248 // Make kinematic selection
00249 //
00250 const Selection select = SelectTrue::GetSelection(key);
00251
00252 if (select == kAll) return true;
00253 else if(select == kBad) return false;
00254
00255 const TruthIter itruth = record.FindTruth(event);
00256 if(itruth == record.TruthEnd())
00257 {
00258 return false;
00259 }
00260
00261 if(select == kNC)
00262 {
00263 if(itruth -> IsNC()) return true;
00264 }
00265 else
00266 {
00267 if(itruth -> IsNC())
00268 {
00269 return false;
00270 }
00271 else if(itruth -> Particle() != Particle::kNuM &&
00272 itruth -> Particle() != Particle::kNuMBar)
00273 {
00274 return false;
00275 }
00276
00277 if(select == kQES || select == kRES || select == kDIS)
00278 {
00279 if (select == kQES && itruth -> IsQES()) return true;
00280 else if(select == kRES && itruth -> IsRES()) return true;
00281 else if(select == kDIS && itruth -> IsDIS()) return true;
00282 }
00283 else if(select == kCC)
00284 {
00285 if(itruth -> IsCC()) return true;
00286 }
00287 else if(select == kCCPos)
00288 {
00289 if(itruth -> IsCC() && itruth -> Particle() == Particle::kNuMBar) return true;
00290 }
00291 else if(select == kCCNeg)
00292 {
00293 if(itruth -> IsCC() && itruth -> Particle() == Particle::kNuM) return true;
00294 }
00295 }
00296
00297 return false;
00298 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 204 of file SelectTrue.cxx. References fDir, fDirName, and Anp::GetDir(). Referenced by GetAlg(). 00205 {
00206 if(!dir)
00207 {
00208 return;
00209 }
00210
00211 fDir = Anp::GetDir(fDirName, dir);
00212 }
|
|
|
Definition at line 58 of file SelectTrue.h. Referenced by Config(). |
|
|
Definition at line 76 of file SelectTrue.h. |
|
|
Definition at line 59 of file SelectTrue.h. |
|
|
Definition at line 62 of file SelectTrue.h. |
|
|
Definition at line 56 of file SelectTrue.h. |
|
|
Definition at line 60 of file SelectTrue.h. |
|
|
Definition at line 69 of file SelectTrue.h. |
|
|
Definition at line 67 of file SelectTrue.h. |
|
|
Definition at line 71 of file SelectTrue.h. |
|
|
Definition at line 63 of file SelectTrue.h. |
|
|
Definition at line 74 of file SelectTrue.h. |
|
|
Definition at line 66 of file SelectTrue.h. |
|
|
Definition at line 70 of file SelectTrue.h. |
|
|
Definition at line 68 of file SelectTrue.h. |
|
|
Definition at line 64 of file SelectTrue.h. Referenced by Run(). |
|
|
Definition at line 72 of file SelectTrue.h. |
1.3.9.1