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

Public Member Functions | |
| SelectKinem () | |
| virtual | ~SelectKinem () |
| 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 | Kinematic { kBad, kNC, kCC, kQES, kRES, kDIS, kExitBack, kExitSide, kExitCalr, kExitSpec, kStop } |
| enum | Selection { kUnknown, kAll, kAntiEasy, kAntiReco, kEasy, kReco } |
Private Member Functions | |
| AlgSnarlPtr | GetAlg (const std::string &key) |
| bool | Select (Event &event, const Record &record, const std::string &key) const |
| bool | Pass (const Event &event, const Record &record, const Kinematic kinem, const Selection selec) const |
| Kinematic | GetKinematic (const std::string &key) const |
| Selection | GetSelection (const std::string &key) const |
Private Attributes | |
| TDirectory * | fDir |
| std::string | fAlgList |
| std::string | fAlgName |
| std::string | fDirName |
| std::string | fRegPath |
| Registry | fConfig |
| Header | fHeader |
| Record | fRecord |
| int | fDISKey |
| int | fQESKey |
| double | fDISCut |
| double | fQESCut |
| double | fEHCut |
| double | fUVCut |
| double | fW2Cut |
| std::vector< std::string > | fKeys |
| std::map< std::string, AlgSnarlPtr > | fAlgMap |
|
|
Definition at line 42 of file SelectKinem.h. Referenced by Config(), GetKinematic(), and Select(). 00043 {
00044 kBad, kNC, kCC, kQES, kRES, kDIS, kExitBack, kExitSide, kExitCalr, kExitSpec, kStop
00045 };
|
|
|
Definition at line 47 of file SelectKinem.h. Referenced by Config(), GetSelection(), and Select(). 00048 {
00049 kUnknown, kAll, kAntiEasy, kAntiReco, kEasy, kReco
00050 };
|
|
|
Definition at line 31 of file SelectKinem.cxx. 00032 :fDir(0), 00033 fAlgList(""), 00034 fAlgName(""), 00035 fDirName(""), 00036 fRegPath("SelectKinem.txt"), 00037 fConfig(false), 00038 fHeader(), 00039 fRecord(), 00040 fDISKey(1523), 00041 fQESKey(1521), 00042 fDISCut(0.25), 00043 fQESCut(0.75), 00044 fEHCut(0.15), 00045 fUVCut(-1.0), 00046 fW2Cut(4.0) 00047 { 00048 }
|
|
|
Definition at line 51 of file SelectKinem.cxx. 00052 {
00053 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 109 of file SelectKinem.cxx. References fAlgList, fAlgName, fConfig, fDirName, fDISCut, fDISKey, fEHCut, fKeys, fQESCut, fQESKey, fRegPath, fUVCut, fW2Cut, Registry::Get(), infile, kAll, kBad, Registry::KeyExists(), Kinematic, Registry::Merge(), Anp::ReadRegistry(), reg, Selection, Registry::Set(), UtilString::StringTok(), Registry::UnLockKeys(), and Registry::UnLockValues(). Referenced by GetAlg(). 00110 {
00111 //
00112 // Configure self
00113 //
00114
00115 const char *value_path = 0;
00116 if(reg_.Get("SelectKinemRegPath", value_path) && value_path)
00117 {
00118 fRegPath = value_path;
00119 }
00120
00121 Registry tmp(false);
00122 Registry reg(reg_);
00123
00124 ifstream infile(fRegPath.c_str());
00125 if(infile.is_open() && Anp::ReadRegistry(fRegPath, tmp, true))
00126 {
00127 cout << "SelectKinem::Config - read registry configuration from: " << endl
00128 << " " << fRegPath << endl;
00129
00130 reg.UnLockKeys();
00131 reg.UnLockValues();
00132 reg.Merge(tmp);
00133 }
00134
00135 const char *value_char = 0;
00136 if(reg.Get("SelectKinemAlgName", value_char) && value_char)
00137 {
00138 fAlgName = value_char;
00139 }
00140
00141 value_char = 0;
00142 if(reg.Get("SelectKinemDirName", value_char) && value_char)
00143 {
00144 fDirName = value_char;
00145 }
00146
00147 reg.Get("SelectKinemDISKey", fDISKey);
00148 reg.Get("SelectKinemQESKey", fQESKey);
00149 reg.Get("SelectKinemDISCut", fDISCut);
00150 reg.Get("SelectKinemQESCut", fQESCut);
00151
00152 reg.Get("SelectKinemEHCut", fEHCut);
00153 reg.Get("SelectKinemUVCut", fUVCut);
00154 reg.Get("SelectKinemW2Cut", fW2Cut);
00155
00156 //
00157 // Merge main registry and reset some keys used by RunAlgSnarl
00158 //
00159 fConfig.Merge(reg);
00160 fConfig.Set("AlgEventList", "");
00161 fConfig.Set("AlgSnarlList", "");
00162 fConfig.Set("AlgSnarlDirName", "");
00163 fConfig.Set("AlgSnarlMakeCopy", "no");
00164 fConfig.Set("AlgSnarlPrintEnd", "no");
00165
00166 //
00167 // Read and set list of algorithms from SelectKinemList key
00168 //
00169 value_char = 0;
00170 if(reg.Get("SelectKinemList", value_char) && value_char)
00171 {
00172 const string alist = value_char;
00173 if(alist.find("SelectKinem") == string::npos)
00174 {
00175 fAlgList = alist;
00176 if (fAlgName.find("Event") != string::npos) fConfig.Set("AlgEventList", alist.c_str());
00177 else if(fAlgName.find("Snarl") != string::npos) fConfig.Set("AlgSnarlList", alist.c_str());
00178 }
00179 else
00180 {
00181 cerr << "SelectKinem::Config - algorithm list should not include self" << endl;
00182 }
00183 }
00184
00185 if(reg.Get("SelectKinem", value_char) && value_char)
00186 {
00187 vector<string> svec;
00188
00189 UtilString::StringTok(svec, string(value_char), ", ");
00190
00191 for(vector<string>::const_iterator sit = svec.begin(); sit != svec.end(); ++sit)
00192 {
00193 const string &key = *sit;
00194
00195 const Selection selec = SelectKinem::GetSelection(key);
00196 const Kinematic kinem = SelectKinem::GetKinematic(key);
00197
00198 if(selec == kAll || (kinem != kBad && selec != kUnknown))
00199 {
00200 fKeys.push_back(key);
00201 continue;
00202 }
00203
00204 cerr << "SelectKinem::Config - ignoring unknown key: " << key << endl;
00205 }
00206
00207 std::sort(fKeys.begin(), fKeys.end());
00208 }
00209
00210 if(fConfig.KeyExists("PrintConfig") || fConfig.KeyExists("PrintKinem"))
00211 {
00212 cout << "SelectKinem::Config" << endl
00213 << " AlgList = " << fAlgList << endl
00214 << " AlgName = " << fAlgName << endl
00215 << " DirName = " << fDirName << endl
00216 << " RegPath = " << fRegPath << endl
00217 << " DISKey = " << fDISKey << endl
00218 << " QESKey = " << fQESKey << endl
00219 << " DISCut = " << fDISCut << endl
00220 << " QESCut = " << fQESCut << endl
00221 << " EHCut = " << fEHCut << endl
00222 << " UVCut = " << fUVCut << endl
00223 << " W2Cut = " << fW2Cut << endl
00224 << " Added " << fKeys.size() << " keys" << endl;
00225
00226 for(vector<string>::const_iterator it = fKeys.begin(); it != fKeys.end(); ++it)
00227 {
00228 if(it == fKeys.begin())
00229 {
00230 cout << " " << *it;
00231 }
00232 else if(it + 1 == fKeys.end())
00233 {
00234 cout << " " << *it << endl;
00235 }
00236 else
00237 {
00238 cout << " " << *it;
00239 }
00240 }
00241 }
00242 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 269 of file SelectKinem.cxx. References Anp::AlgSnarlPtr, fAlgMap, and Anp::Handle< T >::valid(). 00270 {
00271 for(map<string, AlgSnarlPtr>::iterator ialg = fAlgMap.begin(); ialg != fAlgMap.end(); ++ialg)
00272 {
00273 AlgSnarlPtr alg = ialg -> second;
00274
00275 if(alg.valid())
00276 {
00277 alg -> End(block);
00278 }
00279 }
00280
00281 fAlgMap.clear();
00282 }
|
|
|
Definition at line 419 of file SelectKinem.cxx. References Anp::AlgSnarlPtr, Config(), Anp::Factory< T >::Create(), fAlgMap, fAlgName, fConfig, fDir, fHeader, Init(), Anp::Factory< T >::Instance(), Anp::AlgSnarl::Name(), reg, Set(), Anp::SetKey(), and Anp::Handle< T >::valid(). 00420 {
00421 //
00422 // Create child algorithm
00423 //
00424
00425 map<string, AlgSnarlPtr>::iterator fit = fAlgMap.find(key);
00426 if(fit == fAlgMap.end())
00427 {
00428 Handle<AlgSnarl> alg;
00429 Registry reg(fConfig);
00430
00431 if(!alg.valid())
00432 {
00433 Anp::Lock<Mutex> lock(Anp::GetMainMutex());
00434 alg = Anp::Factory<AlgSnarl>::Instance().Create(fAlgName);
00435 Anp::SetKey(reg, "KINEM", key.c_str());
00436 }
00437
00438 if(alg.valid())
00439 {
00440 alg -> Name(fAlgName + "-" + key);
00441 alg -> Config(reg);
00442 alg -> Set(Anp::GetDir(key, fDir));
00443 alg -> Init(fHeader);
00444 }
00445
00446 fit = fAlgMap.insert(map<string, AlgSnarlPtr>::value_type(key, alg)).first;
00447 }
00448
00449 return fit -> second;
00450 }
|
|
|
Definition at line 454 of file SelectKinem.cxx. References Kinematic. 00455 {
00456 //
00457 // Extract kinematics key
00458 //
00459
00460 if (key.find("qes") != string::npos) return kQES;
00461 else if(key.find("dis") != string::npos) return kDIS;
00462 else if(key.find("res") != string::npos) return kRES;
00463 else if(key.find("cc") != string::npos) return kCC;
00464 else if(key.find("nc") != string::npos) return kNC;
00465 else if(key.find("back") != string::npos) return kExitBack;
00466 else if(key.find("side") != string::npos) return kExitSide;
00467 else if(key.find("calr") != string::npos) return kExitCalr;
00468 else if(key.find("spec") != string::npos) return kExitSpec;
00469 else if(key.find("stop") != string::npos) return kStop;
00470
00471 return kBad;
00472 }
|
|
|
Definition at line 475 of file SelectKinem.cxx. References Selection. 00476 {
00477 //
00478 // Extract selection algorithm
00479 //
00480 if(key == "all") return kAll;
00481
00482 if(key.find("anti") != string::npos)
00483 {
00484 if (key.find("easy") != string::npos) return kAntiEasy;
00485 else if(key.find("reco") != string::npos) return kAntiReco;
00486 }
00487 else if(key.find("easy") != string::npos)
00488 {
00489 return kEasy;
00490 }
00491 else if(key.find("reco") != string::npos)
00492 {
00493 return kReco;
00494 }
00495 else if(key.find("exit") != string::npos ||
00496 key.find("stop") != string::npos)
00497
00498 {
00499 return kReco;
00500 }
00501
00502 return kUnknown;
00503 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 256 of file SelectKinem.cxx. References fHeader, and Anp::Header::IsValid(). Referenced by GetAlg(). 00257 {
00258 //
00259 // Configure self and save copy of Header
00260 //
00261 assert(!fHeader.IsValid() && "SelectKinem already has valid header - logic errror");
00262
00263 fHeader = header;
00264
00265 return fHeader.IsValid();
00266 }
|
|
||||||||||||||||||||
|
Definition at line 342 of file SelectKinem.cxx. References Anp::RecoNu::EHad(), Anp::RecoNu::ExitBack(), Anp::RecoNu::ExitSide(), fUVCut, Anp::Record::GetHeader(), Anp::Event::GetNu(), Anp::Header::IsNear(), kDIS, kExitBack, kExitCalr, kExitSide, kExitSpec, kQES, kReco, kRES, kStop, Anp::LongestTrack(), Anp::RecoNu::Stop(), Anp::Record::TrackEnd(), and Anp::TrackIter. 00344 {
00345 //
00346 // Check if event passed kinematic selections
00347 //
00348
00349 if(kinem == kBad)
00350 {
00351 cerr << "SelectKinem::Pass - unknown kinematics: " << kinem << endl;
00352 return false;
00353 }
00354
00355 if(selec == kReco)
00356 {
00357 if (kinem == kQES && event[fQESKey] > fQESCut) return true;
00358 else if(kinem == kDIS && event[fDISKey] > fDISCut) return true;
00359 else if(kinem == kRES &&
00360 !SelectKinem::Pass(event, record, kQES, kReco) &&
00361 !SelectKinem::Pass(event, record, kDIS, kReco))
00362 {
00363 return true;
00364 }
00365 else if(kinem == kExitBack && event.GetNu().ExitBack()) return true;
00366 else if(kinem == kExitSide && event.GetNu().ExitSide()) return true;
00367 else if(kinem == kStop && event.GetNu().Stop()) return true;
00368 else if(kinem == kExitCalr || kinem == kExitSpec)
00369 {
00370 if(event.GetNu().ExitSide() && record.GetHeader().IsNear())
00371 {
00372 const TrackIter itrack = Anp::LongestTrack(event, record);
00373 if(itrack != record.TrackEnd())
00374 {
00375 if(kinem == kExitCalr && itrack -> GetBasic().EndPlane() < 121) return true;
00376 if(kinem == kExitSpec && itrack -> GetBasic().EndPlane() > 120) return true;
00377 }
00378 }
00379 }
00380
00381 return false;
00382 }
00383 else if(selec == kEasy)
00384 {
00385 if(event.GetNu().EHad() < fEHCut)
00386 {
00387 if(kinem == kQES) return true;
00388 return false;
00389 }
00390 else
00391 {
00392 if(fUVCut > 0.0 && std::fabs(Anp::GetUVAssymForQES(event, record)) > fUVCut)
00393 {
00394 if(kinem == kQES) return true;
00395 return false;
00396 }
00397
00398 if(kinem == kQES) return false;
00399
00400 if(event.GetNu().W2() < fW2Cut)
00401 {
00402 if(kinem == kRES) return true;
00403 }
00404 else
00405 {
00406 if(kinem == kDIS) return true;
00407 }
00408
00409 return false;
00410 }
00411 }
00412
00413 cerr << "SelectKinem::Pass - uknown selection key: " << selec << endl;
00414
00415 return false;
00416 }
|
|
|
Implements Anp::AlgSnarl. Definition at line 56 of file SelectKinem.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, Anp::Record::GetHeader(), Anp::Header::IsData(), and Anp::Handle< T >::valid(). 00057 {
00058 //
00059 // Create empty Record class, code runs faster when this is outside loop.
00060 //
00061 for(vector<string>::const_iterator kit = fKeys.begin(); kit != fKeys.end(); ++kit)
00062 {
00063 const string &key = *kit;
00064
00065 AlgSnarlPtr alg = SelectKinem::GetAlg(key);
00066 if(!alg.valid())
00067 {
00068 continue;
00069 }
00070
00071 if(key.find("true") != string::npos && record.GetHeader().IsData())
00072 {
00073 continue;
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(SelectKinem::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 285 of file SelectKinem.cxx. References fDISKey, fQESKey, kBad, kEasy, Anp::Event::KeyExists(), Kinematic, kReco, and Selection. 00286 {
00287 //
00288 // Make kinematic selection
00289 //
00290
00291 const Selection selec = SelectKinem::GetSelection(key);
00292 const Kinematic kinem = SelectKinem::GetKinematic(key);
00293
00294 if(selec == kAll)
00295 {
00296 return true;
00297 }
00298 else if(kinem == kBad || selec == kUnknown)
00299 {
00300 return false;
00301 }
00302
00303 if(selec == kReco)
00304 {
00305 //
00306 // Select events based on reconstucted variables
00307 //
00308 if(!event.KeyExists(fQESKey) || !event.KeyExists(fDISKey))
00309 {
00310 return false;
00311 }
00312
00313 return SelectKinem::Pass(event, record, kinem, kReco);
00314 }
00315 else if(selec == kEasy)
00316 {
00317 return SelectKinem::Pass(event, record, kinem, kEasy);
00318 }
00319 else if(selec == kAntiReco)
00320 {
00321 //
00322 // Select events based on reconstucted variables
00323 //
00324 if(!event.KeyExists(fQESKey) || !event.KeyExists(fDISKey))
00325 {
00326 return false;
00327 }
00328
00329 return !SelectKinem::Pass(event, record, kinem, kReco);
00330 }
00331 else if(selec == kAntiEasy)
00332 {
00333 return !SelectKinem::Pass(event, record, kinem, kEasy);
00334 }
00335
00336 cerr << "SelectKinem::Select - unknown key: " << key << endl;
00337
00338 return false;
00339 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 245 of file SelectKinem.cxx. References fDir, fDirName, and Anp::GetDir(). Referenced by GetAlg(). 00246 {
00247 if(!dir)
00248 {
00249 return;
00250 }
00251
00252 fDir = Anp::GetDir(fDirName, dir);
00253 }
|
|
|
Definition at line 68 of file SelectKinem.h. Referenced by Config(). |
|
|
Definition at line 87 of file SelectKinem.h. |
|
|
Definition at line 69 of file SelectKinem.h. |
|
|
Definition at line 73 of file SelectKinem.h. |
|
|
Definition at line 66 of file SelectKinem.h. |
|
|
Definition at line 70 of file SelectKinem.h. |
|
|
Definition at line 79 of file SelectKinem.h. Referenced by Config(). |
|
|
Definition at line 77 of file SelectKinem.h. |
|
|
Definition at line 81 of file SelectKinem.h. Referenced by Config(). |
|
|
Definition at line 74 of file SelectKinem.h. |
|
|
Definition at line 85 of file SelectKinem.h. |
|
|
Definition at line 80 of file SelectKinem.h. Referenced by Config(). |
|
|
Definition at line 78 of file SelectKinem.h. |
|
|
Definition at line 75 of file SelectKinem.h. Referenced by Run(). |
|
|
Definition at line 71 of file SelectKinem.h. Referenced by Config(). |
|
|
Definition at line 82 of file SelectKinem.h. |
|
|
Definition at line 83 of file SelectKinem.h. Referenced by Config(). |
1.3.9.1