Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NuFCExperimentFactory Class Reference

Factory to generate pseudo-experiments for the nubar FC analysis. More...

#include <NuFCExperimentFactory.h>

List of all members.

Public Member Functions

 NuFCExperimentFactory (TRandom3 *rgen, TString nd_path, TString fd_path, TString tau_path)
 Construct the factory.
virtual ~NuFCExperimentFactory ()
const std::string & GetName () const
void GenerateNewExperiment (NuMMRunNuBar *mmRunSource, const NuMMParameters &mmPars, bool reroll=true)
 Generates a new experiment.
const NuMatrixSpectrumGetPQSpectrum () const
 Get a reference to the FD PQ Spectrum.
const NuMatrixSpectrumGetNewPQSpectrum () const
 Get a new copy (pointer) to the FD PQ Spectrum.
const NuMatrixSpectrumGetNQSpectrum () const
 Get a reference to the FD NQ Spectrum (blank, but with the right PoTs).
const NuMatrixSpectrumGetNewNQSpectrum () const
 Get a new copy (pointer) to the FD NQ Spectrum (blank, but with the right PoTs).
const NuMatrixSpectrumGetPQSpectrumND () const
 Get a reference to the ND PQ Spectrum.
const NuMatrixSpectrumGetNewPQSpectrumND () const
 Get a new copy (pointer) to the ND PQ Spectrum.
const NuMatrixSpectrumGetNQSpectrumND () const
 Get a reference to the ND NQ Spectrum (this is static).
const NuMatrixSpectrumGetNewNQSpectrumND () const
 Get a new copy (pointer) to the ND NQ Spectrum (this is static).
void SetGausSyst (bool _gs)
 Set to true to have gaussian distributed syst values and false to have them be uniform.
void SetSystNorm (double size)
 Normalization systematic. Shift value is 1 +/- size. 0 = off.
void SetSystCurv (double size)
 Absolute Track Energy from curvature far systematic. Shift value is 1 +/- size. 0 = off.
void SetSystRelCurv (double size)
 Relative Track Energy from curvature far systematic. Shift value is 1 +/- size. 0 = off.
void SetSystRange (double size)
 Track Energy from range systematic. Shift value is 1 +/- size. 0 = off.
void SetSystShower (double size)
 Shower Energy overall systematic. Shift value is 1 +/- size. 0 = off.
void SetSystRelShower (double size)
 Relative shower energy (far only). Shift value is 1 +/- size. 0 = off.
bool IsDP (const NuFCEvent *nu) const
void SetDPCorr (bool _cor)
 Set to true to do the fully correlated DP systematic.
void SetOldDP (bool _old)
 Set to true to do the the old symmetric DP syst.
void SetSystDP (double size)
 Decay systematic. Shift value is 1 +/- size. 0 = off.
void SetSystBG (double size)
 NC and WS background systematic. Shift value is 1 +/- size. 0 = off.
void SetSystXSec (double size)
 All combined and NuBar cross-section systematics. Shift value is +/- size sigma. 0 = off.
void SetSystSKZP (double size)
 SKZP flux systematics. Shift value is +/- size sigma. 0 = off.
void NoSystematics ()
 Turn off all systematics.
void NoND (bool n=true)
 Don't generate a new ND spectrum each time. This means no ND systematics.
void DebugMode (bool deb=true)
 Fix systematics so the same is used in every experiment.
void PrintLoopProgress (Int_t entry, Float_t nEntries) const
 Print out a progress report in 5% increments.
int Counts (Sample_t s)
 Return the number of events in Sample s in last experiment.

Private Member Functions

void ScaleRejection (double &reject, int &nevents, double rand, double shift)
void FillMCEvents (TString mc_path)
void FillFromFilter (TTree *tin, int det)
void FillFromFCTree (TTree *tin, int det)
void FillFromDST (TString mc_path, int det)
Bool_t IsGoodStdCuts (const NuEvent &nu) const
int Int (Sample_t s) const
void GenerateND (NuMMRunNuBar *mmRunSource)
int EBin (double E) const
void Distro (Sample_t s, TString name, TString title)
TH1D * Distro (Sample_t s) const
int N (Sample_t s) const
void StoreEvent (Sample_t s, float *vals, int det)
void StoreEvent (Sample_t s, NuEvent ev, int det)
void StoreEvent (Sample_t s, NuFCEvent ev, int det)
double GetReject (Sample_t s, int i) const
void MakeSampler (Sample_t s, NuMatrixSpectrum pred)
double GetNormShift () const
double GetTrkEnergy (const NuFCEvent *ev) const
double GetShowerEnergy (const NuFCEvent *ev) const
double GetDPShift (const NuFCEvent *ev) const
double GetBGShift (const NuFCEvent *ev) const
double GetBGShift (const Sample_t s) const
double GetXSecShift (const NuFCEvent *ev) const
double GetSKZPShift (const NuFCEvent *ev) const
double GetShift (double size) const
void RollSystematics ()
void InvertShifts ()
 ClassDef (NuFCExperimentFactory, 0)

Private Attributes

bool noND
const int IntND
double ndPoT
TH1D * spect [10]
TH1D * hSampler [10]
int counts [10]
std::vector< NuFCEvent * > events [10]
NuMatrixSpectrum fPQHist
NuMatrixSpectrum fNQHist
NuMatrixSpectrum fPQHistND
NuMatrixSpectrum fNQHistND
Int_t numRecoBins
Int_t numTrueBins
std::vector< Double_t > vReco
std::vector< Double_t > vTrue
TRandom * fRandy
std::string fName
 Pointer to the random number generator.
int counter
 String name of this experiment.
bool fixedSyst
bool gausSyst
double norm_size
double norm_shift
double curv_size
double curv_shift
double relcurv_size
double relcurv_shift
double range_size
double range_shift
double shower_size
double shower_shift
double relshow_size
double relshow_shift
bool dp_corr
bool dp_old
double dp_size
double dp_shift
double bg_size
double bg_shift
double xsec_size
double xsec_shift
double skzp_size
double skzp_shift


Detailed Description

Factory to generate pseudo-experiments for the nubar FC analysis.

Author:
Alex Himmel, Last checkin
Author
ahimmel
Version:
Revision
1.21
Date:
Date
2009/09/12 22:54:14
Created on: Sat Aug 16, 2008

Definition at line 37 of file NuFCExperimentFactory.h.


Constructor & Destructor Documentation

NuFCExperimentFactory::NuFCExperimentFactory TRandom3 *  rgen,
TString  nd_path,
TString  fd_path,
TString  tau_path
 

Construct the factory.

The library files can be in one of three forms. They can be trees of NuFCEvent objects (these are available in the NuBar common area and can be generated with NuDSTAna::MakeFCTree), trees of the right variables made with NuFarNear, or simple NuDSTs.

Parameters:
rgen TRandom3* random engine.
nd_path Location of the near events library .root file.
fd_path Location of the far events library .root file.
tau_path Location of the tau events library .root file.
NuDSTAna::MakeFCTree

Definition at line 44 of file NuFCExperimentFactory.cxx.

References bg_size, curv_size, Distro(), dp_size, FillMCEvents(), fRandy, Sample::kAppearedPQ, Sample::kNCPQ, Sample::kSignalPQ, Sample::kTauPQ, Sample::kWrongSignPQ, noND, norm_size, numRecoBins, numTrueBins, range_size, NuUtilities::RecoBins(), relcurv_size, relshow_size, shower_size, skzp_size, NuUtilities::TrueBins(), vReco, vTrue, and xsec_size.

00045   : IntND(0), ndPoT(0), 
00046     fPQHist(), fNQHist(), fPQHistND(), fNQHistND(), 
00047     fRandy(rgen), 
00048     counter(0), 
00049     fixedSyst(false), gausSyst(false), dp_corr(false), dp_old(false)
00050 {
00051   // Check if our random number generator is correctly setup
00052   if (!fRandy) {
00053     // If not, just use gRandom
00054     fRandy = gRandom;
00055   }
00056   noND = false;
00057   
00058   norm_size    = 0.04;
00059 
00060   curv_size    = 0.02;
00061   relcurv_size = 0.04;
00062   range_size   = 0.02;
00063   shower_size  = 0.10;
00064   relshow_size = 0.033;
00065   
00066   dp_size      = 0.80;
00067   bg_size      = 0.50;
00068   
00069   xsec_size    = 1;
00070   skzp_size    = 1;
00071 
00072   // Get the binning scheme set up
00073   const NuUtilities cuts;
00074   NuBinningScheme::NuBinningScheme_t binningScheme =
00075   static_cast<NuBinningScheme::NuBinningScheme_t>(4);
00076   vReco = cuts.RecoBins(binningScheme);
00077   vTrue = cuts.TrueBins(binningScheme);
00078   
00079   numRecoBins = vReco.size() - 1;
00080   numTrueBins = vTrue.size() - 1;
00081   //recoBinsArray = &(vReco[0]);
00082   //trueBinsArray = &(vTrue[0]);
00083 
00084   Distro(kSignalPQ, "signalSpect", "Signal Distro");
00085   Distro(kWrongSignPQ, "wsSpect", "Wrong Sign Distro");
00086   Distro(kNCPQ, "ncSpect", "NC Distro");
00087   Distro(kTauPQ, "tauSpect", "Tau Distro");
00088   Distro(kAppearedPQ, "appearedSpect", "Appeared Distro");
00089   
00090   // Set up the FD MC chain
00091   FillMCEvents(nd_path);
00092   FillMCEvents(fd_path);
00093   FillMCEvents(tau_path);
00094 }

virtual NuFCExperimentFactory::~NuFCExperimentFactory  )  [inline, virtual]
 

Definition at line 43 of file NuFCExperimentFactory.h.

00043 {};


Member Function Documentation

NuFCExperimentFactory::ClassDef NuFCExperimentFactory  ,
[private]
 

int NuFCExperimentFactory::Counts Sample_t  s  )  [inline]
 

Return the number of events in Sample s in last experiment.

Definition at line 115 of file NuFCExperimentFactory.h.

References s().

00115 {return counts[Int(s)];};

void NuFCExperimentFactory::DebugMode bool  deb = true  ) 
 

Fix systematics so the same is used in every experiment.

Instead of randomly drawing the systematics for each new experiment, every systematic is always taken at its passed (maximum) value.

Parameters:
deb true = debug on, false = debug off. true by default.

Definition at line 706 of file NuFCExperimentFactory.cxx.

References fixedSyst, and MSG.

00707 {
00708   fixedSyst = deb;
00709   
00710   if (fixedSyst) {
00711     MSG("NuFCExperimentFactory",Msg::kInfo) << "Now in debugging mode.  Systematics are not random -- they are fixed at the input values." << endl;
00712   }
00713   else {
00714     MSG("NuFCExperimentFactory",Msg::kInfo) << "Now out of debugging mode.  Systematics are randomly chosen based on input values." << endl;
00715   }
00716 }

TH1D * NuFCExperimentFactory::Distro Sample_t  s  )  const [private]
 

Return the unweighted spectrum of the library events for sample s

Definition at line 591 of file NuFCExperimentFactory.cxx.

References Int(), s(), and spect.

00592 {
00593   return spect[Int(s)];
00594 }

void NuFCExperimentFactory::Distro Sample_t  s,
TString  name,
TString  title
[inline, private]
 

Initialize the histograms needed for sample s. This is the nweighted spectrum of events in the library and the rejection probability sampling historgram.

Definition at line 581 of file NuFCExperimentFactory.cxx.

References hSampler, Int(), numTrueBins, s(), spect, and vTrue.

Referenced by MakeSampler(), NuFCExperimentFactory(), and StoreEvent().

00582 {
00583   spect[Int(s)] = new TH1D(name, title, numTrueBins, &(vTrue[0]));
00584   hSampler[Int(s)] = new TH1D();  // Prevents seg faults
00585 }

int NuFCExperimentFactory::EBin double  E  )  const [private]
 

A faster way of filling a histogram. Retuns the bin number that energy E refers to in binning scheme 4. Faster than Root's bin finder by more than a factor of 2.

Definition at line 521 of file NuFCExperimentFactory.cxx.

Referenced by GenerateND().

00522 {
00523   if (E < 0) return 0;
00524   if (E < 0.5) return 1;
00525   if (E < 20.) return static_cast<int>(E*4.);
00526   if (E < 30.) return static_cast<int>(E)+60;
00527   if (E < 50.) return static_cast<int>(E)/2+75;
00528   return 100;
00529 }

void NuFCExperimentFactory::FillFromDST TString  mc_path,
int  det
[private]
 

Fill the event library for detector det from the NuDSTs in mc_path.

Definition at line 343 of file NuFCExperimentFactory.cxx.

References det, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuEvent::iaction, NuInputEvents::InitialiseChains(), NuInputEvents::InitialiseNuEventBranch(), NuInputEvents::InputFileName(), NuEvent::inu, NuEvent::inunoosc, IsGoodStdCuts(), Sample::kAppearedPQ, Sample::kNCPQ, Sample::kSignalPQ, Sample::kTauPQ, Sample::kWrongSignPQ, MSG, NuInputEvents::ResetNuEventLoopPositionToStart(), and StoreEvent().

Referenced by FillMCEvents().

00344 {
00345   MSG("NuFCExperimentFactory",Msg::kInfo) << "Entering FillFromDST(" << mc_path << ")" << endl;
00346   
00347   // TChain holding all the FD MC
00348   NuInputEvents* mc_input = new NuInputEvents();
00349   mc_input->InputFileName(mc_path.Data());
00350   mc_input->InitialiseChains();
00351   mc_input->InitialiseNuEventBranch();  
00352   mc_input->ResetNuEventLoopPositionToStart();
00353   
00354   for (Int_t i=0; i < mc_input->GetEntriesNuEvent(); ++i) {
00355     NuEvent &nu=const_cast<NuEvent&>(mc_input->GetNextNuEvent(Msg::kInfo));
00356     
00357     //this->PrintLoopProgress(i,mc_input->GetEntriesNuEvent());
00358     
00359     if (!IsGoodStdCuts(nu)) continue;
00360     
00361     if (nu.inu == 16 || nu.inu == -16) {
00362       // Ignore taus from Nue's, NC's
00363       if (nu.inunoosc == 12 || nu.inunoosc==-12 || nu.iaction == 0) continue;
00364       StoreEvent(kTauPQ, nu, det);
00365     }
00366     else if (nu.iaction == 0) StoreEvent(kNCPQ, nu, det);
00367     else if (nu.inu == -14)   {
00368       StoreEvent(kAppearedPQ, nu, det);
00369       StoreEvent(kSignalPQ, nu, det);
00370     }
00371     else StoreEvent(kWrongSignPQ, nu, det);
00372   }
00373   
00374   MSG("NuFCExperimentFactory",Msg::kInfo) << "Leaving FillFromDST" << endl;  
00375 }

void NuFCExperimentFactory::FillFromFCTree TTree *  tin,
int  det
[private]
 

Fill the event library for detector det from the NuFCEvent tree tin.

Definition at line 313 of file NuFCExperimentFactory.cxx.

References det, NuFCEvent::iaction, NuFCEvent::inu, NuFCEvent::inunoosc, Sample::kAppearedPQ, Sample::kNCPQ, Sample::kSignalPQ, Sample::kTauPQ, Sample::kWrongSignPQ, MSG, PrintLoopProgress(), and StoreEvent().

Referenced by FillMCEvents().

00314 {
00315   MSG("NuFCExperimentFactory",Msg::kInfo) << "Entering FillFromFCTree" << endl;
00316   
00317   NuFCEvent *nu = new NuFCEvent();
00318   tin->SetBranchAddress("NuFCEvent", &nu);
00319 
00320   for (Int_t i=0; i < tin->GetEntries(); ++i) {
00321     tin->GetEntry(i);
00322     this->PrintLoopProgress(i,tin->GetEntries());
00323 
00324     if (nu->inu == 16 || nu->inu == -16) {
00325       // Ignore taus from Nue's, NC's
00326       if (nu->inunoosc == 12 || nu->inunoosc==-12 || nu->iaction == 0) continue;
00327       StoreEvent(kTauPQ, *nu, det);
00328     }
00329     else if (nu->iaction == 0) StoreEvent(kNCPQ, *nu, det);
00330     else if (nu->inu == -14)   {
00331       StoreEvent(kAppearedPQ, *nu, det);
00332       StoreEvent(kSignalPQ, *nu, det);
00333     }
00334     else StoreEvent(kWrongSignPQ, *nu, det);
00335   }
00336   MSG("NuFCExperimentFactory",Msg::kInfo) << "Leaving FillFromFCTree" << endl;  
00337 }

void NuFCExperimentFactory::FillFromFilter TTree *  tin,
int  det
[private]
 

Fill the event library for detector det from the NuFarNear Filter tree tin.

Definition at line 262 of file NuFCExperimentFactory.cxx.

References det, Sample::kAppearedPQ, Sample::kNCPQ, Sample::kSignalPQ, Sample::kTauPQ, Sample::kWrongSignPQ, MSG, PrintLoopProgress(), and StoreEvent().

Referenced by FillMCEvents().

00263 {
00264   MSG("NuFCExperimentFactory",Msg::kInfo) << "Entering FillFromFilter" << endl;
00265   
00266   Float_t energy;       tin->SetBranchAddress("energy",       &energy);
00267   Float_t trkEn;        tin->SetBranchAddress("trkEn",        &trkEn);
00268   Float_t shwEn;        tin->SetBranchAddress("shwEn",        &shwEn);
00269   Float_t neuEnMC;      tin->SetBranchAddress("neuEnMC",      &neuEnMC);  
00270   Int_t   iaction;      tin->SetBranchAddress("iaction",      &iaction);    
00271   Int_t   inu;          tin->SetBranchAddress("inu",          &inu);
00272   Float_t charge;       tin->SetBranchAddress("charge",       &charge);
00273   Float_t ppvz;         tin->SetBranchAddress("ppvz",         &ppvz); 
00274   Int_t   containedTrk; tin->SetBranchAddress("containedTrk", &containedTrk); 
00275   Float_t fluxErr;      tin->SetBranchAddress("fluxErr",      &fluxErr); 
00276   
00277   float vals[10];
00278   for (Int_t i=0; i < tin->GetEntries(); ++i) {
00279     tin->GetEntry(i);
00280     this->PrintLoopProgress(i,tin->GetEntries());
00281    
00282     vals[0] = energy;
00283     vals[1] = trkEn;
00284     vals[2] = shwEn;
00285     vals[3] = neuEnMC;
00286     vals[4] = (float)iaction;
00287     vals[5] = (float)inu;
00288     vals[6] = charge;
00289     vals[7] = ppvz;    
00290     vals[8] = (float)containedTrk;
00291     vals[9] = fluxErr;
00292     
00293     if (inu == 16 || inu == -16) {
00294       // Ignore taus from Nue's, NC's
00295 //      if (nu->inunoosc == 12 || nu->inunoosc==-12 || nu->iaction == 0) continue;
00296       if (iaction == 0) continue;
00297       StoreEvent(kTauPQ, vals, det);
00298     }
00299     else if (iaction == 0) StoreEvent(kNCPQ, vals, det);
00300     else if (inu == -14)   {
00301       StoreEvent(kAppearedPQ, vals, det);
00302       StoreEvent(kSignalPQ, vals, det);
00303     }
00304     else StoreEvent(kWrongSignPQ, vals, det);
00305   }
00306   MSG("NuFCExperimentFactory",Msg::kInfo) << "Leaving FillFromFilter" << endl;  
00307 }

void NuFCExperimentFactory::FillMCEvents TString  mc_path  )  [private]
 

Fill the event library for the files in mc_path. What type of files and what detector they come from is determined automatically.

Definition at line 217 of file NuFCExperimentFactory.cxx.

References det, FillFromDST(), FillFromFCTree(), FillFromFilter(), NuMatrixSpectrum::Integral(), MSG, and ndPoT.

Referenced by NuFCExperimentFactory().

00218 {
00219   MSG("NuFCExperimentFactory",Msg::kInfo) << "Entering FillMCEvents(\"" << mc_path << "\")" << endl;
00220   TFile *fin = new TFile(mc_path,"READ");
00221 
00222   // Test the file opened, and fail otherwise
00223   if (fin->IsZombie()) {
00224     MSG("NuFCExperimentFactory",Msg::kError) << "Failed to read in events file " << mc_path << endl;
00225     throw runtime_error("Failed to read MC events file");
00226   }
00227   
00228   // Determine which Detector this file is for
00229   TH1D *hDetector = (TH1D*)gROOT->FindObject("hDetector");
00230   int det = (int)hDetector->GetMean();
00231  
00232   // Get the ND Pot
00233   if (det == 1) {
00234     TH1D *hTotalPot = (TH1D*)gROOT->FindObject("hTotalPot");
00235     ndPoT += hTotalPot->Integral();
00236   }
00237   
00238   // Attempt to load the known tree types
00239   TTree *t1 = (TTree*)fin->Get("FDFilter");
00240   TTree *t2 = (TTree*)fin->Get("TAUFilter");
00241   TTree *t3 = (TTree*)fin->Get("NDFilter");
00242   TTree *t4 = (TTree*)fin->Get("FCTree");
00243   TTree *t5 = (TTree*)fin->Get("s");
00244 
00245   // If the tree exists in the file, load it
00246   if (t1)      FillFromFilter(t1, det);
00247   else if (t2) FillFromFilter(t2, det);
00248   else if (t3) FillFromFilter(t3, det);
00249   else if (t4) FillFromFCTree(t4, det);
00250   else if (t5) FillFromDST(mc_path, det);
00251   else {
00252     MSG("NuFCExperimentFactory",Msg::kError) << "No recognized tree in file: " << mc_path << endl;      
00253   }
00254   
00255   MSG("NuFCExperimentFactory",Msg::kInfo) << "Leaving FillMCEvents" << endl;  
00256 }  

void NuFCExperimentFactory::GenerateND NuMMRunNuBar mmRunSource  )  [private]
 

Generate the ND spectra. mmRunSource is needed to get the ND NQ spectrum since those events are not stored.

Definition at line 455 of file NuFCExperimentFactory.cxx.

References NuMatrixSpectrum::Add(), dp_shift, EBin(), events, fNQHistND, fPQHistND, GetBGShift(), GetDPShift(), NuMMRunNuBar::GetNDBarData(), NuMMRunNuBar::GetNDNuData(), GetShowerEnergy(), GetSKZPShift(), GetTrkEnergy(), NuMatrixSpectrum::GetXaxis(), GetXSecShift(), NuMatrixSpectrum::Integral(), IsDP(), MAXMSG, N(), ndPoT, numRecoBins, NuMatrixSpectrum::ResetPoT(), NuMatrixSpectrum::ResetSpectrum(), and vReco.

Referenced by GenerateNewExperiment().

00456 {
00457   if (noND) {
00458     MAXMSG("NuFCExperimentFactory",Msg::kInfo,1) << "Not Generating the ND" << endl;
00459     fPQHistND = *(mmRunSource->GetNDBarData());
00460   }
00461   else {  
00462     MAXMSG("NuFCExperimentFactory",Msg::kInfo,1) << "Entering GenerateND" << endl;
00463     TString name = "ndSpect";
00464     name += counter;
00465     TH1D newND(name,"ND Spect", numRecoBins, &(vReco[0]));
00466     TH1D newDP(name+"_dp","ND Spect, DP", numRecoBins, &(vReco[0]));      
00467     /*
00468      unsigned int max = event[IntND].size();
00469      if (max == 0) {
00470      MSG("NuFCExperimentFactor",Msg::kError) << "No ND events loaded.  Cannot make an ND spectrum."
00471      }
00472      */
00473     
00474     double E;
00475     double rw;
00476     vector<NuFCEvent*>::const_iterator it;
00477     for (it = events[IntND].begin(); it != events[IntND].end(); ++it) {
00478       E = GetTrkEnergy(*it) + GetShowerEnergy(*it);
00479       rw = (*it)->rw;
00480       rw *= GetBGShift(*it);
00481       rw *= GetXSecShift(*it);
00482       rw *= GetSKZPShift(*it);
00483       
00484       if (dp_corr) {
00485         if (IsDP(*it)) newDP.AddBinContent(EBin(E), rw);
00486         else           newND.AddBinContent(EBin(E), rw);
00487       }
00488       else {
00489         rw *= GetDPShift(*it);
00490         newND.AddBinContent(EBin(E), rw);
00491       }
00492     }
00493     
00494     if (dp_corr) {
00495       // Set the decay pipe systematic size
00496       int lowb = 1;
00497       int highb = newND.GetXaxis()->FindFixBin(13.0);
00498       double U = newND.Integral(lowb, highb) / ndPoT * 2.92878e+20;
00499       double D = newDP.Integral(lowb, highb)/ ndPoT * 2.92878e+20;
00500       double N = 198064.;
00501       dp_shift = (N - U) / D;
00502       if (dp_shift < 0) dp_shift = 0;
00503       newDP.Scale(dp_shift);
00504       newND.Add(&newDP);
00505     }
00506     
00507     fPQHistND.ResetSpectrum(newND);
00508     fPQHistND.ResetPoT(ndPoT);
00509     MAXMSG("NuFCExperimentFactory",Msg::kInfo,1) << "Leaving GenerateND" << endl;
00510   }
00511 
00512   fNQHistND = *(mmRunSource->GetNDNuData());
00513 }

void NuFCExperimentFactory::GenerateNewExperiment NuMMRunNuBar mmRunSource,
const NuMMParameters mmPars,
bool  reroll = true
 

Generates a new experiment.

The internal NQ, PQ, Near, Far spectra are replaced with newly generated histograms with a new set of random systematics. The parameters are used to create the FD prediction that is the target distribution of the rejection sampling.

Parameters:
mmRunSource A NuMMRunFC or NuMMRunTransition object, as need. It also provides the ND NQ spectrum.
mmPars A set of parameters with the desired oscillations and/or transitions.

Definition at line 107 of file NuFCExperimentFactory.cxx.

References counter, counts, events, fNQHist, fPQHist, fRandy, GenerateND(), GetBGShift(), GetDPShift(), GetNormShift(), GetReject(), GetShowerEnergy(), GetSKZPShift(), GetTrkEnergy(), GetXSecShift(), Int(), NuMatrixSpectrum::Integral(), MakeSampler(), MAXMSG, NuMatrixSpectrum::Multiply(), N(), numRecoBins, NuMatrixSpectrum::PoT(), NuMMRun::QuietModeOn(), NuMatrixSpectrum::ResetPoT(), NuMatrixSpectrum::ResetSpectrum(), RollSystematics(), s(), Sample::Sample_t, ScaleRejection(), NuMatrixSpectrum::Spectrum(), NuMMRunNuBar::TrueComponents(), and vReco.

Referenced by NuFCGridPoint::Run().

00108 {
00109   MAXMSG("NuFCExperimentFactory",Msg::kInfo,1) << "Entering GenerateNewExperiment" << endl;
00110   
00111   TString name = "fdExp";
00112   name += (counter++);
00113   TH1D *fdExp = new TH1D(name,"Single FC Experiment", numRecoBins, &(vReco[0]));
00114 
00115   NuMatrixSpectrum fdBar;
00116   mmRunSource->QuietModeOn();
00117 
00118   if (reroll) RollSystematics();
00119   GenerateND(mmRunSource);
00120   
00121   for (int i = 1; i <= 5; i++) {
00122     Sample_t s = (Sample_t)i;
00123     
00124     fdBar = mmRunSource->TrueComponents(mmPars, s);
00125     
00126     // Apply Normalization to the Prediction
00127     fdBar.Multiply(GetNormShift());
00128     fdBar.Multiply(GetBGShift(s));
00129     
00130     // Get the average events by integrating the PDF
00131     Double_t average_events = fdBar.Spectrum()->Integral();
00132     counts[Int(s)] = 0;
00133     if (average_events == 0) continue;
00134     
00135     // Get the number of events to generate
00136     Int_t nevents = fRandy->Poisson(average_events);
00137 
00138     // Create sampling distribution
00139     MakeSampler(s, fdBar);
00140     
00141     double numdraws = 0;
00142 
00143     // Now start sampling
00144     int ev;
00145     double rand, reject, E;
00146     bool seeking;
00147     
00148     while (nevents > 0) {
00149       // Get an event -- takes care of rejection sampling
00150       seeking = true;
00151       while (seeking) {
00152         ev = fRandy->Integer(N(s));
00153         ++numdraws;
00154         
00155         rand = fRandy->Uniform();
00156         reject = GetReject(s, ev);       
00157         
00158         if (s != kAppearedPQ) {
00159           ScaleRejection(reject, nevents, rand, GetDPShift(events[Int(s)][ev]));
00160         }
00161         if (s != kWrongSignPQ) {
00162           ScaleRejection(reject, nevents, rand, GetXSecShift(events[Int(s)][ev]));
00163         }
00164         ScaleRejection(reject, nevents, rand, GetSKZPShift(events[Int(s)][ev]));
00165 
00166         
00167         seeking = rand > reject;
00168       }
00169 
00170       // Get the new reco energy -- apply the systematic
00171       E = GetTrkEnergy(events[Int(s)][ev]) + GetShowerEnergy(events[Int(s)][ev]);
00172 
00173       // Fill our final reco spectrum
00174       fdExp->Fill(E);
00175       ++counts[Int(s)];
00176       
00177       --nevents;
00178     }
00179   }
00180   
00181   fNQHist.ResetPoT(fdBar.PoT());
00182   fPQHist.ResetPoT(fdBar.PoT());
00183   fPQHist.ResetSpectrum(*fdExp);
00184 
00185   delete fdExp;
00186   
00187   MAXMSG("NuFCExperimentFactory",Msg::kInfo,1) << "Leaving GenerateNewExperiment" << endl;
00188 }

double NuFCExperimentFactory::GetBGShift const Sample_t  s  )  const [inline, private]
 

Return the wrong sign/nc background systematic shift for the total number of background events if s is a background sample. Return 1 (no effect) otherwise.

Definition at line 879 of file NuFCExperimentFactory.cxx.

References Sample::kWrongSignPQ, and s().

00880 {
00881   if (s == kWrongSignPQ || s == kNCPQ) return bg_shift;
00882   return 1;
00883 }

double NuFCExperimentFactory::GetBGShift const NuFCEvent nu  )  const [inline, private]
 

Return the wrong sign/nc background systematic weight shift for this event. Return 1 (no effect) if nu is not a background event.

Definition at line 868 of file NuFCExperimentFactory.cxx.

References NuFCEvent::iaction, and NuFCEvent::inu.

Referenced by GenerateND(), and GenerateNewExperiment().

00869 {
00870   if (nu->iaction == 0 || nu->inu == 14) return bg_shift;
00871   return 1;
00872 }

double NuFCExperimentFactory::GetDPShift const NuFCEvent nu  )  const [inline, private]
 

Return the decay pipe systematic weight shift. Return 1 (no effect) if nu is not a decay pipe event.

Definition at line 858 of file NuFCExperimentFactory.cxx.

References IsDP().

Referenced by GenerateND(), and GenerateNewExperiment().

00859 {
00860   if (IsDP(nu)) return dp_shift;
00861   return 1;  
00862 }

const std::string& NuFCExperimentFactory::GetName void   )  const [inline]
 

Definition at line 44 of file NuFCExperimentFactory.h.

00044 { return fName; }

const NuMatrixSpectrum* NuFCExperimentFactory::GetNewNQSpectrum  )  const [inline]
 

Get a new copy (pointer) to the FD NQ Spectrum (blank, but with the right PoTs).

Definition at line 56 of file NuFCExperimentFactory.h.

00056 { return new NuMatrixSpectrum(fNQHist); }

const NuMatrixSpectrum* NuFCExperimentFactory::GetNewNQSpectrumND  )  const [inline]
 

Get a new copy (pointer) to the ND NQ Spectrum (this is static).

Definition at line 66 of file NuFCExperimentFactory.h.

00066 { return new NuMatrixSpectrum(fNQHistND); }  

const NuMatrixSpectrum* NuFCExperimentFactory::GetNewPQSpectrum  )  const [inline]
 

Get a new copy (pointer) to the FD PQ Spectrum.

Definition at line 51 of file NuFCExperimentFactory.h.

00051 { return new NuMatrixSpectrum(fPQHist); }

const NuMatrixSpectrum* NuFCExperimentFactory::GetNewPQSpectrumND  )  const [inline]
 

Get a new copy (pointer) to the ND PQ Spectrum.

Definition at line 61 of file NuFCExperimentFactory.h.

00061 { return new NuMatrixSpectrum(fPQHistND); }

double NuFCExperimentFactory::GetNormShift  )  const [inline, private]
 

Return the normalization systematic shift. Use this to scale the total number of events being drawn.

Definition at line 811 of file NuFCExperimentFactory.cxx.

Referenced by GenerateNewExperiment().

00812 {
00813   return norm_shift;
00814 }

const NuMatrixSpectrum& NuFCExperimentFactory::GetNQSpectrum  )  const [inline]
 

Get a reference to the FD NQ Spectrum (blank, but with the right PoTs).

Definition at line 54 of file NuFCExperimentFactory.h.

Referenced by NuFCGridPoint::Run().

00054 { return fNQHist; }

const NuMatrixSpectrum& NuFCExperimentFactory::GetNQSpectrumND  )  const [inline]
 

Get a reference to the ND NQ Spectrum (this is static).

Definition at line 64 of file NuFCExperimentFactory.h.

Referenced by NuFCGridPoint::Run().

00064 { return fNQHistND; }

const NuMatrixSpectrum& NuFCExperimentFactory::GetPQSpectrum  )  const [inline]
 

Get a reference to the FD PQ Spectrum.

Definition at line 49 of file NuFCExperimentFactory.h.

Referenced by NuFCGridPoint::Run().

00049 { return fPQHist; }

const NuMatrixSpectrum& NuFCExperimentFactory::GetPQSpectrumND  )  const [inline]
 

Get a reference to the ND PQ Spectrum.

Definition at line 59 of file NuFCExperimentFactory.h.

Referenced by NuFCGridPoint::Run().

00059 { return fPQHistND; }

double NuFCExperimentFactory::GetReject Sample_t  s,
int  i
const [private]
 

Get the rejection probability of event number i of sample s. Essentially, determine which energy bin this event is in and return the ratio in that bin.

MakeSampler for sample s needs to have been run for the results to be sensible.

MakeSampler

Definition at line 669 of file NuFCExperimentFactory.cxx.

References NuFCEvent::energy, events, hSampler, Int(), NuFCEvent::neuEnMC, and s().

Referenced by GenerateNewExperiment().

00670 {
00671   double Esel, reject;
00672   if (s == kNCPQ) Esel = events[Int(s)][i]->energy;
00673   else            Esel = events[Int(s)][i]->neuEnMC;
00674   
00675   int bin = hSampler[Int(s)]->GetXaxis()->FindFixBin(Esel);
00676   reject = hSampler[Int(s)]->GetBinContent(bin);
00677   return reject;
00678 }

double NuFCExperimentFactory::GetShift double  size  )  const [inline, private]
 

Get a systematic shift of the size passed. This can be random or or fixed depending on the debugging mode used.

Definition at line 751 of file NuFCExperimentFactory.cxx.

References fRandy.

Referenced by RollSystematics().

00752 { 
00753   if (fixedSyst)     return size;
00754   else if (gausSyst) return fRandy->Gaus(0, size);
00755   else               return fRandy->Uniform(-size, size); 
00756 }

double NuFCExperimentFactory::GetShowerEnergy const NuFCEvent nu  )  const [inline, private]
 

Return the systematically shifted shower energy. Accounts for both overall and relative shower energy scales.

Definition at line 835 of file NuFCExperimentFactory.cxx.

References NuFCEvent::detector, and NuFCEvent::shwEn.

Referenced by GenerateND(), and GenerateNewExperiment().

00836 {
00837   double E = nu->shwEn * shower_shift;
00838   if (nu->detector == 2) E *= relshow_shift;
00839   return E;
00840 }

double NuFCExperimentFactory::GetSKZPShift const NuFCEvent nu  )  const [inline, private]
 

Return the skzp systematic shift for this event. It is based on the fluxErr stored in nu.

Definition at line 912 of file NuFCExperimentFactory.cxx.

References NuFCEvent::fluxErr, and skzp_shift.

Referenced by GenerateND(), and GenerateNewExperiment().

00913 {
00914   return 1. + skzp_shift*(nu->fluxErr - 1.);
00915 }

double NuFCExperimentFactory::GetTrkEnergy const NuFCEvent nu  )  const [inline, private]
 

Return the systematically shifted track energy. Accounts for both range and curvature as required for this event.

Definition at line 820 of file NuFCExperimentFactory.cxx.

References NuFCEvent::containedTrk, NuFCEvent::detector, and NuFCEvent::trkEn.

Referenced by GenerateND(), and GenerateNewExperiment().

00821 {
00822   double E = nu->trkEn;
00823   if (nu->containedTrk == 1) E *= range_shift;
00824   else {
00825     E *= curv_shift;
00826     if (nu->detector == 2) E *= relcurv_shift;
00827   }
00828   return E;
00829 }

double NuFCExperimentFactory::GetXSecShift const NuFCEvent ev  )  const [inline, private]
 

Return the cross-section systematic weight shift for CC events. This includes both combined cross-section errors and the NuBar-Nu systematic ratio errors.

Definition at line 889 of file NuFCExperimentFactory.cxx.

References NuFCEvent::iaction, NuFCEvent::neuEnMC, and xsec_shift.

Referenced by GenerateND(), and GenerateNewExperiment().

00890 {
00891   if (ev->iaction != 1) return 1;
00892   
00893   static double xp = 25.;
00894   static double a = 0.895;
00895   static double xc = 4.0;
00896   static double b = 7.59e-3;
00897   static double c = -8.05e-4;
00898   double E = ev->neuEnMC;
00899   double shift = -0.0617;
00900   
00901   if (E < 25) shift += a - 1 + 2.*(1.-a)*E/xp + (a - 1.)*E*E/(xp*xp);
00902   if (E < xc) shift += (c*(xc-E)*(xc-E)*(xc-E)+b*(xc-E)*(xc-E));
00903   
00904   shift = 1 + xsec_shift * shift;
00905   return shift;
00906 }

int NuFCExperimentFactory::Int Sample_t  s  )  const [private]
 

Return the integer value corresponding to sample s. Used to access the appropriate array elements.

Definition at line 557 of file NuFCExperimentFactory.cxx.

References Sample::kAppearedPQ, Sample::kNCPQ, Sample::kSignalPQ, Sample::kTauPQ, Sample::kWrongSignPQ, MSG, and s().

Referenced by Distro(), GenerateNewExperiment(), GetReject(), MakeSampler(), and StoreEvent().

00558 {
00559   switch (s) {
00560       case kSignalPQ:
00561         return 1;
00562       case kWrongSignPQ:
00563         return 2;
00564       case kNCPQ:
00565         return 3;
00566       case kTauPQ:
00567         return 4;
00568       case kAppearedPQ:
00569         return 5;
00570       default:
00571         MSG("NuFCExperimentFactor",Msg::kError) << s << " is not a known Sample_t.  Returning -1" << endl;
00572         return -1;
00573   }
00574 }

void NuFCExperimentFactory::InvertShifts  )  [private]
 

Set every shift (the randomly drawn ones) to its negative. No longer in use.

Definition at line 789 of file NuFCExperimentFactory.cxx.

References bg_shift, curv_shift, dp_shift, norm_shift, range_shift, relcurv_shift, relshow_shift, shower_shift, skzp_shift, and xsec_shift.

00790 {
00791   // Get a single copy of these systematics
00792   norm_shift = 2 - norm_shift;
00793   
00794   curv_shift = 2 - curv_shift;
00795   relcurv_shift = 2 - curv_shift;
00796   range_shift = 2 - range_shift;
00797   shower_shift = 2 - shower_shift;
00798   relshow_shift = 2 - relshow_shift;
00799   
00800   dp_shift = 2 - dp_shift;
00801   bg_shift = 2 - bg_shift;
00802   
00803   xsec_shift *= -1;
00804   skzp_shift *= -1;
00805 }

bool NuFCExperimentFactory::IsDP const NuFCEvent nu  )  const
 

Return true if nu is a decay pipe event.

Definition at line 846 of file NuFCExperimentFactory.cxx.

References abs(), NuFCEvent::ppvz, and NuFCEvent::ptype.

Referenced by GenerateND(), and GetDPShift().

00847 {
00848   if (nu->ppvz < 4500) return false;
00849   if (abs(nu->ptype) == 13) return false;
00850   return true;
00851   
00852 }

Bool_t NuFCExperimentFactory::IsGoodStdCuts const NuEvent nu  )  const [private]
 

Just a copy of the standard cuts used in NuDSTana. It is needed in order to get the library events from NuDSTs.

Definition at line 382 of file NuFCExperimentFactory.cxx.

References NuEvent::charge, NuLibrary::cnt, NuLibrary::cuts, NuCounter::evtNotIsLI, NuCounter::evtWithTrkCounter, NuCounter::goodBeamInfoDBCounter, NuCounter::goodDataQualityCounter, NuCounter::goodDirectionCosineCounter, NuCounter::goodFitProbCounter, NuCounter::goodFitSigQPCounter, NuCounter::goodPIDCounter, NuCounter::goodTimeToNearestSpillCounter, NuCounter::goodTrkPassCounter, NuLibrary::Instance(), NuCuts::IsGoodBeam(), NuCuts::IsGoodBeamDetPOTCountingStage(), NuCuts::IsGoodDataQuality(), NuCuts::IsGoodDirCos(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodMajorityCurvature(), NuCuts::IsGoodNumberOfTracks(), NuCuts::IsGoodPID(), NuCuts::IsGoodRelAngle(), NuCuts::IsGoodSigmaQP_QP(), NuCuts::IsGoodTimeToNearestSpill(), NuCuts::IsGoodTrackFitPass(), NuCuts::IsGoodTrackLength(), NuCuts::IsInFidVolTrk(), NuCuts::IsLI(), and NuCounter::trkInFidVolCounter.

Referenced by FillFromDST().

00383 {
00384   // Only keep reconstructed NuBars
00385   if (nu.charge == -1) return false;
00386     
00387   //get an instance of the code library
00388   NuLibrary& lib=NuLibrary::Instance();
00389   
00390   //cut on the sntp good beam and that coil is on
00391   if (!lib.cuts.IsGoodBeamDetPOTCountingStage(nu)) return false;
00392   //lib.cnt.goodBeamDetPOTCountingStage++;
00393   
00394   //ensure good number of tracks in the event
00395   if (!lib.cuts.IsGoodNumberOfTracks(nu)) return false;
00396   lib.cnt.evtWithTrkCounter++;
00397   
00398   //check if the trk is in the fiducial volume
00399   if (!lib.cuts.IsInFidVolTrk(nu)) return false;
00400   lib.cnt.trkInFidVolCounter++;
00401   
00402   //cut on LI
00403   if (lib.cuts.IsLI(nu)) return false;
00404   lib.cnt.evtNotIsLI++;
00405   
00406   //cut on the data quality
00407   if (!lib.cuts.IsGoodDataQuality(nu)) return false;
00408   lib.cnt.goodDataQualityCounter++;
00409   
00410   //cut on the spill time
00411   if (!lib.cuts.IsGoodTimeToNearestSpill(nu)) return false;
00412   lib.cnt.goodTimeToNearestSpillCounter++;
00413   
00414   //cut on the beam
00415   if (!lib.cuts.IsGoodBeam(nu)) return false;
00416   lib.cnt.goodBeamInfoDBCounter++;
00417   
00418   //require a good trk fit
00419   if (!lib.cuts.IsGoodTrackFitPass(nu)) return false;
00420   lib.cnt.goodTrkPassCounter++;
00421   
00422   //require a forward going neutrino about beam direction
00423   if (!lib.cuts.IsGoodDirCos(nu)) return false;
00424   lib.cnt.goodDirectionCosineCounter++;
00425   
00426   //cut on the PID
00427   if (!lib.cuts.IsGoodPID(nu)) return false;
00428   lib.cnt.goodPIDCounter++;   
00429   
00430   //cut on the fractional track momentum and sign error      
00431   if (!lib.cuts.IsGoodSigmaQP_QP(nu)) return false;
00432   lib.cnt.goodFitSigQPCounter++;
00433   
00434   //cut on the track fit probability      
00435   if (!lib.cuts.IsGoodFitProb(nu)) return false;
00436   lib.cnt.goodFitProbCounter++;    
00437   
00438   //cut on majority curvature
00439   if (!lib.cuts.IsGoodMajorityCurvature(nu)) return false;
00440   
00441   // Cut on the track length
00442   if (!lib.cuts.IsGoodTrackLength(nu)) return false;
00443   
00444   // Cut on the relative angle
00445   if (!lib.cuts.IsGoodRelAngle(nu)) return false;
00446   
00447   return true;
00448 }

void NuFCExperimentFactory::MakeSampler Sample_t  s,
NuMatrixSpectrum  pred
[private]
 

Create a sampling distribution (the ratio of target distribution to the distribution we currently have) for rejection sampling. This ratio will be normalized so its maximum value is 1.

Parameters:
s The sample were creating the sampler for.
pred The target distribution.

Definition at line 689 of file NuFCExperimentFactory.cxx.

References Distro(), hSampler, Int(), s(), and NuMatrixSpectrum::Spectrum().

Referenced by GenerateNewExperiment().

00690 {
00691   if (hSampler[Int(s)]) delete hSampler[Int(s)];
00692   hSampler[Int(s)] = new TH1D(*(pred.Spectrum()));
00693   hSampler[Int(s)]->Divide(Distro(s));
00694   hSampler[Int(s)]->Scale(1./hSampler[Int(s)]->GetMaximum());
00695 }

int NuFCExperimentFactory::N Sample_t  s  )  const [inline, private]
 

Definition at line 147 of file NuFCExperimentFactory.h.

References s().

Referenced by GenerateND(), and GenerateNewExperiment().

00147 {return events[Int(s)].size();};

void NuFCExperimentFactory::NoND bool  n = true  )  [inline]
 

Don't generate a new ND spectrum each time. This means no ND systematics.

Definition at line 109 of file NuFCExperimentFactory.h.

00109 {noND = n;};

void NuFCExperimentFactory::NoSystematics  ) 
 

Turn off all systematics.

Turns off all systematics and resets all the random shifts to 0. To test just one systematic, turn off all of them and then set the one you want to the desired value with SetSyst*.

Definition at line 726 of file NuFCExperimentFactory.cxx.

References bg_size, curv_size, dp_size, norm_size, range_size, relcurv_size, relshow_size, RollSystematics(), shower_size, skzp_size, and xsec_size.

Referenced by NuFCGridPoint::NuFCGridPoint().

00727 {
00728   norm_size = 0;
00729   
00730   curv_size = 0;
00731   relcurv_size = 0;
00732   range_size = 0;
00733   shower_size = 0;
00734   relshow_size = 0;
00735   
00736   dp_size = 0;
00737   bg_size = 0;
00738   
00739   xsec_size = 0;
00740   skzp_size = 0;
00741   
00742   // Zero out the shifts
00743   RollSystematics();
00744 }

void NuFCExperimentFactory::PrintLoopProgress Int_t  entry,
Float_t  nEntries
const
 

Print out a progress report in 5% increments.

Parameters:
entry The current count.
nEntries The total count.

Definition at line 539 of file NuFCExperimentFactory.cxx.

References MSG.

Referenced by FillFromFCTree(), and FillFromFilter().

00540 {
00541   Float_t fract=ceil(nEntries/20.);  
00542   if (ceil(((Float_t)entry)/fract)==((Float_t)entry)/fract){
00543     MSG("NuFCExperimentFactory",Msg::kInfo) 
00544     <<"Fraction of loop complete: "<<entry 
00545     <<"/"<<nEntries<<"  ("
00546     <<(Int_t)(100.*entry/nEntries)<<"%)"<<endl;
00547   }
00548 }

void NuFCExperimentFactory::RollSystematics  )  [private]
 

Generate a new set of random systematic shifts.

Definition at line 762 of file NuFCExperimentFactory.cxx.

References bg_shift, bg_size, curv_shift, curv_size, dp_shift, dp_size, GetShift(), norm_shift, norm_size, range_shift, range_size, relcurv_shift, relcurv_size, relshow_shift, relshow_size, shower_shift, shower_size, skzp_shift, skzp_size, xsec_shift, and xsec_size.

Referenced by GenerateNewExperiment(), and NoSystematics().

00763 {
00764   // Get a single copy of these systematics
00765   norm_shift = 1 + GetShift(norm_size);
00766   
00767   curv_shift = 1 + GetShift(curv_size);
00768   relcurv_shift = 1 + GetShift(relcurv_size);
00769   range_shift = 1 + GetShift(range_size);
00770   shower_shift = 1 + GetShift(shower_size);
00771   relshow_shift = 1 + GetShift(relshow_size);
00772 
00773   if (!dp_corr) {
00774     if (dp_size == 0) dp_shift = 1;
00775     else if (dp_old)  dp_shift = 1.0 + GetShift(dp_size);
00776     else              dp_shift = 0.8 + GetShift(dp_size);
00777     if (dp_shift < 0) dp_shift = 0;
00778   }
00779   bg_shift = 1 + GetShift(bg_size);
00780   
00781   xsec_shift = GetShift(xsec_size);
00782   skzp_shift = GetShift(skzp_size);
00783 }

void NuFCExperimentFactory::ScaleRejection double &  reject,
int &  nevents,
double  rand,
double  shift
[inline, private]
 

This is the rejection-sampling equivalent to reweighting an events. A new, shifted rejection probability is calculated -- this will be used to determine whether to keep or reject the event. But, if this new rejection probability will keep an event that would have been rejected, increase the total number we draw to account for this change in normalization. If we now reject an event we would have kept, decrease the total number of events.

Parameters:
reject The original rejection probability. This may be modified to the new rejection probability.
nevents The number of events remaining to be drawn for this experiment. This may be modified.
rand The random number drawn for rejection purposes.
shift The shift in event "weight."

Definition at line 203 of file NuFCExperimentFactory.cxx.

Referenced by GenerateNewExperiment().

00204 { 
00205   double reject_new = reject*shift;
00206   if (rand > reject && rand < reject_new) nevents++;
00207   if (rand < reject && rand > reject_new) nevents--;
00208   
00209   reject = reject_new;
00210 }

void NuFCExperimentFactory::SetDPCorr bool  _cor  )  [inline]
 

Set to true to do the fully correlated DP systematic.

Definition at line 93 of file NuFCExperimentFactory.h.

00093 {dp_corr = _cor;};

void NuFCExperimentFactory::SetGausSyst bool  _gs  )  [inline]
 

Set to true to have gaussian distributed syst values and false to have them be uniform.

Definition at line 69 of file NuFCExperimentFactory.h.

00069 {gausSyst = _gs;}

void NuFCExperimentFactory::SetOldDP bool  _old  )  [inline]
 

Set to true to do the the old symmetric DP syst.

Definition at line 95 of file NuFCExperimentFactory.h.

00095 {dp_old = _old;};

void NuFCExperimentFactory::SetSystBG double  size  )  [inline]
 

NC and WS background systematic. Shift value is 1 +/- size. 0 = off.

Definition at line 99 of file NuFCExperimentFactory.h.

00099 {bg_size = size;};

void NuFCExperimentFactory::SetSystCurv double  size  )  [inline]
 

Absolute Track Energy from curvature far systematic. Shift value is 1 +/- size. 0 = off.

Definition at line 80 of file NuFCExperimentFactory.h.

00080 {curv_size = size;};

void NuFCExperimentFactory::SetSystDP double  size  )  [inline]
 

Decay systematic. Shift value is 1 +/- size. 0 = off.

Definition at line 97 of file NuFCExperimentFactory.h.

00097 {dp_size = size;};

void NuFCExperimentFactory::SetSystNorm double  size  )  [inline]
 

Normalization systematic. Shift value is 1 +/- size. 0 = off.

SetSyst* Functions -- set the size of these systematic shifts The actual shifted value is varied from experiment to experiment Shift values are defined as 1 +/- size Set to 0 to turn off that systematic

Definition at line 77 of file NuFCExperimentFactory.h.

00077 {norm_size = size;};

void NuFCExperimentFactory::SetSystRange double  size  )  [inline]
 

Track Energy from range systematic. Shift value is 1 +/- size. 0 = off.

Definition at line 84 of file NuFCExperimentFactory.h.

00084 {range_size = size;};

void NuFCExperimentFactory::SetSystRelCurv double  size  )  [inline]
 

Relative Track Energy from curvature far systematic. Shift value is 1 +/- size. 0 = off.

Definition at line 82 of file NuFCExperimentFactory.h.

00082 {relcurv_size = size;};

void NuFCExperimentFactory::SetSystRelShower double  size  )  [inline]
 

Relative shower energy (far only). Shift value is 1 +/- size. 0 = off.

Definition at line 88 of file NuFCExperimentFactory.h.

00088 {relshow_size = size;};

void NuFCExperimentFactory::SetSystShower double  size  )  [inline]
 

Shower Energy overall systematic. Shift value is 1 +/- size. 0 = off.

Definition at line 86 of file NuFCExperimentFactory.h.

00086 {shower_size = size;};

void NuFCExperimentFactory::SetSystSKZP double  size  )  [inline]
 

SKZP flux systematics. Shift value is +/- size sigma. 0 = off.

Definition at line 104 of file NuFCExperimentFactory.h.

00104 {skzp_size = size;};

void NuFCExperimentFactory::SetSystXSec double  size  )  [inline]
 

All combined and NuBar cross-section systematics. Shift value is +/- size sigma. 0 = off.

Definition at line 102 of file NuFCExperimentFactory.h.

00102 {xsec_size = size;};

void NuFCExperimentFactory::StoreEvent Sample_t  s,
NuFCEvent  ev,
int  det
[private]
 

Store the NuFCEvent ev in the sample s cache. Set its detector type to det.

Definition at line 635 of file NuFCExperimentFactory.cxx.

References det, NuFCEvent::detector, Distro(), NuFCEvent::energy, events, Int(), MSG, NuFCEvent::neuEnMC, and s().

00636 {
00637   NuFCEvent * loc = new NuFCEvent(ev);
00638   loc->detector = det;
00639   
00640   if (loc->detector == 2) { // Far Det and Taus
00641     events[Int(s)].push_back(loc);
00642     
00643     double E;
00644     if (s == kNCPQ) E = loc->energy;
00645     else            E = loc->neuEnMC;
00646     
00647     Distro(s)->Fill(E);
00648   }
00649   else if (loc->detector == 1) {
00650     // Prevent double counting the appeared events.
00651     if (s != kAppearedPQ) events[IntND].push_back(loc);
00652   }
00653   else {
00654     MSG("NuFCExperimentFactory",Msg::kWarning) << "Detector " << det << " not recognized.  Event not stored." << endl;
00655   }
00656 }

void NuFCExperimentFactory::StoreEvent Sample_t  s,
NuEvent  ev,
int  det
[private]
 

Store the NuEvent ev in the sample s cache. Set its detector type to det. It will be converted to a NuFCEvent first.

Definition at line 624 of file NuFCExperimentFactory.cxx.

References det, s(), and StoreEvent().

00625 {
00626   NuFCEvent loc(ev);
00627   StoreEvent(s, loc, det);
00628 }

void NuFCExperimentFactory::StoreEvent Sample_t  s,
float *  vals,
int  det
[private]
 

Store the event described by the values in vals in the sample s cache. Set its detector typ to det. The expected order of fields is: energy, trkEn, shwEn, neuEnMC, iaction, inu, charge, ppvz, containedTrk, fluxErr.

Definition at line 602 of file NuFCExperimentFactory.cxx.

References NuFCEvent::charge, NuFCEvent::containedTrk, det, NuFCEvent::energy, NuFCEvent::fluxErr, NuFCEvent::iaction, NuFCEvent::inu, NuFCEvent::neuEnMC, NuFCEvent::ppvz, s(), NuFCEvent::shwEn, and NuFCEvent::trkEn.

Referenced by FillFromDST(), FillFromFCTree(), FillFromFilter(), and StoreEvent().

00603 {
00604   NuFCEvent loc;
00605   loc.energy       = vals[0];
00606   loc.trkEn        = vals[1];
00607   loc.shwEn        = vals[2];
00608   loc.neuEnMC      = vals[3];
00609   loc.iaction      = (Int_t)vals[4];
00610   loc.inu          = (Int_t)vals[5];
00611   loc.charge       = (Int_t)vals[6];
00612   loc.ppvz         = vals[7];
00613   loc.containedTrk = (Int_t)vals[8];
00614   loc.fluxErr      = vals[9];    
00615   
00616   StoreEvent(s, loc, det);
00617 }


Member Data Documentation

double NuFCExperimentFactory::bg_shift [private]
 

Definition at line 213 of file NuFCExperimentFactory.h.

Referenced by InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::bg_size [private]
 

Definition at line 213 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

int NuFCExperimentFactory::counter [private]
 

String name of this experiment.

Definition at line 191 of file NuFCExperimentFactory.h.

Referenced by GenerateNewExperiment().

int NuFCExperimentFactory::counts[10] [private]
 

Definition at line 169 of file NuFCExperimentFactory.h.

Referenced by GenerateNewExperiment().

double NuFCExperimentFactory::curv_shift [private]
 

Definition at line 204 of file NuFCExperimentFactory.h.

Referenced by InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::curv_size [private]
 

Definition at line 204 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

bool NuFCExperimentFactory::dp_corr [private]
 

Definition at line 210 of file NuFCExperimentFactory.h.

bool NuFCExperimentFactory::dp_old [private]
 

Definition at line 211 of file NuFCExperimentFactory.h.

double NuFCExperimentFactory::dp_shift [private]
 

Definition at line 212 of file NuFCExperimentFactory.h.

Referenced by GenerateND(), InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::dp_size [private]
 

Definition at line 212 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

std::vector<NuFCEvent*> NuFCExperimentFactory::events[10] [private]
 

Definition at line 172 of file NuFCExperimentFactory.h.

Referenced by GenerateND(), GenerateNewExperiment(), GetReject(), and StoreEvent().

bool NuFCExperimentFactory::fixedSyst [private]
 

Definition at line 199 of file NuFCExperimentFactory.h.

Referenced by DebugMode().

std::string NuFCExperimentFactory::fName [private]
 

Pointer to the random number generator.

Definition at line 189 of file NuFCExperimentFactory.h.

NuMatrixSpectrum NuFCExperimentFactory::fNQHist [private]
 

Definition at line 176 of file NuFCExperimentFactory.h.

Referenced by GenerateNewExperiment().

NuMatrixSpectrum NuFCExperimentFactory::fNQHistND [private]
 

Definition at line 178 of file NuFCExperimentFactory.h.

Referenced by GenerateND().

NuMatrixSpectrum NuFCExperimentFactory::fPQHist [private]
 

Definition at line 175 of file NuFCExperimentFactory.h.

Referenced by GenerateNewExperiment().

NuMatrixSpectrum NuFCExperimentFactory::fPQHistND [private]
 

Definition at line 177 of file NuFCExperimentFactory.h.

Referenced by GenerateND().

TRandom* NuFCExperimentFactory::fRandy [private]
 

Definition at line 188 of file NuFCExperimentFactory.h.

Referenced by GenerateNewExperiment(), GetShift(), and NuFCExperimentFactory().

bool NuFCExperimentFactory::gausSyst [private]
 

Definition at line 200 of file NuFCExperimentFactory.h.

TH1D* NuFCExperimentFactory::hSampler[10] [private]
 

Definition at line 168 of file NuFCExperimentFactory.h.

Referenced by Distro(), GetReject(), and MakeSampler().

const int NuFCExperimentFactory::IntND [private]
 

Definition at line 137 of file NuFCExperimentFactory.h.

double NuFCExperimentFactory::ndPoT [private]
 

Definition at line 138 of file NuFCExperimentFactory.h.

Referenced by FillMCEvents(), and GenerateND().

bool NuFCExperimentFactory::noND [private]
 

Definition at line 136 of file NuFCExperimentFactory.h.

Referenced by NuFCExperimentFactory().

double NuFCExperimentFactory::norm_shift [private]
 

Definition at line 202 of file NuFCExperimentFactory.h.

Referenced by InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::norm_size [private]
 

Definition at line 202 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

Int_t NuFCExperimentFactory::numRecoBins [private]
 

Definition at line 182 of file NuFCExperimentFactory.h.

Referenced by GenerateND(), GenerateNewExperiment(), and NuFCExperimentFactory().

Int_t NuFCExperimentFactory::numTrueBins [private]
 

Definition at line 183 of file NuFCExperimentFactory.h.

Referenced by Distro(), and NuFCExperimentFactory().

double NuFCExperimentFactory::range_shift [private]
 

Definition at line 206 of file NuFCExperimentFactory.h.

Referenced by InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::range_size [private]
 

Definition at line 206 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

double NuFCExperimentFactory::relcurv_shift [private]
 

Definition at line 205 of file NuFCExperimentFactory.h.

Referenced by InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::relcurv_size [private]
 

Definition at line 205 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

double NuFCExperimentFactory::relshow_shift [private]
 

Definition at line 208 of file NuFCExperimentFactory.h.

Referenced by InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::relshow_size [private]
 

Definition at line 208 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

double NuFCExperimentFactory::shower_shift [private]
 

Definition at line 207 of file NuFCExperimentFactory.h.

Referenced by InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::shower_size [private]
 

Definition at line 207 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

double NuFCExperimentFactory::skzp_shift [private]
 

Definition at line 216 of file NuFCExperimentFactory.h.

Referenced by GetSKZPShift(), InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::skzp_size [private]
 

Definition at line 216 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().

TH1D* NuFCExperimentFactory::spect[10] [private]
 

Definition at line 167 of file NuFCExperimentFactory.h.

Referenced by Distro().

std::vector<Double_t> NuFCExperimentFactory::vReco [private]
 

Definition at line 184 of file NuFCExperimentFactory.h.

Referenced by GenerateND(), GenerateNewExperiment(), and NuFCExperimentFactory().

std::vector<Double_t> NuFCExperimentFactory::vTrue [private]
 

Definition at line 185 of file NuFCExperimentFactory.h.

Referenced by Distro(), and NuFCExperimentFactory().

double NuFCExperimentFactory::xsec_shift [private]
 

Definition at line 215 of file NuFCExperimentFactory.h.

Referenced by GetXSecShift(), InvertShifts(), and RollSystematics().

double NuFCExperimentFactory::xsec_size [private]
 

Definition at line 215 of file NuFCExperimentFactory.h.

Referenced by NoSystematics(), NuFCExperimentFactory(), and RollSystematics().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:09:50 2010 for loon by  doxygen 1.3.9.1