SolarCycleRW Class Reference

#include <SolarCycleRW.h>

List of all members.

Public Member Functions

double Weight (double Enu, double CosZenith, int IDnu, double *WErr=0)
double Weight (double Enu, double CosZenith, int IDnu, int time, double *WErr=0)
double MinWeight (double Enu, double CosZenith, int IDnu, double *WErr=0)
double MaxWeight (double Enu, double CosZenith, int IDnu, double *WErr=0)
void DFunction (double period, double phase)
void DFactor (double dfactor)
void TimePeriod (int mintime, int maxtime)
int GenTime ()

Static Public Member Functions

static SolarCycleRWInstance (const char *hfile="")

Private Member Functions

void ReadHistFile (const char *histfile)
void ReadTextFile (const char *textfile)
void SimpleRWHists ()
 SolarCycleRW (const char *hfile="")
virtual ~SolarCycleRW ()

Private Attributes

bool fUseDFactor
bool fUseDFunction
double fDFactor
double fSolarPeriod
double fSolarOffset
int fMinTime
int fMaxTime
TH2F * fRWNue
TH2F * fRWNumu
TH2F * fRWNuebar
TH2F * fRWNumubar

Static Private Attributes

static SolarCycleRWfRWInstance = 0

Detailed Description

Definition at line 8 of file SolarCycleRW.h.


Constructor & Destructor Documentation

SolarCycleRW::SolarCycleRW ( const char *  hfile = ""  )  [private]

Definition at line 23 of file SolarCycleRW.cxx.

Referenced by Instance().

00024 {
00025   fUseDFactor = 0;
00026   fDFactor = 0.0;
00027 
00028   fUseDFunction = 1;      // default settings
00029   fSolarPeriod = 3.610e8; // 
00030   fSolarOffset = 0.439;   //
00031 
00032   fMinTime = 1059706100;  // min: 1st August 2003
00033   fMaxTime = 1467244800;  // max: 30th June 2016
00034 
00035   string hfile_str = hfile;
00036   if(hfile_str.find(".root") != string::npos) ReadHistFile(hfile);
00037   else if(hfile_str.find(".txt") != string::npos) ReadTextFile(hfile);
00038   else SimpleRWHists();  
00039 
00040   const time_t theTime = time(0);
00041   tm* theTimeStruc = gmtime(&theTime);
00042   int seconds = 60*theTimeStruc->tm_min
00043                  + theTimeStruc->tm_sec;
00044   int seed = seconds;
00045 
00046   gRandom->SetSeed(seed);
00047 }

SolarCycleRW::~SolarCycleRW (  )  [private, virtual]

Definition at line 49 of file SolarCycleRW.cxx.

00050 {
00051 
00052 }


Member Function Documentation

void SolarCycleRW::DFactor ( double  dfactor  )  [inline]

Definition at line 23 of file SolarCycleRW.h.

References fDFactor, fUseDFactor, and fUseDFunction.

00023                                { 
00024     fUseDFunction=0; fUseDFactor=1; fDFactor=dfactor; 
00025   }

void SolarCycleRW::DFunction ( double  period,
double  phase 
) [inline]

Definition at line 19 of file SolarCycleRW.h.

References fSolarOffset, fSolarPeriod, fUseDFactor, and fUseDFunction.

00019                                               { 
00020     fUseDFunction=1; fUseDFactor=0; fSolarPeriod=period; fSolarOffset=phase; 
00021   }

int SolarCycleRW::GenTime (  ) 

Definition at line 66 of file SolarCycleRW.cxx.

References fMaxTime, and fMinTime.

Referenced by AtNuEventCounter::AddData(), AtNuOscFitTemplateMaker::Run(), Weight(), and AtNuEventNtuple::WriteVariables().

00067 {
00068   double alpha = gRandom->Uniform();
00069   double time = fMinTime*(1.0-alpha) + fMaxTime*alpha;
00070   return (int)time;
00071 }

SolarCycleRW * SolarCycleRW::Instance ( const char *  hfile = ""  )  [static]

Definition at line 54 of file SolarCycleRW.cxx.

References fRWInstance, and SolarCycleRW().

Referenced by AtNuEventCounter::AddData(), AtNuOscFitTemplateMaker::Run(), AtNuOscFitTemplateMaker::SetTimePeriod(), AtNuEventCounter::SetTimePeriod(), and AtNuEventNtuple::WriteVariables().

00055 {
00056   if (!fRWInstance) {
00057     fRWInstance = new SolarCycleRW(hfile);
00058   }
00059 
00060   // die if finder hasn't actually been created
00061   if(!fRWInstance) assert(fRWInstance);
00062 
00063   return fRWInstance;
00064 }

double SolarCycleRW::MaxWeight ( double  Enu,
double  CosZenith,
int  IDnu,
double *  WErr = 0 
)

Definition at line 148 of file SolarCycleRW.cxx.

Referenced by AtNuEventNtuple::WriteVariables().

00149 {
00150   return 1.0;
00151 }

double SolarCycleRW::MinWeight ( double  Enu,
double  CosZenith,
int  IDnu,
double *  WErr = 0 
)

Definition at line 119 of file SolarCycleRW.cxx.

References fRWNue, fRWNuebar, fRWNumu, and fRWNumubar.

Referenced by AtNuEventNtuple::WriteVariables().

00121 {
00122   TH2F *fRWHist=0;
00123 
00124   switch (IDnu) {
00125     case  12: fRWHist = fRWNue;     break;
00126     case  14: fRWHist = fRWNumu;    break;
00127     case  16: fRWHist = fRWNumu;    break;
00128     case -12: fRWHist = fRWNuebar;  break;
00129     case -14: fRWHist = fRWNumubar; break;
00130     case -16: fRWHist = fRWNumubar; break;
00131     default:  fRWHist = 0;          break;
00132   }
00133 
00134   if(!fRWHist) return 1.0;
00135 
00136   double MinRW = 1.0;
00137 
00138   if(WErr) *WErr = 0.1;
00139   if (Enu < 10.0)  {
00140     int Bin = fRWHist->FindBin(Enu, CosZenith);
00141     MinRW = fRWHist->GetBinContent(Bin);
00142     if(WErr) *WErr = fRWHist->GetBinError(Bin);
00143   }
00144 
00145   return MinRW;
00146 }

void SolarCycleRW::ReadHistFile ( const char *  histfile  )  [private]

Definition at line 153 of file SolarCycleRW.cxx.

References fRWNue, fRWNuebar, fRWNumu, and fRWNumubar.

00154 {
00155   cout << " SolarCycleRW: Reading histograms from root file " << histfile << endl;
00156   
00157   bool ADStatus = TH1::AddDirectoryStatus();
00158   TH1::AddDirectory(false);
00159 
00160   TFile *tf = TFile::Open(histfile);
00161 
00162   TH2F *hist = 0;
00163   hist = dynamic_cast<TH2F*>(tf->Get("RMinMaxEnergyZenNue"));
00164   if(hist) fRWNue = dynamic_cast<TH2F*>(hist->Clone("RWNue"));
00165   hist = dynamic_cast<TH2F*>(tf->Get("RMinMaxEnergyZenNum"));
00166   if(hist) fRWNumu = dynamic_cast<TH2F*>(hist->Clone("RWNumu"));
00167   hist = dynamic_cast<TH2F*>(tf->Get("RMinMaxEnergyZenNbe"));
00168   if(hist) fRWNuebar = dynamic_cast<TH2F*>(hist->Clone("RWNuebar"));
00169   hist = dynamic_cast<TH2F*>(tf->Get("RMinMaxEnergyZenNbm"));
00170   if(hist) fRWNumubar = dynamic_cast<TH2F*>(hist->Clone("RWNumubar"));
00171 
00172   tf->Close();
00173 
00174   TH1::AddDirectory(ADStatus);
00175 }

void SolarCycleRW::ReadTextFile ( const char *  textfile  )  [private]

Definition at line 177 of file SolarCycleRW.cxx.

References fRWNue, fRWNuebar, fRWNumu, and fRWNumubar.

00178 {
00179   cout << " SolarCycleRW: Reading histograms from text file " << textfile << endl;
00180 
00181   //Setup Log10(Energy) Bins
00182   const int EnergyBins = 20;
00183   double *XBins;
00184   XBins = new double[EnergyBins+1];
00185   double XBinW = (TMath::Log10(10)-TMath::Log10(0.1))/EnergyBins;
00186 
00187   for (int i=0; i<=EnergyBins; i++) {
00188     XBins[i] = 0.1*TMath::Power(10., (i*XBinW));
00189   }
00190 
00191   fRWNue = new TH2F("RWNue","", EnergyBins,XBins, 20,-1.0,1.0);
00192   fRWNumu = new TH2F("RWNumu","", EnergyBins,XBins, 20,-1.0,1.0);
00193   fRWNuebar = new TH2F("RWNuebar","", EnergyBins,XBins, 20,-1.0,1.0);
00194   fRWNumubar = new TH2F("RWNumubar","", EnergyBins,XBins, 20,-1.0,1.0);
00195 
00196   //Not fully setup yet, need to implement a method that divides the 4 nu types
00197   std::ifstream file_in(textfile);
00198   double Energy(0), Zenith(0), RW(0), RWErr(0);
00199   while (1) {
00200     file_in >> Energy >> Zenith >> RW >> RWErr;
00201     if(!file_in.good()) break;
00202     int Bin2D = fRWNue->FindBin(Energy, Zenith);
00203     fRWNue->SetBinContent(Bin2D, RW);
00204     fRWNue->SetBinError(Bin2D, RWErr);
00205   }
00206   file_in.close();
00207 }

void SolarCycleRW::SimpleRWHists (  )  [private]

Definition at line 209 of file SolarCycleRW.cxx.

References fRWNue, fRWNuebar, fRWNumu, fRWNumubar, and MakeRWhists().

00210 {
00211   cout << " SolarCycleRW: Constructing Solar Reweight Histograms " << endl;
00212   TH2F **RWhists = MakeRWhists();
00213 
00214   fRWNue = RWhists[0];
00215   fRWNumu = RWhists[2];
00216   fRWNuebar = RWhists[1];
00217   fRWNumubar = RWhists[3];
00218 }

void SolarCycleRW::TimePeriod ( int  mintime,
int  maxtime 
) [inline]

Definition at line 27 of file SolarCycleRW.h.

References fMaxTime, and fMinTime.

Referenced by AtNuOscFitTemplateMaker::SetTimePeriod(), and AtNuEventCounter::SetTimePeriod().

00027                                             {
00028     fMinTime = mintime; fMaxTime = maxtime;
00029   }

double SolarCycleRW::Weight ( double  Enu,
double  CosZenith,
int  IDnu,
int  time,
double *  WErr = 0 
)

Definition at line 80 of file SolarCycleRW.cxx.

References fDFactor, fRWNue, fRWNuebar, fRWNumu, fRWNumubar, fSolarOffset, fSolarPeriod, fUseDFactor, and fUseDFunction.

00083 {
00084   TH2F *fRWHist=0;
00085 
00086   switch (IDnu) {
00087     case  12: fRWHist = fRWNue;     break;
00088     case  14: fRWHist = fRWNumu;    break;
00089     case  16: fRWHist = fRWNumu;    break;
00090     case -12: fRWHist = fRWNuebar;  break;
00091     case -14: fRWHist = fRWNumubar; break;
00092     case -16: fRWHist = fRWNumubar; break;
00093     default:  fRWHist = 0;          break;
00094   }
00095 
00096   if(!fRWHist) return 1.0;
00097 
00098   double MinRW = 1.0;
00099   if(WErr) *WErr = 0.1;
00100   if (Enu < 10.0)  {
00101     int Bin = fRWHist->FindBin(Enu, CosZenith);
00102     MinRW = fRWHist->GetBinContent(Bin);
00103     if(WErr) *WErr = fRWHist->GetBinError(Bin);
00104   }
00105 
00106   double dfactor = 0.0;
00107   if( fUseDFactor ){
00108     if( fDFactor>=-1 && fDFactor<=+1) dfactor = fDFactor;
00109   }
00110   else if( fUseDFunction ){
00111     if( fSolarPeriod>0 && time>0 ) dfactor = TMath::Sin((2.0*TMath::Pi()*time/fSolarPeriod)-fSolarOffset);
00112   }
00113 
00114   double RW = MinRW*(1.0+dfactor)/2.0 + (1.0-dfactor)/2.0;
00115 
00116   return RW;
00117 }

double SolarCycleRW::Weight ( double  Enu,
double  CosZenith,
int  IDnu,
double *  WErr = 0 
)

Definition at line 73 of file SolarCycleRW.cxx.

References GenTime().

Referenced by AtNuEventCounter::AddData(), AtNuOscFitTemplateMaker::Run(), and AtNuEventNtuple::WriteVariables().

00075 {
00076   int time = GenTime();
00077   return Weight( Enu, CosZenith, IDnu, time, WErr);
00078 }


Member Data Documentation

double SolarCycleRW::fDFactor [private]

Definition at line 38 of file SolarCycleRW.h.

Referenced by DFactor(), and Weight().

int SolarCycleRW::fMaxTime [private]

Definition at line 43 of file SolarCycleRW.h.

Referenced by GenTime(), and TimePeriod().

int SolarCycleRW::fMinTime [private]

Definition at line 42 of file SolarCycleRW.h.

Referenced by GenTime(), and TimePeriod().

SolarCycleRW * SolarCycleRW::fRWInstance = 0 [static, private]

Definition at line 57 of file SolarCycleRW.h.

Referenced by Instance().

TH2F* SolarCycleRW::fRWNue [private]

Definition at line 45 of file SolarCycleRW.h.

Referenced by MinWeight(), ReadHistFile(), ReadTextFile(), SimpleRWHists(), and Weight().

TH2F* SolarCycleRW::fRWNuebar [private]

Definition at line 47 of file SolarCycleRW.h.

Referenced by MinWeight(), ReadHistFile(), ReadTextFile(), SimpleRWHists(), and Weight().

TH2F* SolarCycleRW::fRWNumu [private]

Definition at line 46 of file SolarCycleRW.h.

Referenced by MinWeight(), ReadHistFile(), ReadTextFile(), SimpleRWHists(), and Weight().

TH2F* SolarCycleRW::fRWNumubar [private]

Definition at line 48 of file SolarCycleRW.h.

Referenced by MinWeight(), ReadHistFile(), ReadTextFile(), SimpleRWHists(), and Weight().

double SolarCycleRW::fSolarOffset [private]

Definition at line 40 of file SolarCycleRW.h.

Referenced by DFunction(), and Weight().

double SolarCycleRW::fSolarPeriod [private]

Definition at line 39 of file SolarCycleRW.h.

Referenced by DFunction(), and Weight().

bool SolarCycleRW::fUseDFactor [private]

Definition at line 35 of file SolarCycleRW.h.

Referenced by DFactor(), DFunction(), and Weight().

Definition at line 36 of file SolarCycleRW.h.

Referenced by DFactor(), DFunction(), and Weight().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1