DemoMCFilter Class Reference

#include <DemoMCFilter.h>

Inheritance diagram for DemoMCFilter:
JobCModule

List of all members.

Public Types

enum  ENeuInt {
  kCCnue = 0x0001, kCCnuebar = 0x0002, kCCnumu = 0x0004, kCCnumubar = 0x0008,
  kCCnutau = 0x0010, kCCnutaubar = 0x0020, kNC = 0x0040, kAllNuInt = 0xFFFF
}
enum  Emode { kElastic = 0x0001, kResonant = 0x0002, kDIS = 0x0003, kAllMode = 0xFFFF }
typedef int NuInt_t
typedef int Mode_t

Public Member Functions

 DemoMCFilter ()
const RegistryDefaultConfig () const
JobCResult Ana (const MomNavigator *mom)
void Config (const Registry &r)
void Report ()
void HandleCommand (JobCommand *cmd)
void Help ()
void SetNuInt (NuInt_t i)
void SetNuMode (Mode_t i)
void SetEnuMin (double e)
void SetEnuMax (double e)
void SetYmin (double y)
void SetYmax (double y)
void SetPrint (bool doPrint=true)

Private Member Functions

NuInt_t GetNuInt (const REROOT_NeuKin *nukin)
Mode_t GetMode (const REROOT_NeuKin *nukin)
double GetEnu (const REROOT_NeuKin *nukin)
double GetY (const REROOT_NeuKin *nukin)
void Print (const REROOT_NeuKin *nukin)

Private Attributes

double fEnuMin
double fEnuMax
double fYmin
double fYmax
int fNuIntSelect
int fModeSelect
bool fDoPrint

Detailed Description

Definition at line 14 of file DemoMCFilter.h.


Member Typedef Documentation

typedef int DemoMCFilter::Mode_t

Definition at line 50 of file DemoMCFilter.h.

typedef int DemoMCFilter::NuInt_t

Definition at line 41 of file DemoMCFilter.h.


Member Enumeration Documentation

Enumerator:
kElastic 
kResonant 
kDIS 
kAllMode 

Definition at line 44 of file DemoMCFilter.h.

00044              {
00045     kElastic  = 0x0001,
00046     kResonant = 0x0002,
00047     kDIS      = 0x0003,
00048     kAllMode  = 0xFFFF
00049   };

Enumerator:
kCCnue 
kCCnuebar 
kCCnumu 
kCCnumubar 
kCCnutau 
kCCnutaubar 
kNC 
kAllNuInt 

Definition at line 31 of file DemoMCFilter.h.

00031                {
00032     kCCnue      = 0x0001,
00033     kCCnuebar   = 0x0002,
00034     kCCnumu     = 0x0004,
00035     kCCnumubar  = 0x0008,
00036     kCCnutau    = 0x0010,
00037     kCCnutaubar = 0x0020,
00038     kNC         = 0x0040,
00039     kAllNuInt   = 0xFFFF
00040   };


Constructor & Destructor Documentation

DemoMCFilter::DemoMCFilter (  ) 

Definition at line 27 of file DemoMCFilter.cxx.

00027 : fNuIntSelect(0), fModeSelect(0) { }


Member Function Documentation

JobCResult DemoMCFilter::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 31 of file DemoMCFilter.cxx.

References fDoPrint, fEnuMax, fEnuMin, fModeSelect, fNuIntSelect, fYmax, fYmin, GetEnu(), GetMode(), GetNuInt(), MINFast::GetREROOTEvent(), GetY(), gMINFast, JobCResult::kFailed, JobCResult::kPassed, REROOT_Event::neukins(), and Print().

00032 {
00033 //======================================================================
00034 // Analyze the event to see if the MC information meets the selection
00035 // criteria.
00036 //======================================================================
00037   // Get the pointer to the neutrino interaction data
00038   const REROOT_Event*  rrevt = gMINFast->GetREROOTEvent();
00039   const REROOT_NeuKin* nukin = 
00040     dynamic_cast<REROOT_NeuKin*>(rrevt->neukins()->First());
00041   
00042   // Energy cut
00043   double Enu = this->GetEnu(nukin);
00044   if (Enu < fEnuMin) return JobCResult::kFailed;
00045   if (Enu > fEnuMax) return JobCResult::kFailed;
00046 
00047   // y cut
00048   double y = this->GetY(nukin);
00049   if (y < fYmin) return JobCResult::kFailed;
00050   if (y > fYmax) return JobCResult::kFailed;
00051   
00052   // Interaction cut
00053   NuInt_t nuint = this->GetNuInt(nukin);
00054   if ((nuint & fNuIntSelect) == 0) return JobCResult::kFailed;
00055 
00056   // Interaction mode cut
00057   Mode_t numode = this->GetMode(nukin);
00058   if ((numode & fModeSelect) == 0) return JobCResult::kFailed;
00059 
00060   // Get here if all checks passed
00061   if (fDoPrint) this->Print(nukin);
00062   return JobCResult::kPassed;
00063 }

void DemoMCFilter::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 104 of file DemoMCFilter.cxx.

References fDoPrint, fEnuMax, fEnuMin, fModeSelect, fNuIntSelect, fYmax, fYmin, Registry::Get(), kAllMode, kAllNuInt, kCCnue, kCCnuebar, kCCnumu, kCCnumubar, kCCnutau, kCCnutaubar, kDIS, kElastic, and kResonant.

00105 {
00106 //======================================================================
00107 // Configure the module given the registry r
00108 //======================================================================
00109   int    tmpb;
00110   double tmpd;
00111 
00112   if (r.Get("EnuMin", tmpd)) { fEnuMin = tmpd; }
00113   if (r.Get("EnuMax", tmpd)) { fEnuMax = tmpd; }
00114   if (r.Get("Ymin",   tmpd)) { fYmin   = tmpd; }
00115   if (r.Get("Ymax",   tmpd)) { fYmax   = tmpd; }
00116   
00117   if (r.Get("CCnue", tmpb)) {
00118     tmpb ? fNuIntSelect |= kCCnue : fNuIntSelect &= ~kCCnue;
00119   }
00120   if (r.Get("CCnuebar", tmpb)) {
00121     tmpb ? fNuIntSelect |= kCCnuebar : fNuIntSelect &= ~kCCnuebar;
00122   }
00123   if (r.Get("CCnumu", tmpb)) {
00124     tmpb ? fNuIntSelect |= kCCnumu : fNuIntSelect &= ~kCCnumu;
00125   }
00126   if (r.Get("CCnumubar", tmpb)) {
00127     tmpb ? fNuIntSelect |= kCCnumubar : fNuIntSelect &= ~kCCnumubar;
00128   }
00129   if (r.Get("CCnutau", tmpb)) {
00130     tmpb ? fNuIntSelect |= kCCnutau : fNuIntSelect &= ~kCCnutau;
00131   }
00132   if (r.Get("CCnutaubar", tmpb)) {
00133     tmpb ? fNuIntSelect |= kCCnutaubar : fNuIntSelect &= ~kCCnutaubar;
00134   }
00135   if (r.Get("NC", tmpb)) {
00136     tmpb ? fNuIntSelect |= kCCnumubar : fNuIntSelect &= ~kCCnumubar;
00137   }
00138   if (r.Get("AllNuInt", tmpb)) { 
00139     if (tmpb) fNuIntSelect = kAllNuInt; 
00140   }
00141   // if absolutely nothing is selected default to "all"
00142   if (!fNuIntSelect) fNuIntSelect = kAllNuInt;
00143 
00144   if (r.Get("Elastic", tmpb)) {
00145     tmpb ? fModeSelect |= kElastic : fModeSelect &= ~kElastic;
00146   }
00147   if (r.Get("Resonant", tmpb)) {
00148     tmpb ? fModeSelect |= kResonant : fModeSelect &= ~kResonant;
00149   }
00150   if (r.Get("DIS", tmpb)) {
00151     tmpb ? fModeSelect |= kDIS : fModeSelect &= ~kDIS;
00152   }
00153   if (r.Get("AllMode", tmpb)) {
00154     if (tmpb) fModeSelect = kAllMode;
00155   }
00156   // if absolutely nothing is selected default to "all"
00157   if (!fModeSelect) fModeSelect = kAllMode;
00158 
00159   if (r.Get("DoPrint", tmpb)) { fDoPrint = tmpb; }
00160 }

const Registry & DemoMCFilter::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 67 of file DemoMCFilter.cxx.

References JobCModule::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00068 {
00069 //======================================================================
00070 // Supply a default configuration for this module
00071 //======================================================================
00072   static Registry r;
00073   std::string name = this->GetName();
00074   name += ".config.default";
00075   
00076   r.UnLockValues();
00077   r.Set("EnuMin",      0.0);
00078   r.Set("EnuMax", 999999.0);
00079   r.Set("Ymin",        0.0);
00080   r.Set("Ymax",        1.0);
00081 
00082   r.Set("CCnue",     false);
00083   r.Set("CCnuebar",  false);
00084   r.Set("CCnumu",    false);
00085   r.Set("CCnumubar", false);
00086   r.Set("CCnutau",   false);
00087   r.Set("CCnutaubar",false);
00088   r.Set("NC",        false);
00089   r.Set("AllNuInt",  false);
00090 
00091   r.Set("Elastic",  false);
00092   r.Set("Resonant", false);
00093   r.Set("DIS",      false);
00094   r.Set("AllMode",  false);
00095 
00096   r.Set("DoPrint",   false);
00097   r.LockValues();
00098 
00099   return r;
00100 }

double DemoMCFilter::GetEnu ( const REROOT_NeuKin nukin  )  [private]

Definition at line 324 of file DemoMCFilter.cxx.

References REROOT_NeuKin::P4Neu().

Referenced by Ana().

00325 { 
00326   return nukin->P4Neu()[3];
00327 }

DemoMCFilter::Mode_t DemoMCFilter::GetMode ( const REROOT_NeuKin nukin  )  [private]

Definition at line 317 of file DemoMCFilter.cxx.

References kAllMode.

Referenced by Ana().

00318 { 
00319   return kAllMode;
00320 }

DemoMCFilter::NuInt_t DemoMCFilter::GetNuInt ( const REROOT_NeuKin nukin  )  [private]

Definition at line 298 of file DemoMCFilter.cxx.

References REROOT_NeuKin::IAction(), REROOT_NeuKin::INu(), kCCnue, kCCnuebar, kCCnumu, kCCnumubar, kCCnutau, kCCnutaubar, and kNC.

Referenced by Ana().

00299 { 
00300   bool isNC = (nukin->IAction()==0);
00301 
00302   if (isNC) { return kNC; }
00303 
00304   int ntype = nukin->INu();
00305   if (ntype ==  12) { return kCCnue;      }
00306   if (ntype == -12) { return kCCnuebar;   }
00307   if (ntype ==  14) { return kCCnumu;     }
00308   if (ntype == -14) { return kCCnumubar;  }
00309   if (ntype ==  16) { return kCCnutau;    }
00310   if (ntype == -16) { return kCCnutaubar; }
00311 
00312   return 0;
00313 }

double DemoMCFilter::GetY ( const REROOT_NeuKin nukin  )  [private]

Definition at line 331 of file DemoMCFilter.cxx.

References REROOT_NeuKin::Y().

Referenced by Ana().

00332 { 
00333   return nukin->Y();
00334 }

void DemoMCFilter::HandleCommand ( JobCommand command  )  [virtual]

Implement to handle a JobCommand

Reimplemented from JobCModule.

Definition at line 164 of file DemoMCFilter.cxx.

References MuELoss::e, kAllMode, kAllNuInt, kCCnue, kCCnuebar, kCCnumu, kCCnumubar, kCCnutau, kCCnutaubar, kDIS, kElastic, kNC, kResonant, JobCommand::PopCmd(), JobCommand::PopFloatOpt(), JobCommand::PopOpt(), Report(), SetEnuMax(), SetEnuMin(), SetNuInt(), SetNuMode(), SetYmax(), and SetYmin().

00165 {
00166   const char* c = cmd->PopCmd();
00167   if (c) {
00168     string cs(c);
00169     if (cs == "Report") { 
00170       this->Report(); 
00171       return; 
00172     }
00173     if (cs == "Accept") {
00174       NuInt_t nuIntAccept = 0;
00175       Mode_t  modeAccept  = 0;
00176       const char* opt = 0;
00177       while ( (opt=cmd->PopOpt()) !=0 ) {
00178         string sopt(opt);
00179 
00180         // Which interactions to accept?
00181         if      (sopt == "CCnue")       nuIntAccept |=  kCCnue;
00182         else if (sopt == "CCnuebar")    nuIntAccept |=  kCCnuebar;
00183         else if (sopt == "CCnumu")      nuIntAccept |=  kCCnumu;
00184         else if (sopt == "CCnumubar")   nuIntAccept |=  kCCnumubar;
00185         else if (sopt == "CCnutau")     nuIntAccept |=  kCCnutau;
00186         else if (sopt == "CCnutaubar")  nuIntAccept |=  kCCnutaubar;
00187         else if (sopt == "NC")          nuIntAccept |=  kNC;
00188         else if (sopt == "AllNuInt")    nuIntAccept |=  kAllNuInt;
00189 
00190         if      (sopt == "Elastic")     modeAccept  |=  kElastic;
00191         else if (sopt == "Resonant")    modeAccept  |=  kResonant;
00192         else if (sopt == "DIS")         modeAccept  |=  kDIS;
00193         else if (sopt == "AllMode")     modeAccept  |=  kAllMode;
00194 
00195         // Which interaction modes to accept?   
00196         if (sopt == "Emin") {
00197           float e = cmd->PopFloatOpt();
00198           this->SetEnuMin(e);
00199         }
00200 
00201         // Which range of neutrino energy to accept?
00202         if (sopt == "Emax") {
00203           float e = cmd->PopFloatOpt();
00204           this->SetEnuMax(e);
00205         }
00206 
00207         // Which range of y to accept?
00208         if (sopt == "Ymin") {
00209           float y = cmd->PopFloatOpt();
00210           this->SetYmin(y);
00211         }
00212         if (sopt == "Ymax") {
00213           float y = cmd->PopFloatOpt();
00214           this->SetYmax(y);
00215         }
00216       }
00217       // Apply interaction selections
00218       if (nuIntAccept !=0 ) this->SetNuInt(nuIntAccept);
00219       if (modeAccept  !=0 ) this->SetNuMode(modeAccept);
00220       return;
00221     }
00222   }
00223 }

void DemoMCFilter::Help (  )  [virtual]

Implement to spew some useful help to cout

Reimplemented from JobCModule.

Definition at line 227 of file DemoMCFilter.cxx.

00227 {}

void DemoMCFilter::Print ( const REROOT_NeuKin nukin  )  [private]

Definition at line 338 of file DemoMCFilter.cxx.

Referenced by Ana().

00339 { 
00340 }

void DemoMCFilter::Report (  )  [virtual]

Implement to spew end of running report

Reimplemented from JobCModule.

Definition at line 231 of file DemoMCFilter.cxx.

References fEnuMax, fEnuMin, fModeSelect, fNuIntSelect, fYmax, fYmin, JobCModule::GetName(), kAllMode, kAllNuInt, kCCnue, kCCnuebar, kCCnumu, kCCnumubar, kCCnutau, kCCnutaubar, kDIS, kElastic, Msg::kInfo, kNC, kResonant, and MSGSTREAM.

Referenced by HandleCommand().

00232 {
00233   MsgStream& msg = MSGSTREAM("Demo",Msg::kInfo);
00234   
00235   msg << 
00236     this->GetName() << ": Selecting events with:\n" << 
00237     "-> Enu in range [" << fEnuMin << "," << fEnuMax << "]\n" <<
00238     "-> y in range [" << fYmin << "," << fYmax << "]\n" <<
00239     "-> Interactions types: ( ";
00240   if (fNuIntSelect>=kAllNuInt) {
00241     msg << "All ";
00242   }
00243   else {
00244     if (fNuIntSelect&kCCnue)      msg << "CCnue ";
00245     if (fNuIntSelect&kCCnuebar)   msg << "CCnuebar ";
00246     if (fNuIntSelect&kCCnumu)     msg << "CCnumu ";
00247     if (fNuIntSelect&kCCnumubar)  msg << "CCnumubar ";
00248     if (fNuIntSelect&kCCnutau)    msg << "CCnutau ";
00249     if (fNuIntSelect&kCCnutaubar) msg << "CCnutaubar ";
00250     if (fNuIntSelect&kNC)         msg << "NC ";
00251   }
00252   msg << ")\n";
00253   msg << "-> Interaction modes: ( ";
00254   if (fModeSelect>=kAllMode) {
00255     msg << "All ";
00256   }
00257   else {
00258     if (fModeSelect&kElastic)  msg << "Elastic ";  
00259     if (fModeSelect&kResonant) msg << "Resonant ";
00260     if (fModeSelect&kDIS)      msg << "DIS ";
00261   }
00262   msg << ")\n";
00263 }

void DemoMCFilter::SetEnuMax ( double  e  ) 

Definition at line 291 of file DemoMCFilter.cxx.

References fEnuMax.

Referenced by HandleCommand().

00291 { fEnuMax = e;        }

void DemoMCFilter::SetEnuMin ( double  e  ) 

Definition at line 290 of file DemoMCFilter.cxx.

References fEnuMin.

Referenced by HandleCommand().

00290 { fEnuMin = e;        }

void DemoMCFilter::SetNuInt ( NuInt_t  i  ) 

Definition at line 267 of file DemoMCFilter.cxx.

References fNuIntSelect, and kAllNuInt.

Referenced by HandleCommand().

00267                                         { 
00268   if (i>=kAllNuInt) {
00269     fNuIntSelect = kAllNuInt;
00270   }
00271   else {
00272     fNuIntSelect = i;  
00273   }
00274 }

void DemoMCFilter::SetNuMode ( Mode_t  i  ) 

Definition at line 278 of file DemoMCFilter.cxx.

References fModeSelect, and kAllMode.

Referenced by HandleCommand().

00279 {
00280   if (i>=kAllMode) {
00281     fModeSelect = kAllMode;
00282   }
00283   else {
00284     fModeSelect  = i;  
00285   }
00286 }

void DemoMCFilter::SetPrint ( bool  doPrint = true  ) 

Definition at line 294 of file DemoMCFilter.cxx.

References fDoPrint.

00294 { fDoPrint = doPrint; }

void DemoMCFilter::SetYmax ( double  y  ) 

Definition at line 293 of file DemoMCFilter.cxx.

References fYmax.

Referenced by HandleCommand().

00293 { fYmax = y;          }

void DemoMCFilter::SetYmin ( double  y  ) 

Definition at line 292 of file DemoMCFilter.cxx.

References fYmin.

Referenced by HandleCommand().

00292 { fYmin = y;          }


Member Data Documentation

bool DemoMCFilter::fDoPrint [private]

Definition at line 77 of file DemoMCFilter.h.

Referenced by Ana(), Config(), and SetPrint().

double DemoMCFilter::fEnuMax [private]

Definition at line 72 of file DemoMCFilter.h.

Referenced by Ana(), Config(), Report(), and SetEnuMax().

double DemoMCFilter::fEnuMin [private]

Definition at line 71 of file DemoMCFilter.h.

Referenced by Ana(), Config(), Report(), and SetEnuMin().

Definition at line 76 of file DemoMCFilter.h.

Referenced by Ana(), Config(), Report(), and SetNuMode().

Definition at line 75 of file DemoMCFilter.h.

Referenced by Ana(), Config(), Report(), and SetNuInt().

double DemoMCFilter::fYmax [private]

Definition at line 74 of file DemoMCFilter.h.

Referenced by Ana(), Config(), Report(), and SetYmax().

double DemoMCFilter::fYmin [private]

Definition at line 73 of file DemoMCFilter.h.

Referenced by Ana(), Config(), Report(), and SetYmin().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1