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

NCExtrapolation Class Reference

Base class for the various extrapolations More...

#include <NCExtrapolation.h>

Inheritance diagram for NCExtrapolation:

NCExtrapolationFarNear NCExtrapolationNone NCExtrapolationPID List of all members.

Public Types

typedef std::map< NCBeam::Info,
double > 
POTMap
typedef std::map< NCBeam::Info,
double > 
ScaleMap

Public Member Functions

 NCExtrapolation ()
 NCExtrapolation (POTMap &dataNear, POTMap &mcNear, POTMap &dataFar, POTMap &mcFar)
virtual ~NCExtrapolation ()
virtual void AddEvent (NCEventInfo eventInfo, bool useMCAsData, NCType::EFileType fileType, NCBeam::Info beamInfo)
virtual void DoneFilling ()
 Called after the final AddEvent() but before any calls to FindSpectraForPars().

virtual void Prepare (const Registry &r)
virtual void WriteResources (const NC::OscProb::OscPars *trueOscPars)
void DrawBestFitSpectra (Detector::Detector_t det)
void DrawBestFitRatios (Detector::Detector_t det)
virtual void CombineRuns (Detector::Detector_t det)
virtual TString GetShortName () const=0
 This is the name used to name things in the output file etc.

virtual TString GetLongName () const=0
 This is the name the extrapolation is known under on plots and such.

virtual void Reset (bool nearData, bool farData, bool nearMC, bool farMC)
 Causes the extrapolation to forget everything it knows about the requested spectra.

NC::Fitter::CoordNDim GetBestFitCoordNDim () const
const NC::CoordinateConverterGetCoordConv () const
NC::OscProb::OscParsGetBestFitOscPars () const
 Get best fit oscillation parameters found by the fitter or set manually.

double FindChiSqrForPars (const NC::OscProb::OscPars *oscPars, const NC::SystPars &systPars)
double ChiSqrAtBestFit () const
 The best $ \chi^2 $ value found by the fitter.

void SetBestFitCoordNDim (const NC::Fitter::CoordNDim minCoord)
 Set fMinCoord and prepare GetBestFitSysts and GetBestFitOscPars.

virtual bool EnableNearToFarExtrapolation (bool)
 Enable or disable corrections to FD spectra based on ND spectra.

virtual std::vector< const
TH1 * > 
GetNearMCSpectra (std::vector< NCBeam::Info >)
void InitializeInterpolator (const NC::OscProb::OscPars *osc)
 Create fInterpolator and initialize it with shifted spectra.


Static Public Member Functions

const RegistryDefaultConfig ()
 Return a default config that will be merged with the NCExtrapolationModule DefaultConfig.


Protected Types

typedef map< pair< NCBeam::Info,
Detector::Detector_t >, NCBeam * > 
fBeams_t

Protected Member Functions

virtual void FindSpectraForPars (const NC::OscProb::OscPars *oscPars, const NC::SystPars &systPars, std::vector< NCBeam::Info > beamsToUse, std::vector< TH1 * > &exps, std::vector< TH1 * > &obss)=0
 Override this in the derived class.

virtual void CleanupSpectra (std::vector< TH1 * > exps, std::vector< TH1 * > obss)
 Called after FindSpectraForPars() to delete necessary spectra.

NC::SystPars GetBestFitSysts () const
 Get best fit systematics found by the fitter or set manually.

void SetBestFitSysts (NC::SystPars systs)
 Warning - doesn't affect fMinCoord.

void SetBestFitOscPars (NC::OscProb::OscPars *pars)
 Warning - doesn't affect fMinCoord.

NCBeamGetBeam (Detector::Detector_t det, NCBeam::Info beamInfo, bool add=false, double dataPOT=-1, double mcPOT=-1)
void FillResultHistograms (NCBeam *beam)
double LogLikelihood (const std::vector< TH1 * > &exp, const std::vector< TH1 * > &obs) const
 The log-likelihood formula from the PDG.

double CalculateBestNormalization (double M, double D) const
 Analytically calculate the best normalization.

void GetPOTForBeam (NCBeam::Info info, Detector::Detector_t det, double &dataPOT, double &mcPOT)
 Look up the data and MC POT counts for beam info.


Protected Attributes

fBeams_t fBeams
vector< bool > fSystematicsToUse
vector< double > fSystematicsAdjust
POTMap fDataPOTNear
 scale factors for scaling MC to same exposure as data

POTMap fMCPOTNear
 scale factors for scaling MC to same exposure as data

POTMap fDataPOTFar
 scale factors for scaling MC to same exposure as data

POTMap fMCPOTFar
 scale factors for scaling MC to same exposure as data

bool fUseCC
bool fUseNC
bool fHideFDData
 Preserve blinding by not showing FD data in plots.

NCType::EOscModel fOscillationModel
int fSys
int fSystShift
int fDoSystStudy
int fExtractionType
TString fSystFileName
bool fSoftPenalty
double fEnergyThreshold
 Don't accept any events below this energy.

NC::CoordinateConverter fCoordConv
bool fDoSystematicInterpolation
NC::SpectrumInterpolatorfInterpolator
bool fUseSystPenalty

Private Attributes

double fMinChiSqr
bool fPrintFDEvents
 Whether to print all FD data events.

NC::Fitter::CoordNDim fMinCoord
 This is the best fit point as found by the fitter.

NC::SystPars fBestFitSysts
NC::OscProb::OscParsfBestFitOscPars
std::map< const NC::OscProb::OscPars *,
NC::SpectrumInterpolator *,
InterpCacheCompare
fInterpCache

Detailed Description

Base class for the various extrapolations

Definition at line 41 of file NCExtrapolation.h.


Member Typedef Documentation

typedef map<pair<NCBeam::Info, Detector::Detector_t>, NCBeam*> NCExtrapolation::fBeams_t [protected]
 

vector of objects describing each beam, ie LE-10 185 ND, LE-10 185 FD, pME ND, pHE ND, etc

Definition at line 191 of file NCExtrapolation.h.

typedef std::map<NCBeam::Info, double> NCExtrapolation::POTMap
 

Definition at line 48 of file NCExtrapolation.h.

Referenced by NCExtrapolation().

typedef std::map<NCBeam::Info, double> NCExtrapolation::ScaleMap
 

Definition at line 49 of file NCExtrapolation.h.


Constructor & Destructor Documentation

NCExtrapolation::NCExtrapolation  ) 
 

NCExtrapolation::NCExtrapolation POTMap dataNear,
POTMap mcNear,
POTMap dataFar,
POTMap mcFar
 

Definition at line 48 of file NCExtrapolation.cxx.

References fDataPOTFar, fDataPOTNear, fMCPOTFar, fMCPOTNear, fSystematicsAdjust, fSystematicsToUse, MSG, and POTMap.

00049                                                                  :
00050   fDataPOTNear(dataNear),
00051   fMCPOTNear(mcNear),
00052   fDataPOTFar(dataFar),
00053   fMCPOTFar(mcFar),
00054   fEnergyThreshold(0),
00055   fInterpolator(0),
00056   fUseSystPenalty(true),
00057   fBestFitOscPars(0)
00058 {
00059   for(int i = 0; i < NCType::kNumParameters; ++i){
00060     fSystematicsToUse.push_back(false);
00061     fSystematicsAdjust.push_back(NCType::kParams[i].defaultVal);
00062   }
00063 
00064   for(POTMap::const_iterator i = fDataPOTNear.begin();
00065       i != fDataPOTNear.end(); ++i){
00066     MSG("NCExtrapolation", Msg::kInfo)
00067       << "fDataPOTNear for " << i->first.GetDescription()
00068       << " = " << i->second << endl;
00069   }
00070 
00071   for(POTMap::const_iterator i = fMCPOTNear.begin();
00072       i != fMCPOTNear.end(); ++i){
00073     MSG("NCExtrapolation", Msg::kInfo)
00074       << "fMCPOTNear for " << i->first.GetDescription()
00075       << " = " << i->second << endl;
00076   }
00077 
00078   for(POTMap::const_iterator i = fDataPOTFar.begin();
00079       i != fDataPOTFar.end(); ++i){
00080     MSG("NCExtrapolation", Msg::kInfo)
00081       << "fDataPOTFar for " << i->first.GetDescription()
00082       << " = " << i->second << endl;
00083   }
00084 
00085   for(POTMap::const_iterator i = fMCPOTFar.begin();
00086       i != fMCPOTFar.end(); ++i){
00087     MSG("NCExtrapolation", Msg::kInfo)
00088       << "fMCPOTFar for " << i->first.GetDescription()
00089       << " = " << i->second << endl;
00090   } // end for i
00091 }

NCExtrapolation::~NCExtrapolation  )  [virtual]
 

Definition at line 94 of file NCExtrapolation.cxx.

References fBeams, fBestFitOscPars, and fInterpolator.

00095 {
00096   if(fBestFitOscPars) delete fBestFitOscPars;
00097 
00098   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it)
00099     delete it->second;
00100 
00101   if(fInterpolator) delete fInterpolator;
00102 }


Member Function Documentation

void NCExtrapolation::AddEvent NCEventInfo  eventInfo,
bool  useMCAsData,
NCType::EFileType  fileType,
NCBeam::Info  beamInfo
[virtual]
 

Reimplemented in NCExtrapolationNone, and NCExtrapolationPID.

Definition at line 221 of file NCExtrapolation.cxx.

References NCBeam::AddEvent(), NCEventInfo::analysis, NCEventInfo::beam, ANtpHeaderInfo::dataType, ANtpHeaderInfo::detector, Detector::Detector_t, fEnergyThreshold, fPrintFDEvents, GetBeam(), GetPOTForBeam(), NCEventInfo::header, ANtpRecoInfo::inFiducialVolume, ANtpAnalysisInfo::isCC, ANtpRecoInfo::isCleanHighMultSnarl, ANtpAnalysisInfo::isNC, ANtpHeaderInfo::month, MSG, ANtpRecoInfo::nuEnergy, NCEventInfo::reco, ANtpHeaderInfo::run, run(), ANtpHeaderInfo::snarl, ANtpHeaderInfo::subRun, NCEventInfo::truth, and ANtpHeaderInfo::year.

Referenced by NCExtrapolationPID::AddEvent(), and NCExtrapolationNone::AddEvent().

00225 {
00226   //method to add events to near detector beams.  all methods should see
00227   //the same near detector spectra, so there is no loss of generalization.
00228 
00229   //dont bother with events outside the fiducial volume
00230   if(info.reco->inFiducialVolume < 1 ||
00231      (info.header->detector == int(Detector::kNear) &&
00232       info.reco->isCleanHighMultSnarl < 1)
00233      )
00234      return;
00235 
00236 
00237   if(info.reco->nuEnergy < fEnergyThreshold) return;
00238 
00239 
00240   //need to check if this type of beam already exists in the vector.
00241   //if so add the event to that beam. if not, make it the beam then
00242   //the add event to it
00243   Detector::Detector_t detector = Detector::Detector_t(info.header->detector);
00244 
00245   double dataPOT, mcPOT;
00246   GetPOTForBeam(beamInfo, detector, dataPOT, mcPOT);
00247 
00248   NCBeam* beam = GetBeam(detector, beamInfo, true, dataPOT, mcPOT);
00249 
00250   beam->AddEvent(info.header, info.beam, info.reco,
00251                  info.analysis, info.truth, useMCAsData, fileType);
00252 
00253   // TODO - I don't know what this was achieving, but whatever it was it isn't anymore
00254   /*
00255   //if this is MC and not useMCAsData, look to see if there are
00256   //other run types for the same beam.  default run type for MC is
00257   //NCType::kRunI
00258   if(info.header->dataType == int(SimFlag::kMC) && !useMCAsData){
00259     for(int i = NCType::kRunII; i < NCType::kMaxRun+1; ++i){
00260       beam = FindBeamIndex(detector, beamType, NCType::ERunType(i));
00261       if(beam < 100)
00262         fBeams[beam]->AddEvent(info.header, info.beam, info.reco,
00263                               info.analysis, info.truth, useMCAsData, fileType);
00264     }//end loop over possible runs
00265   }//end if mc and needs to be added to other runs for this beam
00266   */
00267 
00268   //print out the far detector events if requested
00269   if(fPrintFDEvents && detector == Detector::kFar && 
00270      info.header->dataType == int(SimFlag::kData)){
00271     TString stream = "DataEventListNC";
00272     TString date = TString::Format("%d-0%d ", info.header->year, info.header->month);
00273     if(info.header->month > 9)
00274       date = TString::Format("%d-%d ", info.header->year, info.header->month);
00275 
00276     TString run = TString::Format("F000%d", info.header->run, info.header->subRun);
00277 
00278     if(info.analysis->isNC < 1 && info.analysis->isCC > 0) stream = "DataEventListCC";
00279 
00280       MSG(stream, Msg::kInfo)
00281         << date
00282         << run << " " << info.header->subRun
00283         << " " << info.header->snarl
00284         << " " << info.reco->nuEnergy
00285         << " " << info.analysis->isCC
00286         << " " << info.analysis->isNC << endl;
00287 
00288       MSG("DataEventListAll", Msg::kInfo)
00289         << date
00290         << run << " " << info.header->subRun
00291         << " " << info.header->snarl
00292         << " " << info.reco->nuEnergy
00293         << " " << info.analysis->isCC
00294         << " " << info.analysis->isNC << endl;
00295 
00296   }
00297 }

double NCExtrapolation::CalculateBestNormalization double  M,
double  D
const [protected]
 

Analytically calculate the best normalization.

Parameters:
M Total number of events in oscillated, shifted Monte Carlo
D Total number of events in data
Returns:
The normalization s that minimizes $ \Delta\chi^2 $ for the log likelihood formula plus quadratic penalty for s
See docdb-4628/normcalcwriteup.pdf for derivation

See also:
LogLikelihood

Definition at line 770 of file NCExtrapolation.cxx.

References NCType::kNormalization, and SQR().

00771 {
00772   const double sigmaSqr = SQR(NCType::kParams[kNormalization].sigma);
00773 
00774   const double x = (1-sigmaSqr*M)/2;
00775 
00776   return x + sqrt(SQR(x)+D*sigmaSqr);
00777 }

double NCExtrapolation::ChiSqrAtBestFit  )  const [inline]
 

The best $ \chi^2 $ value found by the fitter.

If this function is called before a fit has been performed the result will be garbage

Definition at line 124 of file NCExtrapolation.h.

References fMinChiSqr.

00124 {return fMinChiSqr;}

void NCExtrapolation::CleanupSpectra std::vector< TH1 * >  exps,
std::vector< TH1 * >  obss
[protected, virtual]
 

Called after FindSpectraForPars() to delete necessary spectra.

Parameters:
exps The expected spectra just returned from FindSpectraForPars()
obss The observed spectra just returned from FindSpectraForPars()

Reimplemented in NCExtrapolationFarNear, NCExtrapolationNone, and NCExtrapolationPID.

Definition at line 723 of file NCExtrapolation.cxx.

Referenced by FindChiSqrForPars().

00725 {
00726   // Do nothing. This is for derived classes to, optionally, override
00727 }

void NCExtrapolation::CombineRuns Detector::Detector_t  det  )  [virtual]
 

Definition at line 640 of file NCExtrapolation.cxx.

References NCBeam::Add(), Detector::Detector_t, fBeams, GetBeam(), NCBeam::GetBeamType(), NCBeam::GetDetector(), NCBeam::GetInfo(), and NCBeam::GetRunType().

00641 {
00642   // For every beam that is in the right detector, lookup the corresponding
00643   // RunAll beam, and add the contents in. GetBeam is magic, and creates
00644   // a new beam if none exists with the requested specification.
00645   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00646     NCBeam* beam = it->second;
00647     if(beam->GetDetector() == det){
00648       // This could happen if this function were called twice for the same
00649       // detector - and it would screw everything up
00650       assert(beam->GetRunType() != NCType::kRunAll);
00651 
00652       // We don't want  to include shifted beams here
00653       if(!beam->GetInfo().IsNominal()) continue;
00654 
00655       NCBeam::Info info(beam->GetBeamType(), NCType::kRunAll);
00656       NCBeam* beam_all = GetBeam(det, info, true, 0, 0);
00657 
00658       beam_all->Add(*beam);
00659     }
00660   }
00661 }

const Registry & NCExtrapolation::DefaultConfig  )  [static]
 

Return a default config that will be merged with the NCExtrapolationModule DefaultConfig.

Reimplemented in NCExtrapolationFarNear, NCExtrapolationNone, and NCExtrapolationPID.

Definition at line 105 of file NCExtrapolation.cxx.

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

00106 {
00107   static Registry r;
00108 
00109   r.UnLockValues();
00110 
00111   r.Set("EnergyThreshold",           0);
00112 
00113   r.Set("UseCCEvents",               true);
00114   r.Set("UseNCEvents",               true);
00115   r.Set("Prediction",                false);
00116   r.Set("PredictionWriteData",       false);
00117 
00118   r.Set("PrintFDEvents",             false);
00119   r.Set("HideFDData",                false);
00120 
00121   r.Set("DoSystematicInterpolation", false);
00122   r.Set("DisableSystPenalty",        false);
00123 
00124   r.LockValues();
00125   return r;
00126 }

virtual void NCExtrapolation::DoneFilling  )  [inline, virtual]
 

Called after the final AddEvent() but before any calls to FindSpectraForPars().

Reimplemented in NCExtrapolationPID.

Definition at line 63 of file NCExtrapolation.h.

00063 {}

void NCExtrapolation::DrawBestFitRatios Detector::Detector_t  det  ) 
 

!! mc_hist->Add(beam->GetMCFitNuEToNuEHistogram(i));

Definition at line 409 of file NCExtrapolation.cxx.

References Detector::AsString(), Detector::Detector_t, NCType::EEventType, fBeams, fHideFDData, NCBeam::GetDataGraph(), NCBeam::GetDetector(), NCBeam::GetInfo(), NCBeam::GetMCFitHistogram(), NCBeam::GetMCHistogram(), and GetShortName().

Referenced by WriteResources().

00410 {
00411   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00412     NCBeam* beam = it->second;
00413     if(beam->GetDetector() != det) continue;
00414 
00415     TString name = "bestFitRatiosCanv"+GetShortName();
00416     name += Detector::AsString(det);
00417     name += beam->GetInfo().GetDescription();
00418     TCanvas *canv = new TCanvas(name, name, 150, 10, 1200, 300);
00419     TPad *pad1 = new TPad(name+"pad1", "", 0.00, 0.0, 0.50, 1.0, 10);
00420     TPad *pad2 = new TPad(name+"pad2", "", 0.50, 0.0, 1.00, 1.0, 10);
00421     pad1->Draw();
00422     pad2->Draw();
00423     pad1->cd();
00424 
00425     for(NCType::EEventType i = NCType::kNC;
00426         i <= NCType::kCC;
00427         i = NCType::EEventType(int(i)+1)){
00428       if(i == NCType::kCC) pad2->cd();
00429 
00430       TString title = Detector::AsString(det);
00431       if(i == NCType::kNC)
00432         title += " Detector Neutral Current Selected";
00433       else
00434         title += " Detector Charged Current Selected";
00435 
00436       TH1* mc_ratio = (TH1*)beam->GetMCFitHistogram(i)->Clone();
00437       TH1* mc_hist = (TH1*)beam->GetMCHistogram(i)->Clone();
00439       mc_ratio->Divide(mc_hist);
00440 
00441       mc_ratio->SetTitle(title);
00442       mc_ratio->GetYaxis()->SetRangeUser(0, 1.5);
00443       mc_ratio->GetYaxis()->SetTitle("Ratio to no oscillations");
00444       mc_ratio->Draw("][");
00445 
00446       // This option plots only the ND data when making a prediction.
00447       // This effectively preserves blinding while being able to make
00448       // a FD prediction using the actual data.
00449 
00450       TGraphAsymmErrors* data_ratio = 0;
00451 
00452       if(!fHideFDData || beam->GetDetector() != Detector::kFar){
00453         data_ratio = (TGraphAsymmErrors*)beam->GetDataGraph(i)->Clone();
00454 
00455         for(int n = 0; n < data_ratio->GetN(); ++n){
00456           double x, y;
00457           data_ratio->GetPoint(n, x, y);
00458           double hi = y+data_ratio->GetErrorYhigh(n);
00459           double lo = y-data_ratio->GetErrorYlow(n);
00460           double div = mc_hist->GetBinContent(mc_hist->FindBin(x));
00461           if(div == 0){ // Don't want to see this point...
00462             div = 1;
00463             x = -1;
00464           }
00465           y /= div; hi /= div; lo /= div;
00466           data_ratio->SetPoint(n, x, y);
00467           data_ratio->SetPointEYhigh(n, hi-y);
00468           data_ratio->SetPointEYlow(n, y-lo);
00469         }
00470 
00471         data_ratio->Draw("pe1same");
00472       }
00473 
00474       TLine* one = new TLine(0, 1, mc_ratio->GetXaxis()->GetXmax(), 1);
00475       one->SetLineStyle(7); // medium dashed
00476       one->Draw("same");
00477 
00478 
00479       TLegend* leg = new TLegend(0.45, 0.35, 0.85, 0.15);
00480       leg->SetBorderSize(0);
00481       if(data_ratio) leg->AddEntry(data_ratio, "Data", "l");
00482       leg->AddEntry(mc_ratio, "Best Fit", "l");
00483 
00484       leg->Draw();
00485 
00486     }//end loop over NC/CC
00487 
00488     canv->Update();
00489 
00490     // Append the canvas object to the current directory
00491     // otherwise it can't be found and saved later
00492     gDirectory->Append(canv);
00493 
00494   }//end loop over beams
00495 }

void NCExtrapolation::DrawBestFitSpectra Detector::Detector_t  det  ) 
 

Loop over all the beams. Draw pairs of plots for each beam in the chosen detector - NC and CC

Definition at line 301 of file NCExtrapolation.cxx.

References Detector::AsString(), Detector::Detector_t, NCType::EEventType, fBeams, fHideFDData, NCBeam::GetDataGraph(), NCBeam::GetDetector(), NCBeam::GetInfo(), NCBeam::GetMCBackgroundHistogram(), NCBeam::GetMCFitHistogram(), NCBeam::GetMCFitNuEToNuEHistogram(), NCBeam::GetMCFitNuMuToNuEHistogram(), NCBeam::GetMCFitNuMuToNuTauHistogram(), NCBeam::GetMCHistogram(), NCBeam::GetMCNoFitBackgroundHistogram(), NCBeam::GetMCNoFitNuEToNuEHistogram(), and GetShortName().

Referenced by WriteResources().

00302 {
00303   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00304     NCBeam* beam = it->second;
00305     if(beam->GetDetector() != det) continue;
00306 
00307     TString name = "bestFitSpectraCanv"+GetShortName();
00308     name += Detector::AsString(det);
00309     name += beam->GetInfo().GetDescription();
00310     TCanvas *canv = new TCanvas(name, name, 150, 10, 1200, 300);
00311     TPad *pad1 = new TPad(name+"pad1", "", 0.00, 0.0, 0.50, 1.0, 10);
00312     TPad *pad2 = new TPad(name+"pad2", "", 0.50, 0.0, 1.00, 1.0, 10);
00313     pad1->Draw();
00314     pad2->Draw();
00315     pad1->cd();
00316 
00317     /*
00318     TString bestDeltaM;
00319     bestDeltaM.Format("#Deltam^{2} = %5.4f", BestDeltaMSqr());
00320     TString bestUMu3Sqr;
00321     bestUMu3Sqr.Format("sin^{2}(2#theta) = %3.2f", BestUMu3Sqr());
00322     TString bestUS3Sqr;
00323     bestUS3Sqr.Format("f_{s} = %3.2f", BestUS3Sqr());
00324     TString minChiSqr;
00325     minChiSqr.Format("#chi^{2} = %3.2f", fMinChiSqr);
00326     */
00327 
00328     for(NCType::EEventType i = NCType::kNC;
00329         i <= NCType::kCC;
00330         i = NCType::EEventType(int(i)+1)){
00331       if(i == NCType::kCC) pad2->cd();
00332 
00333       double maxY = 1.3*TMath::Max(beam->GetMCHistogram(i)->GetMaximum(),
00334                                    beam->GetDataGraph(i)->GetHistogram()->GetMaximum());
00335 
00336       beam->GetMCHistogram(i)->SetMaximum(maxY);
00337       TString title = Detector::AsString(det);
00338       if(i == NCType::kNC)
00339         title += " Detector Neutral Current Selected";
00340       else
00341         title += " Detector Charged Current Selected";
00342       beam->GetMCHistogram(i)->SetTitle(title);
00343       beam->GetMCHistogram(i)->Draw();
00344       //if the fit histogram was filled, draw the fits
00345       if(beam->GetMCFitHistogram(i)->Integral() > 0.){
00346         beam->GetMCFitHistogram(i)->Draw("same");
00347         beam->GetMCBackgroundHistogram(i)->Draw("same");
00348         beam->GetMCFitNuMuToNuTauHistogram(i)->Draw("same");
00349         beam->GetMCFitNuEToNuEHistogram(i)->Draw("same");
00350         beam->GetMCFitNuMuToNuEHistogram(i)->Draw("same");
00351       }
00352       else{
00353         //no fit, no point drawing NuMuToNuTau or NuMuToNuE
00354         beam->GetMCNoFitBackgroundHistogram(i)->Draw("same");
00355         beam->GetMCNoFitNuEToNuEHistogram(i)->Draw("same");
00356       }
00357 
00358       // This option plots only the ND data when making a prediction.
00359       // This effectively preserves blinding while being able to make
00360       // a FD prediction using the actual data.
00361 
00362       if(!fHideFDData || beam->GetDetector() != Detector::kFar){
00363         beam->GetDataGraph(i)->Draw("pe1same");
00364       }
00365 
00366       TLegend *leg = new TLegend(0.45, 0.65, 0.85, 0.85);
00367       leg->SetBorderSize(0);
00368       leg->AddEntry(beam->GetDataGraph(i), "Data", "lep");
00369       leg->AddEntry(beam->GetMCHistogram(i),
00370                     "Monte Carlo (Nominal)", "l");
00371       if(beam->GetMCFitHistogram(i)->Integral() > 0.){
00372         leg->AddEntry(beam->GetMCFitHistogram(i),
00373                       "Monte Carlo (Best Fit)", "l");
00374         leg->AddEntry(beam->GetMCBackgroundHistogram(i),
00375                       "Background", "bf");
00376         leg->AddEntry(beam->GetMCFitNuMuToNuTauHistogram(i),
00377                       "Background - #nu_{#tau} CC", "bf");
00378         leg->AddEntry(beam->GetMCFitNuEToNuEHistogram(i),
00379                       "Background - Beam #nu_{e} CC", "bf");
00380         leg->AddEntry(beam->GetMCFitNuMuToNuEHistogram(i),
00381                       "Background - #nu_{e} CC", "bf");
00382       }
00383       else{
00384         leg->AddEntry(beam->GetMCNoFitBackgroundHistogram(i),
00385                       "Background", "bf");
00386         leg->AddEntry(beam->GetMCNoFitNuEToNuEHistogram(i),
00387                       "Background - Beam #nu_{e} CC", "bf");
00388       }
00389 //       leg->AddEntry(beam->GetDataGraph(i), bestDeltaM, "");
00390 //       leg->AddEntry(beam->GetDataGraph(i), bestUS3Sqr, "");
00391 //       leg->AddEntry(beam->GetDataGraph(i), bestUMu3Sqr, "");
00392 //       leg->AddEntry(beam->GetDataGraph(i), minChiSqr, "");
00393       leg->Draw();
00394 
00395     }//end loop over NC/CC
00396 
00397 
00398     canv->Update();
00399 
00400     // Append the canvas object to the current directory
00401     // otherwise it can't be found and saved later
00402     gDirectory->Append(canv);
00403 
00404   }//end loop over beams
00405 }

virtual bool NCExtrapolation::EnableNearToFarExtrapolation bool   )  [inline, virtual]
 

Enable or disable corrections to FD spectra based on ND spectra.

enable true to perform extrapolation. false to give produce unextrapolated spectra

Returns:
The previous value of this setting
The default value of this setting should be to true

Reimplemented in NCExtrapolationFarNear, and NCExtrapolationPID.

Definition at line 136 of file NCExtrapolation.h.

Referenced by InitializeInterpolator().

00137   {
00138     assert(0 && "EnableNearToFarExtrapolation needs to be overridden");
00139   }

void NCExtrapolation::FillResultHistograms NCBeam beam  )  [protected]
 

Definition at line 630 of file NCExtrapolation.cxx.

References NCBeam::FillResultHistograms(), GetBestFitOscPars(), and GetBestFitSysts().

Referenced by NCExtrapolationFarNear::WriteResources(), and WriteResources().

00631 {
00632   NC::OscProb::OscPars* oscPars = GetBestFitOscPars();
00633   if(!oscPars) return;
00634   const NC::SystPars systPars = GetBestFitSysts();
00635   beam->FillResultHistograms(oscPars, &systPars);
00636 }

double NCExtrapolation::FindChiSqrForPars const NC::OscProb::OscPars oscPars,
const NC::SystPars systPars
 

Definition at line 665 of file NCExtrapolation.cxx.

References CleanupSpectra(), fBeams, FindSpectraForPars(), fUseSystPenalty, NCBeam::GetDetector(), NCBeam::GetInfo(), NCBeam::GetRunType(), LogLikelihood(), and NC::SystPars::PenaltyForShifts().

Referenced by NCExtrapolationModule::DoMockExperiments(), and NC::GetChiSqrFromDerived::EvalAtEx().

00667 {
00668   std::vector<TH1*> exps;
00669   std::vector<TH1*> obss;
00670 
00671   // For the moment just use all the beams
00672   std::vector<NCBeam::Info> beamsToUse;
00673   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00674     NCBeam* beam = it->second;
00675     // Only want to ask for each physical beam once (arbitrarily FD)
00676     // Don't take the overall combined "kRunAll" beam
00677     if(beam->GetDetector() == Detector::kFar &&
00678        beam->GetRunType() != NCType::kRunAll &&
00679        beam->GetInfo().IsNominal())
00680       beamsToUse.push_back(beam->GetInfo());
00681   }
00682 
00683   FindSpectraForPars(oscPars, systPars, beamsToUse, exps, obss);
00684 
00685   const double ret = LogLikelihood(exps, obss)+
00686     (fUseSystPenalty ? systPars.PenaltyForShifts() : 0);
00687 
00688   CleanupSpectra(exps, obss);
00689 
00690   return ret;
00691 }

virtual void NCExtrapolation::FindSpectraForPars const NC::OscProb::OscPars oscPars,
const NC::SystPars systPars,
std::vector< NCBeam::Info beamsToUse,
std::vector< TH1 * > &  exps,
std::vector< TH1 * > &  obss
[protected, pure virtual]
 

Override this in the derived class.

Parameters:
oscPars Oscillation parameters
systPars Systematic shifts
beamsToUse Only fill exps and obss with spectra from beams with these indices
out] exps To be filled with expected spectra
out] obss To be filled with the corresponding observed spectra

Implemented in NCExtrapolationFarNear, NCExtrapolationNone, and NCExtrapolationPID.

Referenced by FindChiSqrForPars(), and InitializeInterpolator().

NCBeam * NCExtrapolation::GetBeam Detector::Detector_t  det,
NCBeam::Info  beamInfo,
bool  add = false,
double  dataPOT = -1,
double  mcPOT = -1
[protected]
 

Definition at line 601 of file NCExtrapolation.cxx.

References Detector::AsString(), Detector::Detector_t, fBeams, fUseCC, fUseNC, NCBeam::Info::GetDescription(), and MSG.

Referenced by AddEvent(), CombineRuns(), NCExtrapolationNone::FindSpectraForPars(), NCExtrapolationFarNear::FindSpectraForPars(), NCExtrapolationFarNear::GetNearMCSpectra(), and NCExtrapolationFarNear::WriteResources().

00606 {
00607   pair<NCBeam::Info, Detector::Detector_t> key(beamInfo, det);
00608   fBeams_t::iterator it = fBeams.find(key);
00609   if(it != fBeams.end()) return it->second;
00610 
00611   if(!add) return 0;
00612 
00613   NCBeam* beam = new NCBeam(det, beamInfo, dataPOT, mcPOT, fUseCC, fUseNC);
00614   fBeams[key] = beam;
00615 
00616   MSG("NCExtrapolation", Msg::kInfo) << "adding new beam "
00617                                      << beamInfo.GetDescription()
00618                                      << " to "
00619                                      << Detector::AsString(det)
00620                                      << " data pot = " << dataPOT
00621                                      << " mc pot = " << mcPOT << endl;
00622 
00623   return beam;
00624 }

NC::Fitter::CoordNDim NCExtrapolation::GetBestFitCoordNDim  )  const [inline]
 

Definition at line 99 of file NCExtrapolation.h.

References NC::Fitter::CoordNDim, and fMinCoord.

00099 {return fMinCoord;}

NC::OscProb::OscPars* NCExtrapolation::GetBestFitOscPars  )  const [inline]
 

Get best fit oscillation parameters found by the fitter or set manually.

Once MakeDeltaChiSqrMaps has found the minimum, or after SetBestFitCoordNDim or SetBestFitOscPars have been called returns the oscillation parameters component of the best fit point.

Before then it will return a null pointer.

Definition at line 112 of file NCExtrapolation.h.

References fCoordConv, fMinCoord, and NC::CoordinateConverter::OscParsFromCoordNDim().

Referenced by FillResultHistograms(), NCExtrapolationPID::WriteResources(), and NCExtrapolationFarNear::WriteResources().

00113   {
00114     return fCoordConv.OscParsFromCoordNDim(fMinCoord);
00115   }

NC::SystPars NCExtrapolation::GetBestFitSysts  )  const [inline, protected]
 

Get best fit systematics found by the fitter or set manually.

Once MakeDeltaChiSqrMaps has found the minimum, or after SetBestFitCoordNDim or SetBestFitSysts have been called returns the systematic component of the best fit point.

Before then it will return unshifted systematics.

Definition at line 181 of file NCExtrapolation.h.

References fCoordConv, fMinCoord, and NC::CoordinateConverter::SystParsFromCoordNDim().

Referenced by FillResultHistograms(), NCExtrapolationPID::WriteResources(), and NCExtrapolationFarNear::WriteResources().

00181 {return fCoordConv.SystParsFromCoordNDim(fMinCoord);}

const NC::CoordinateConverter* NCExtrapolation::GetCoordConv  )  const [inline]
 

Definition at line 101 of file NCExtrapolation.h.

References fCoordConv.

Referenced by NC::GetChiSqrFromDerived::EvalAtEx().

00101 {return &fCoordConv;}

virtual TString NCExtrapolation::GetLongName  )  const [pure virtual]
 

This is the name the extrapolation is known under on plots and such.

Implemented in NCExtrapolationFarNear, NCExtrapolationNone, and NCExtrapolationPID.

virtual std::vector<const TH1*> NCExtrapolation::GetNearMCSpectra std::vector< NCBeam::Info  )  [inline, virtual]
 

Reimplemented in NCExtrapolationFarNear, and NCExtrapolationPID.

Definition at line 142 of file NCExtrapolation.h.

Referenced by InitializeInterpolator().

00143   {
00144     assert(0 && "GetNearMCSpectra needs to be overridden");
00145   }

void NCExtrapolation::GetPOTForBeam NCBeam::Info  info,
Detector::Detector_t  det,
double &  dataPOT,
double &  mcPOT
[protected]
 

Look up the data and MC POT counts for beam info.

If no matching information is found for both the data and MC then try again with the systematic shifts removed from the beam (we assume shifted beams have the same POT as the nominal). If still fail then the POTs will be zero.

Definition at line 781 of file NCExtrapolation.cxx.

References Detector::Detector_t, fDataPOTFar, fDataPOTNear, fMCPOTFar, fMCPOTNear, and NCBeam::Info::SetSystShifts().

Referenced by AddEvent(), and NCExtrapolationPID::GetMCScaleFactor().

00785 {
00786   bool adj[NCType::kNumSystematicParameters] = {false,};
00787   double vals[NCType::kNumSystematicParameters] = {0};
00788 
00789   if(det == Detector::kNear){
00790     bool found = fDataPOTNear.find(info) != fDataPOTNear.end();
00791     found = found && fMCPOTNear.find(info) != fMCPOTNear.end();
00792 
00793     if(!found) info.SetSystShifts(adj, vals);
00794 
00795     dataPOT = fDataPOTNear[info];
00796     mcPOT = fMCPOTNear[info];
00797     return;
00798   }
00799   if(det == Detector::kFar){
00800     bool found = fDataPOTFar.find(info) != fDataPOTFar.end();
00801     found = found && fMCPOTFar.find(info) != fMCPOTFar.end();
00802 
00803     if(!found) info.SetSystShifts(adj, vals);
00804 
00805     dataPOT = fDataPOTFar[info];
00806     mcPOT = fMCPOTFar[info];
00807     return;
00808   }
00809   assert(0 && "This should never happen");
00810 }

virtual TString NCExtrapolation::GetShortName  )  const [pure virtual]
 

This is the name used to name things in the output file etc.

Implemented in NCExtrapolationFarNear, NCExtrapolationNone, and NCExtrapolationPID.

Referenced by DrawBestFitRatios(), DrawBestFitSpectra(), NC::FitMaster::WriteResources(), and WriteResources().

void NCExtrapolation::InitializeInterpolator const NC::OscProb::OscPars osc  ) 
 

Create fInterpolator and initialize it with shifted spectra.

Definition at line 814 of file NCExtrapolation.cxx.

References NC::SpectrumInterpolator::DivideFast(), EnableNearToFarExtrapolation(), fBeams, fDoSystematicInterpolation, FindSpectraForPars(), fInterpCache, fInterpolator, NCBeam::Info::GetDescription(), NCBeam::GetDetector(), NCBeam::GetInfo(), GetNearMCSpectra(), NCBeam::GetRunType(), and NCBeam::Info::IsShifted().

Referenced by NCExtrapolationPID::FindSpectraForPars(), and NCExtrapolationFarNear::FindSpectraForPars().

00815 {
00816   assert(fDoSystematicInterpolation);
00817 
00818   // Ignore calls that come as a result of running this function
00819   static bool already = false;
00820   if(already) return;
00821   already = true;
00822 
00823 
00824   if(fInterpCache.find(osc) != fInterpCache.end()){
00825     fInterpolator = fInterpCache[osc];
00826     already = false;
00827     if(fInterpCache.size() > 100) fInterpCache.clear();
00828     return;
00829   }
00830 
00831 
00832   // Because profiling reveals we spend all our time in ~TH1 removing ourselves
00833   // from the current directory. We restore this at the end of the function,
00834   // need to remember not to take any early returns
00835   const bool addDirectoryRestore = TH1::AddDirectoryStatus();
00836   TH1::AddDirectory(false);
00837 
00838   // Disable extrapolation so that we get independently shifted spectrum in FD
00839   const bool farNearRestore = EnableNearToFarExtrapolation(false);
00840 
00841   // Hardcode to this single beam - TODO fix
00842   vector<NCBeam::Info> beamsToUseNom;
00843   beamsToUseNom.push_back(NCBeam::Info(BeamType::kL010z185i, NCType::kRunI));
00844 
00845   vector<TH1*> junk;    // We don't need to data spectra
00846   vector<TH1*> tmp_nom; // Need to do this to get constness right
00847   FindSpectraForPars(osc, NC::SystPars(), beamsToUseNom, tmp_nom, junk);
00848 
00849   vector<const TH1*> noms; // nominal spectra
00850   noms.reserve(tmp_nom.size());
00851   for(unsigned int n = 0; n < tmp_nom.size(); ++n)
00852     noms.push_back(NC::SpectrumInterpolator::CloneFast(tmp_nom[n]));
00853 
00854   // We stack the nominal ND spectra on the end, so the first half of noms
00855   // is the FD nominal spectra, and the second half are the corresponding
00856   // ND spectra.
00857   vector<const TH1*> noms_nd = GetNearMCSpectra(beamsToUseNom);
00858   noms.insert(noms.end(), noms_nd.begin(), noms_nd.end());
00859 
00860   // Work out which systematics have shifts. Go through all beams and take
00861   // the combination of all shifts we see.
00862   bool shiftedVars[NCType::kNumSystematicParameters] = {false,};
00863   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00864     NCBeam* beam = it->second;
00865     for(int n = 0; n < NCType::kNumSystematicParameters; ++n){
00866       if(beam->GetInfo().IsShifted(NCType::EFitParam(n)))
00867         shiftedVars[n] = true;
00868     }
00869   }
00870 
00871   // Don't assign to fInterpolator yet, as we still have some more calls
00872   // to FindSpectraForPars to make that don't require interpolation.
00873   NC::SpectrumInterpolator* interp = new NC::SpectrumInterpolatorSimple;
00874 
00875   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00876     NCBeam* beam = it->second;
00877     const NCBeam::Info info = beam->GetInfo();
00878 
00879     // RunAll isn't a "real" beam
00880     if(beam->GetRunType() == NCType::kRunAll) continue;
00881     // Arbitrary - just need to get each beam description once
00882     if(beam->GetDetector() != Detector::kFar) continue;
00883 
00884     // Request corresponding spectra for "beam"
00885     vector<NCBeam::Info> beamsToUse;
00886     beamsToUse.push_back(info);
00887     vector<TH1*> tmp; // Need to do this to get constness right
00888     FindSpectraForPars(osc, NC::SystPars(), beamsToUse, tmp, junk);
00889     vector<const TH1*> exps; // shifted FD expectations
00890     for(unsigned int n = 0; n < tmp.size(); ++n) exps.push_back(tmp[n]);
00891     // We stack the shifted ND spectra on the end as we did for nominals
00892     vector<const TH1*> exps_nd = GetNearMCSpectra(beamsToUse);
00893     exps.insert(exps.end(), exps_nd.begin(), exps_nd.end());
00894 
00895     // Translation of 'info' into number of sigma shifts in each parameter
00896     vector<double> shift;
00897     shift.reserve(NCType::kNumSystematicParameters);
00898     for(int n = 0; n < NCType::kNumSystematicParameters; ++n){
00899       if(shiftedVars[n]){
00900         double val;
00901         if(!info.IsShifted(NCType::EFitParam(n), &val)) val = 0;
00902         const double sigmas = val/NCType::kParams[n].sigma;
00903         // Currently the interpolator can't understand shifts that aren't +/-1
00904         assert(sigmas == 0 || sigmas == 1 || sigmas == -1);
00905         shift.push_back(sigmas);
00906       }
00907     } // end for n
00908 
00909     assert(exps.size() == noms.size());
00910 
00911     // The shifted spectra are stored in the interpolator as ratios over the
00912     // nominal spectra.
00913     vector<TH1*> ratios;
00914     ratios.reserve(exps.size());
00915     for(unsigned int n = 0; n < exps.size(); ++n){
00916       ratios.push_back(NC::SpectrumInterpolator::CloneFast(exps[n]));
00917       NC::SpectrumInterpolator::DivideFast(ratios[n], noms[n]);
00918     }
00919     assert(ratios.size() == exps.size());
00920     interp->AddInputSpectra(shift, ratios, info.GetDescription());
00921   } // end for it (beams)
00922 
00923   // Put extrapolation setting back to however it was.
00924   EnableNearToFarExtrapolation(farNearRestore);
00925 
00926   // Have to wait till the last moment, because if fSpectrumInterpolator exists
00927   // then FindSpectraForPars tries to use it -> chicken and egg problem.
00928   fInterpolator = interp;
00929 
00930   fInterpCache[const_cast<NC::OscProb::OscPars*>(osc)->Clone()] = fInterpolator;
00931 
00932   already = false;
00933 
00934   TH1::AddDirectory(addDirectoryRestore);
00935 }

double NCExtrapolation::LogLikelihood const std::vector< TH1 * > &  exp,
const std::vector< TH1 * > &  obs
const [protected]
 

The log-likelihood formula from the PDG.

Parameters:
exp A set of expected spectra
obs The corresponding observed spectra
Returns:
The log-likelihood formula from the PDG

\[ \chi^2=2\sum_i^{\rm bins}\left(e_i-o_i+o_i\ln\left({o_i\over e_i}\right)\right) \]

Includes underflow and overflow bins and handles zero observed or expected events correctly.

Definition at line 731 of file NCExtrapolation.cxx.

Referenced by FindChiSqrForPars().

00733 {
00734   assert(exps.size() == obss.size());
00735 
00736   // Horrible hack to get at the number of entries in the underlying
00737   // representation of a TH1 subclass.
00738   struct CellsGetter: public TH1{int NCells(){return fNcells;}};
00739 
00740   // With this value, negative expected events and one observed
00741   // events gives a chisq from this one bin of 182.
00742 
00743   const double minexp = 1e-40; // Don't let expectation go lower than this
00744 
00745   double chisqr = 0;
00746 
00747   for(unsigned int n = 0; n < exps.size(); ++n){
00748     const int expssize = ((CellsGetter*)exps[n])->NCells();
00749     const int obsssize = ((CellsGetter*)obss[n])->NCells();
00750 
00751     assert(expssize == obsssize);
00752 
00753     for(int i = 0; i < expssize; ++i){
00754       double exp = exps[n]->GetBinContent(i);
00755       if(exp < minexp) exp = minexp;
00756 
00757       const double obs = obss[n]->GetBinContent(i);
00758       assert(obs >= 0);
00759 
00760       chisqr += 2*(exp-obs);
00761       if(obs) chisqr += 2*obs*log(obs/exp);
00762     }
00763   }
00764 
00765   return chisqr;
00766 }

void NCExtrapolation::Prepare const Registry r  )  [virtual]
 

Read whatever values you need out of the registry to initialize yourself. Please remember to chain up to the NCExtrapolation implementation too.

Reimplemented in NCExtrapolationFarNear, NCExtrapolationNone, and NCExtrapolationPID.

Definition at line 133 of file NCExtrapolation.cxx.

References NCType::EOscModel, fCoordConv, fDoSystematicInterpolation, fDoSystStudy, fEnergyThreshold, fHideFDData, fOscillationModel, fPrintFDEvents, fSys, fSystematicsAdjust, fSystematicsToUse, fSystShift, fUseCC, fUseNC, fUseSystPenalty, Registry::Get(), MSG, and NC::CoordinateConverter::Prepare().

Referenced by NCExtrapolationPID::Prepare(), NCExtrapolationNone::Prepare(), and NCExtrapolationFarNear::Prepare().

00134 {
00135   MSG("NCExtrapolation", Msg::kInfo) << "NCExtrapolation::Prepare(const Registry& r)"
00136                                      << endl;
00137   int         tmpb;  // a temp bool.
00138   int         tmpi;  // a temp int.
00139   double      tmpd;  // a temp double.
00140   const char* tmps;  // a temp string
00141 
00142   if(r.Get("OscillationModel",    tmpi)) fOscillationModel    = NCType::EOscModel(tmpi);
00143 
00144   //set the defaults for the systematic parameters
00145   //set them all off by default
00146   TString adjust = "Adjust";
00147   for(int i = 0; i < NCType::kNumSystematicParameters; ++i){
00148     if(r.Get(NCType::kParams[i].name, tmpb)) fSystematicsToUse[i] = tmpb;
00149     if(r.Get(adjust + NCType::kParams[i].name, tmpd)) fSystematicsAdjust[i] = tmpd;
00150   }
00151 
00152   MSG("NCExtrapolation", Msg::kInfo) << "PARAMETERS WE ARE USING:" << endl;
00153   for(int i = 0; i < NCType::kNumSystematicParameters; ++i){
00154     MSG("NCExtrapolation", Msg::kInfo) << i << ") "
00155                                        << NCType::kParams[i].name
00156                                        << " = " << fSystematicsToUse[i]
00157                                        << " with default = "
00158                                        << NCType::kParams[i].defaultVal
00159                                        << " adjust = "
00160                                        << fSystematicsAdjust[i] << endl;
00161   }
00162 
00163   tmpi = 0;
00164   tmps = "s";
00165 
00166   if(r.Get("EnergyThreshold",       tmpd)) fEnergyThreshold = tmpd;
00167 
00168   if(r.Get("UseCCEvents",           tmpb)) fUseCC           = tmpb;
00169   if(r.Get("UseNCEvents",           tmpb)) fUseNC           = tmpb;
00170 
00171   fCoordConv.Prepare(r);
00172 
00173   //Get the systematic values we are running with
00174   TString mcAsData = "ChangeMCAsData";
00175 
00176   fSys=-2;
00177 
00178   if (r.Get("DoSystStudy", tmpb)){
00179     fDoSystStudy = tmpb;
00180   }
00181 
00182   if (fDoSystStudy){
00183 
00184     //Find which systematic we are running with
00185     for (int k=0; k < NCType::kNumSystematicParameters; k++){
00186       if( r.Get(mcAsData + NCType::kParams[k].name, tmpb) ){
00187         if(tmpb){
00188           fSys = k;
00189         }
00190       }
00191     }//for(k)
00192 
00193 
00194     if (r.Get("SystShift", tmpi)){
00195       fSystShift = tmpi;
00196     }
00197 
00198     MSG("NCExtrapolation", Msg::kInfo) << endl << "fSys: " << fSys << "  ";
00199     if(fSys >= 0){
00200       MSG("NCExtrapolation", Msg::kInfo) << NCType::kParams[fSys].name
00201                                          << " Limit:"
00202                                          << NCType::kParams[fSys].sigma
00203                                          <<endl << endl;
00204     }else {
00205       MSG("NCExtrapolation", Msg::kInfo) << "No Systematics applied"
00206                                          << endl << endl;
00207     }
00208   }//if(fDoSystStudy)
00209 
00210   if(r.Get("PrintFDEvents", tmpb)) fPrintFDEvents = tmpb;
00211   if(r.Get("HideFDData",    tmpb)) fHideFDData    = tmpb;
00212 
00213   if(r.Get("DoSystematicInterpolation", tmpb))
00214     fDoSystematicInterpolation = tmpb;
00215 
00216   if(r.Get("DisableSystPenalty", tmpb)) fUseSystPenalty = !tmpb;
00217 }

void NCExtrapolation::Reset bool  nearData,
bool  farData,
bool  nearMC,
bool  farMC
[virtual]
 

Causes the extrapolation to forget everything it knows about the requested spectra.

This implementation clears the relevant NCBeam objects

Derived classes please override if you handle spectra yourself

Reimplemented in NCExtrapolationPID.

Definition at line 707 of file NCExtrapolation.cxx.

References fBeams, NCBeam::GetDetector(), and NCBeam::Reset().

00709 {
00710   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00711     NCBeam* beam = it->second;
00712     if(beam->GetDetector() == Detector::kFar){
00713       if(farData || farMC) beam->Reset(farData, farMC);
00714     }
00715     else{
00716       if(nearData || nearMC) beam->Reset(nearData, nearMC);
00717     }
00718   }
00719 }

void NCExtrapolation::SetBestFitCoordNDim const NC::Fitter::CoordNDim  minCoord  ) 
 

Set fMinCoord and prepare GetBestFitSysts and GetBestFitOscPars.

Definition at line 695 of file NCExtrapolation.cxx.

References NC::Fitter::CoordNDim, fBestFitOscPars, fBestFitSysts, fCoordConv, fMinCoord, NC::CoordinateConverter::OscParsFromCoordNDim(), and NC::CoordinateConverter::SystParsFromCoordNDim().

Referenced by NC::FitMaster::Run().

00696 {
00697   fMinCoord = minCoord;
00698 
00699   if(fBestFitOscPars) delete fBestFitOscPars;
00700 
00701   fBestFitSysts = fCoordConv.SystParsFromCoordNDim(minCoord);
00702   fBestFitOscPars = fCoordConv.OscParsFromCoordNDim(minCoord);
00703 }

void NCExtrapolation::SetBestFitOscPars NC::OscProb::OscPars pars  )  [inline, protected]
 

Warning - doesn't affect fMinCoord.

Definition at line 187 of file NCExtrapolation.h.

References fBestFitOscPars.

00187 {fBestFitOscPars = pars;}

void NCExtrapolation::SetBestFitSysts NC::SystPars  systs  )  [inline, protected]
 

Warning - doesn't affect fMinCoord.

Definition at line 184 of file NCExtrapolation.h.

References fBestFitSysts.

00184 {fBestFitSysts = systs;}

void NCExtrapolation::WriteResources const NC::OscProb::OscPars trueOscPars  )  [virtual]
 

gDirectory will point to the output file. Please remember to chain up to the NCExtrapolation implementation.

trueOscPars may be zero (eg obviously in case of fit to real data)

Reimplemented in NCExtrapolationFarNear, NCExtrapolationNone, and NCExtrapolationPID.

Definition at line 503 of file NCExtrapolation.cxx.

References DrawBestFitRatios(), DrawBestFitSpectra(), fBeams, fCoordConv, fDoSystStudy, fExtractionType, fHideFDData, FillResultHistograms(), fInterpolator, fMinChiSqr, fMinCoord, fOscillationModel, fSys, fSystFileName, fSystShift, NCBeam::GetDetector(), NCBeam::GetInfo(), GetShortName(), handler(), IgnoreErrors(), NCBeam::MakeResultPlots(), MSG, NC::CoordinateConverter::ParameterForFitterIndex(), NCParameter::ShortName(), NCBeam::WritePredictionResources(), NC::SpectrumInterpolator::WriteResources(), and NCBeam::WriteResources().

Referenced by NCExtrapolationPID::WriteResources(), NCExtrapolationNone::WriteResources(), and NCExtrapolationFarNear::WriteResources().

00504 {
00505   MSG("NCExtrapolation", Msg::kInfo)
00506     << "NCExtrapolation::WriteResources() - "
00507     << GetShortName() << endl;
00508 
00509   // Make sure all those pretty NCBeam plots get filled
00510   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it)
00511     FillResultHistograms(it->second);
00512 
00513   // get a pointer to the current directory
00514   // this is one of the output files
00515   TDirectory* saveDir = gDirectory;
00516 
00517   TDirectory* beamsDir = gDirectory->mkdir("beams", "beams");
00518   beamsDir->cd();
00519 
00520   //write out the spectra etc from the beam objects, while
00521   //checking on the prediction only flag
00522   for(fBeams_t::iterator it = fBeams.begin(); it != fBeams.end(); ++it){
00523     NCBeam* beam = it->second;
00524     TString dirName = beam->GetInfo().GetDescription();
00525 
00526     // Make the directory dirName, or if it already exists then cd into it.
00527     // There seems to be no way to do this without trigerring an error, so
00528     // tell ROOT to ignore them, and then restore the old state afterwards.
00529     ErrorHandlerFunc_t handler = GetErrorHandler();
00530     SetErrorHandler(IgnoreErrors);
00531     if(!beamsDir->cd(dirName)) beamsDir->mkdir(dirName)->cd();
00532     SetErrorHandler(handler);
00533 
00534     beam->MakeResultPlots();
00535     if(fHideFDData && beam->GetDetector() == Detector::kFar)
00536       beam->WritePredictionResources();
00537     else
00538       beam->WriteResources();
00539 
00540   }//end loop over beams
00541 
00542   saveDir->cd();
00543 
00544   DrawBestFitSpectra(Detector::kNear);
00545   DrawBestFitSpectra(Detector::kFar);
00546 
00547   DrawBestFitRatios(Detector::kNear);
00548   DrawBestFitRatios(Detector::kFar);
00549 
00550 
00551   if(fInterpolator){
00552     TDirectory* saveDir = gDirectory;
00553     gDirectory->mkdir("interp")->cd();
00554     fInterpolator->WriteResources();
00555     saveDir->cd();
00556   }
00557 
00558 
00559   saveDir->cd();
00560 
00561   //Write file with fit results for systematic study case
00562   char loc[400];
00563 
00564   if(fSys >= 0){
00565     if(fDoSystStudy){
00566       sprintf( loc,fSystFileName.Data() );
00567 
00568       ofstream ofs(loc);
00569       ofs << GetShortName() << " "
00570           << NCType::kExtractionNames[fExtractionType] << " "
00571           << fOscillationModel << " "
00572           << NCType::kParams[fSys].name << " "
00573           << fSystShift << " "
00574           << NCType::kParams[fSys].sigma << " ";
00575       for(unsigned int n = 0; n < fMinCoord.size(); ++n)
00576         ofs << fCoordConv.ParameterForFitterIndex(n).ShortName() << " = " << fMinCoord[n] << " ";
00577       ofs << "chisq = "  << fMinChiSqr  << endl;
00578     }
00579 
00580   }else{
00581     if(fDoSystStudy){
00582       sprintf( loc,fSystFileName.Data() );
00583 
00584       ofstream ofs(loc);
00585       ofs << GetShortName() << " "
00586           << NCType::kExtractionNames[fExtractionType] << " "
00587           << fOscillationModel << " "
00588           << "Nominal" << " "
00589           << fSystShift << " "
00590           << "1.0" << " ";
00591       for(unsigned int n = 0; n < fMinCoord.size(); ++n)
00592         ofs << fCoordConv.ParameterForFitterIndex(n).ShortName() << "= " << fMinCoord[n] << " ";
00593       ofs << "chisq= "  << fMinChiSqr  << endl;
00594     }
00595   }
00596 }


Member Data Documentation

fBeams_t NCExtrapolation::fBeams [protected]
 

Definition at line 192 of file NCExtrapolation.h.

Referenced by CombineRuns(), DrawBestFitRatios(), DrawBestFitSpectra(), FindChiSqrForPars(), GetBeam(), InitializeInterpolator(), Reset(), WriteResources(), and ~NCExtrapolation().

NC::OscProb::OscPars* NCExtrapolation::fBestFitOscPars [private]
 

Definition at line 286 of file NCExtrapolation.h.

Referenced by SetBestFitCoordNDim(), SetBestFitOscPars(), and ~NCExtrapolation().

NC::SystPars NCExtrapolation::fBestFitSysts [private]
 

Definition at line 285 of file NCExtrapolation.h.

Referenced by SetBestFitCoordNDim(), and SetBestFitSysts().

NC::CoordinateConverter NCExtrapolation::fCoordConv [protected]
 

Definition at line 265 of file NCExtrapolation.h.

Referenced by GetBestFitOscPars(), GetBestFitSysts(), GetCoordConv(), Prepare(), SetBestFitCoordNDim(), and WriteResources().

POTMap NCExtrapolation::fDataPOTFar [protected]
 

scale factors for scaling MC to same exposure as data

Definition at line 197 of file NCExtrapolation.h.

Referenced by GetPOTForBeam(), and NCExtrapolation().

POTMap NCExtrapolation::fDataPOTNear [protected]
 

scale factors for scaling MC to same exposure as data

Definition at line 197 of file NCExtrapolation.h.

Referenced by GetPOTForBeam(), and NCExtrapolation().

bool NCExtrapolation::fDoSystematicInterpolation [protected]
 

Definition at line 267 of file NCExtrapolation.h.

Referenced by InitializeInterpolator(), and Prepare().

int NCExtrapolation::fDoSystStudy [protected]
 

Definition at line 235 of file NCExtrapolation.h.

Referenced by Prepare(), and WriteResources().

double NCExtrapolation::fEnergyThreshold [protected]
 

Don't accept any events below this energy.

Definition at line 241 of file NCExtrapolation.h.

Referenced by AddEvent(), and Prepare().

int NCExtrapolation::fExtractionType [protected]
 

Definition at line 236 of file NCExtrapolation.h.

Referenced by WriteResources().

bool NCExtrapolation::fHideFDData [protected]
 

Preserve blinding by not showing FD data in plots.

Definition at line 206 of file NCExtrapolation.h.

Referenced by DrawBestFitRatios(), DrawBestFitSpectra(), Prepare(), and WriteResources().

std::map<const NC::OscProb::OscPars*, NC::SpectrumInterpolator*, InterpCacheCompare> NCExtrapolation::fInterpCache [private]
 

Definition at line 297 of file NCExtrapolation.h.

Referenced by InitializeInterpolator().

NC::SpectrumInterpolator* NCExtrapolation::fInterpolator [protected]
 

Definition at line 268 of file NCExtrapolation.h.

Referenced by InitializeInterpolator(), WriteResources(), and ~NCExtrapolation().

POTMap NCExtrapolation::fMCPOTFar [protected]
 

scale factors for scaling MC to same exposure as data

Definition at line 197 of file NCExtrapolation.h.

Referenced by GetPOTForBeam(), and NCExtrapolation().

POTMap NCExtrapolation::fMCPOTNear [protected]
 

scale factors for scaling MC to same exposure as data

Definition at line 197 of file NCExtrapolation.h.

Referenced by GetPOTForBeam(), and NCExtrapolation().

double NCExtrapolation::fMinChiSqr [private]
 

Definition at line 273 of file NCExtrapolation.h.

Referenced by ChiSqrAtBestFit(), and WriteResources().

NC::Fitter::CoordNDim NCExtrapolation::fMinCoord [private]
 

This is the best fit point as found by the fitter.

Warning - the SetBestFitOscPars and SetBestFitSysts functions DO NOT modify this variable. It is only to be used if you are genuinely interested in the *fitter* output.

Definition at line 283 of file NCExtrapolation.h.

Referenced by GetBestFitCoordNDim(), GetBestFitOscPars(), GetBestFitSysts(), SetBestFitCoordNDim(), and WriteResources().

NCType::EOscModel NCExtrapolation::fOscillationModel [protected]
 

Definition at line 208 of file NCExtrapolation.h.

Referenced by Prepare(), and WriteResources().

bool NCExtrapolation::fPrintFDEvents [private]
 

Whether to print all FD data events.

Definition at line 276 of file NCExtrapolation.h.

Referenced by AddEvent(), and Prepare().

bool NCExtrapolation::fSoftPenalty [protected]
 

Definition at line 239 of file NCExtrapolation.h.

int NCExtrapolation::fSys [protected]
 

Definition at line 233 of file NCExtrapolation.h.

Referenced by Prepare(), and WriteResources().

vector<double> NCExtrapolation::fSystematicsAdjust [protected]
 

Definition at line 194 of file NCExtrapolation.h.

Referenced by NCExtrapolation(), and Prepare().

vector<bool> NCExtrapolation::fSystematicsToUse [protected]
 

Definition at line 193 of file NCExtrapolation.h.

Referenced by NCExtrapolation(), and Prepare().

TString NCExtrapolation::fSystFileName [protected]
 

Definition at line 237 of file NCExtrapolation.h.

Referenced by WriteResources().

int NCExtrapolation::fSystShift [protected]
 

Definition at line 234 of file NCExtrapolation.h.

Referenced by Prepare(), and WriteResources().

bool NCExtrapolation::fUseCC [protected]
 

Definition at line 202 of file NCExtrapolation.h.

Referenced by GetBeam(), and Prepare().

bool NCExtrapolation::fUseNC [protected]
 

Definition at line 203 of file NCExtrapolation.h.

Referenced by GetBeam(), and Prepare().

bool NCExtrapolation::fUseSystPenalty [protected]
 

Definition at line 270 of file NCExtrapolation.h.

Referenced by FindChiSqrForPars(), and Prepare().


The documentation for this class was generated from the following files:
Generated on Mon Feb 16 22:55:37 2009 for loon by doxygen 1.3.5