OscFit::TemplatesForBeamData Class Reference

#include <TemplatesForBeamData.h>

List of all members.

Public Member Functions

void BuildMC ()
void BuildData ()
void BuildFakeData (Double_t dmsq, Double_t sinsq, const char *filename)
void BuildFakeData (Double_t dmsq, Double_t sinsq23, Double_t sinsq13, Double_t deltaCP, const char *filename)
void BuildFakeData (Double_t dmsq21, Double_t dmsq32, Double_t sinsq12, Double_t sinsq23, Double_t sinsq13, Double_t deltaCP, const char *filename)
void BuildFakeData (GridPoint *gridPoint, const char *filename)
void BuildFakeData (Double_t dmsq, Double_t sinsq23, Double_t sinsq13, Double_t deltaCP, Double_t beam_numu_norm, Double_t beam_numu_ncbkg, Double_t beam_numu_shwen, Double_t beam_numu_trken, const char *filename)
void BuildTemplates ()
void BuildTemplates (Run_t run)
void BuildTemplates (Run_t run, Sample_t sample)
void BuildTemplates (Run_t run, Sample_t sample, Charge_t charge, Resolution_t resolution, Systematic_t systematic, Shift_t shift)
void PrintTemplates ()
void WriteTemplates ()
void SwitchOnSystematics ()
void SwitchOffSystematics ()
void SetScale (Double_t scale)
void RunGridPoint (Int_t ipoint)
void RunGridPoints (Int_t ifirst, Int_t ilast)
void UseSingleSubBin (Bool_t yesno=1)
void SetInputPath (const char *filename)
void SetInputFile (const char *filename)
void SetInputDirectoryCC2010 (const char *dirname)
void SetInputDirectoryMINOSPlus (const char *dirname)
void SetOutputPath (const char *filename)
void SetOutputFile (const char *filename)
void SetFileName (const char *filename)
void UseCC2010Templates ()
void BuildNuMuBar ()
void BuildCCOnly ()
void BuildRHCOnly ()
void BuildNUBAROnly ()
void BuildAll ()
void BuildDataOnly ()
void BuildTemplatesForMINOSPlus ()

Static Public Member Functions

static TemplatesForBeamDataInstance ()

Private Member Functions

 TemplatesForBeamData ()
 ~TemplatesForBeamData ()
void BuildTemplatesCC2012 (Run_t run, Sample_t sample, Charge_t charge, Resolution_t resolution, Systematic_t systematic, Shift_t shift)
void BuildTemplatesCC2010 (Run_t run, Sample_t sample, Charge_t charge, Resolution_t resolution, Systematic_t systematic, Shift_t shift)
void BuildTemplatesRAF2012 (Run_t run, Sample_t sample, Charge_t charge, Resolution_t resolution, Systematic_t systematic, Shift_t shift)
void BuildTemplatesRAF2010 (Run_t run, Sample_t sample, Charge_t charge, Resolution_t resolution, Systematic_t systematic, Shift_t shift)
void BuildTemplatesMINOSPlus (Run_t run, Sample_t sample, Charge_t charge, Resolution_t resolution, Systematic_t systematic, Shift_t shift)
void BuildTemplate (Run_t run, Sample_t sample, Containment_t recoContainment, Charge_t recoCharge, Resolution_t recoResolution, Systematic_t systematic, Shift_t shift)
void BuildTemplate (Run_t run, Sample_t sample, Flavour_t trueFlavour, Charge_t trueCharge, Containment_t recoContainment, Charge_t recoCharge, Resolution_t recoResolution, Systematic_t systematic, Shift_t shift, TH1D *hist)
void BuildTemplate (Run_t run, Sample_t sample, Flavour_t trueFlavour, Charge_t trueCharge, Containment_t recoContainment, Charge_t recoCharge, Resolution_t recoResolution, Systematic_t systematic, Shift_t shift, TH2D *hist)
Double_t GetOscProb (Int_t n, Flavour_t flavour, Charge_t charge, Double_t Enu)
Double_t GetOscProb (Flavour_t flavour, Charge_t charge, Double_t Enu, GridPoint *gridPoint)
Double_t GetOscProb3Flav (Flavour_t flavour, Charge_t charge, Double_t Enu, GridPoint *gridPoint)
Double_t GetOscProb2Flav (Flavour_t flavour, Charge_t charge, Double_t Enu, Double_t dmsq, Double_t sinsq=1.0)
void UnloadCachedOscWeights ()
void LoadCachedOscWeights (Sample_t sample, Flavour_t flavour, Charge_t charge, TH2D *hist)
TH2D * GetCachedOscHist (Int_t n, Sample_t sample, Flavour_t flavour, Charge_t charge)
Double_t GetCachedOscProb (Int_t n, Int_t i, Int_t j, Sample_t sample, Flavour_t flavour, Charge_t charge)
Int_t CacheID (Int_t n, Sample_t sample, Flavour_t flavour, Charge_t charge)
Int_t GetNumberOfSubBins (Double_t emin, Double_t emax)
void SetRangeOfGridPoints ()

Private Attributes

TString fInputPath
TString fInputDirectoryCC2010
TString fInputDirectoryMinosPlus
TString fOutFile
Int_t fFirstPoint
Int_t fLastPoint
Int_t fThisFirstPoint
Int_t fThisLastPoint
Int_t fMinSubBins
Int_t fMaxSubBins
Bool_t fGridIsLoaded
Bool_t fUseSingleSubBin
Bool_t fUseCC2010Templates
Bool_t fBuildNuMuBar
Bool_t fBuildCCOnly
Bool_t fBuildRHCOnly
Bool_t fBuildNUBAROnly
Bool_t fBuildDataOnly
Bool_t fBuildTemplatesForMinosPlus
Double_t fScale
GridPointfSingleGridPoint
std::map< Int_t, TH2D * > fOscillationMap

Detailed Description

Definition at line 16 of file TemplatesForBeamData.h.


Constructor & Destructor Documentation

TemplatesForBeamData::TemplatesForBeamData (  )  [private]

Definition at line 35 of file TemplatesForBeamData.cxx.

References fBuildCCOnly, fBuildDataOnly, fBuildNUBAROnly, fBuildNuMuBar, fBuildRHCOnly, fBuildTemplatesForMinosPlus, fFirstPoint, fGridIsLoaded, fInputDirectoryCC2010, fInputDirectoryMinosPlus, fInputPath, fLastPoint, fMaxSubBins, fMinSubBins, fOutFile, fScale, fSingleGridPoint, fThisFirstPoint, fThisLastPoint, fUseCC2010Templates, and fUseSingleSubBin.

Referenced by Instance().

00036 {
00037   std::cout << " *** TemplatesForBeamData::TemplatesForBeamData() *** " << std::endl;
00038 
00039   fInputPath = "/minos/oscfit/Templates/temp.root";
00040   fOutFile = "temp.root";
00041 
00042   fInputDirectoryCC2010 = "/minos/cc_results_2010/Templates";
00043   fInputDirectoryMinosPlus = "/minos/cc_results_2010/Templates";
00044 
00045   fFirstPoint = -1;
00046   fLastPoint  = -1;
00047 
00048   fThisFirstPoint = -1;
00049   fThisLastPoint  = -1;
00050 
00051   fMinSubBins = 10;
00052   fMaxSubBins = 100;
00053 
00054   fGridIsLoaded = 0;
00055   fUseSingleSubBin = 0; 
00056 
00057   fUseCC2010Templates = 0;
00058   fBuildNuMuBar   = 0;
00059 
00060   fBuildCCOnly    = 0;
00061   fBuildRHCOnly   = 0;
00062   fBuildNUBAROnly = 0;
00063   fBuildDataOnly  = 0;
00064 
00065   fBuildTemplatesForMinosPlus = 0;
00066 
00067   fScale = 1.0;
00068 
00069   fSingleGridPoint = 0;
00070 }

TemplatesForBeamData::~TemplatesForBeamData (  )  [private]

Definition at line 72 of file TemplatesForBeamData.cxx.

00073 {
00074   
00075 }


Member Function Documentation

void OscFit::TemplatesForBeamData::BuildAll (  )  [inline]

Definition at line 133 of file TemplatesForBeamData.h.

References fBuildCCOnly, fBuildNUBAROnly, and fBuildRHCOnly.

00133                     {
00134       fBuildCCOnly    = 0;
00135       fBuildRHCOnly   = 0;
00136       fBuildNUBAROnly = 0;
00137     }

void OscFit::TemplatesForBeamData::BuildCCOnly (  )  [inline]

Definition at line 115 of file TemplatesForBeamData.h.

References fBuildCCOnly, fBuildNUBAROnly, and fBuildRHCOnly.

00115                        {
00116       fBuildCCOnly    = 1;
00117       fBuildRHCOnly   = 0;
00118       fBuildNUBAROnly = 0;
00119     }

void TemplatesForBeamData::BuildData (  ) 

Definition at line 372 of file TemplatesForBeamData.cxx.

References BuildTemplates(), OscFit::GetFirstRun(), OscFit::GetNumRuns(), OscFit::GetRun(), OscFit::kData, and run().

00373 {
00374   for( Int_t irun=OscFit::GetFirstRun(); irun<OscFit::GetNumRuns(); irun++ ){ // [Loop over Run Periods]
00375     Run_t run = OscFit::GetRun(irun);
00376 
00377     BuildTemplates( run, OscFit::kData );
00378   }
00379 }

void OscFit::TemplatesForBeamData::BuildDataOnly (  )  [inline]

Definition at line 139 of file TemplatesForBeamData.h.

References fBuildDataOnly.

00139                          {
00140       fBuildDataOnly = 1;
00141     }

void TemplatesForBeamData::BuildFakeData ( Double_t  dmsq,
Double_t  sinsq23,
Double_t  sinsq13,
Double_t  deltaCP,
Double_t  beam_numu_norm,
Double_t  beam_numu_ncbkg,
Double_t  beam_numu_shwen,
Double_t  beam_numu_trken,
const char *  filename 
)

Definition at line 252 of file TemplatesForBeamData.cxx.

References BuildMC(), fGridIsLoaded, fThisFirstPoint, fThisLastPoint, Instance(), OscFit::Configuration::Instance(), PrintTemplates(), SwitchOnSystematics(), and UnloadCachedOscWeights().

00253 {
00254   std::cout << " *** TemplatesForBeamData::BuildFakeBeamData(...) *** " << std::endl;
00255   std::cout << "   Oscillations: " << std::endl; 
00256   std::cout << "    dmsq    = " << dmsq << std::endl;
00257   std::cout << "    sisnq23 = " << sinsq23 << std::endl;
00258   std::cout << "    sinsq13 = " << sinsq13 << std::endl;
00259   std::cout << "    deltaCP = " << deltaCP << std::endl;
00260   std::cout << "   Systematics: " << std::endl; 
00261   std::cout << "    beam_numu_norm  = " << beam_numu_norm  << std::endl;
00262   std::cout << "    beam_numu_ncbkg = " << beam_numu_ncbkg << std::endl;
00263   std::cout << "    beam_numu_shwen = " << beam_numu_shwen << std::endl;
00264   std::cout << "    beam_numu_trken = " << beam_numu_trken << std::endl;
00265   
00266 
00267   // Other variables
00268   // ===============
00269   Double_t beam_numu_trken_exit = 0.0;
00270   Double_t beam_nue_norm        = 0.0;
00271   Double_t beam_nue_ncbkg       = 0.0;
00272   Double_t beam_nue_energy      = 0.0;
00273 
00274 
00275   // Initialisation
00276   // ==============
00277   Oscillation::Instance()->ThreeFlavours();
00278 
00279   TemplateGrid::Instance()->Reset();
00280   TemplateGrid::Instance()->BuildGridDmsq(std::fabs(dmsq));
00281   TemplateGrid::Instance()->BuildGridSinsq23(sinsq23);
00282   TemplateGrid::Instance()->BuildGridSinsq13(sinsq13);
00283   TemplateGrid::Instance()->BuildGridDeltaCP(deltaCP);
00284 
00285   fThisFirstPoint = 0;
00286   fThisLastPoint  = 3;
00287   fGridIsLoaded   = 1;
00288 
00289 
00290   Bool_t saveSyst = Configuration::Instance()->DoingSystematics();
00291 
00292   Configuration::Instance()->SwitchOnSystematics();
00293 
00294   if( Configuration::Instance()->UsingCachedOscWeights() ){
00295     UnloadCachedOscWeights();
00296   }
00297 
00298 
00299   // Build Templates
00300   // ===============
00301   
00302   BuildMC();
00303 
00304   PrintTemplates();
00305 
00306 
00307   // Write an 'input' file
00308   // =====================
00309   Template* inputTemplate  = new Template();
00310 
00311   TemplateCalculator::Instance()->GetExpectation( dmsq, sinsq23, sinsq13, deltaCP,
00312                                                   beam_numu_norm,  beam_numu_ncbkg, 
00313                                                   beam_numu_shwen, beam_numu_trken,   
00314                                                   beam_numu_trken_exit, 
00315                                                   beam_nue_norm,   beam_nue_ncbkg, 
00316                                                   beam_nue_energy, 
00317                                                   inputTemplate );
00318 
00319   TString inputLabel = ".fakedata";
00320   TString inputFile  = filename;
00321 
00322   if( inputFile.EndsWith(".root") ){
00323     inputFile.Insert(inputFile.Length()-5,inputLabel);
00324   }
00325   else{
00326     inputFile.Append(inputLabel);
00327   }
00328 
00329   TemplateIO::Instance()->WriteBeamData( inputTemplate, inputFile.Data() );
00330   
00331 
00332 
00333   // Write an 'output' file
00334   // ======================
00335   Template* outputTemplate = new Template();
00336    
00337   TemplateCalculator::Instance()->FillCombinedBins( inputTemplate,
00338                                                     outputTemplate );
00339 
00340   TString outputLabel = ".fakedata.output";
00341   TString outputFile  = filename;
00342 
00343   if( outputFile.EndsWith(".root") ){
00344     outputFile.Insert(outputFile.Length()-5,outputLabel);
00345   }
00346   else{
00347     outputFile.Append(outputLabel);
00348   }
00349 
00350   TemplateIO::Instance()->WriteOutput( outputTemplate, outputFile.Data() );
00351 
00352 
00353   // Reset
00354   // =====
00355   std::cout << " *** TemplatesForBeamData::Resetting(...) *** " << std::endl;
00356   Configuration::Instance()->DoSystematics( saveSyst );
00357 
00358   fGridIsLoaded    = 0;
00359 
00360   if( Configuration::Instance()->UsingCachedOscWeights() ){
00361     UnloadCachedOscWeights();
00362   }
00363 
00364   TemplateGrid::Instance()->Reset();
00365 
00366   delete inputTemplate;
00367   delete outputTemplate;
00368 
00369   return;
00370 }

void TemplatesForBeamData::BuildFakeData ( GridPoint gridPoint,
const char *  filename 
)

Definition at line 159 of file TemplatesForBeamData.cxx.

References BuildMC(), fGridIsLoaded, fSingleGridPoint, fThisFirstPoint, fThisLastPoint, Instance(), OscFit::Configuration::Instance(), OscFit::GridPoint::PrintParams(), PrintTemplates(), SwitchOffSystematics(), and UnloadCachedOscWeights().

00160 {
00161   if( gridPoint==0 ) return;
00162 
00163   std::cout << " *** TemplatesForBeamData::BuildFakeData(...) *** " << std::endl;
00164   std::cout << "   Params: "; gridPoint->PrintParams();
00165 
00166 
00167   // Initialisation
00168   // ==============
00169   TemplateGrid::Instance()->Reset();
00170 
00171   fSingleGridPoint = gridPoint;
00172  
00173   fThisFirstPoint = 0;
00174   fThisLastPoint  = 1;
00175   fGridIsLoaded   = 1;
00176   
00177   Bool_t saveSyst = Configuration::Instance()->DoingSystematics();
00178 
00179   Configuration::Instance()->SwitchOffSystematics();
00180 
00181   if( Configuration::Instance()->UsingCachedOscWeights() ){
00182     UnloadCachedOscWeights();
00183   }
00184   
00185   // Build Templates
00186   // ===============
00187 
00188   BuildMC();
00189 
00190   PrintTemplates();
00191 
00192 
00193   // Write an 'input' file
00194   // =====================
00195   Template* inputTemplate  = new Template();
00196   
00197   TemplateCalculator::Instance()->GetMC( inputTemplate ); 
00198 
00199   TString inputLabel = ".fakedata";
00200   TString inputFile  = filename;
00201 
00202   if( inputFile.EndsWith(".root") ){
00203     inputFile.Insert(inputFile.Length()-5,inputLabel);
00204   }
00205   else{
00206     inputFile.Append(inputLabel);
00207   }
00208 
00209   TemplateIO::Instance()->WriteBeamData( inputTemplate, inputFile.Data() );
00210 
00211 
00212   // Write an 'output' file
00213   // ======================
00214   Template* outputTemplate = new Template();
00215   
00216   TemplateCalculator::Instance()->FillCombinedBins( inputTemplate,
00217                                                     outputTemplate );
00218 
00219   TString outputLabel = ".fakedata.output";
00220   TString outputFile  = filename;
00221 
00222   if( outputFile.EndsWith(".root") ){
00223     outputFile.Insert(outputFile.Length()-5,outputLabel);
00224   }
00225   else{
00226     outputFile.Append(outputLabel);
00227   }
00228 
00229   TemplateIO::Instance()->WriteOutput( outputTemplate, outputFile.Data() );
00230 
00231 
00232   // Reset
00233   // =====
00234   std::cout << " *** TemplatesForBeamData::Resetting(...) *** " << std::endl;
00235   Configuration::Instance()->DoSystematics( saveSyst );
00236 
00237   fSingleGridPoint = 0;
00238   fGridIsLoaded    = 0;
00239 
00240   if( Configuration::Instance()->UsingCachedOscWeights() ){
00241     UnloadCachedOscWeights();
00242   }
00243 
00244   TemplateGrid::Instance()->Reset();
00245 
00246   delete inputTemplate;
00247   delete outputTemplate;
00248 
00249   return; 
00250 }

void TemplatesForBeamData::BuildFakeData ( Double_t  dmsq21,
Double_t  dmsq32,
Double_t  sinsq12,
Double_t  sinsq23,
Double_t  sinsq13,
Double_t  deltaCP,
const char *  filename 
)

Definition at line 139 of file TemplatesForBeamData.cxx.

References BuildFakeData(), Instance(), and OscFit::GridPoint::SetParams().

00140 {
00141   Oscillation::Instance()->ThreeFlavours();
00142 
00143   GridPoint* gridPoint = new GridPoint();
00144 
00145   Double_t th23 = asin(sqrt(sinsq23));
00146   Double_t th12 = asin(sqrt(sinsq12));
00147   Double_t th13 = asin(sqrt(sinsq13));
00148   
00149   gridPoint->SetParams( dmsq21, dmsq32, 
00150                         th12, th23, th13, deltaCP );
00151  
00152   BuildFakeData( gridPoint, filename );
00153 
00154   delete gridPoint;
00155   
00156   return;
00157 }

void TemplatesForBeamData::BuildFakeData ( Double_t  dmsq,
Double_t  sinsq23,
Double_t  sinsq13,
Double_t  deltaCP,
const char *  filename 
)

Definition at line 121 of file TemplatesForBeamData.cxx.

References BuildFakeData(), Instance(), and OscFit::GridPoint::SetParams().

00122 {
00123   Oscillation::Instance()->ThreeFlavours();
00124 
00125   GridPoint* gridPoint = new GridPoint();
00126   
00127   Double_t th13 = asin(sqrt(sinsq13));
00128   Double_t th23 = asin(sqrt(sinsq23));
00129 
00130   gridPoint->SetParams( dmsq, th23, th13, deltaCP );
00131  
00132   BuildFakeData( gridPoint, filename );
00133 
00134   delete gridPoint;
00135   
00136   return;
00137 }

void TemplatesForBeamData::BuildFakeData ( Double_t  dmsq,
Double_t  sinsq,
const char *  filename 
)

Definition at line 102 of file TemplatesForBeamData.cxx.

References Instance(), and OscFit::GridPoint::SetParams().

Referenced by BuildFakeData().

00103 {
00104   Oscillation::Instance()->TwoFlavours();
00105 
00106   GridPoint* gridPoint = new GridPoint();
00107 
00108   Double_t th23 = 0.5*asin(sqrt(sinsq));
00109 
00110   gridPoint->SetParams( 0.0, dmsq,    // dmsq12, dmsq23 
00111                         0.0, th23,    // th12, th23
00112                         0.0, 0.0 );   // th13, dcp
00113 
00114   BuildFakeData( gridPoint, filename );
00115 
00116   delete gridPoint;
00117 
00118   return;
00119 }

void TemplatesForBeamData::BuildMC (  ) 

Definition at line 381 of file TemplatesForBeamData.cxx.

References BuildTemplates(), OscFit::GetFirstRun(), OscFit::GetNumRuns(), OscFit::GetRun(), OscFit::kCV, OscFit::kRock, and run().

Referenced by BuildFakeData().

00382 {
00383   for( Int_t irun=OscFit::GetFirstRun(); irun<OscFit::GetNumRuns(); irun++ ){ // [Loop over Run Periods]
00384     Run_t run = OscFit::GetRun(irun);
00385 
00386     BuildTemplates( run, OscFit::kCV );
00387     BuildTemplates( run, OscFit::kRock );
00388   }
00389 }

void OscFit::TemplatesForBeamData::BuildNUBAROnly (  )  [inline]

Definition at line 127 of file TemplatesForBeamData.h.

References fBuildCCOnly, fBuildNUBAROnly, and fBuildRHCOnly.

00127                           {
00128       fBuildCCOnly    = 0;
00129       fBuildRHCOnly   = 0;
00130       fBuildNUBAROnly = 1;
00131     }

void OscFit::TemplatesForBeamData::BuildNuMuBar (  )  [inline]

Definition at line 111 of file TemplatesForBeamData.h.

References fBuildNuMuBar.

00111                        {
00112       fBuildNuMuBar = 1;
00113     }

void OscFit::TemplatesForBeamData::BuildRHCOnly (  )  [inline]

Definition at line 121 of file TemplatesForBeamData.h.

References fBuildCCOnly, fBuildNUBAROnly, and fBuildRHCOnly.

00121                         {
00122       fBuildCCOnly    = 0;
00123       fBuildRHCOnly   = 1;
00124       fBuildNUBAROnly = 0;
00125     }

void TemplatesForBeamData::BuildTemplate ( Run_t  run,
Sample_t  sample,
Flavour_t  trueFlavour,
Charge_t  trueCharge,
Containment_t  recoContainment,
Charge_t  recoCharge,
Resolution_t  recoResolution,
Systematic_t  systematic,
Shift_t  shift,
TH2D *  hist 
) [private]

Definition at line 1230 of file TemplatesForBeamData.cxx.

References fScale, fThisFirstPoint, fThisLastPoint, GetCachedOscProb(), GetNumberOfSubBins(), GetOscProb(), Instance(), OscFit::Configuration::Instance(), OscFit::kBeamData, OscFit::kData, OscFit::kIgnoreElectron, OscFit::kIgnoreProton, OscFit::kNC, OscFit::kNumu, OscFit::kVanilla, LoadCachedOscWeights(), n, and SetRangeOfGridPoints().

01231 { 
01232   // check for oscillating sample
01233   if( sample==kData || trueFlavour==kNC ) return;
01234 
01235   // Building a Template With Oscillations
01236   if( hist==0 ) return;
01237 
01238   // Set Range of Grid Points
01239   SetRangeOfGridPoints();
01240 
01241   Int_t nFirst = fThisFirstPoint;
01242   Int_t nLast  = fThisLastPoint;
01243 
01244   // Build Cached Oscillation Weights
01245   if( Configuration::Instance()->UsingCachedOscWeights() ){
01246     LoadCachedOscWeights( sample, trueFlavour, trueCharge, hist );
01247   }
01248 
01249   // Loop Over Reco Energy (y-axis)
01250   for( Int_t ireco=0; ireco<hist->GetYaxis()->GetNbins(); ireco++ ){
01251     Double_t Ereco = hist->GetYaxis()->GetBinCenter( ireco+1 );
01252 
01253     // Load True Energy Distribution
01254     Spectrum::Instance()->LoadHistogram( hist, Ereco );
01255 
01256     // Loop over True Energy (x-axis)
01257     for( Int_t itrue=0; itrue<hist->GetXaxis()->GetNbins(); itrue++ ){
01258       Double_t Emin = hist->GetXaxis()->GetBinLowEdge( itrue+1 );
01259       Double_t Emax = hist->GetXaxis()->GetBinUpEdge( itrue+1 );
01260       Int_t subBins = GetNumberOfSubBins( Emin, Emax );  
01261 
01262       // Loop over true energy sub-bins 
01263       for( Int_t jtrue=0; jtrue<subBins; jtrue++ ){
01264         Double_t dE = (1.0/double(subBins))*(Emax-Emin);
01265         Double_t Etrue = Emin + ((double)(jtrue+0.5)/(double)(subBins))*(Emax-Emin); 
01266 
01267         // Calculate dN=(dN/dE)*dE at this point
01268         Double_t dNdE = Spectrum::Instance()->GetDensity( Etrue ); 
01269         Double_t Exp = dNdE*dE;
01270 
01271         // Build Multiple Grid Points
01272         for( Int_t n=nFirst; n<nLast; n++ ){
01273 
01274           //
01275           //GridPoint* thisPoint = TemplateGrid::Instance()->GetGridPoint(n);
01276           //
01277           //if( n==0 
01278           // && fSingleGridPoint ) thisPoint = fSingleGridPoint;
01279           //
01280           //Double_t Osc = this->GetOscProb( trueFlavour, trueCharge, 
01281           //                                 Etrue, thisPoint );
01282           // 
01283 
01284           // calculate oscillation weight    
01285           Double_t Osc = 0.0;
01286 
01287           if( Configuration::Instance()->UsingCachedOscWeights() ){
01288             Osc = this->GetCachedOscProb( n, itrue, jtrue, 
01289                                           sample, trueFlavour, trueCharge );
01290           }
01291           else{
01292             Osc = this->GetOscProb( n, trueFlavour, trueCharge, Etrue );
01293           }
01294 
01295           Double_t BinContent = Exp*Osc;        
01296 
01297           BinContent *= fScale; // scale prediction
01298 
01299           OscFit::Interface::Instance()->Fill(n,
01300                                               kBeamData, sample,
01301                                               trueFlavour, trueCharge,
01302                                               systematic, shift,
01303                                               run, recoContainment,
01304                                               kNumu, recoCharge,
01305                                               recoResolution, kVanilla,
01306                                               kIgnoreProton, kIgnoreElectron,
01307                                               Ereco, BinContent);
01308         }
01309       }
01310     }
01311   }
01312 
01313   return;
01314 }

void TemplatesForBeamData::BuildTemplate ( Run_t  run,
Sample_t  sample,
Flavour_t  trueFlavour,
Charge_t  trueCharge,
Containment_t  recoContainment,
Charge_t  recoCharge,
Resolution_t  recoResolution,
Systematic_t  systematic,
Shift_t  shift,
TH1D *  hist 
) [private]

Definition at line 1196 of file TemplatesForBeamData.cxx.

References fScale, fThisFirstPoint, Instance(), OscFit::kBeamData, OscFit::kData, OscFit::kIgnoreElectron, OscFit::kIgnoreProton, OscFit::kNC, OscFit::kNumu, OscFit::kVanilla, n, and SetRangeOfGridPoints().

01197 {
01198   // check for non-oscillating sample
01199   if( !( sample==kData || trueFlavour==kNC ) ) return;
01200 
01201   // Building Template from 1D Histogram
01202   if( hist==0 ) return;
01203 
01204   // Set Range of Grid Points
01205   SetRangeOfGridPoints();
01206 
01207   if( fThisFirstPoint>0 ) return;
01208 
01209   // Fill Histogram
01210   for( Int_t n=0; n<hist->GetXaxis()->GetNbins(); n++ ){
01211     Double_t Ereco = hist->GetXaxis()->GetBinCenter(n+1);
01212     Double_t BinContent = hist->GetBinContent(n+1);
01213 
01214     if( sample!=kData ) BinContent *= fScale; // scale prediction
01215     
01216     OscFit::Interface::Instance()->Fill(0,
01217                                         kBeamData, sample,
01218                                         trueFlavour, trueCharge,
01219                                         systematic, shift,
01220                                         run, recoContainment,
01221                                         kNumu, recoCharge,
01222                                         recoResolution, kVanilla,
01223                                         kIgnoreProton, kIgnoreElectron,
01224                                         Ereco, BinContent);
01225   }
01226 
01227   return;
01228 }

void TemplatesForBeamData::BuildTemplate ( Run_t  run,
Sample_t  sample,
Containment_t  recoContainment,
Charge_t  recoCharge,
Resolution_t  recoResolution,
Systematic_t  systematic,
Shift_t  shift 
) [private]

Definition at line 1122 of file TemplatesForBeamData.cxx.

References fThisFirstPoint, fThisLastPoint, Instance(), OscFit::kBeamData, OscFit::kCV, OscFit::kData, OscFit::kIgnoreElectron, OscFit::kIgnoreProton, OscFit::kNoCharge, OscFit::kNoFlavour, OscFit::kNu, OscFit::kNuBar, OscFit::kNumu, OscFit::kRock, OscFit::kVanilla, n, and SetRangeOfGridPoints().

Referenced by BuildTemplatesCC2010(), BuildTemplatesCC2012(), BuildTemplatesMINOSPlus(), and BuildTemplatesRAF2010().

01123 { 
01124   // Set Range of Grid Points
01125   SetRangeOfGridPoints();
01126 
01127   Int_t nFirst = fThisFirstPoint;
01128   Int_t nLast  = fThisLastPoint;
01129 
01130   // check for non-oscillating sample
01131   if( sample==kData && nFirst>0 ) return;
01132 
01133   // Create Histograms
01134   for( Int_t n=nFirst; n<nLast; n++ ){
01135 
01136     // observed data
01137     if( sample==kData ){
01138 
01139       // no flavour and no charge
01140       OscFit::Interface::Instance()->Make(n,
01141                                           kBeamData, sample,
01142                                           kNoFlavour, kNoCharge,
01143                                           systematic, shift,
01144                                           run, recoContainment,
01145                                           kNumu, recoCharge,
01146                                           recoResolution, kVanilla,
01147                                           kIgnoreProton, kIgnoreElectron );
01148     }
01149 
01150     // contained vertex
01151     else if( sample==kCV ){
01152 
01153       // neutrinos
01154       OscFit::Interface::Instance()->Make(n,
01155                                           kBeamData, sample,
01156                                           kNumu, kNu,
01157                                           systematic, shift,
01158                                           run, recoContainment,
01159                                           kNumu, recoCharge,
01160                                           recoResolution, kVanilla,
01161                                           kIgnoreProton, kIgnoreElectron );
01162 
01163       // anti-neutrinos
01164       OscFit::Interface::Instance()->Make(n,
01165                                           kBeamData, sample,
01166                                           kNumu, kNuBar,
01167                                           systematic, shift,
01168                                           run, recoContainment,
01169                                           kNumu, recoCharge,
01170                                           recoResolution, kVanilla,
01171                                           kIgnoreProton, kIgnoreElectron );
01172     }
01173 
01174     // rock muons
01175     else if( sample==kRock ){
01176 
01177       // neutrinos
01178       OscFit::Interface::Instance()->Make(n,
01179                                           kBeamData, sample,
01180                                           kNumu, kNu,
01181                                           systematic, shift,
01182                                           run, recoContainment,
01183                                           kNumu, recoCharge,
01184                                           recoResolution, kVanilla,
01185                                           kIgnoreProton, kIgnoreElectron );
01186 
01187       // anti-neutrinos
01188       // LEAVE THESE OUT FOR NOW
01189     }
01190 
01191   }
01192 
01193   return;
01194 }

void TemplatesForBeamData::BuildTemplates ( Run_t  run,
Sample_t  sample,
Charge_t  charge,
Resolution_t  resolution,
Systematic_t  systematic,
Shift_t  shift 
)

Definition at line 434 of file TemplatesForBeamData.cxx.

References BuildTemplatesCC2012(), BuildTemplatesMINOSPlus(), BuildTemplatesRAF2012(), and fBuildTemplatesForMinosPlus.

00435 {
00436   // Build templates for MINOS+
00437   // ==========================
00438   if( fBuildTemplatesForMinosPlus ){
00439     // Build templates for MINOS+ analysis
00440     BuildTemplatesMINOSPlus( run, sample, charge, resolution, systematic, shift );
00441   }
00442 
00443   // Build templates for MINOS
00444   // =========================
00445   else{
00446     // Build templates for CC analysis
00447     BuildTemplatesCC2012( run, sample, charge, resolution, systematic, shift );
00448     // Build templates for RAF analysis
00449     BuildTemplatesRAF2012( run, sample, charge, resolution, systematic, shift );
00450   }
00451 }

void TemplatesForBeamData::BuildTemplates ( Run_t  run,
Sample_t  sample 
)

Definition at line 407 of file TemplatesForBeamData.cxx.

References OscFit::AsString(), BuildTemplates(), OscFit::GetCharge(), OscFit::GetNumCharges(), OscFit::GetNumResBins(), OscFit::GetNumShifts(), OscFit::GetNumSystematics(), OscFit::GetResBin(), OscFit::GetShift(), OscFit::GetSystematic(), OscFit::Configuration::Instance(), and SetRangeOfGridPoints().

00408 {
00409   if( Configuration::Instance()->UsingThisRun(run)==0 ) return;
00410   
00411   SetRangeOfGridPoints(); // set range of grid points here
00412 
00413   std::cout << " *** TemplatesForBeamData::BuildTemplates [" << OscFit::AsString(run) << "][" << OscFit::AsString(sample) << "] *** " << std::endl;
00414 
00415   for( Int_t icharge=0; icharge<OscFit::GetNumCharges(); icharge++ ){
00416     for( Int_t ires=0; ires<OscFit::GetNumResBins(); ires++ ){
00417       for( Int_t isys=0; isys<OscFit::GetNumSystematics(); isys++ ){ 
00418         for( Int_t ishift=0; ishift<OscFit::GetNumShifts(); ishift++ ){ 
00419           
00420           Charge_t     charge     = OscFit::GetCharge(icharge);
00421           Resolution_t resolution = OscFit::GetResBin(ires);
00422           Systematic_t systematic = OscFit::GetSystematic(isys);
00423           Shift_t      shift      = OscFit::GetShift(ishift);
00424           
00425           BuildTemplates( run, sample, charge, resolution, systematic, shift );
00426         }
00427       }
00428     }
00429   }
00430 
00431   return;
00432 }

void TemplatesForBeamData::BuildTemplates ( Run_t  run  ) 

Definition at line 399 of file TemplatesForBeamData.cxx.

References BuildTemplates(), OscFit::GetNumSamples(), and OscFit::GetSample().

00400 {
00401   for( Int_t isample=0; isample<OscFit::GetNumSamples(); isample++ ){
00402     Sample_t sample = OscFit::GetSample(isample);
00403     BuildTemplates( run, sample );
00404   }
00405 }

void TemplatesForBeamData::BuildTemplates (  ) 

Definition at line 391 of file TemplatesForBeamData.cxx.

References OscFit::GetFirstRun(), OscFit::GetNumRuns(), OscFit::GetRun(), and run().

Referenced by BuildData(), BuildMC(), and BuildTemplates().

00392 {
00393   for( Int_t irun=OscFit::GetFirstRun(); irun<OscFit::GetNumRuns(); irun++ ){ // [Loop over Run Periods]
00394     Run_t run = OscFit::GetRun(irun);
00395     BuildTemplates( run );
00396   }
00397 }

void TemplatesForBeamData::BuildTemplatesCC2010 ( Run_t  run,
Sample_t  sample,
Charge_t  charge,
Resolution_t  resolution,
Systematic_t  systematic,
Shift_t  shift 
) [private]

Definition at line 690 of file TemplatesForBeamData.cxx.

References OscFit::AsString(), BuildTemplate(), fBuildDataOnly, fBuildNuMuBar, fBuildTemplatesForMinosPlus, fInputDirectoryCC2010, OscFit::GetRunType(), gSystem(), OscFit::Configuration::Instance(), OscFit::kAtmos, OscFit::kCentre, OscFit::kContainedVertex, OscFit::kCV, OscFit::kData, OscFit::kFHC, OscFit::kMinus1, OscFit::kMinus2, OscFit::kNC, OscFit::kNCbkg, OscFit::kNegative, OscFit::kNoCharge, OscFit::kNoFlavour, OscFit::kNoRes, OscFit::kNoShift, OscFit::kNu, OscFit::kNuBar, OscFit::kNumu, OscFit::kNutau, OscFit::kPlus1, OscFit::kPlus2, OscFit::kPositive, OscFit::kResBin0, OscFit::kResBin1, OscFit::kResBin2, OscFit::kResBin3, OscFit::kResBin4, OscFit::kRHC, OscFit::kRock, OscFit::kRunI, OscFit::kRunIHE, OscFit::kRunII, OscFit::kRunIII, OscFit::kRunIVFHC, OscFit::kRunV, OscFit::kRunVI, OscFit::kRunVIII, OscFit::kRunX, OscFit::kRunXI, OscFit::kRunXII, OscFit::kRunXIII, OscFit::kShwEn, and OscFit::kTrkEn.

Referenced by BuildTemplatesCC2012().

00691 {  
00692   // Build Templates using 2010 format
00693   // =================================  
00694 
00695   // building templates for MINOS
00696   if( fBuildTemplatesForMinosPlus==true ) return;
00697 
00698   // sanity checks
00699   if( !( charge==OscFit::kNegative || charge==OscFit::kPositive ) ) return;
00700 
00701   // only generate templates for FHC Analysis
00702   if( OscFit::GetRunType(run) != OscFit::kFHC ) return;
00703 
00704   // not using these runs
00705   if( Configuration::Instance()->UsingThisRun(run)==0 ) return;
00706 
00707   // not using these run periods
00708   if( run==OscFit::kAtmos ) return;
00709   if( run==OscFit::kRunIVFHC ) return;
00710   if( run==OscFit::kRunVIII  ) return;
00711 
00712 
00713   // not using rock muons
00714   if( sample==OscFit::kRock ) return;
00715 
00716   // build Data templates only
00717   if( fBuildDataOnly ){
00718     if( sample!=OscFit::kData ) return;
00719   }
00720 
00721   // building high-purity PQ templates
00722   if( charge==OscFit::kPositive && fBuildNuMuBar==1 ) return;
00723 
00724   // systematics on/off
00725   if( systematic!=OscFit::kCentre 
00726    && Configuration::Instance()->DoingSystematics()==0 ) return;
00727 
00728   // systematic checks
00729   if( sample==OscFit::kData && systematic!=OscFit::kCentre )  return;
00730 
00731   // systematic checks
00732   if( systematic==OscFit::kCentre && shift!=OscFit::kNoShift ) return;
00733   if( systematic!=OscFit::kCentre && shift==OscFit::kNoShift ) return;
00734 
00735   // resolution binning
00736   if( charge==OscFit::kPositive && resolution!=kNoRes ) return;
00737 
00738   // ignoring RHC NQ events 
00739   if( OscFit::GetRunType(run)==OscFit::kRHC
00740    && charge==OscFit::kNegative ) return;
00741 
00742   // ignoring FHC pHE PQ events
00743   if( run==OscFit::kRunIHE && charge==OscFit::kPositive ){
00744     return BuildTemplate( run, sample,
00745                           kContainedVertex, charge, resolution, kCentre, kNoShift);
00746   }
00747 
00748   // construct file name (a lot of hard-coded stuff)
00749   TString filename = fInputDirectoryCC2010;  // Top Level Directory
00750 
00751        if( sample==OscFit::kData )  filename.Append("");
00752   else if( sample==OscFit::kCV )    filename.Append("");
00753   else return;
00754 
00755        if( systematic==OscFit::kCentre ) filename.Append("/Nominal");  // OR Nominal
00756   else if( systematic==OscFit::kNCbkg )  filename.Append("/NCBackground");
00757   else if( systematic==OscFit::kShwEn )  filename.Append("/ShowerEnergyBoth");
00758   else if( systematic==OscFit::kTrkEn )  filename.Append("/TrackEnergyOverall");
00759   else return;
00760 
00761        if( shift==OscFit::kMinus2 ) filename.Append("/DOWN2");
00762   else if( shift==OscFit::kMinus1 ) filename.Append("/DOWN1");
00763   else if( shift==OscFit::kPlus1  ) filename.Append("/UP1");
00764   else if( shift==OscFit::kPlus2  ) filename.Append("/UP2");
00765 
00766        if( run==OscFit::kRunI    )   filename.Append("/jess_run_1LE");
00767   else if( run==OscFit::kRunIHE  )   filename.Append("/jess_run_1pHE");
00768   else if( run==OscFit::kRunII   )   filename.Append("/jess_run_2LE");
00769   else if( run==OscFit::kRunIII  )   filename.Append("/jess_run_3LE");
00770   else if( run==OscFit::kRunV    )   filename.Append("/jess_run_5LE");
00771   else if( run==OscFit::kRunVI   )   filename.Append("/jess_run_6LE");
00772   else if( run==OscFit::kRunX    )   filename.Append("/jess_run_10LE");
00773   else if( run==OscFit::kRunXI   )   filename.Append("/jess_run_11HE");
00774   else if( run==OscFit::kRunXII  )   filename.Append("/jess_run_12HE");
00775   else if( run==OscFit::kRunXIII )   filename.Append("/jess_run_13HE");
00776   else return;
00777 
00778        if( charge==OscFit::kNegative ) filename.Append("_NQ");
00779   else if( charge==OscFit::kPositive ) filename.Append("_PQ");
00780   else return;
00781 
00782        if( resolution==OscFit::kResBin0 )  filename.Append("_res0");
00783   else if( resolution==OscFit::kResBin1 )  filename.Append("_res1");
00784   else if( resolution==OscFit::kResBin2 )  filename.Append("_res2");
00785   else if( resolution==OscFit::kResBin3 )  filename.Append("_res3");
00786   else if( resolution==OscFit::kResBin4 )  filename.Append("_res4");
00787   else if( resolution==OscFit::kNoRes   )  filename.Append("");
00788   else return;
00789 
00790   filename.Append(".root");
00791 
00792 
00793   // build template
00794   std::cout << " Building Template: " << std::endl;
00795   std::cout << "  Using CC2010 Analysis Templates " << std::endl;
00796   std::cout << "  Template: [" << OscFit::AsString(run) << "][" << OscFit::AsString(sample) << "][" << OscFit::AsString(charge) << "][" << OscFit::AsString(resolution) << "][" << OscFit::AsString(systematic) << "][" << OscFit::AsString(shift) << "]" << std::endl;
00797   std::cout << "  FileName: " << filename.Data() << std::endl;
00798             
00799   if( gSystem->AccessPathName(filename) ) { // returns kTrue if non-existent
00800     std::cout << "  Warning: failed to find input file " << std::endl;
00801     return;
00802   }
00803     
00804   // open file
00805   TDirectory* tmpd = gDirectory;
00806   TFile* file = new TFile(filename,"read");
00807 
00808   // selected neutrinos
00809   if( sample==OscFit::kCV && charge==OscFit::kNegative ){
00810     TH2D* hCCPrediction = (TH2D*)( file->Get("nuPrediction") );
00811     this->BuildTemplate( run, sample, kNumu, kNu, 
00812                          kContainedVertex, charge, resolution, systematic, shift,
00813                          hCCPrediction );
00814 
00815     TH2D* hWSBackground = (TH2D*)( file->Get("wsBackground") );
00816     this->BuildTemplate( run, sample, kNumu, kNuBar, 
00817                          kContainedVertex, charge, resolution, systematic, shift,
00818                          hWSBackground );
00819 
00820     TH1D* hNCBackground = (TH1D*)( file->Get("ncBackground") );
00821     this->BuildTemplate( run, sample, kNC, kNu, 
00822                          kContainedVertex, charge, resolution, systematic, shift,
00823                          hNCBackground );
00824  
00825     TH2D* hTauPrediction = (TH2D*)( file->Get("potentialTaus") );
00826     this->BuildTemplate( run, sample, kNutau, kNu, 
00827                          kContainedVertex, charge, resolution, systematic, shift,
00828                          hTauPrediction );
00829   }
00830 
00831   // selected antineutrinos
00832   if( sample==OscFit::kCV && charge==OscFit::kPositive ){
00833     TH2D* hCCPrediction = (TH2D*)( file->Get("nuPrediction") );
00834     this->BuildTemplate( run, sample, kNumu, kNuBar, 
00835                          kContainedVertex, charge, resolution, systematic, shift,
00836                          hCCPrediction );
00837 
00838     TH2D* hWSBackground = (TH2D*)( file->Get("wsBackground") );
00839     this->BuildTemplate( run, sample, kNumu, kNu, 
00840                          kContainedVertex, charge, resolution, systematic, shift,
00841                          hWSBackground );
00842 
00843     TH1D* hNCBackground = (TH1D*)( file->Get("ncBackground") );
00844     this->BuildTemplate( run, sample, kNC, kNuBar, 
00845                          kContainedVertex, charge, resolution, systematic, shift,
00846                          hNCBackground );
00847  
00848     TH2D* hTauPrediction = (TH2D*)( file->Get("potentialTaus") );
00849     this->BuildTemplate( run, sample, kNutau, kNuBar, 
00850                          kContainedVertex, charge, resolution, systematic, shift,
00851                          hTauPrediction );
00852     //    TemplateGrid::Instance()->GetTemplate(0)
00853   }
00854 
00855   // observed data
00856   if( sample==OscFit::kData ){
00857     TH1D* hData = (TH1D*)( file->Get("data") );
00858     this->BuildTemplate( run, sample, kNoFlavour, kNoCharge, 
00859                          kContainedVertex, charge, resolution, systematic, shift,
00860                          hData );
00861   }
00862 
00863   file->Close();
00864   tmpd->cd();
00865  
00866   std::cout << "  Building Template... Done! " << std::endl;
00867 
00868   return;
00869 }

void TemplatesForBeamData::BuildTemplatesCC2012 ( Run_t  run,
Sample_t  sample,
Charge_t  charge,
Resolution_t  resolution,
Systematic_t  systematic,
Shift_t  shift 
) [private]

Definition at line 453 of file TemplatesForBeamData.cxx.

References OscFit::AsString(), BuildTemplate(), BuildTemplatesCC2010(), fBuildCCOnly, fBuildDataOnly, fBuildNUBAROnly, fBuildNuMuBar, fBuildRHCOnly, fBuildTemplatesForMinosPlus, fInputPath, fUseCC2010Templates, OscFit::GetRunType(), gSystem(), OscFit::Configuration::Instance(), OscFit::kAtmos, OscFit::kCentre, OscFit::kContainedVertex, OscFit::kCV, OscFit::kData, OscFit::kFHC, OscFit::kMinus1, OscFit::kMinus2, OscFit::kNC, OscFit::kNCbkg, OscFit::kNegative, OscFit::kNoCharge, OscFit::kNoFlavour, OscFit::kNoRes, OscFit::kNoShift, OscFit::kNu, OscFit::kNuBar, OscFit::kNumu, OscFit::kNutau, OscFit::kPlus1, OscFit::kPlus2, OscFit::kPositive, OscFit::kResBin0, OscFit::kResBin1, OscFit::kResBin2, OscFit::kResBin3, OscFit::kResBin4, OscFit::kRHC, OscFit::kRock, OscFit::kRunI, OscFit::kRunIHE, OscFit::kRunII, OscFit::kRunIII, OscFit::kRunIV, OscFit::kRunIVFHC, OscFit::kRunIX, OscFit::kRunV, OscFit::kRunVI, OscFit::kRunVII, OscFit::kRunVIII, OscFit::kRunX, OscFit::kRunXI, OscFit::kShwEn, and OscFit::kTrkEn.

Referenced by BuildTemplates().

00454 {  
00455   // Build Templates using 2012 format
00456   // =================================  
00457 
00458   // building templates for MINOS
00459   if( fBuildTemplatesForMinosPlus==true ) return;
00460 
00461   // sanity checks
00462   if( !( charge==OscFit::kNegative || charge==OscFit::kPositive ) ) return;
00463 
00464   // not using these runs
00465   if( Configuration::Instance()->UsingThisRun(run)==0 ) return;
00466 
00467   // not using these runs
00468   if( run==OscFit::kAtmos ) return;
00469   if( run==OscFit::kRunIVFHC ) return;
00470   if( run==OscFit::kRunVIII  ) return;
00471 
00472 
00473   // not using rock muons
00474   if( sample==OscFit::kRock ) return;
00475 
00476   // build Data templates only
00477   if( fBuildDataOnly ){
00478     if( sample!=OscFit::kData ) return;
00479   }
00480 
00481   // build CC templates only
00482   if( fBuildCCOnly ){
00483     if( OscFit::GetRunType(run)==OscFit::kRHC ) return;
00484     if( charge==OscFit::kPositive && fBuildNuMuBar==1 ) return;
00485   }
00486 
00487   // build RHC templates only
00488   if( fBuildRHCOnly ){
00489     if( OscFit::GetRunType(run)==OscFit::kFHC ) return;
00490     if( charge==OscFit::kNegative ) return;
00491   }
00492 
00493   // build NUBAR templates only
00494   if( fBuildNUBAROnly ){
00495     if( OscFit::GetRunType(run)==OscFit::kRHC ) return;
00496     if( charge==OscFit::kNegative || fBuildNuMuBar==0 ) return;
00497   }
00498 
00499   // systematics on/off
00500   if( systematic!=OscFit::kCentre 
00501    && Configuration::Instance()->DoingSystematics()==0 ) return;
00502 
00503   // systematics checks
00504   if( sample==OscFit::kData && systematic!=OscFit::kCentre )   return;
00505 
00506   // systematics checks
00507   if( systematic==OscFit::kCentre && shift!=OscFit::kNoShift ) return;
00508   if( systematic!=OscFit::kCentre && shift==OscFit::kNoShift ) return;
00509 
00510   // resolution binning
00511   if( charge==OscFit::kPositive && resolution!=kNoRes ) return;
00512   //  if( charge==OscFit::kNegative && resolution==kNoRes ) return;
00513 
00514   // ignoring RHC NQ events 
00515   if( OscFit::GetRunType(run)==OscFit::kRHC
00516    && charge==OscFit::kNegative ) return;
00517 
00518   // ignoring FHC pHE PQ events
00519   if( run==OscFit::kRunIHE && charge==OscFit::kPositive ){
00520     return BuildTemplate( run, sample, 
00521                           kContainedVertex, charge, resolution, kCentre, kNoShift);
00522   }
00523 
00524   // if still using templates from 2010 CC analysis,
00525   // then intercept FHC events here 
00526   if( fUseCC2010Templates ){
00527     if( OscFit::GetRunType(run)==OscFit::kFHC 
00528      && ( charge==OscFit::kNegative || fBuildNuMuBar==0 ) ){
00529       return BuildTemplatesCC2010( run, sample, charge, resolution, systematic, shift );
00530     }
00531   }
00532 
00533   // construct file name (a lot of hard-coded stuff)
00534   TString filename = fInputPath;
00535   TString tag = "";
00536 
00537        if( sample==OscFit::kData  ) tag.Append("");
00538   else if( sample==OscFit::kCV    ) tag.Append("");
00539   else return;
00540 
00541        if( run==OscFit::kRunI   )  tag.Append("_Run01");
00542   else if( run==OscFit::kRunIHE )  tag.Append("_Run01HE");
00543   else if( run==OscFit::kRunII  )  tag.Append("_Run02");
00544   else if( run==OscFit::kRunIII )  tag.Append("_Run03");
00545   else if( run==OscFit::kRunIV  )  tag.Append("_Run04");
00546   else if( run==OscFit::kRunV   )  tag.Append("_Run05");
00547   else if( run==OscFit::kRunVI  )  tag.Append("_Run06");
00548   else if( run==OscFit::kRunVII )  tag.Append("_Run07");
00549   else if( run==OscFit::kRunIX  )  tag.Append("_Run09");
00550   else if( run==OscFit::kRunX   )  tag.Append("_Run10");
00551   else if( run==OscFit::kRunXI  )  tag.Append("_Run11");
00552   else return;
00553 
00554        if( charge==kNegative )     tag.Append("_NQ");
00555   else if( charge==kPositive )     tag.Append("_PQ"); 
00556   else return;
00557 
00558        if( resolution==OscFit::kResBin0 )  tag.Append("_0");
00559   else if( resolution==OscFit::kResBin1 )  tag.Append("_1");
00560   else if( resolution==OscFit::kResBin2 )  tag.Append("_2");
00561   else if( resolution==OscFit::kResBin3 )  tag.Append("_3");
00562   else if( resolution==OscFit::kResBin4 )  tag.Append("_4");
00563   else if( resolution==OscFit::kNoRes   )  tag.Append("");
00564   else return;
00565 
00566   if( fBuildNuMuBar
00567    && OscFit::GetRunType(run)==OscFit::kFHC ) tag.Append("_NuMuBar");
00568 
00569        if( systematic==OscFit::kCentre ) tag.Append("_Nominal");  // OR Nominal
00570   else if( systematic==OscFit::kNCbkg )  tag.Append("_NCBackground");
00571   else if( systematic==OscFit::kShwEn )  tag.Append("_ShowerEnergy");
00572   else if( systematic==OscFit::kTrkEn )  tag.Append("_TrackEnergy");
00573   else return;
00574 
00575        if( shift==OscFit::kMinus2 ) tag.Append("_Down2");
00576   else if( shift==OscFit::kMinus1 ) tag.Append("_Down1");
00577   else if( shift==OscFit::kPlus1  ) tag.Append("_Up1");
00578   else if( shift==OscFit::kPlus2  ) tag.Append("_Up2");
00579 
00580   if( filename.EndsWith(".root") ){
00581     filename.Insert(filename.Length()-5,tag);
00582   }
00583   else{
00584     filename.Append(tag);
00585   }
00586 
00587   // build template
00588   std::cout << " Building Template: " << std::endl;
00589   std::cout << "  Template: [" << OscFit::AsString(run) << "][" << OscFit::AsString(sample) << "][" << OscFit::AsString(charge) << "][" << OscFit::AsString(resolution) << "][" << OscFit::AsString(systematic) << "][" << OscFit::AsString(shift) << "]" << std::endl;
00590   std::cout << "  FileName: " << filename.Data() << std::endl;
00591             
00592   if( gSystem->AccessPathName(filename) ) { // returns kTrue if non-existent
00593     std::cout << "  Warning: failed to find input file " << std::endl;
00594     return;
00595   }
00596 
00597   // histogram names
00598   // ===============  
00599 
00600   // Neutrinos (NQ)
00601   //  [TH2D] hNQfromCCTau
00602   //  [TH2D] hNQFromCCTauBar
00603   //  [TH1D] hNQFromNC
00604   //  [TH2D] hNQFromCCMu
00605   //  [TH2D] hNQFromCCMuBar
00606   //  [TH1D] hNQData
00607   
00608   // Anti-Neutrinos (PQ)
00609   //  [TH2D] hPQfromCCTau
00610   //  [TH2D] hPQFromCCTauBar
00611   //  [TH1D] hPQFromNC
00612   //  [TH2D] hPQFromCCMu
00613   //  [TH2D] hPQFromCCMuBar
00614   //  [TH1D] hPQData
00615 
00616   TString histname_cc_nutau    = "";
00617   TString histname_cc_nutaubar = "";
00618   TString histname_cc_numu     = "";
00619   TString histname_cc_numubar  = "";
00620   TString histname_nc          = "";
00621   TString histname_data        = "";
00622 
00623   if( charge==OscFit::kPositive ){
00624     histname_cc_nutau    = "hPQfromCCTau"; // Note: little 'f'!!
00625     histname_cc_nutaubar = "hPQFromCCTauBar";
00626     histname_cc_numu     = "hPQFromCCMu";
00627     histname_cc_numubar  = "hPQFromCCMuBar";
00628     histname_nc          = "hPQFromNC";
00629     histname_data        = "hPQData";
00630   }
00631   
00632   if( charge==OscFit::kNegative ){
00633     histname_cc_nutau    = "hNQfromCCTau"; // Note: little 'f'!!
00634     histname_cc_nutaubar = "hNQFromCCTauBar";
00635     histname_cc_numu     = "hNQFromCCMu";
00636     histname_cc_numubar  = "hNQFromCCMuBar";
00637     histname_nc          = "hNQFromNC";
00638     histname_data        = "hNQData";
00639   }
00640 
00641   // build histograms
00642   // ================
00643 
00644   TDirectory* tmpd = gDirectory;
00645   TFile* file = new TFile(filename,"read");
00646 
00647   if( sample==OscFit::kCV ){
00648     std::cout<<"CV"<<std::endl;
00649     TH2D* histFromCCMuBar = (TH2D*)( file->Get( histname_cc_numubar.Data() ) );
00650     this->BuildTemplate( run, sample, kNumu, kNuBar, 
00651                          kContainedVertex, charge, resolution, systematic, shift,
00652                          histFromCCMuBar );
00653 
00654     TH2D* histFromCCMu = (TH2D*)( file->Get( histname_cc_numu.Data() ) );
00655     this->BuildTemplate( run, sample, kNumu, kNu, 
00656                          kContainedVertex, charge, resolution, systematic, shift,
00657                          histFromCCMu );
00658 
00659     TH1D* histFromNC = (TH1D*)( file->Get( histname_nc.Data() ) );
00660     this->BuildTemplate( run, sample, kNC, kNu, 
00661                          kContainedVertex, charge, resolution, systematic, shift,
00662                          histFromNC );
00663   
00664     TH2D* histFromCCTauBar = (TH2D*)( file->Get( histname_cc_nutaubar.Data() ) ); 
00665     this->BuildTemplate( run, sample, kNutau, kNuBar, 
00666                          kContainedVertex, charge, resolution, systematic, shift,
00667                          histFromCCTauBar );
00668 
00669     TH2D* histFromCCTau = (TH2D*)( file->Get( histname_cc_nutau.Data() ) );
00670     this->BuildTemplate( run, sample, kNutau, kNu, 
00671                          kContainedVertex, charge, resolution, systematic, shift,
00672                          histFromCCTau );
00673   }
00674 
00675   if( sample==OscFit::kData ){
00676     TH1D* histData = (TH1D*)( file->Get( histname_data.Data() ) );
00677     this->BuildTemplate( run, sample, kNoFlavour, kNoCharge, 
00678                          kContainedVertex, charge, resolution, systematic, shift,
00679                          histData );
00680   }
00681 
00682   file->Close();
00683   tmpd->cd();
00684  
00685   std::cout << "  Building Template... Done! " << std::endl;
00686 
00687   return;
00688 }

void OscFit::TemplatesForBeamData::BuildTemplatesForMINOSPlus (  )  [inline]

Definition at line 143 of file TemplatesForBeamData.h.

References fBuildTemplatesForMinosPlus.

00143                                       {
00144       fBuildTemplatesForMinosPlus = 1;
00145     }

void TemplatesForBeamData::BuildTemplatesMINOSPlus ( Run_t  run,
Sample_t  sample,
Charge_t  charge,
Resolution_t  resolution,
Systematic_t  systematic,
Shift_t  shift 
) [private]

Definition at line 1023 of file TemplatesForBeamData.cxx.

References OscFit::AsString(), BuildTemplate(), fBuildTemplatesForMinosPlus, fInputDirectoryMinosPlus, gSystem(), OscFit::Configuration::Instance(), OscFit::kCentre, OscFit::kContainedVertex, OscFit::kCV, OscFit::kNC, OscFit::kNegative, OscFit::kNoRes, OscFit::kNoShift, OscFit::kNu, OscFit::kNuBar, OscFit::kNumu, OscFit::kNutau, OscFit::kPositive, OscFit::kRunXI, OscFit::kRunXII, and OscFit::kRunXIII.

Referenced by BuildTemplates().

01024 {  
01025   // Build Templates using 2010 format
01026   // =================================  
01027 
01028   // building templates for MINOS+
01029   if( fBuildTemplatesForMinosPlus==false ) return;
01030 
01031   // MINOS+ FHC Mode (denoted Run 11).
01032   if( run!=OscFit::kRunXI && run!=OscFit::kRunXII && run!=OscFit::kRunXIII ) return;
01033   
01034   // contained vertex events, no resolution binning
01035   if( sample!=OscFit::kCV || charge!=OscFit::kNegative || resolution!=OscFit::kNoRes ) return;
01036 
01037   // systematics on/off
01038   if( systematic!=OscFit::kCentre 
01039    && Configuration::Instance()->DoingSystematics()==0 ) return;
01040 
01041   // systematic checks
01042   if( systematic==OscFit::kCentre && shift!=OscFit::kNoShift ) return;
01043   if( systematic!=OscFit::kCentre && shift==OscFit::kNoShift ) return;
01044 
01045   // construct file name (a lot of hard-coded stuff)
01046   TString filename = fInputDirectoryMinosPlus;  // Top Level Directory
01047 
01048        if( systematic==OscFit::kCentre ) filename.Append("/MINOSPlusFHCGhostFitterTemplate");  // OR Nominal
01049   else return;
01050 
01051   filename.Append(".root");
01052 
01053   // build template
01054   std::cout << " Building Template: " << std::endl;
01055   std::cout << "  Using CC2010 Analysis Templates " << std::endl;
01056   std::cout << "  Template: [" << OscFit::AsString(run) << "][" << OscFit::AsString(sample) << "][" << OscFit::AsString(charge) << "][" << OscFit::AsString(resolution) << "][" << OscFit::AsString(systematic) << "][" << OscFit::AsString(shift) << "]" << std::endl;
01057   std::cout << "  FileName: " << filename.Data() << std::endl;
01058               
01059   if( gSystem->AccessPathName(filename) ) { // returns kTrue if non-existent
01060     std::cout << "  Warning: failed to find input file " << std::endl;
01061     return;
01062   }
01063     
01064   // open file
01065   TDirectory* tmpd = gDirectory;
01066   TFile* file = new TFile(filename,"read");
01067 
01068   // selected neutrinos
01069   if( sample==OscFit::kCV && charge==OscFit::kNegative ){
01070     TH2D* hCCPrediction = (TH2D*)( file->Get("nuPrediction") );
01071     this->BuildTemplate( run, sample, kNumu, kNu, 
01072                          kContainedVertex, charge, resolution, systematic, shift,
01073                          hCCPrediction );
01074 
01075     TH2D* hWSBackground = (TH2D*)( file->Get("wsBackground") );
01076     this->BuildTemplate( run, sample, kNumu, kNuBar, 
01077                          kContainedVertex, charge, resolution, systematic, shift,
01078                          hWSBackground );
01079 
01080     TH1D* hNCBackground = (TH1D*)( file->Get("ncBackground") );
01081     this->BuildTemplate( run, sample, kNC, kNu, 
01082                          kContainedVertex, charge, resolution, systematic, shift,
01083                          hNCBackground );
01084  
01085     TH2D* hTauPrediction = (TH2D*)( file->Get("potentialTaus") );
01086     this->BuildTemplate( run, sample, kNutau, kNu, 
01087                          kContainedVertex, charge, resolution, systematic, shift,
01088                          hTauPrediction );
01089   }
01090 
01091   // selected antineutrinos
01092   if( sample==OscFit::kCV && charge==OscFit::kPositive ){
01093     TH2D* hCCPrediction = (TH2D*)( file->Get("nuPrediction") );
01094     this->BuildTemplate( run, sample, kNumu, kNuBar, 
01095                          kContainedVertex, charge, resolution, systematic, shift,
01096                          hCCPrediction );
01097 
01098     TH2D* hWSBackground = (TH2D*)( file->Get("wsBackground") );
01099     this->BuildTemplate( run, sample, kNumu, kNu, 
01100                          kContainedVertex, charge, resolution, systematic, shift,
01101                          hWSBackground );
01102 
01103     TH1D* hNCBackground = (TH1D*)( file->Get("ncBackground") );
01104     this->BuildTemplate( run, sample, kNC, kNuBar, 
01105                          kContainedVertex, charge, resolution, systematic, shift,
01106                          hNCBackground );
01107  
01108     TH2D* hTauPrediction = (TH2D*)( file->Get("potentialTaus") );
01109     this->BuildTemplate( run, sample, kNutau, kNuBar, 
01110                          kContainedVertex, charge, resolution, systematic, shift,
01111                          hTauPrediction );
01112   }
01113   
01114   file->Close();
01115   tmpd->cd();
01116  
01117   std::cout << "  Building Template... Done! " << std::endl;
01118 
01119   return;
01120 }

void TemplatesForBeamData::BuildTemplatesRAF2010 ( Run_t  run,
Sample_t  sample,
Charge_t  charge,
Resolution_t  resolution,
Systematic_t  systematic,
Shift_t  shift 
) [private]

Definition at line 876 of file TemplatesForBeamData.cxx.

References OscFit::AsString(), BuildTemplate(), fBuildDataOnly, fBuildTemplatesForMinosPlus, fInputDirectoryCC2010, OscFit::GetRunType(), gSystem(), OscFit::Configuration::Instance(), OscFit::kAtmos, OscFit::kCentre, OscFit::kCV, OscFit::kData, OscFit::kFHC, OscFit::kMinus1, OscFit::kMinus2, OscFit::kNC, OscFit::kNCbkg, OscFit::kNegative, OscFit::kNoCharge, OscFit::kNoFlavour, OscFit::kNoRes, OscFit::kNoShift, OscFit::kNu, OscFit::kNuBar, OscFit::kNumu, OscFit::kNutau, OscFit::kPlus1, OscFit::kPlus2, OscFit::kPositive, OscFit::kRock, OscFit::kRockMuon, OscFit::kRunI, OscFit::kRunIHE, OscFit::kRunII, OscFit::kRunIII, OscFit::kRunIVFHC, OscFit::kRunV, OscFit::kRunVI, OscFit::kRunVIII, OscFit::kRunX, OscFit::kRunXI, OscFit::kRunXII, OscFit::kRunXIII, OscFit::kShwEn, and OscFit::kTrkEn.

Referenced by BuildTemplatesRAF2012().

00877 {  
00878   // Build Templates using 2010 format
00879   // =================================  
00880 
00881   // building templates for MINOS
00882   if( fBuildTemplatesForMinosPlus==true ) return;
00883 
00884   // sanity checks
00885   if( !( charge==OscFit::kNegative || charge==OscFit::kPositive ) ) return;
00886 
00887   // only generate templates for FHC Analysis
00888   if( OscFit::GetRunType(run) != OscFit::kFHC ) return;
00889 
00890   // not using these runs
00891   if( Configuration::Instance()->UsingThisRun(run)==0 ) return;
00892 
00893   // not using these run periods
00894   if( run==OscFit::kAtmos ) return;
00895   if( run==OscFit::kRunIVFHC ) return;
00896   if( run==OscFit::kRunVIII  ) return;
00897   if( run==OscFit::kRunXI    ) return;
00898   if( run==OscFit::kRunXII   ) return;
00899   if( run==OscFit::kRunXIII  ) return;
00900 
00901   // not using contained vertex events
00902   if( sample==OscFit::kCV ) return;
00903 
00904   // build Data templates only
00905   if( fBuildDataOnly ){
00906     if( sample!=OscFit::kData ) return;
00907   }
00908 
00909   // no PQ templates, no resolution bins
00910   if( charge!=OscFit::kNegative || resolution!=OscFit::kNoRes ) return;
00911 
00912   // systematics on/off
00913   if( systematic!=OscFit::kCentre 
00914    && Configuration::Instance()->DoingSystematics()==0 ) return;
00915 
00916   // systematic checks
00917   if( sample==OscFit::kData && systematic!=OscFit::kCentre )  return;
00918 
00919   // systematic checks
00920   if( systematic==OscFit::kCentre && shift!=OscFit::kNoShift ) return;
00921   if( systematic!=OscFit::kCentre && shift==OscFit::kNoShift ) return;
00922 
00923   // construct file name (a lot of hard-coded stuff)
00924   TString filename = fInputDirectoryCC2010;  // Top Level Directory
00925 
00926        if( sample==OscFit::kData )  filename.Append("");
00927   else if( sample==OscFit::kRock )  filename.Append("");
00928   else return;
00929 
00930        if( systematic==OscFit::kCentre ) filename.Append("/Data");  // OR Nominal
00931   else if( systematic==OscFit::kNCbkg )  filename.Append("/NCBackground");
00932   else if( systematic==OscFit::kShwEn )  filename.Append("/ShowerEnergyBoth");
00933   else if( systematic==OscFit::kTrkEn )  filename.Append("/TrackEnergyOverall");
00934   else return;
00935 
00936        if( shift==OscFit::kMinus2 ) filename.Append("/DOWN2");
00937   else if( shift==OscFit::kMinus1 ) filename.Append("/DOWN1");
00938   else if( shift==OscFit::kPlus1  ) filename.Append("/UP1");
00939   else if( shift==OscFit::kPlus2  ) filename.Append("/UP2");
00940 
00941        if( run==OscFit::kRunI   )   filename.Append("/jess_run_1LE");
00942   else if( run==OscFit::kRunIHE )   filename.Append("/jess_run_1pHE");
00943   else if( run==OscFit::kRunII  )   filename.Append("/jess_run_2LE");
00944   else if( run==OscFit::kRunIII )   filename.Append("/jess_run_3LE");
00945   else if( run==OscFit::kRunV   )   filename.Append("/jess_run_5LE");
00946   else if( run==OscFit::kRunVI  )   filename.Append("/jess_run_6LE");
00947   else if( run==OscFit::kRunX   )   filename.Append("/jess_run_10LE");
00948   else if( run==OscFit::kRunXI   )   filename.Append("/jess_run_11HE");
00949   else return;
00950  
00951        if( resolution==OscFit::kNoRes )  filename.Append("_RAF");
00952   else return;
00953 
00954   filename.Append(".root");
00955 
00956   // build template
00957   std::cout << " Building Template: " << std::endl;
00958   std::cout << "  Using CC2010 Analysis Templates " << std::endl;
00959   std::cout << "  Template: [" << OscFit::AsString(run) << "][" << OscFit::AsString(sample) << "][" << OscFit::AsString(charge) << "][" << OscFit::AsString(resolution) << "][" << OscFit::AsString(systematic) << "][" << OscFit::AsString(shift) << "]" << std::endl;
00960   std::cout << "  FileName: " << filename.Data() << std::endl;
00961               
00962   if( gSystem->AccessPathName(filename) ) { // returns kTrue if non-existent
00963     std::cout << "  Warning: failed to find input file " << std::endl;
00964     return;
00965   }
00966     
00967   // open file
00968   TDirectory* tmpd = gDirectory;
00969   TFile* file = new TFile(filename,"read");
00970 
00971   // selected neutrinos
00972   if( sample==OscFit::kRock && charge==OscFit::kNegative ){
00973     TH2D* hCCPrediction = (TH2D*)( file->Get("mc_jess_ccmu") );
00974     this->BuildTemplate( run, sample, kNumu, kNu, 
00975                          kRockMuon, charge, resolution, systematic, shift,
00976                          hCCPrediction );
00977 
00978     TH1D* hNCBackground = (TH1D*)( file->Get("mc_jess_no") );
00979     this->BuildTemplate( run, sample, kNC, kNu, 
00980                          kRockMuon, charge, resolution, systematic, shift,
00981                          hNCBackground );
00982     
00983     TH2D* hTauPrediction = (TH2D*)( file->Get("mc_jess_cctau") );
00984     this->BuildTemplate( run, sample, kNutau, kNu, 
00985                          kRockMuon, charge, resolution, systematic, shift,
00986                          hTauPrediction );
00987   }
00988 
00989   // selected antineutrinos
00990   if( sample==OscFit::kRock && charge==OscFit::kPositive ){
00991     TH2D* hCCPrediction = (TH2D*)( file->Get("mc_jess_ccmu") );
00992     this->BuildTemplate( run, sample, kNumu, kNuBar, 
00993                          kRockMuon, charge, resolution, systematic, shift,
00994                          hCCPrediction );
00995 
00996     TH1D* hNCBackground = (TH1D*)( file->Get("mc_jess_no") );
00997     this->BuildTemplate( run, sample, kNC, kNuBar, 
00998                          kRockMuon, charge, resolution, systematic, shift,
00999                          hNCBackground );
01000     
01001     TH2D* hTauPrediction = (TH2D*)( file->Get("mc_jess_cctau") );
01002     this->BuildTemplate( run, sample, kNutau, kNuBar, 
01003                          kRockMuon, charge, resolution, systematic, shift,
01004                          hTauPrediction );
01005   }
01006 
01007   // observed data
01008   if( sample==OscFit::kData ){
01009     TH1D* hData = (TH1D*)( file->Get("data_allreco") );
01010     this->BuildTemplate( run, sample, kNoFlavour, kNoCharge, 
01011                          kRockMuon, charge, resolution, systematic, shift,
01012                          hData );
01013   }
01014   
01015   file->Close();
01016   tmpd->cd();
01017  
01018   std::cout << "  Building Template... Done! " << std::endl;
01019 
01020   return;
01021 }

void TemplatesForBeamData::BuildTemplatesRAF2012 ( Run_t  run,
Sample_t  sample,
Charge_t  charge,
Resolution_t  resolution,
Systematic_t  systematic,
Shift_t  shift 
) [private]

Definition at line 871 of file TemplatesForBeamData.cxx.

References BuildTemplatesRAF2010().

Referenced by BuildTemplates().

00872 {  
00873   return BuildTemplatesRAF2010( run, sample, charge, resolution, systematic, shift );
00874 }

Int_t TemplatesForBeamData::CacheID ( Int_t  n,
Sample_t  sample,
Flavour_t  flavour,
Charge_t  charge 
) [private]

Definition at line 1513 of file TemplatesForBeamData.cxx.

References OscFit::GetNumCharges(), OscFit::GetNumFlavours(), OscFit::GetNumSamples(), OscFit::kCV, OscFit::kNu, OscFit::kNuBar, OscFit::kNumu, OscFit::kNutau, and OscFit::kRock.

Referenced by GetCachedOscHist(), and LoadCachedOscWeights().

01514 {
01515   if( !( sample==OscFit::kCV || sample==OscFit::kRock ) ) 
01516     return -1;
01517 
01518   if( !( flavour==OscFit::kNumu || flavour==OscFit::kNutau ) )
01519     return -1;
01520 
01521   if( !( charge==OscFit::kNu || charge==OscFit::kNuBar ) )
01522     return -1;
01523 
01524   Int_t id = -1;
01525 
01526   Int_t isample  = static_cast<Int_t>(sample);
01527   Int_t iflavour = static_cast<Int_t>(flavour);
01528   Int_t icharge  = static_cast<Int_t>(charge);
01529 
01530   if( isample>=0  && isample<GetNumSamples()
01531    && iflavour>=0 && iflavour<GetNumFlavours()
01532    && icharge>=0  && icharge<GetNumCharges() ){
01533     
01534     id = n            * 1000
01535        + (1+isample)  * 100
01536        + (1+iflavour) * 10
01537        + (1+icharge); 
01538   }
01539 
01540   return id;
01541 }

TH2D * TemplatesForBeamData::GetCachedOscHist ( Int_t  n,
Sample_t  sample,
Flavour_t  flavour,
Charge_t  charge 
) [private]

Definition at line 1428 of file TemplatesForBeamData.cxx.

References CacheID(), and fOscillationMap.

Referenced by GetCachedOscProb(), and LoadCachedOscWeights().

01429 {
01430   TH2D* cachedHist = NULL;
01431   
01432   Int_t id = this->CacheID( n, sample, flavour, charge );
01433 
01434   if( id<0 ) return NULL;
01435 
01436   std::map<Int_t,TH2D*>::iterator myEntry = fOscillationMap.find(id);
01437 
01438   if( myEntry != fOscillationMap.end() ){
01439     cachedHist = myEntry->second;
01440   }
01441 
01442   return cachedHist;
01443 }

Double_t TemplatesForBeamData::GetCachedOscProb ( Int_t  n,
Int_t  i,
Int_t  j,
Sample_t  sample,
Flavour_t  flavour,
Charge_t  charge 
) [private]

Definition at line 1419 of file TemplatesForBeamData.cxx.

References GetCachedOscHist().

Referenced by BuildTemplate().

01420 {
01421   TH2D* cachedHist = this->GetCachedOscHist( n, sample, flavour, charge );   
01422 
01423   assert( cachedHist );
01424 
01425   return cachedHist->GetBinContent( i+1, j+1 );
01426 }

Int_t TemplatesForBeamData::GetNumberOfSubBins ( Double_t  emin,
Double_t  emax 
) [private]

Definition at line 1316 of file TemplatesForBeamData.cxx.

References fMaxSubBins, fMinSubBins, and fUseSingleSubBin.

Referenced by BuildTemplate(), and LoadCachedOscWeights().

01317 {
01318   // using single bin
01319   if( fUseSingleSubBin ) return 1;
01320 
01321   // sanity check
01322   if( emax<=emin ) return 1;
01323 
01324   // size of bin
01325   Double_t dE = emax-emin;
01326 
01327   // size of sub-bin (Old)       
01328   //      if( emin< 5.0 ) dE = 0.005;  //   0.05 GeV bins -> 10 sub-bins
01329   // else if( emin<10.0 ) dE = 0.005;  //   0.25 GeV bins -> 50 sub-bins
01330   // else if( emin<20.0 ) dE = 0.010;  //   0.25 GeV bins -> 25 sub-bins
01331   // else if( emin<25.0 ) dE = 0.025;  //   1.00 GeV bins -> 40 sub-bins 
01332   // else if( emin<30.0 ) dE = 0.050;  //   1.00 GeV bins -> 20 sub-bins
01333   // else if( emin<50.0 ) dE = 0.125;  //   2.00 GeV bins -> 16 sub-bins
01334   // else                 dE = 5.000;  // 150.00 GeV bins -> 30 sub-bins
01335 
01336   // size of sub-bin (New)              
01337        if( emin< 5.0 ) dE = 0.005;  //   0.05 GeV bins -> 10 sub-bins
01338   else if( emin<10.0 ) dE = 0.010;  //   0.25 GeV bins -> 25 sub-bins
01339   else if( emin<20.0 ) dE = 0.0125; //   0.25 GeV bins -> 20 sub-bins
01340   else if( emin<30.0 ) dE = 0.050;  //   1.00 GeV bins -> 20 sub-bins
01341   else if( emin<50.0 ) dE = 0.125;  //   2.00 GeV bins -> 16 sub-bins
01342   else                 dE = 5.000;  // 150.00 GeV bins -> 30 sub-bins
01343 
01344   // number of sub-bins
01345   Int_t subBins = (Int_t)((emax-emin)/dE);
01346 
01347   // set lower limit
01348   if( subBins<fMinSubBins ) subBins = fMinSubBins;
01349 
01350   // set upper limit 
01351   if( subBins>fMaxSubBins ) subBins = fMaxSubBins;
01352 
01353   return subBins;
01354 }

Double_t TemplatesForBeamData::GetOscProb ( Flavour_t  flavour,
Charge_t  charge,
Double_t  Enu,
GridPoint gridPoint 
) [private]

Definition at line 1366 of file TemplatesForBeamData.cxx.

References GetOscProb3Flav().

01367 {
01368   // Now always use Oscillation class
01369   // ================================
01370   return GetOscProb3Flav( flavour, charge, Enu, gridPoint );
01371 }

Double_t TemplatesForBeamData::GetOscProb ( Int_t  n,
Flavour_t  flavour,
Charge_t  charge,
Double_t  Enu 
) [private]

Definition at line 1356 of file TemplatesForBeamData.cxx.

References fSingleGridPoint, and Instance().

Referenced by BuildTemplate(), and LoadCachedOscWeights().

01357 { 
01358   GridPoint* thisPoint = TemplateGrid::Instance()->GetGridPoint(n);
01359 
01360   if( n==0 
01361    && fSingleGridPoint ) thisPoint = fSingleGridPoint;
01362 
01363   return this->GetOscProb( flavour, charge, Enu, thisPoint );
01364 }

Double_t TemplatesForBeamData::GetOscProb2Flav ( Flavour_t  flavour,
Charge_t  charge,
Double_t  Enu,
Double_t  dmsq,
Double_t  sinsq = 1.0 
) [private]

Definition at line 1406 of file TemplatesForBeamData.cxx.

References OscFit::kNue, OscFit::kNutau, and OscFit::PropagationDistance().

01407 { 
01408   // Neglect Numu <-> Nue Oscillations
01409   if( flavour==kNue ) return 1.0;
01410 
01411   // Two-Flavour Oscillations
01412   Double_t Lnu = OscFit::PropagationDistance(); // MINOS ND->FD BaseLine: 734.3 km
01413   Double_t pOsc = sinsq*pow(sin(1.267*dmsq*Lnu/Enu),2.0);
01414 
01415   if( flavour==OscFit::kNutau ) return pOsc;  // NuTau Appearance Probability
01416   else return 1.0 - pOsc;                     // NuMu  Survival Probability
01417 } 

Double_t TemplatesForBeamData::GetOscProb3Flav ( Flavour_t  flavour,
Charge_t  charge,
Double_t  Enu,
GridPoint gridPoint 
) [private]

Definition at line 1373 of file TemplatesForBeamData.cxx.

References Instance(), OscFit::kNC, OscFit::kNu, OscFit::kNuBar, OscFit::kNue, OscFit::kNumu, OscFit::kNutau, and OscFit::GridPoint::Oscillations().

Referenced by GetOscProb().

01374 {
01375   // Sanity Check
01376   if( gridPoint==0 ) return 0.0;
01377 
01378   // Neglect Numu <-> Nue Oscillations
01379   if( flavour==OscFit::kNue 
01380    || flavour==OscFit::kNC ) return 1.0;
01381   
01382   // Check for Oscillations
01383   if( gridPoint->Oscillations()==false ){
01384     if( flavour==OscFit::kNutau ) return 0.0;
01385     else                          return 1.0;
01386   } 
01387 
01388   // Three-Flavour Oscillations
01389   Oscillation::Instance()->SetParams( gridPoint );
01390 
01391   // NuMu -> NuMu  Oscillations
01392   if( flavour==OscFit::kNumu ){
01393     if( charge==OscFit::kNu )    return Oscillation::Instance()->OscProb( +14, +14, Enu );
01394     if( charge==OscFit::kNuBar ) return Oscillation::Instance()->OscProb( -14, -14, Enu );
01395   }
01396 
01397   // NuMu -> NuTau Oscillations
01398   if( flavour==OscFit::kNutau ){
01399     if( charge==OscFit::kNu )    return Oscillation::Instance()->OscProb( +14, +16, Enu );
01400     if( charge==OscFit::kNuBar ) return Oscillation::Instance()->OscProb( -14, -16, Enu );
01401   }
01402 
01403   return 0.0;
01404 }

TemplatesForBeamData * TemplatesForBeamData::Instance (  )  [static]
void TemplatesForBeamData::LoadCachedOscWeights ( Sample_t  sample,
Flavour_t  flavour,
Charge_t  charge,
TH2D *  hist 
) [private]

Definition at line 1445 of file TemplatesForBeamData.cxx.

References OscFit::AsString(), CacheID(), fMaxSubBins, fOscillationMap, fSingleGridPoint, fThisFirstPoint, fThisLastPoint, GetCachedOscHist(), GetNumberOfSubBins(), GetOscProb(), Instance(), n, and SetRangeOfGridPoints().

Referenced by BuildTemplate().

01446 {
01447   // Set Range of Grid Points
01448   SetRangeOfGridPoints();
01449 
01450   // Build Multiple Grid Points
01451   Int_t nFirst = fThisFirstPoint;
01452   Int_t nLast  = fThisLastPoint;
01453 
01454   if( this->GetCachedOscHist( nFirst, sample, flavour, charge ) )
01455     return;
01456 
01457   std::cout << "   LoadCachedOscWeights: [" << nFirst << "," << nLast << "][" << OscFit::AsString(sample) << "][" << OscFit::AsString(flavour) << "][" << OscFit::AsString(charge) << "] " << std::endl;
01458 
01459   for( Int_t n=nFirst; n<nLast; n++ ){
01460     GridPoint* thisPoint = TemplateGrid::Instance()->GetGridPoint(n);
01461 
01462     if( n==0 
01463      && fSingleGridPoint ) thisPoint = fSingleGridPoint;
01464 
01465     Int_t id = this->CacheID( n, sample, flavour, charge );
01466 
01467     if( id<0 ) continue;
01468 
01469     TString cachedHistName = "cachedHist";
01470     cachedHistName.Append("_"); cachedHistName+=n;
01471     cachedHistName.Append("_"); cachedHistName+=OscFit::AsString(sample);
01472     cachedHistName.Append("_"); cachedHistName+=OscFit::AsString(flavour);
01473     cachedHistName.Append("_"); cachedHistName+=OscFit::AsString(charge);
01474 
01475     TH2D* cachedHist = new TH2D( cachedHistName.Data(), "", 
01476                                  inputHist->GetXaxis()->GetNbins(), 0.5, inputHist->GetXaxis()->GetNbins()+0.5,
01477                                  fMaxSubBins, 0.5, fMaxSubBins+0.5 );
01478     cachedHist->SetDirectory(0); 
01479                                     
01480     for( Int_t itrue=0; itrue<inputHist->GetXaxis()->GetNbins(); itrue++ ){
01481       Double_t Emin = inputHist->GetXaxis()->GetBinLowEdge( itrue+1 );
01482       Double_t Emax = inputHist->GetXaxis()->GetBinUpEdge( itrue+1 );
01483       Int_t subBins = GetNumberOfSubBins( Emin, Emax );  
01484 
01485       for( Int_t jtrue=0; jtrue<subBins; jtrue++ ){
01486         Double_t Etrue = Emin + ((double)(jtrue+0.5)/(double)(subBins))*(Emax-Emin); 
01487         Double_t Osc   = this->GetOscProb( flavour, charge, Etrue, thisPoint );
01488 
01489         cachedHist->SetBinContent( itrue+1, jtrue+1, Osc );
01490       }
01491     }
01492 
01493     fOscillationMap.insert( std::pair<Int_t,TH2D*>(id,cachedHist) );
01494   }
01495 }

void TemplatesForBeamData::PrintTemplates (  ) 

Definition at line 87 of file TemplatesForBeamData.cxx.

References Instance(), and PrintTemplates().

Referenced by BuildFakeData(), and PrintTemplates().

00088 {
00089   TemplateGrid::Instance()->PrintTemplates();
00090 }

void OscFit::TemplatesForBeamData::RunGridPoint ( Int_t  ipoint  )  [inline]

Definition at line 65 of file TemplatesForBeamData.h.

References RunGridPoints().

Referenced by RunGridPoints().

00065                                      {
00066       RunGridPoints( ipoint, ipoint+1 );
00067     }

void OscFit::TemplatesForBeamData::RunGridPoints ( Int_t  ifirst,
Int_t  ilast 
) [inline]

Definition at line 69 of file TemplatesForBeamData.h.

References fFirstPoint, fLastPoint, and RunGridPoint().

Referenced by RunGridPoint().

00069                                                    {
00070       if( ifirst>=0 && ilast<0 ) return RunGridPoint( ifirst );
00071       fFirstPoint = ifirst;  fLastPoint = ilast;
00072     }

void OscFit::TemplatesForBeamData::SetFileName ( const char *  filename  )  [inline]

Definition at line 102 of file TemplatesForBeamData.h.

References fOutFile.

Referenced by SetOutputFile(), and SetOutputPath().

00102                                             {
00103       fOutFile = filename;
00104     }

void OscFit::TemplatesForBeamData::SetInputDirectoryCC2010 ( const char *  dirname  )  [inline]

Definition at line 86 of file TemplatesForBeamData.h.

References fInputDirectoryCC2010.

00086                                                        {
00087       fInputDirectoryCC2010 = dirname;
00088     }

void OscFit::TemplatesForBeamData::SetInputDirectoryMINOSPlus ( const char *  dirname  )  [inline]

Definition at line 90 of file TemplatesForBeamData.h.

References fInputDirectoryMinosPlus.

00090                                                           {
00091       fInputDirectoryMinosPlus = dirname;
00092     }

void OscFit::TemplatesForBeamData::SetInputFile ( const char *  filename  )  [inline]

Definition at line 82 of file TemplatesForBeamData.h.

References SetInputPath().

00082                                              {
00083       SetInputPath( filename );
00084     }

void OscFit::TemplatesForBeamData::SetInputPath ( const char *  filename  )  [inline]

Definition at line 78 of file TemplatesForBeamData.h.

References fInputPath.

Referenced by SetInputFile().

00078                                              {
00079       fInputPath = filename;
00080     }

void OscFit::TemplatesForBeamData::SetOutputFile ( const char *  filename  )  [inline]

Definition at line 98 of file TemplatesForBeamData.h.

References SetFileName().

00098                                               {
00099       SetFileName( filename );
00100     }

void OscFit::TemplatesForBeamData::SetOutputPath ( const char *  filename  )  [inline]

Definition at line 94 of file TemplatesForBeamData.h.

References SetFileName().

00094                                               {
00095       SetFileName( filename );
00096     }

void TemplatesForBeamData::SetRangeOfGridPoints (  )  [private]

Definition at line 1543 of file TemplatesForBeamData.cxx.

References fFirstPoint, fGridIsLoaded, fLastPoint, fThisFirstPoint, fThisLastPoint, OscFit::TemplateGrid::Instance(), and Instance().

Referenced by BuildTemplate(), BuildTemplates(), and LoadCachedOscWeights().

01544 {
01545   if( fGridIsLoaded ) return;
01546  
01547   fThisFirstPoint = fFirstPoint;
01548   if( fThisFirstPoint<0 ) fThisFirstPoint = 0;
01549 
01550   fThisLastPoint = fLastPoint;
01551   if( fThisLastPoint<0 
01552    || fThisLastPoint>=TemplateGrid::Instance()->GetNumGridPoints() ){
01553     fThisLastPoint = TemplateGrid::Instance()->GetNumGridPoints();
01554   }
01555 
01556   std::cout << " *** TemplatesForBeamData::SetRangeOfGridPoints() *** " << std::endl;
01557   std::cout << "  First: " << fThisFirstPoint << std::endl;
01558   std::cout << "  Last:  " << fThisLastPoint << std::endl;
01559   std::cout << " (Total: " << TemplateGrid::Instance()->GetNumGridPoints() << ")" << std::endl;
01560 
01561   assert( fThisLastPoint>fThisFirstPoint 
01562        && fThisFirstPoint<TemplateGrid::Instance()->GetNumGridPoints() );
01563 
01564   fGridIsLoaded = 1;
01565 }

void OscFit::TemplatesForBeamData::SetScale ( Double_t  scale  )  [inline]

Definition at line 60 of file TemplatesForBeamData.h.

References fScale.

00061     {
00062       fScale = scale;
00063     }

void TemplatesForBeamData::SwitchOffSystematics (  ) 

Definition at line 82 of file TemplatesForBeamData.cxx.

References Instance(), and SwitchOffSystematics().

Referenced by BuildFakeData(), and SwitchOffSystematics().

00083 { 
00084   Configuration::Instance()->SwitchOffSystematics();
00085 }

void TemplatesForBeamData::SwitchOnSystematics (  ) 

Definition at line 77 of file TemplatesForBeamData.cxx.

References Instance(), and SwitchOnSystematics().

Referenced by BuildFakeData(), and SwitchOnSystematics().

00078 { 
00079   Configuration::Instance()->SwitchOnSystematics();
00080 }

void TemplatesForBeamData::UnloadCachedOscWeights (  )  [private]

Definition at line 1497 of file TemplatesForBeamData.cxx.

References fOscillationMap.

Referenced by BuildFakeData().

01498 {
01499   std::cout << " *** TemplatesForBeamData::UnloadCachedOscWeights() *** " << std::endl;
01500 
01501   std::map<Int_t,TH2D*>::iterator myIter = fOscillationMap.begin();
01502 
01503   for( ; myIter!=fOscillationMap.end(); myIter++ ){
01504     TH2D* cachedHist = myIter->second;
01505     if( cachedHist ) delete cachedHist;
01506   }
01507 
01508   fOscillationMap.clear();
01509 
01510   return;
01511 }

void OscFit::TemplatesForBeamData::UseCC2010Templates (  )  [inline]

Definition at line 106 of file TemplatesForBeamData.h.

References fUseCC2010Templates.

00107     {
00108       fUseCC2010Templates = 1;
00109     }

void OscFit::TemplatesForBeamData::UseSingleSubBin ( Bool_t  yesno = 1  )  [inline]

Definition at line 74 of file TemplatesForBeamData.h.

References fUseSingleSubBin.

00074                                             {
00075       fUseSingleSubBin = yesno;
00076     }

void TemplatesForBeamData::WriteTemplates (  ) 

Definition at line 92 of file TemplatesForBeamData.cxx.

References fOutFile, and Instance().

00093 {
00094   std::cout << " *** TemplatesForBeamData::WriteTemplates() *** " << std::endl;
00095   std::cout << "  OutFile = " << fOutFile.Data() << std::endl;
00096 
00097   TemplateIO::Instance()->Write( fOutFile.Data() );
00098 
00099   return;
00100 }


Member Data Documentation

Definition at line 287 of file TemplatesForBeamData.h.

Referenced by GetNumberOfSubBins(), and TemplatesForBeamData().

std::map<Int_t,TH2D*> OscFit::TemplatesForBeamData::fOscillationMap [private]

Definition at line 279 of file TemplatesForBeamData.h.

Referenced by SetFileName(), TemplatesForBeamData(), and WriteTemplates().

Definition at line 303 of file TemplatesForBeamData.h.

Referenced by BuildTemplate(), SetScale(), and TemplatesForBeamData().


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

Generated on 21 Jun 2018 for loon by  doxygen 1.6.1