GENIEGenerator
Loading...
Searching...
No Matches
gEvPick.cxx File Reference
#include <cassert>
#include <string>
#include <sstream>
#include <TSystem.h>
#include <TFile.h>
#include <TTree.h>
#include <TChain.h>
#include <TChainElement.h>
#include "Framework/Conventions/GBuild.h"
#include "Framework/EventGen/EventRecord.h"
#include "Framework/GHEP/GHepStatus.h"
#include "Framework/GHEP/GHepParticle.h"
#include "Framework/GHEP/GHepUtils.h"
#include "Framework/Ntuple/NtpMCFormat.h"
#include "Framework/Ntuple/NtpMCTreeHeader.h"
#include "Framework/Ntuple/NtpMCEventRecord.h"
#include "Framework/Ntuple/NtpWriter.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/ParticleData/PDGCodes.h"
#include "Framework/ParticleData/PDGUtils.h"
#include "Framework/ParticleData/PDGLibrary.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/CmdLnArgParser.h"
#include "Framework/Utils/SystemUtils.h"
#include "Framework/Utils/RunOpt.h"
Include dependency graph for gEvPick.cxx:

Go to the source code of this file.

Typedefs

typedef enum EGPickType GPickType_t

Enumerations

enum  EGPickType {
  kPtUndefined = 0 , kPtAll , kPtTopoNumuCC1pip , kPtTopoNumuCC1pi0 ,
  kPtTopoNumuCC1pim , kPtTopoNumuNC1pip , kPtTopoNumuNC1pi0 , kPtTopoNumuNC1pim ,
  kPtTopoNumuCChyperon , kPtTopoNumubarCChyperon , kPtTopoCChyperon , kPtReacModeCCQE ,
  kPtReacModeNumuCCQE , kPtReacModeCCMEC , kPtReacModeNumuCCMEC , kPtReacModeCCQEMEC ,
  kPtReacModeNumuCCQEMEC , kPtReacModeNotCCQEMEC , kPtReacModeCCNotQEMEC , kPtReacModeNotNumuCCQEMEC ,
  kPtReacModeNumuNotCCQEMEC
}

Functions

void GetCommandLineArgs (int argc, char **argv)
void RunCherryPicker (void)
bool AcceptEvent (const EventRecord &event)
void PrintSyntax (void)
string DefaultOutputFile (void)
int main (int argc, char **argv)

Variables

string gOptInpFileNames
 input file name
string gOptOutFileName
 output file name
string gPickedTypeStr
 output file name
GPickType_t gPickedType
 output file format id

Typedef Documentation

◆ GPickType_t

typedef enum EGPickType GPickType_t

Enumeration Type Documentation

◆ EGPickType

enum EGPickType
Enumerator
kPtUndefined 
kPtAll 
kPtTopoNumuCC1pip 
kPtTopoNumuCC1pi0 
kPtTopoNumuCC1pim 
kPtTopoNumuNC1pip 
kPtTopoNumuNC1pi0 
kPtTopoNumuNC1pim 
kPtTopoNumuCChyperon 
kPtTopoNumubarCChyperon 
kPtTopoCChyperon 
kPtReacModeCCQE 
kPtReacModeNumuCCQE 
kPtReacModeCCMEC 
kPtReacModeNumuCCMEC 
kPtReacModeCCQEMEC 
kPtReacModeNumuCCQEMEC 
kPtReacModeNotCCQEMEC 
kPtReacModeCCNotQEMEC 
kPtReacModeNotNumuCCQEMEC 
kPtReacModeNumuNotCCQEMEC 

Definition at line 183 of file gEvPick.cxx.

183 {
184 kPtUndefined = 0,
185 kPtAll,
186 //
187 // Types based on final state topology, regardless of reaction mode
188 //
198 //
199 // Types based on true reaction mode, regardless of final state topology
200 //
211
enum EGPickType GPickType_t
@ kPtTopoNumubarCChyperon
Definition gEvPick.cxx:196
@ kPtReacModeNotNumuCCQEMEC
Definition gEvPick.cxx:209
@ kPtReacModeNumuCCMEC
Definition gEvPick.cxx:204
@ kPtReacModeCCNotQEMEC
Definition gEvPick.cxx:208
@ kPtReacModeNumuCCQEMEC
Definition gEvPick.cxx:206
@ kPtTopoNumuCC1pim
Definition gEvPick.cxx:191
@ kPtReacModeCCMEC
Definition gEvPick.cxx:203
@ kPtReacModeCCQEMEC
Definition gEvPick.cxx:205
@ kPtTopoNumuNC1pip
Definition gEvPick.cxx:192
@ kPtReacModeCCQE
Definition gEvPick.cxx:201
@ kPtTopoNumuCC1pip
Definition gEvPick.cxx:189
@ kPtTopoNumuCChyperon
Definition gEvPick.cxx:195
@ kPtAll
Definition gEvPick.cxx:185
@ kPtTopoNumuNC1pi0
Definition gEvPick.cxx:193
@ kPtTopoCChyperon
Definition gEvPick.cxx:197
@ kPtReacModeNumuNotCCQEMEC
Definition gEvPick.cxx:210
@ kPtTopoNumuNC1pim
Definition gEvPick.cxx:194
@ kPtUndefined
Definition gEvPick.cxx:184
@ kPtReacModeNumuCCQE
Definition gEvPick.cxx:202
@ kPtTopoNumuCC1pi0
Definition gEvPick.cxx:190
@ kPtReacModeNotCCQEMEC
Definition gEvPick.cxx:207

Function Documentation

◆ AcceptEvent()

bool AcceptEvent ( const EventRecord & event)

Definition at line 331 of file gEvPick.cxx.

332{
333 if ( gPickedType == kPtAll ) return true;
334 if ( gPickedType == kPtUndefined ) return false;
335
336 const Interaction * interaction = event.Summary();
337
338 int nupdg = event.Probe()->Pdg();
339 bool isnumu = (nupdg == kPdgNuMu);
340 bool isnumubar = (nupdg == kPdgAntiNuMu);
341 bool iscc = interaction->ProcInfo().IsWeakCC();
342 bool isnc = interaction->ProcInfo().IsWeakNC();
343 bool isqe = interaction->ProcInfo().IsQuasiElastic();
344 bool ismec = interaction->ProcInfo().IsMEC();
345 bool isstr = interaction->ExclTag().IsStrangeEvent();
346 bool ischm = interaction->ExclTag().IsCharmEvent();
347
348 int NfP = 0; // number of protons in final state
349 int NfPbar = 0; // number of anti-protons in final state
350 int NfN = 0; // number of neutrons in final state
351 int NfNbar = 0; // number of anti-neutrons in final state
352 int NfPip = 0; // number of \pi^+'s in final state
353 int NfPim = 0; // number of \pi^-'s in final state
354 int NfPi0 = 0; // number of \pi^0's in final state
355 int NfKp = 0; // number of \K^+'s in final state
356 int NfKm = 0; // number of \K^-'s in final state
357 int NfK0 = 0; // number of \K^0's in final state
358 int NfK0bar = 0; // number of \bar{\K^0}'s in final state
359 int NfSigmap = 0; // number of \Sigma^+'s in final state
360 int NfSigma0 = 0; // number of \Sigma^0's in final state
361 int NfSigmam = 0; // number of \Sigma^-'s in final state
362 int NfLambda0 = 0; // number of \Lambda^0's in final state
363 int NfXi0 = 0; // number of \Xi^0's in final state
364 int NfXim = 0; // number of \Xi^-'s in final state
365 int NfOmegam = 0; // number of \Omega^-'s in final state
366 int NfOther = 0; // number of other particles in final state
367
368 TObjArrayIter piter(&event);
369 GHepParticle * p = 0;
370 int ip=-1;
371 while( (p = (GHepParticle *) piter.Next())) {
372 ip++;
373 int pdgc = p->Pdg();
374 int ist = p->Status();
375 // only final state particles
376 if(ist!=kIStStableFinalState) continue;
377 // don't count final state lepton as part of the hadronic system
378 if(event.Particle(ip)->FirstMother()==0) continue;
379 // skip pseudo-particles
380 if(pdg::IsPseudoParticle(pdgc)) continue;
381 // count ...
382 if (pdgc == kPdgProton ) NfP++;
383 else if (pdgc == kPdgAntiProton ) NfPbar++;
384 else if (pdgc == kPdgNeutron ) NfN++;
385 else if (pdgc == kPdgAntiNeutron) NfNbar++;
386 else if (pdgc == kPdgPiP ) NfPip++;
387 else if (pdgc == kPdgPiM ) NfPim++;
388 else if (pdgc == kPdgPi0 ) NfPi0++;
389 else if (pdgc == kPdgKP ) NfKp++;
390 else if (pdgc == kPdgKM ) NfKm++;
391 else if (pdgc == kPdgK0 ) NfK0++;
392 else if (pdgc == kPdgAntiK0 ) NfK0bar++;
393 else if (pdgc == kPdgSigmaP ) NfSigmap++;
394 else if (pdgc == kPdgSigma0 ) NfSigma0++;
395 else if (pdgc == kPdgSigmaM ) NfSigmam++;
396 else if (pdgc == kPdgLambda ) NfLambda0++;
397 else if (pdgc == kPdgXi0 ) NfXi0++;
398 else if (pdgc == kPdgXiM ) NfXim++;
399 else if (pdgc == kPdgOmegaM ) NfOmegam++;
400 else NfOther++;
401 }
402
403 bool is1pipX = (NfPip==1 && NfPi0==0 && NfPim==0);
404 bool is1pi0X = (NfPip==0 && NfPi0==1 && NfPim==0);
405 bool is1pimX = (NfPip==0 && NfPi0==0 && NfPim==1);
406 bool has_hype = (NfSigmap+NfSigma0+NfSigmam+NfLambda0+NfXi0+NfXim+NfOmegam > 0);
407
409 if(isnumu && iscc && is1pipX) return true;
410 }
411 else
413 if(isnumu && iscc && is1pi0X) return true;
414 }
415 else
417 if(isnumu && iscc && is1pimX) return true;
418 }
419 else
421 if(isnumu && isnc && is1pipX) return true;
422 }
423 else
425 if(isnumu && isnc && is1pi0X) return true;
426 }
427 else
429 if(isnumu && isnc && is1pimX) return true;
430 }
431 else
433 if(isnumu && iscc && has_hype) return true;
434 }
435 else
437 if(isnumubar && iscc && has_hype) return true;
438 }
439 else
440 if ( gPickedType == kPtTopoCChyperon ) {
441 if(iscc && has_hype) return true;
442 }
443 else
444 if ( gPickedType == kPtReacModeCCQE ) {
445 if(isstr || ischm) return false;
446 if(iscc && isqe) return true;
447 }
448 else
450 if(isstr || ischm) return false;
451 if(isnumu && iscc && isqe) return true;
452 }
453 else
454 if ( gPickedType == kPtReacModeCCMEC ) {
455 if(isstr || ischm) return false;
456 if(iscc && ismec) return true;
457 }
458 else
460 if(isstr || ischm) return false;
461 if(isnumu && iscc && ismec) return true;
462 }
463 else
465 if(isstr || ischm) return false;
466 if(iscc && (isqe || ismec)) return true;
467 }
468 else
470 if(isstr || ischm) return false;
471 if(isnumu && iscc && (isqe || ismec)) return true;
472 }
473 else
475 if(isstr || ischm) return false;
476 if(!(iscc && (isqe || ismec))) return true;
477 }
478 else
480 if(isstr || ischm) return false;
481 if(!(isnumu && iscc && (isqe || ismec))) return true;
482 }
483 else
485 if(isstr || ischm) return false;
486 if(iscc && !(isqe || ismec)) return true;
487 }
488 else
490 if(isstr || ischm) return false;
491 if(isnumu && !(iscc && (isqe || ismec))) return true;
492 }
493
494 return false;
495}
STDHEP-like event record entry that can fit a particle or a nucleus.
int FirstMother(void) const
int Pdg(void) const
GHepStatus_t Status(void) const
virtual GHepParticle * Particle(int position) const
Summary information for an interaction.
Definition Interaction.h:56
const XclsTag & ExclTag(void) const
Definition Interaction.h:72
const ProcessInfo & ProcInfo(void) const
Definition Interaction.h:70
bool IsWeakNC(void) const
bool IsWeakCC(void) const
bool IsQuasiElastic(void) const
bool IsMEC(void) const
bool IsStrangeEvent(void) const
Definition XclsTag.h:53
bool IsCharmEvent(void) const
Definition XclsTag.h:50
GPickType_t gPickedType
output file format id
Definition gEvPick.cxx:218
bool IsPseudoParticle(int pdgc)
Definition PDGUtils.cxx:27
const int kPdgPiM
Definition PDGCodes.h:159
@ kIStStableFinalState
Definition GHepStatus.h:30
const int kPdgSigma0
Definition PDGCodes.h:88
const int kPdgAntiProton
Definition PDGCodes.h:82
const int kPdgProton
Definition PDGCodes.h:81
const int kPdgSigmaP
Definition PDGCodes.h:87
const int kPdgPi0
Definition PDGCodes.h:160
const int kPdgKP
Definition PDGCodes.h:172
const int kPdgNeutron
Definition PDGCodes.h:83
const int kPdgOmegaM
Definition PDGCodes.h:97
const int kPdgKM
Definition PDGCodes.h:173
const int kPdgAntiNuMu
Definition PDGCodes.h:31
const int kPdgPiP
Definition PDGCodes.h:158
const int kPdgLambda
Definition PDGCodes.h:85
const int kPdgSigmaM
Definition PDGCodes.h:89
const int kPdgXiM
Definition PDGCodes.h:94
const int kPdgNuMu
Definition PDGCodes.h:30
const int kPdgAntiNeutron
Definition PDGCodes.h:84
const int kPdgXi0
Definition PDGCodes.h:93
const int kPdgAntiK0
Definition PDGCodes.h:175
const int kPdgK0
Definition PDGCodes.h:174

References genie::Interaction::ExclTag(), genie::GHepParticle::FirstMother(), gPickedType, genie::XclsTag::IsCharmEvent(), genie::ProcessInfo::IsMEC(), genie::pdg::IsPseudoParticle(), genie::ProcessInfo::IsQuasiElastic(), genie::XclsTag::IsStrangeEvent(), genie::ProcessInfo::IsWeakCC(), genie::ProcessInfo::IsWeakNC(), genie::kIStStableFinalState, genie::kPdgAntiK0, genie::kPdgAntiNeutron, genie::kPdgAntiNuMu, genie::kPdgAntiProton, genie::kPdgK0, genie::kPdgKM, genie::kPdgKP, genie::kPdgLambda, genie::kPdgNeutron, genie::kPdgNuMu, genie::kPdgOmegaM, genie::kPdgPi0, genie::kPdgPiM, genie::kPdgPiP, genie::kPdgProton, genie::kPdgSigma0, genie::kPdgSigmaM, genie::kPdgSigmaP, genie::kPdgXi0, genie::kPdgXiM, kPtAll, kPtReacModeCCMEC, kPtReacModeCCNotQEMEC, kPtReacModeCCQE, kPtReacModeCCQEMEC, kPtReacModeNotCCQEMEC, kPtReacModeNotNumuCCQEMEC, kPtReacModeNumuCCMEC, kPtReacModeNumuCCQE, kPtReacModeNumuCCQEMEC, kPtReacModeNumuNotCCQEMEC, kPtTopoCChyperon, kPtTopoNumubarCChyperon, kPtTopoNumuCC1pi0, kPtTopoNumuCC1pim, kPtTopoNumuCC1pip, kPtTopoNumuCChyperon, kPtTopoNumuNC1pi0, kPtTopoNumuNC1pim, kPtTopoNumuNC1pip, kPtUndefined, genie::GHepRecord::Particle(), genie::GHepParticle::Pdg(), genie::Interaction::ProcInfo(), and genie::GHepParticle::Status().

Referenced by RunCherryPicker().

◆ DefaultOutputFile()

string DefaultOutputFile ( void )

Definition at line 577 of file gEvPick.cxx.

578{
579 string tp = "";
580
581 if (gPickedType == kPtAll ) { tp = "all"; }
582
583 else if (gPickedType == kPtTopoNumuCC1pip ) { tp = "numu_cc_1pip"; }
584 else if (gPickedType == kPtTopoNumuCC1pi0 ) { tp = "numu_cc_1pi0"; }
585 else if (gPickedType == kPtTopoNumuCC1pim ) { tp = "numu_cc_1pim"; }
586 else if (gPickedType == kPtTopoNumuNC1pip ) { tp = "numu_nc_1pip"; }
587 else if (gPickedType == kPtTopoNumuNC1pi0 ) { tp = "numu_nc_1pi0"; }
588 else if (gPickedType == kPtTopoNumuNC1pim ) { tp = "numu_nc_1pim"; }
589 else if (gPickedType == kPtTopoNumuCChyperon ) { tp = "numu_cc_hyperon"; }
590 else if (gPickedType == kPtTopoNumubarCChyperon ) { tp = "numubar_cc_hyperon"; }
591 else if (gPickedType == kPtTopoCChyperon ) { tp = "cc_hyperon"; }
592
593 else if (gPickedType == kPtReacModeCCQE ) { tp = "cc_qe"; }
594 else if (gPickedType == kPtReacModeNumuCCQE ) { tp = "numu_cc_qe"; }
595 else if (gPickedType == kPtReacModeCCMEC ) { tp = "cc_mec"; }
596 else if (gPickedType == kPtReacModeNumuCCMEC ) { tp = "numu_cc_mec"; }
597 else if (gPickedType == kPtReacModeCCQEMEC ) { tp = "cc_qe_mec"; }
598 else if (gPickedType == kPtReacModeNumuCCQEMEC ) { tp = "numu_cc_qe_mec"; }
599 else if (gPickedType == kPtReacModeNotCCQEMEC ) { tp = "not_cc_qe_mec"; }
600 else if (gPickedType == kPtReacModeCCNotQEMEC ) { tp = "cc_not_qe_mec"; }
601 else if (gPickedType == kPtReacModeNotNumuCCQEMEC ) { tp = "not_numu_cc_qe_mec"; }
602 else if (gPickedType == kPtReacModeNumuNotCCQEMEC ) { tp = "numu_not_cc_qe_mec"; }
603
604 ostringstream fnm;
605 fnm << "gntp." << tp << ".ghep.root";
606
607 return fnm.str();
608}

References gPickedType, kPtAll, kPtReacModeCCMEC, kPtReacModeCCNotQEMEC, kPtReacModeCCQE, kPtReacModeCCQEMEC, kPtReacModeNotCCQEMEC, kPtReacModeNotNumuCCQEMEC, kPtReacModeNumuCCMEC, kPtReacModeNumuCCQE, kPtReacModeNumuCCQEMEC, kPtReacModeNumuNotCCQEMEC, kPtTopoCChyperon, kPtTopoNumubarCChyperon, kPtTopoNumuCC1pi0, kPtTopoNumuCC1pim, kPtTopoNumuCC1pip, kPtTopoNumuCChyperon, kPtTopoNumuNC1pi0, kPtTopoNumuNC1pim, and kPtTopoNumuNC1pip.

Referenced by GetCommandLineArgs().

◆ GetCommandLineArgs()

void GetCommandLineArgs ( int argc,
char ** argv )

Definition at line 497 of file gEvPick.cxx.

498{
499 // Common run options. Set defaults and read.
501
502 // Parse run options for this app
503
504 CmdLnArgParser parser(argc,argv);
505
506 // get input ROOT file (containing a GENIE GHEP event tree)
507 if( parser.OptionExists('i') ) {
508 gOptInpFileNames = parser.ArgAsString('i');
509 } else {
510 LOG("gevpick", pFATAL)
511 << "Unspecified input filename - Exiting";
512 PrintSyntax();
513 gAbortingInErr = true;
514 exit(1);
515 }
516
517 // requested event type
518 string evtype = "";
519 if( parser.OptionExists('t') ) {
520 evtype = parser.ArgAsString('t');
521 if ( evtype == "all" ) { gPickedType = kPtAll; }
522
523 else if ( evtype == "numu_cc_1pip" ) { gPickedType = kPtTopoNumuCC1pip; }
524 else if ( evtype == "numu_cc_1pi0" ) { gPickedType = kPtTopoNumuCC1pi0; }
525 else if ( evtype == "numu_cc_1pim" ) { gPickedType = kPtTopoNumuCC1pim; }
526 else if ( evtype == "numu_nc_1pip" ) { gPickedType = kPtTopoNumuNC1pip; }
527 else if ( evtype == "numu_nc_1pi0" ) { gPickedType = kPtTopoNumuNC1pi0; }
528 else if ( evtype == "numu_nc_1pim" ) { gPickedType = kPtTopoNumuNC1pim; }
529 else if ( evtype == "numu_cc_hyperon" ) { gPickedType = kPtTopoNumuCChyperon; }
530 else if ( evtype == "numubar_cc_hyperon" ) { gPickedType = kPtTopoNumubarCChyperon; }
531 else if ( evtype == "cc_hyperon" ) { gPickedType = kPtTopoCChyperon; }
532
533 else if ( evtype == "cc_qe" ) { gPickedType = kPtReacModeCCQE; }
534 else if ( evtype == "numu_cc_qe" ) { gPickedType = kPtReacModeNumuCCQE; }
535 else if ( evtype == "cc_mec" ) { gPickedType = kPtReacModeCCMEC; }
536 else if ( evtype == "numu_cc_mec" ) { gPickedType = kPtReacModeNumuCCMEC; }
537 else if ( evtype == "cc_qe_mec" ) { gPickedType = kPtReacModeCCQEMEC; }
538 else if ( evtype == "numu_cc_qe_mec" ) { gPickedType = kPtReacModeNumuCCQEMEC; }
539 else if ( evtype == "not_cc_qe_mec" ) { gPickedType = kPtReacModeNotCCQEMEC; }
540 else if ( evtype == "cc_not_qe_mec" ) { gPickedType = kPtReacModeCCNotQEMEC; }
541 else if ( evtype == "not_numu_cc_qe_mec" ) { gPickedType = kPtReacModeNotNumuCCQEMEC; }
542 else if ( evtype == "numu_not_cc_qe_mec" ) { gPickedType = kPtReacModeNumuNotCCQEMEC; }
543
544 else { gPickedType = kPtUndefined; }
545
547 LOG("gevpick", pFATAL) << "Unknown event type (" << evtype << ")";
548 gAbortingInErr = true;
549 exit(1);
550 }
551 gPickedTypeStr = evtype;
552
553 } else {
554 LOG("gevpick", pFATAL) << "Unspecified event type";
555 gAbortingInErr = true;
556 exit(1);
557 }
558
559 // get output file name
560 if( parser.OptionExists('o') ) {
561 gOptOutFileName = parser.ArgAsString('o');
562 } else {
563 LOG("gevpick", pINFO)
564 << "Unspecified output filename - Using default";
566 }
567
568 // Summarize
569 LOG("gevpick", pNOTICE)
570 << "\n\n gevpick job info: "
571 << "\n - input file(s) : " << gOptInpFileNames
572 << "\n - output file : " << gOptOutFileName
573 << "\n - cherry-picked topology : " << evtype
574 << "\n";
575}
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define pFATAL
Definition Messenger.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
Command line argument parser.
void ReadFromCommandLine(int argc, char **argv)
Definition RunOpt.cxx:99
static RunOpt * Instance(void)
Definition RunOpt.cxx:54
string gOptOutFileName
Definition gEvGen.cxx:241
string gPickedTypeStr
output file name
Definition gEvPick.cxx:217
string gOptInpFileNames
input file name
Definition gEvPick.cxx:215
string DefaultOutputFile(void)
Definition gEvPick.cxx:577
void PrintSyntax(void)
Definition gEvPick.cxx:610
bool gAbortingInErr
Definition Messenger.cxx:34

References genie::CmdLnArgParser::ArgAsString(), DefaultOutputFile(), genie::gAbortingInErr, gOptInpFileNames, gOptOutFileName, gPickedType, gPickedTypeStr, genie::RunOpt::Instance(), kPtAll, kPtReacModeCCMEC, kPtReacModeCCNotQEMEC, kPtReacModeCCQE, kPtReacModeCCQEMEC, kPtReacModeNotCCQEMEC, kPtReacModeNotNumuCCQEMEC, kPtReacModeNumuCCMEC, kPtReacModeNumuCCQE, kPtReacModeNumuCCQEMEC, kPtReacModeNumuNotCCQEMEC, kPtTopoCChyperon, kPtTopoNumubarCChyperon, kPtTopoNumuCC1pi0, kPtTopoNumuCC1pim, kPtTopoNumuCC1pip, kPtTopoNumuCChyperon, kPtTopoNumuNC1pi0, kPtTopoNumuNC1pim, kPtTopoNumuNC1pip, kPtUndefined, LOG, genie::CmdLnArgParser::OptionExists(), pFATAL, pINFO, pNOTICE, PrintSyntax(), and genie::RunOpt::ReadFromCommandLine().

Referenced by main().

◆ main()

int main ( int argc,
char ** argv )

Definition at line 221 of file gEvPick.cxx.

222{
223 GetCommandLineArgs(argc, argv);
224
225 utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
226 GHepRecord::SetPrintLevel(RunOpt::Instance()->EventRecordPrintLevel());
227
229
230 return 0;
231}
static void SetPrintLevel(int print_level)
void GetCommandLineArgs(int argc, char **argv)
Definition gEvPick.cxx:497
void RunCherryPicker(void)
Definition gEvPick.cxx:233
void MesgThresholds(string inpfile)
Definition AppInit.cxx:99

References GetCommandLineArgs(), genie::RunOpt::Instance(), genie::utils::app_init::MesgThresholds(), RunCherryPicker(), and genie::GHepRecord::SetPrintLevel().

◆ PrintSyntax()

void PrintSyntax ( void )

Definition at line 610 of file gEvPick.cxx.

611{
612 string basedir = string( gSystem->Getenv("GENIE") );
613 string thisfile = basedir + string("/src/Apps/gEvPick.cxx");
614 string cmd = "less " + thisfile;
615
616 gSystem->Exec(cmd.c_str());
617}

Referenced by GetCommandLineArgs().

◆ RunCherryPicker()

void RunCherryPicker ( void )

Definition at line 233 of file gEvPick.cxx.

234{
235 // Create an NtpWriter for writing out a tree with the cherry-picked events
236 // Add 2 additional branches to the output event tree to save the original filename
237 // and the event number in the original file (so that all info can be traced back
238 // to its source).
239
240 NtpWriter ntpw(kNFGHEP, 0);
241 ntpw.CustomizeFilename(gOptOutFileName);
242 ntpw.Initialize();
243 TObjString* brOrigFilename = new TObjString;
244 Long64_t brOrigEvtNum;
245 ntpw.EventTree()->Branch("orig_filename", "TObjString", &brOrigFilename, 5000,0);
246 ntpw.EventTree()->Branch("orig_evtnum", &brOrigEvtNum, "brOrigEvtNum/L");
247 Long64_t iev_glob = 0;
248
249 // Load input trees. More than one trees can be loaded here if a wildcard was
250 // specified with -f (eg -f /data/myfiles/genie/*.ghep.root)
251
252 TChain gchain;
253 gchain.Add(gOptInpFileNames.c_str());
254
255 TObjArray * file_array = gchain.GetListOfFiles();
256 int nfiles = file_array->GetEntries();
257 LOG("gevpick", pNOTICE)
258 << "Processing " << nfiles
259 << (nfiles==1 ? " file " : " files ");
260
261 //
262 // Loop over input event files
263 //
264
265 TIter next_file(file_array);
266 TChainElement *chEl=0;
267
268 unsigned int total_events = 0;
269 unsigned int picked_events = 0;
270
271 while (( chEl=(TChainElement*)next_file() )) {
272
273 TFile fin(chEl->GetTitle(),"read");
274 TTree * ghep_tree =
275 dynamic_cast <TTree *> ( fin.Get("gtree") );
276
277 if(!ghep_tree) {
278 LOG("gevpick", pWARN)
279 << "No GHEP tree found in " << chEl->GetTitle();
280 LOG("gevpick", pWARN)
281 << "Skipping to next file...";
282 continue;
283 }
284
285 NtpMCEventRecord * mcrec = 0;
286 ghep_tree->SetBranchAddress("gmcrec", &mcrec);
287 if (!mcrec) {
288 LOG("gevpick", pERROR) << "Null MC record";
289 return;
290 }
291 Long64_t nmax = ghep_tree->GetEntries();
292 LOG("gevpick", pNOTICE)
293 << "* Analyzing: " << nmax
294 << " events from GHEP tree in file: " << chEl->GetTitle();
295
296 NtpMCTreeHeader * thdr =
297 dynamic_cast <NtpMCTreeHeader *> ( fin.Get("header") );
298 LOG("gevpick", pNOTICE)
299 << "Input tree header: " << *thdr;
300
301 //
302 // Loop over events in current file
303 //
304
305 for(Long64_t iev = 0; iev < nmax; iev++) {
306 total_events++;
307 ghep_tree->GetEntry(iev);
308 NtpMCRecHeader rec_header = mcrec->hdr;
309 EventRecord & event = *(mcrec->event);
310 LOG("gevpick", pDEBUG) << rec_header;
311 LOG("gevpick", pDEBUG) << event;
312 if(AcceptEvent(event)) {
313 picked_events++;
314 brOrigFilename->SetString(chEl->GetTitle());
315 brOrigEvtNum = iev;
316 ntpw.AddEventRecord( iev_glob, &event );
317 iev_glob++;
318 }
319 mcrec->Clear();
320
321 } // event loop (current file)
322 }// file loop
323
324 // save the cherry-picked MC events
325 ntpw.Save();
326
327 LOG("gevpick", pNOTICE) << "Picked " << picked_events << " / " << total_events << " events of type " << gPickedTypeStr;
328 LOG("gevpick", pNOTICE) << "Done!";
329}
#define pERROR
Definition Messenger.h:59
#define pDEBUG
Definition Messenger.h:63
#define pWARN
Definition Messenger.h:60
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition EventRecord.h:37
MINOS-style ntuple record. Each such ntuple record holds a generated EventRecord object....
EventRecord * event
event
void Clear(Option_t *opt="")
MINOS-style Ntuple Class to hold an MC Event Record Header.
NtpMCRecHeader hdr
record header
MINOS-style Ntuple Class to hold an output MC Tree Header.
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records.
Definition NtpWriter.h:39
bool AcceptEvent(const EventRecord &event)
Definition gEvPick.cxx:331
@ kNFGHEP
Definition NtpMCFormat.h:30

References AcceptEvent(), genie::NtpWriter::AddEventRecord(), genie::NtpMCEventRecord::Clear(), genie::NtpWriter::CustomizeFilename(), genie::NtpMCEventRecord::event, genie::NtpWriter::EventTree(), gOptInpFileNames, gOptOutFileName, gPickedTypeStr, genie::NtpMCRecordI::hdr, genie::NtpWriter::Initialize(), genie::kNFGHEP, LOG, pDEBUG, pERROR, pNOTICE, pWARN, and genie::NtpWriter::Save().

Referenced by main().

Variable Documentation

◆ gOptInpFileNames

string gOptInpFileNames

input file name

Definition at line 215 of file gEvPick.cxx.

Referenced by GetCommandLineArgs(), and RunCherryPicker().

◆ gOptOutFileName

string gOptOutFileName

output file name

Definition at line 216 of file gEvPick.cxx.

◆ gPickedType

GPickType_t gPickedType

output file format id

Definition at line 218 of file gEvPick.cxx.

Referenced by AcceptEvent(), DefaultOutputFile(), and GetCommandLineArgs().

◆ gPickedTypeStr

string gPickedTypeStr

output file name

Definition at line 217 of file gEvPick.cxx.

Referenced by GetCommandLineArgs(), and RunCherryPicker().