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

Public Types | |
| typedef std::map< std::string, AlgThread * > | ThreadMap |
Public Member Functions | |
| RunkNN () | |
| virtual | ~RunkNN () |
| bool | Run (Record &record) |
| void | Config (const Registry ®) |
| bool | Init (const Header &header) |
| void | End (const DataBlock &) |
Private Member Functions | |
| bool | SaveParts (const Header &header) |
| bool | MakeNames (const Header &header) |
| void | MakeAlg (const Header &header) |
| void | MakePid (const Header &header, const std::string &file, int abase) |
| void | MakeKin (const Header &header, const std::string &file, int abase) |
| bool | Alg (const std::string &name, const Registry ®, int base, int k1, int k2, int k3, int k4) |
| bool | Add (const std::string &name, int abase) |
| void | AddData (Record &record) |
| void | CutData (Record &record) |
Private Attributes | |
| bool | fCreateNew |
| bool | fEraseData |
| bool | fMakeAllBeam |
| bool | fMultiThread |
| bool | fPrint |
| int | fMuonKey |
| int | fKinBase |
| int | fPidBase |
| double | fComCut |
| double | fPurCut |
| double | fQoPCut |
| Registry | fConfig |
| std::string | fPath |
| std::map< std::string, int > | fFile |
| std::string | PREFIX |
| std::string | DETECTOR |
| std::string | MCRLTYPE |
| std::string | RECOTYPE |
| std::string | BEAMTYPE |
| std::string | fSelect |
| ThreadMap | fMap |
|
|
|
|
|
Definition at line 26 of file RunkNN.cxx. 00027 :fCreateNew(false), 00028 fEraseData(true), 00029 fMakeAllBeam(false), 00030 fMultiThread(false), 00031 fPrint(false), 00032 fMuonKey(7000), 00033 fKinBase(1100), 00034 fPidBase(4000), 00035 fComCut(0.90), 00036 fPurCut(0.90), 00037 fQoPCut(-0.005), 00038 fConfig(false), 00039 fPath(""), 00040 fFile(), 00041 PREFIX("prototype"), 00042 DETECTOR(""), 00043 MCRLTYPE(""), 00044 RECOTYPE(""), 00045 BEAMTYPE(""), 00046 fSelect("physics") 00047 { 00048 }
|
|
|
Definition at line 51 of file RunkNN.cxx. 00052 {
00053 }
|
|
||||||||||||
|
Definition at line 623 of file RunkNN.cxx. References fFile. Referenced by MakeNames(). 00624 {
00625 //
00626 // If file name and key are unique then add values
00627 //
00628
00629 if(fFile.find(name) != fFile.end())
00630 {
00631 cerr << "RunkNN::Add - file name already exists: " << name << endl;
00632 return false;
00633 }
00634
00635 for(map<string, int>::const_iterator it = fFile.begin(); it != fFile.end(); ++it)
00636 {
00637 if(it -> second == kbase)
00638 {
00639 cerr << "RunkNN::Add - key already exists: " << kbase << endl;
00640 return false;
00641 }
00642 }
00643
00644 fFile[name] = kbase;
00645
00646 return true;
00647 }
|
|
|
Definition at line 650 of file RunkNN.cxx. References Anp::Event::Add(), Anp::RecoNu::CosN(), Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), Anp::EventIterator, Lit::Find(), Anp::Record::FindTruth(), fKinBase, fMuonKey, fPurCut, Anp::Record::GetHeader(), Anp::Event::GetNu(), Anp::Header::IsData(), Anp::LongestTrack(), Anp::RecoNu::PLep(), Anp::RecoNu::Q2(), Anp::Record::TrackEnd(), Anp::TrackIter, Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), Anp::TruthIter, Anp::TruthRecoIter, Anp::RecoNu::W2(), Anp::RecoNu::X(), and Anp::RecoNu::Y(). Referenced by Run(). 00651 {
00652 //
00653 // Add temporary data required for kinematic kNN selection
00654 //
00655
00656 for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00657 {
00658 Event &event = *ievent;
00659
00660 //
00661 // Find longest reconstructed track
00662 //
00663 TrackIter itrack = Anp::LongestTrack(event, record);
00664
00665 //
00666 // Event must have a track
00667 //
00668 if(itrack == record.TrackEnd()) continue;
00669
00670 //
00671 // Track must pass fit
00672 //
00673 if(!(itrack -> PassFit())) continue;
00674
00675 //
00676 // Add data keys
00677 //
00678 const double cosn = event.GetNu().CosN();
00679 if(cosn < -1.0 || cosn > +1.0)
00680 {
00681 continue;
00682 }
00683 else
00684 {
00685 event.Add(fKinBase + 10, std::acos(cosn));
00686 }
00687
00688 event.Add(fKinBase + 4, event.GetNu().PLep());
00689 event.Add(fKinBase + 5, event.GetNu().Q2());
00690 event.Add(fKinBase + 6, event.GetNu().Y());
00691 event.Add(fKinBase + 7, event.GetNu().W2());
00692 event.Add(fKinBase + 8, event.GetNu().X());
00693 event.Add(fKinBase + 9, cosn);
00694
00695 //
00696 // Pass this point only if running on Monte-Carlo with truth records filled
00697 //
00698 if(record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd()) continue;
00699
00700 const TruthIter itruth = record.FindTruth(event);
00701 if(itruth == record.TruthEnd())
00702 {
00703 cerr << "RunkNN::AddData - failed to find Truth" << endl;
00704 continue;
00705 }
00706
00707 TruthRecoIter ireco = itruth -> Find(event);
00708 if(ireco == itruth -> RecoEnd())
00709 {
00710 cerr << "RunkNN::AddData - failed to find reconstructed truth info" << endl;
00711 continue;
00712 }
00713 else
00714 {
00715 //
00716 // Add purity and completeness variables for debugging
00717 //
00718 event.Add(fKinBase + 2, ireco -> Purity());
00719 event.Add(fKinBase + 3, ireco -> ComplAll());
00720 }
00721
00722 //
00723 // Use tracks with reconstructed negative curvature
00724 //
00725 if(itrack -> QP() > fQoPCut) continue;
00726
00727 //
00728 // Use true muon neutrino interactions
00729 //
00730 if(itruth -> Particle() != Particle::kNuM) continue;
00731
00732 //
00733 // Use true QES, RES or DIS charged current events
00734 //
00735 if(itruth -> Interaction() != 1 || (itruth -> Resonance() != 1001 &&
00736 itruth -> Resonance() != 1002 &&
00737 itruth -> Resonance() != 1003)) continue;
00738
00739 //
00740 // Use well reconstructed events
00741 //
00742 if(ireco -> Purity() < fPurCut || ireco -> ComplAll() < fComCut) continue;
00743
00744 //
00745 // Find muon truth key which is filled by FillMuonId
00746 //
00747 if(!(itrack -> KeyExists(fMuonKey)))
00748 {
00749 cerr << "RunkNN::AddData - failed to find muon truth key: " << fMuonKey << endl;
00750 continue;
00751 }
00752
00753 //
00754 // Reconstucted track must match true muon !!!hardcoded numbers!!!
00755 //
00756 if(itrack -> DataAt(fMuonKey) < 0.999 || itrack -> DataAt(fMuonKey) > 1.001)
00757 {
00758 continue;
00759 }
00760
00761 //
00762 // Add resonance code for QES, RES or DIS and use this event for training
00763 //
00764 event.Add(fKinBase + 1, float(itruth -> Resonance() % 1000));
00765 }
00766 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 580 of file RunkNN.cxx. References base, Config(), fMap, reg, Registry::Set(), and Anp::Handle< T >::valid(). Referenced by MakeKin(), and MakePid(). 00582 {
00583 //
00584 // Create one FillkNN algorithm
00585 //
00586
00587 Registry kreg(reg);
00588
00589 stringstream keys;
00590 if(k1 > 0) keys << std::setw(5) << std::setfill(' ') << std::right << k1 << " ";
00591 if(k2 > 0) keys << std::setw(5) << std::setfill(' ') << std::right << k2 << " ";
00592 if(k3 > 0) keys << std::setw(5) << std::setfill(' ') << std::right << k3 << " ";
00593 if(k4 > 0) keys << std::setw(5) << std::setfill(' ') << std::right << k4 << " ";
00594
00595 kreg.Set("FillkNNKeyBase", base);
00596 kreg.Set("FillkNNKeyList", keys.str().c_str());
00597
00598 const string name = file + ":" + keys.str();
00599
00600 if(fMap.find(name) != fMap.end())
00601 {
00602 cerr << "RunkNN::Alg - name already exists: " << name << endl;
00603 return false;
00604 }
00605
00606 Handle<AlgSnarl> alg = Factory<AlgSnarl>::Instance().Create("FillkNN");
00607 if(!alg.valid())
00608 {
00609 cerr << "RunkNN::Alg - failed to create FillkNN algorithm!" << endl;
00610 return false;
00611 }
00612
00613 //
00614 // Configure algorithm - this is the only direct access
00615 // to FillkNN algorithm from this class.
00616 //
00617 alg -> Config(kreg);
00618
00619 return fMap.insert(ThreadMap::value_type(name, new AlgThread(alg, name))).second;
00620 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 171 of file RunkNN.cxx. References fComCut, fConfig, fCreateNew, fEraseData, fKinBase, fMakeAllBeam, fMultiThread, fMuonKey, fPath, fPidBase, fPrint, fPurCut, fQoPCut, fSelect, Registry::Get(), Registry::KeyExists(), Registry::Merge(), PREFIX, Anp::Read(), and reg. Referenced by Alg(). 00172 {
00173 //
00174 // Configure self and save Registry for children
00175 //
00176
00177 Anp::Read(reg, "RunkNNCreateNew", fCreateNew);
00178 Anp::Read(reg, "RunkNNEraseData", fEraseData);
00179 Anp::Read(reg, "RunkNNMultiThread", fMultiThread);
00180 Anp::Read(reg, "RunkNNMakeAllBeam", fMakeAllBeam);
00181 Anp::Read(reg, "RunkNNPrint", fPrint);
00182
00183 //
00184 // Do not multi-thread when making new knn prototype(s)
00185 //
00186 if(fCreateNew) fMultiThread = false;
00187
00188 const char *value_path = 0;
00189 if(reg.Get("RunkNNPath", value_path) && value_path)
00190 {
00191 fPath = value_path;
00192 }
00193
00194 if(!fPath.empty() && fPath[fPath.size()-1] != '/') fPath += "/";
00195
00196 const char *value_pref = 0;
00197 if(reg.Get("RunkNNPrefix", value_pref) && value_pref)
00198 {
00199 PREFIX = value_pref;
00200 }
00201
00202 const char *value_selc = 0;
00203 if(reg.Get("RunkNNSelect", value_selc) && value_selc)
00204 {
00205 fSelect = value_selc;
00206 }
00207
00208 reg.Get("RunkNNComCut", fComCut);
00209 reg.Get("RunkNNPurCut", fPurCut);
00210 reg.Get("RunkNNQoPCut", fQoPCut);
00211 if(fSelect=="QPall") fQoPCut = 10000;
00212 if(reg.KeyExists("PrintConfig"))
00213 {
00214 cout << "RunkNN::Config" << endl
00215 << " CreateNew = " << fCreateNew << endl
00216 << " EraseData = " << fEraseData << endl
00217 << " MultiThread = " << fMultiThread << endl
00218 << " MuonKey = " << fMuonKey << endl
00219 << " KinBase = " << fKinBase << endl
00220 << " PidBase = " << fPidBase << endl
00221 << " ComCut = " << fComCut << endl
00222 << " PurCut = " << fPurCut << endl
00223 << " QoPCut = " << fQoPCut << endl
00224 << " Print = " << fPrint << endl
00225 << " Path = " << fPath << endl
00226 << " PREFIX = " << PREFIX << endl
00227 << " Select = " << fSelect << endl;
00228 }
00229
00230 //
00231 // Configure generic Registry for kNN
00232 //
00233 fConfig.Merge(reg);
00234 }
|
|
|
Definition at line 769 of file RunkNN.cxx. References Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), Anp::EventIterator, and fKinBase. Referenced by Run(). 00770 {
00771 //
00772 // Erase temporary data required for kinematic kNN selection
00773 //
00774
00775 vector<short> kvec;
00776 kvec.push_back(fKinBase + 1);
00777 kvec.push_back(fKinBase + 2);
00778 kvec.push_back(fKinBase + 3);
00779 kvec.push_back(fKinBase + 4);
00780 kvec.push_back(fKinBase + 5);
00781 kvec.push_back(fKinBase + 6);
00782 kvec.push_back(fKinBase + 7);
00783 kvec.push_back(fKinBase + 8);
00784 kvec.push_back(fKinBase + 9);
00785 kvec.push_back(fKinBase + 10);
00786
00787 for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00788 {
00789 ievent -> Erase(std::remove_if(ievent -> DataBegIterator(),
00790 ievent -> DataEndIterator(),
00791 Anp::PrevDataKey(kvec)), ievent -> DataEndIterator());
00792 }
00793 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 258 of file RunkNN.cxx. References fMap. 00259 {
00260 //
00261 // Destroy AlgThread pointers
00262 //
00263 for(ThreadMap::iterator it = fMap.begin(); it != fMap.end(); ++it)
00264 {
00265 AlgThread *alg = it -> second;
00266 assert(alg && "logic error");
00267
00268 cout << " " << it -> first << endl;
00269 alg -> End(block);
00270 delete alg;
00271 }
00272
00273 fMap.clear();
00274 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 237 of file RunkNN.cxx. References fMap, MakeAlg(), MakeNames(), and SaveParts(). 00238 {
00239 //
00240 // Initiliaze self and AlgThread algorithm(s)
00241 //
00242
00243 assert(fMap.empty() && "logic error - Init() function is probably called twice");
00244
00245 SaveParts(header);
00246 MakeNames(header);
00247 MakeAlg(header);
00248
00249 for(ThreadMap::iterator ialg = fMap.begin(); ialg != fMap.end(); ++ialg)
00250 {
00251 ialg -> second -> Init(header);
00252 }
00253
00254 return true;
00255 }
|
|
|
Definition at line 397 of file RunkNN.cxx. References fFile, fPath, infile, MakeKin(), and MakePid(). Referenced by Init(). 00398 {
00399 //
00400 // Make kNN algorithms... lots of hardcoded numbers and decisions...
00401 //
00402
00403 if(fFile.empty())
00404 {
00405 cerr << "RunkNN::MakeAlg - no kNN file names available" << endl;
00406 return;
00407 }
00408
00409 for(map<string, int>::const_iterator ifile = fFile.begin(); ifile != fFile.end(); ++ifile)
00410 {
00411 //
00412 // If not creating new kNN algorithm then check if prototype file exists
00413 //
00414 const string file = fPath + ifile -> first;
00415 ifstream infile(file.c_str(), std::ios_base::in);
00416
00417 if(fCreateNew)
00418 {
00419 if(infile.is_open())
00420 {
00421 cerr << "RunkNN::MakeAlg - file already exists:\n " << file << endl;
00422 continue;
00423 }
00424 }
00425 else
00426 {
00427 if(!infile.is_open())
00428 {
00429 cerr << "RunkNN::MakeAlg - file does not exist:\n " << file << endl;
00430 continue;
00431 }
00432 }
00433
00434 //
00435 // Make FillkNN algorithms for current file and key
00436 //
00437 MakePid(header, ifile -> first, ifile -> second);
00438 MakeKin(header, ifile -> first, ifile -> second);
00439 }
00440 }
|
|
||||||||||||||||
|
Definition at line 535 of file RunkNN.cxx. References Alg(), fConfig, fKinBase, fPath, fSelect, reg, and Registry::Set(). Referenced by MakeAlg(). 00536 {
00537 //
00538 // Lots of hardcoded numbers, will overwrite some FillkNN keys
00539 //
00540
00541 Registry reg(fConfig);
00542 reg.Set("FillkNNFilePath", (fPath + file).c_str());
00543 reg.Set("FillkNNKeyTruth", int(fKinBase + 1));
00544 reg.Set("FillkNNKNeighbor", int(122));
00545 reg.Set("FillkNNKNeighborMod", int(40));
00546 reg.Set("FillkNNAddAll", "yes");
00547 reg.Set("FillkNNAddEvent", "yes");
00548 reg.Set("FillkNNUseTrack", "no");
00549 reg.Set("FillkNNTrim", "yes");
00550 reg.Set("FillkNNTrimDelta", int(1000));
00551
00552 if(fCreateNew)
00553 {
00554 reg.Set("FillkNN", "yes");
00555 }
00556 else
00557 {
00558 reg.Set("FillkNN", "no");
00559 }
00560
00561 //
00562 // Input variables for 1st selection:
00563 //
00564 if(fCreateNew)
00565 {
00566 Alg(file, reg, 0, fKinBase+5, fKinBase+6, fKinBase+ 7, -1); // Q^2, Y, W^2
00567 Alg(file, reg, 0, fKinBase+4, fKinBase+6, fKinBase+10, -1); // P_{\mu}, Y, \theta_{\mu}
00568 }
00569 else
00570 {
00571 if(fSelect == "kinem")
00572 {
00573 Alg(file, reg, fKinBase + kbase, fKinBase+5, fKinBase+6, fKinBase+ 7, -1);
00574 Alg(file, reg, fKinBase + kbase + 300, fKinBase+4, fKinBase+6, fKinBase+10, -1);
00575 }
00576 }
00577 }
|
|
|
Definition at line 303 of file RunkNN.cxx. References Add(), BEAMTYPE, DETECTOR, fMakeAllBeam, fSelect, Anp::Header::IsData(), MCRLTYPE, PREFIX, and RECOTYPE. Referenced by Init(). 00304 {
00305 //
00306 // Make file names for kNN algorithms. This function has
00307 // some hardcoded names and decisions.
00308 //
00309 // File name is ideally created as follows:
00310 //
00311 // PREFIX.DETECTOR.MCRLTYPE.RECOTYPE.BEAMTYPE.root
00312 //
00313
00314 //
00315 // Case when creating new prototype
00316 //
00317 if(fCreateNew)
00318 {
00319 //
00320 // Can not create prototype from data events
00321 //
00322 if(header.IsData()) return true;
00323
00324 //
00325 // Create single file, base key is 0 because no keys should be computed
00326 //
00327 return Add(PREFIX+"."+DETECTOR+"."+MCRLTYPE+"."+RECOTYPE+"."+BEAMTYPE+".root", 0);
00328 }
00329
00330 //
00331 // !!!KLUDGE!!! Only know how to deal with cedar-like releases
00332 //
00333 if(RECOTYPE.find("cedar") == string::npos && RECOTYPE.find("dogwood1")==string::npos)
00334 {
00335 cerr << "RunkNN::MakeNames - unknown reconstruction release: " << RECOTYPE << endl;
00336 return false;
00337 }
00338
00339 //
00340 // !!!KLUDGE!!! Use 3 different Monte-Carlo daikon/cedar releases
00341 //
00342 if(fSelect == "physics" && !(RECOTYPE=="dogwood1"))
00343 {
00344 Add(PREFIX + "." + DETECTOR + ".daikon_04.cedar_phy_bhcurv.L010z185i.root", 0);
00345 Add(PREFIX + "." + DETECTOR + ".daikon_00.cedar_phy.L010z185i.root", 1000);
00346 }
00347 else if(fSelect=="physics")
00348 {
00349 Add(PREFIX + "." + DETECTOR + ".daikon_04.dogwood1.L010z185i.root", 0);
00350 }
00351 else if(RECOTYPE == "cedar_phy_bhcurv")
00352 {
00353 Add(PREFIX + "." + DETECTOR + ".daikon_04.cedar_phy_bhcurv.L010z185i.root", 0);
00354 }
00355 else if(RECOTYPE == "cedar_phy")
00356 {
00357 Add(PREFIX + "." + DETECTOR + ".daikon_00.cedar_phy.L010z185i.root", 1000);
00358 }
00359 else if(RECOTYPE == "dogwood1")
00360 {
00361 Add(PREFIX + "." + DETECTOR + ".daikon_04.dogwood1.L010z185i.root", 0);
00362 }
00363 else if(RECOTYPE == "dogwood1" && fSelect=="QPall")
00364 {
00365 Add(PREFIX + "." + DETECTOR + ".daikon_04.dogwood1.L010z185i.QPall.root", 1000);
00366 }
00367
00368
00369 return true;
00370
00371 //
00372 // Native beam
00373 //
00374 if(BEAMTYPE != "L010z185i" && (RECOTYPE == "cedar" ||
00375 RECOTYPE == "cedar_phy" ||
00376 RECOTYPE == "cedar_phy_bhcurv" ||
00377 RECOTYPE == "dogwood1" ))
00378 {
00379 Add(PREFIX+"."+DETECTOR+"."+MCRLTYPE+"."+RECOTYPE+"."+BEAMTYPE+".root", 10000);
00380 }
00381
00382 //
00383 // Many beams combined
00384 //
00385 if(fMakeAllBeam && (RECOTYPE == "cedar" ||
00386 RECOTYPE == "cedar_phy" ||
00387 RECOTYPE == "cedar_phy_bhcurv" ||
00388 RECOTYPE == "dogwood1" ))
00389 {
00390 Add(PREFIX+"."+DETECTOR+"."+MCRLTYPE+"."+RECOTYPE+"."+"ALLBEAM.root", 11000);
00391 }
00392
00393 return true;
00394 }
|
|
||||||||||||||||
|
Definition at line 443 of file RunkNN.cxx. References Alg(), fConfig, fPath, fPidBase, fSelect, reg, and Registry::Set(). Referenced by MakeAlg(). 00444 {
00445 //
00446 // Lots of hardcoded numbers, will overwrite some FillkNN keys
00447 //
00448
00449 Registry reg(fConfig);
00450 reg.Set("FillkNNFilePath", (fPath + file).c_str());
00451 reg.Set("FillkNNKeySignal", int(1)); // for historical reasons muon have type=1
00452 reg.Set("FillkNNKeyTruth", int(7000)); // value for this key is set by FillMuonId
00453 reg.Set("FillkNNKNeighbor", int(82));
00454 reg.Set("FillkNNKNeighborMod", int(20));
00455 reg.Set("FillkNNAddEvent", "no");
00456 reg.Set("FillkNNUseTrack", "yes");
00457 reg.Set("FillkNNTrim", "yes");
00458 reg.Set("FillkNNTrimDelta", int(1000));
00459
00460 if(fCreateNew)
00461 {
00462 reg.Set("FillkNN", "yes");
00463 }
00464 else
00465 {
00466 reg.Set("FillkNN", "no");
00467 }
00468
00469 //
00470 // !!!KLUDGE!!! Multiple selections...
00471 //
00472 if(fCreateNew)
00473 {
00474 if(fSelect == "physics" )
00475 {
00476 Alg(file, reg, 0, 7001, 7010, 7020, 7040);
00477 Alg(file, reg, 0, 7001, 7210, 7220, 7240);
00478 Alg(file, reg, 0, 7001, 7310, 7320, 7340);
00479 Alg(file, reg, 0, 7001, 7410, 7420, 7440);
00480 Alg(file, reg, 0, 11001, 11210, 11220, 11240);
00481 Alg(file, reg, 0, 11001, 11410, 11420, 11440);
00482 }
00483 else
00484 {
00485 Alg(file, reg, 0, 7001, 7010, 7020, 7040);
00486 Alg(file, reg, 0, 7001, 7210, 7220, 7240);
00487 Alg(file, reg, 0, 7001, 7310, 7320, 7340);
00488 Alg(file, reg, 0, 7001, 7410, 7420, 7440);
00489 Alg(file, reg, 0, 9001, 9210, 9220, 9240);
00490 Alg(file, reg, 0, 9001, 9410, 9420, 9440);
00491 Alg(file, reg, 0, 10001, 10210, 10220, 10240);
00492 Alg(file, reg, 0, 10001, 10410, 10420, 10440);
00493 Alg(file, reg, 0, 11001, 11210, 11220, 11240);
00494 Alg(file, reg, 0, 11001, 11410, 11420, 11440);
00495 Alg(file, reg, 0, 12001, 12210, 12220, 12240);
00496 Alg(file, reg, 0, 12001, 12410, 12420, 12440);
00497 }
00498 }
00499 else
00500 {
00501 if(fSelect == "physics" || fSelect=="QPall")
00502 {
00503 Alg(file, reg, fPidBase + kbase, 7001, 7010, 7020, 7040);
00504 Alg(file, reg, fPidBase + kbase + 200, 11001, 11410, 11420, 11440);
00505 }
00506 else if(fSelect == "study-sigall")
00507 {
00508 Alg(file, reg, fPidBase + kbase, 7001, 7010, 7020, 7040);
00509 Alg(file, reg, fPidBase + kbase + 100, 7001, 7210, 7220, 7240);
00510 Alg(file, reg, fPidBase + kbase + 200, 7001, 7310, 7320, 7340);
00511 Alg(file, reg, fPidBase + kbase + 300, 7001, 7410, 7420, 7440);
00512 }
00513 else if(fSelect == "study-sigcor")
00514 {
00515 Alg(file, reg, fPidBase + kbase, 7001, 7010, 7020, 7040);
00516 Alg(file, reg, fPidBase + kbase + 100, 7001, 7210, 7220, 7240);
00517 Alg(file, reg, fPidBase + kbase + 200, 9001, 9210, 9220, 9240);
00518 Alg(file, reg, fPidBase + kbase + 300, 10001, 10210, 10220, 10240);
00519 Alg(file, reg, fPidBase + kbase + 400, 11001, 11210, 11220, 11240);
00520 Alg(file, reg, fPidBase + kbase + 500, 12001, 12210, 12220, 12240);
00521 }
00522 else if(fSelect == "study-sigmip")
00523 {
00524 Alg(file, reg, fPidBase + kbase, 7001, 7310, 7320, 7340);
00525 Alg(file, reg, fPidBase + kbase + 100, 7001, 7410, 7420, 7440);
00526 Alg(file, reg, fPidBase + kbase + 200, 9001, 9410, 9420, 9440);
00527 Alg(file, reg, fPidBase + kbase + 300, 10001, 10410, 10420, 10440);
00528 Alg(file, reg, fPidBase + kbase + 400, 11001, 11410, 11420, 11440);
00529 Alg(file, reg, fPidBase + kbase + 500, 12001, 12410, 12420, 12440);
00530 }
00531 }
00532 }
|
|
|
Implements Anp::AlgSnarl. Definition at line 56 of file RunkNN.cxx. References AddData(), copy(), CutData(), Anp::Record::EventBeg(), Anp::Record::EventBegIterator(), Anp::Record::EventEnd(), Anp::Record::EventEndIterator(), Anp::EventIter, Anp::EventIterator, fMap, fMultiThread, Anp::Record::GetStdHep(), Anp::Record::GetStrip(), Anp::Record::TrackBeg(), Anp::Record::TrackBegIterator(), Anp::Record::TrackEnd(), Anp::Record::TrackEndIterator(), Anp::TrackIter, and Anp::TrackIterator. 00057 {
00058 //
00059 // Add data to record, run multiple kNN algorithm, the collect and save knn ouput
00060 //
00061
00062 if(fPrint)
00063 {
00064 for(EventIter it = record.EventBeg(); it != record.EventEnd(); ++it)
00065 {
00066 cout << "beg: event index " << it -> EventIndex() << endl;
00067 std::copy(it -> DataBeg(), it -> DataEnd(), ostream_iterator<Data>(cout, "\n"));
00068 }
00069 for(TrackIter it = record.TrackBeg(); it != record.TrackEnd(); ++it)
00070 {
00071 cout << "beg: track index " << it -> TrackIndex() << endl;
00072 std::copy(it -> DataBeg(), it -> DataEnd(), ostream_iterator<Data>(cout, "\n"));
00073 }
00074 }
00075
00076 //
00077 // Add data needed by kinematic kNN selection
00078 //
00079 AddData(record);
00080
00081 //
00082 // Make lightweight copy of Record for AlgThread(s)
00083 //
00084 Record copy = record;
00085 copy.GetStrip().clear();
00086 copy.GetStdHep().clear();
00087
00088 //
00089 // First pass, run all kNN algorithms
00090 //
00091 for(ThreadMap::iterator ialg = fMap.begin(); ialg != fMap.end(); ++ialg)
00092 {
00093 ialg -> second -> Run(copy, fMultiThread);
00094 }
00095
00096 //
00097 // Second pass, collect data
00098 //
00099 for(ThreadMap::iterator ialg = fMap.begin(); ialg != fMap.end(); ++ialg)
00100 {
00101 AlgThread *alg = ialg -> second;
00102
00103 if(fMultiThread && alg -> Join() != 0)
00104 {
00105 cerr << "RunkNN::Run - thread join function failed" << endl;
00106 continue;
00107 }
00108
00109 //
00110 // Collect data from current AlgThread algorithm
00111 //
00112 map<int, PrevDataKey> event_map, track_map;
00113
00114 for(EventIter it = alg -> GetRecord().EventBeg(); it != alg -> GetRecord().EventEnd(); ++it)
00115 {
00116 event_map[it -> EventIndex()] = PrevDataKey(it -> DataBeg(), it -> DataEnd());
00117 }
00118 for(TrackIter it = alg -> GetRecord().TrackBeg(); it != alg -> GetRecord().TrackEnd(); ++it)
00119 {
00120 track_map[it -> TrackIndex()] = PrevDataKey(it -> DataBeg(), it -> DataEnd());
00121 }
00122
00123 //
00124 // Add data from current AlgThread algorithm to events and tracks
00125 //
00126 for(EventIterator it = record.EventBegIterator(); it != record.EventEndIterator(); ++it)
00127 {
00128 event_map[it -> EventIndex()](*it);
00129 }
00130 for(TrackIterator it = record.TrackBegIterator(); it != record.TrackEndIterator(); ++it)
00131 {
00132 track_map[it -> TrackIndex()](*it);
00133 }
00134 }
00135
00136 //
00137 // Sort event and track data by keys
00138 //
00139 for(EventIterator it = record.EventBegIterator(); it != record.EventEndIterator(); ++it)
00140 {
00141 std::sort(it -> DataBegIterator(), it -> DataEndIterator());
00142 }
00143 for(TrackIterator it = record.TrackBegIterator(); it != record.TrackEndIterator(); ++it)
00144 {
00145 std::sort(it -> DataBegIterator(), it -> DataEndIterator());
00146 }
00147
00148 //
00149 // Erase temporary data added by this algorithm
00150 //
00151 if(fEraseData) CutData(record);
00152
00153 if(fPrint)
00154 {
00155 for(EventIter it = record.EventBeg(); it != record.EventEnd(); ++it)
00156 {
00157 cout << "end: event index " << it -> EventIndex() << endl;
00158 std::copy(it -> DataBeg(), it -> DataEnd(), ostream_iterator<Data>(cout, "\n"));
00159 }
00160 for(TrackIter it = record.TrackBeg(); it != record.TrackEnd(); ++it)
00161 {
00162 cout << "end: track index " << it -> TrackIndex() << endl;
00163 std::copy(it -> DataBeg(), it -> DataEnd(), ostream_iterator<Data>(cout, "\n"));
00164 }
00165 }
00166
00167 return true;
00168 }
|
|
|
Definition at line 277 of file RunkNN.cxx. References BEAMTYPE, DETECTOR, Anp::Header::GetBEAMTYPE(), Anp::Header::GetDETECTOR(), Anp::Header::GetMCRLTYPE(), Anp::Header::GetRECOTYPE(), MCRLTYPE, and RECOTYPE. Referenced by Init(). 00278 {
00279 //
00280 // Collect parts of information for knn prototype file name.
00281 //
00282
00283 DETECTOR = header.GetDETECTOR();
00284 MCRLTYPE = header.GetMCRLTYPE();
00285 RECOTYPE = header.GetRECOTYPE();
00286
00287 //
00288 // Do not specify BEAMTYPE if fMakeAllBeam is set to true.
00289 //
00290 if(fMakeAllBeam)
00291 {
00292 BEAMTYPE = "ALLBEAM";
00293 }
00294 else
00295 {
00296 BEAMTYPE = header.GetBEAMTYPE();
00297 }
00298
00299 return false;
00300 }
|
|
|
Definition at line 90 of file RunkNN.h. Referenced by MakeNames(), and SaveParts(). |
|
|
Definition at line 87 of file RunkNN.h. Referenced by MakeNames(), and SaveParts(). |
|
|
Definition at line 77 of file RunkNN.h. Referenced by Config(). |
|
|
|
|
|
Definition at line 67 of file RunkNN.h. Referenced by Config(). |
|
|
Definition at line 68 of file RunkNN.h. Referenced by Config(). |
|
|
|
|
|
Definition at line 74 of file RunkNN.h. Referenced by AddData(), Config(), CutData(), and MakeKin(). |
|
|
Definition at line 69 of file RunkNN.h. Referenced by Config(), and MakeNames(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 83 of file RunkNN.h. Referenced by Config(), MakeAlg(), MakeKin(), and MakePid(). |
|
|
|
|
|
Definition at line 71 of file RunkNN.h. Referenced by Config(). |
|
|
|
|
|
Definition at line 79 of file RunkNN.h. Referenced by Config(). |
|
|
Definition at line 91 of file RunkNN.h. Referenced by Config(), MakeKin(), MakeNames(), and MakePid(). |
|
|
Definition at line 88 of file RunkNN.h. Referenced by MakeNames(), and SaveParts(). |
|
|
Definition at line 86 of file RunkNN.h. Referenced by Config(), and MakeNames(). |
|
|
Definition at line 89 of file RunkNN.h. Referenced by MakeNames(), and SaveParts(). |
1.3.9.1