NuUtilities Class Reference

#include <NuUtilities.h>

List of all members.

Public Member Functions

 NuUtilities ()
virtual ~NuUtilities ()
 ClassDef (NuUtilities, 0)

Static Public Member Functions

static TGraph ConvertLikelihoodSurfaceToContour (TH2D *hLikelihood, Double_t upValue)
static Double_t DistanceTargetToND ()
static void CalcFiducialMass ()
static TString PrintRelease (int releaseType)
static BeamType::BeamType_t ReturnConventionsBeamType (const NuConfig &config)
static BeamType::BeamType_t ConvertToConventionsBeamType (const Int_t beamType, const Int_t intensity)
static std::vector< Double_t > GenerateBins (int ngroups, double edges[], double steps[])
static std::vector< Double_t > RecoBins (const NuBinningScheme::NuBinningScheme_t binningScheme)
static std::vector< Double_t > TrueBins (const NuBinningScheme::NuBinningScheme_t binningScheme)
static Double_t ValueAt (TH1 *h, Double_t val)
static void WriteHistosToFile (const std::vector< TH1D > &vHistos, TFile &file, bool Quiet=false)
static void WriteHistosToFile (const std::vector< NuMatrixSpectrum > &vHistos, TFile &file, bool Quiet=false)
static void WriteHistosToFile (const std::pair< NuMatrixSpectrum, NuMatrixSpectrum > &vHistos, TFile &file)
static TH1D * RebinHistogram (const TH1D *old, int nbins, const double binedges[999])
static TH1D * RebinHistogram (const TH1D *old, std::vector< Double_t > &bins)
static TH1D * RebinHistogram (const TH1D *old, NuBinningScheme::NuBinningScheme_t scheme)
static Double_t LogLikelihood (Double_t data, Double_t MC)
static Double_t GetChisqFromCL (double cl=0.6827, int n=1)
static Double_t GetChisqFromSigma (double s=1, int n=1)
static void OscillateJesstogram (TH2D *h, double dm2, double sn2)
static void FixDogwoodQP (NuEvent &nu)
static std::vector< TString > GetListOfFilesInDir (const TString &wildcardString)
static int GetDigit (int num, int d)
static bool CheckConsistency (const TH1 *h1, const TH1 *h2)
 Checks two histograms have the same binning.
static const TH1D IntegralMarginalize (const TH2D *surf, const char axis= 'y')
static const TH1D MinimumMarginalize (const TH2D *surf, const char axis= 'y')
static void ProgressBar (Int_t entry, Float_t nEntriesF, Int_t mintime=0)

Static Public Attributes

static VldTimeStamp vtsRunIEnd
static VldTimeStamp vtsRunIIEnd
static VldTimeStamp vtsRunIIIEnd
static VldTimeStamp vtsRunIVEnd
static VldTimeStamp vtsRunVEnd
static VldTimeStamp vtsRunVIEnd
static VldTimeStamp vtsRunVIIEnd
static VldTimeStamp vtsRunVIIIEnd
static VldTimeStamp vtsRunIXEnd
static VldTimeStamp vtsRunXEnd

Detailed Description

Definition at line 46 of file NuUtilities.h.


Constructor & Destructor Documentation

NuUtilities::NuUtilities (  ) 

Definition at line 55 of file NuUtilities.cxx.

00056 {
00057 }

NuUtilities::~NuUtilities (  )  [virtual]

Definition at line 60 of file NuUtilities.cxx.

00061 {
00062 }


Member Function Documentation

void NuUtilities::CalcFiducialMass (  )  [static]

Definition at line 82 of file NuUtilities.cxx.

References Munits::cm, Munits::cm3, Munits::g, Munits::kilotonne, Munits::m, and Munits::m2.

00083 {
00084 
00085 
00086   const Float_t avPlSteelDensityNDData=7.847*(Munits::g/Munits::cm3);
00087   const Float_t avPlSteelThicknessNDData=2.563*(Munits::cm);
00088   const Float_t avPlScintDensityNDData=1.0457*(Munits::g/Munits::cm3);
00089   const Float_t avPlScintThicknessNDData=1.02*(Munits::cm);
00090   const Float_t avPlAlumDensityNDData=2.7*(Munits::g/Munits::cm3);
00091   const Float_t avPlAlumThicknessNDData=0.1*(Munits::cm);
00092 
00093   const Float_t avPlSteelDensityFDData=avPlSteelDensityNDData;
00094   const Float_t avPlSteelThicknessFDData=2.559*(Munits::cm);
00095   const Float_t avPlScintDensityFDData=avPlScintDensityNDData;
00096   const Float_t avPlScintThicknessFDData=avPlScintThicknessNDData;
00097   const Float_t avPlAlumDensityFDData=avPlAlumDensityNDData;
00098   const Float_t avPlAlumThicknessFDData=avPlAlumThicknessNDData;
00099 
00100   //MC
00101   const Float_t avPlSteelDensityNDMC=avPlSteelDensityNDData;
00102   const Float_t avPlSteelThicknessNDMC=2.54*(Munits::cm);
00103   const Float_t avPlScintDensityNDMC=avPlScintDensityNDData;
00104   const Float_t avPlScintThicknessNDMC=1.0*(Munits::cm);
00105   const Float_t avPlAlumDensityNDMC=avPlAlumDensityNDData;
00106   const Float_t avPlAlumThicknessNDMC=avPlAlumThicknessNDData;
00107 
00108   const Float_t avPlSteelDensityFDMC=avPlSteelDensityNDMC;
00109   const Float_t avPlSteelThicknessFDMC=avPlSteelThicknessNDMC;
00110   const Float_t avPlScintDensityFDMC=avPlScintDensityNDMC;
00111   const Float_t avPlScintThicknessFDMC=avPlScintThicknessNDMC;
00112   const Float_t avPlAlumDensityFDMC=avPlAlumDensityNDMC;
00113   const Float_t avPlAlumThicknessFDMC=avPlAlumThicknessNDMC;
00114 
00115   cout<<"************** Thickness and Density ******************"<<endl;
00116   cout<<"Thickness ND Data:"
00117       <<" steel="<<avPlSteelThicknessNDData
00118       <<", scint="<<avPlScintThicknessNDData
00119       <<", alum="<<avPlAlumThicknessNDData<<endl;
00120   cout<<"Density ND Data:"
00121       <<" steel="<<avPlSteelDensityNDData
00122       <<", scint="<<avPlScintDensityNDData
00123       <<", alum="<<avPlAlumDensityNDData<<endl;
00124   cout<<endl;
00125     cout<<"Thickness ND MC:"
00126       <<" steel="<<avPlSteelThicknessNDMC
00127       <<", scint="<<avPlScintThicknessNDMC
00128       <<", alum="<<avPlAlumThicknessNDMC<<endl;
00129   cout<<"Density ND MC:"
00130       <<" steel="<<avPlSteelDensityNDMC
00131       <<", scint="<<avPlScintDensityNDMC
00132       <<", alum="<<avPlAlumDensityNDMC<<endl;
00133 
00134   cout<<endl<<endl;
00135   cout<<"Thickness FD Data:"
00136       <<" steel="<<avPlSteelThicknessFDData
00137       <<", scint="<<avPlScintThicknessFDData
00138       <<", alum="<<avPlAlumThicknessFDData<<endl;
00139   cout<<"Density FD Data:"
00140       <<" steel="<<avPlSteelDensityFDData
00141   <<", scint="<<avPlScintDensityFDData
00142       <<", alum="<<avPlAlumDensityFDData<<endl;
00143   cout<<endl;
00144     cout<<"Thickness FD MC:"
00145       <<" steel="<<avPlSteelThicknessFDMC
00146       <<", scint="<<avPlScintThicknessFDMC
00147       <<", alum="<<avPlAlumThicknessFDMC<<endl;
00148   cout<<"Density FD MC:"
00149       <<" steel="<<avPlSteelDensityFDMC
00150       <<", scint="<<avPlScintDensityFDMC
00151       <<", alum="<<avPlAlumDensityFDMC<<endl;
00152 
00153   const Float_t avPlSteelStPwNDData=
00154     avPlSteelThicknessNDData*avPlSteelDensityNDData;
00155   const Float_t avPlScintStPwNDData=
00156     avPlScintThicknessNDData*avPlScintDensityNDData;
00157   const Float_t avPlAlumStPwNDData=
00158     avPlAlumThicknessNDData*avPlAlumDensityNDData;
00159 
00160   const Float_t avPlSteelStPwFDData=
00161     avPlSteelThicknessFDData*avPlSteelDensityFDData;
00162   const Float_t avPlScintStPwFDData=
00163     avPlScintThicknessFDData*avPlScintDensityFDData;
00164   const Float_t avPlAlumStPwFDData=
00165     avPlAlumThicknessFDData*avPlAlumDensityFDData;
00166 
00167   const Float_t avPlSteelStPwNDMC=
00168     avPlSteelThicknessNDMC*avPlSteelDensityNDMC;
00169   const Float_t avPlScintStPwNDMC=
00170     avPlScintThicknessNDMC*avPlScintDensityNDMC;
00171   const Float_t avPlAlumStPwNDMC=
00172     avPlAlumThicknessNDMC*avPlAlumDensityNDMC;
00173 
00174   const Float_t avPlSteelStPwFDMC=
00175     avPlSteelThicknessFDMC*avPlSteelDensityFDMC;
00176   const Float_t avPlScintStPwFDMC=
00177     avPlScintThicknessFDMC*avPlScintDensityFDMC;
00178   const Float_t avPlAlumStPwFDMC=
00179     avPlAlumThicknessFDMC*avPlAlumDensityFDMC;
00180 
00181   cout<<endl<<endl;
00182   cout<<"**************** Stopping Power ********************"<<endl;
00183   cout<<"StPw ND Data:"
00184       <<" steel="<<avPlSteelStPwNDData
00185       <<", scint="<<avPlScintStPwNDData
00186       <<", alum="<<avPlAlumStPwNDData<<endl;
00187   cout<<endl;
00188   cout<<"StPw ND MC:"
00189       <<" steel="<<avPlSteelStPwNDMC
00190       <<", scint="<<avPlScintStPwNDMC
00191       <<", alum="<<avPlAlumStPwNDMC<<endl;
00192   cout<<endl<<endl;
00193   cout<<"StPw FD Data:"
00194       <<" steel="<<avPlSteelStPwFDData
00195       <<", scint="<<avPlScintStPwFDData
00196       <<", alum="<<avPlAlumStPwFDData<<endl;
00197   cout<<endl;
00198   cout<<"StPw FD MC:"
00199       <<" steel="<<avPlSteelStPwFDMC
00200       <<", scint="<<avPlScintStPwFDMC
00201       <<", alum="<<avPlAlumStPwFDMC<<endl;
00202 
00203 
00204   //NOW CALC AREAS
00205   Float_t areaPlND=3.142*pow(0.8*Munits::m,2);
00206   Float_t areaPlFD=3.142*(14*Munits::m2-pow(0.4*Munits::m,2));
00207   cout<<endl<<endl;
00208   cout<<"Area ND = "<<areaPlND<<endl;
00209   cout<<"Area FD = "<<areaPlFD<<endl;
00210 
00211   //NOW CALC MASS
00212   const Float_t avPlSteelMassNDData=avPlSteelStPwNDData*areaPlND;
00213   const Float_t avPlScintMassNDData=avPlScintStPwNDData*areaPlND;
00214   const Float_t avPlAlumMassNDData=avPlAlumStPwNDData*areaPlND;
00215 
00216   const Float_t avPlSteelMassNDMC=avPlSteelStPwNDMC*areaPlND;
00217   const Float_t avPlScintMassNDMC=avPlScintStPwNDMC*areaPlND;
00218   const Float_t avPlAlumMassNDMC=avPlAlumStPwNDMC*areaPlND;
00219 
00220   const Float_t avPlSteelMassFDData=avPlSteelStPwFDData*areaPlFD;
00221   const Float_t avPlScintMassFDData=avPlScintStPwFDData*areaPlFD;
00222   const Float_t avPlAlumMassFDData=avPlAlumStPwFDData*areaPlFD;
00223 
00224   const Float_t avPlSteelMassFDMC=avPlSteelStPwFDMC*areaPlFD;
00225   const Float_t avPlScintMassFDMC=avPlScintStPwFDMC*areaPlFD;
00226   const Float_t avPlAlumMassFDMC=avPlAlumStPwFDMC*areaPlFD;
00227 
00228   cout<<endl<<endl;
00229   cout<<"**************** MASS ********************"<<endl;
00230   cout<<"Mass ND Data:"
00231       <<" steel="<<avPlSteelMassNDData
00232       <<", scint="<<avPlScintMassNDData
00233       <<", alum="<<avPlAlumMassNDData<<endl;
00234   cout<<endl;
00235   cout<<"Mass ND MC:"
00236       <<" steel="<<avPlSteelMassNDMC
00237       <<", scint="<<avPlScintMassNDMC
00238       <<", alum="<<avPlAlumMassNDMC<<endl;
00239   cout<<endl<<endl;
00240   cout<<"Mass FD Data:"
00241       <<" steel="<<avPlSteelMassFDData
00242       <<", scint="<<avPlScintMassFDData
00243       <<", alum="<<avPlAlumMassFDData<<endl;
00244   cout<<endl;
00245   cout<<"Mass FD MC:"
00246       <<" steel="<<avPlSteelMassFDMC
00247       <<", scint="<<avPlScintMassFDMC
00248       <<", alum="<<avPlAlumMassFDMC<<endl;
00249 
00250 
00251 
00252   const Float_t avPlTotalMassNDData=
00253     avPlSteelMassNDData+avPlScintMassNDData+avPlAlumMassNDData;
00254   const Float_t avPlTotalMassNDMC=
00255     avPlSteelMassNDMC+avPlScintMassNDMC+avPlAlumMassNDMC;
00256   const Float_t avPlTotalMassFDData=
00257     avPlSteelMassFDData+avPlScintMassFDData+avPlAlumMassFDData;
00258   const Float_t avPlTotalMassFDMC=
00259     avPlSteelMassFDMC+avPlScintMassFDMC+avPlAlumMassFDMC;
00260 
00261   const Float_t massSumND=avPlTotalMassNDData+avPlTotalMassNDMC;
00262   const Float_t massSumFD=avPlTotalMassFDData+avPlTotalMassFDMC;
00263   const Float_t massDiffND=avPlTotalMassNDData-avPlTotalMassNDMC;
00264   const Float_t massDiffFD=avPlTotalMassFDData-avPlTotalMassFDMC;
00265 
00266   const Float_t massRelDiffND=massDiffND/(0.5*massSumND);
00267   const Float_t massRelDiffFD=massDiffFD/(0.5*massSumFD);
00268 
00269   cout<<endl<<endl;
00270   cout<<"Mass ND Data Total: "<<avPlTotalMassNDData<<endl;
00271   cout<<"Mass ND MC Total: "<<avPlTotalMassNDMC<<endl;
00272   cout<<"Mass ND Data-MC="<<massDiffND<<endl;
00273   cout<<"Mass ND Data-MC/(0.5*Data+MC)="<<massRelDiffND<<endl;
00274   cout<<endl;
00275   cout<<"Mass FD Data Total: "<<avPlTotalMassFDData<<endl;
00276   cout<<"Mass FD MC Total: "<<avPlTotalMassFDMC<<endl;
00277   cout<<"Mass FD Data-MC="<<massDiffFD<<endl;
00278   cout<<"Mass FD Data-MC/(0.5*Data+MC)="<<massRelDiffFD<<endl;
00279   cout<<endl;
00280 
00281   //Considering events from STEEL planes
00282   //ND: 14->68 inclusive = 55 planes of steel
00283   cout<<endl<<endl;
00284   cout<<"55 planes in ND Data="
00285       <<55*avPlTotalMassNDData/(Munits::kilotonne)<<" kilotonnes"<<endl;
00286   cout<<"55 planes in ND MC  ="
00287       <<55*avPlTotalMassNDMC/(Munits::kilotonne)<<" kilotonnes"<<endl;
00288 
00289   //FD: 4->239 inclusive + 253->464 inclusive = 236 + 212 = 448 planes
00290   cout<<endl<<endl;
00291   cout<<"448 planes in FD Data="
00292       <<448*avPlTotalMassFDData/(Munits::kilotonne)<<" kilotonnes"
00293       <<endl;
00294   cout<<"448 planes in FD MC  ="
00295       <<448*avPlTotalMassFDMC/(Munits::kilotonne)<<" kilotonnes"
00296       <<endl;
00297 
00298 
00299 //Table 5 of minos-doc-3134v2 has updated numbers
00300 //Both detectors have the same densities in MC
00301 //steel = 7.847
00302 //scint = 1.0457, thickness=1.0cm
00303 //The pitches of ND and FD are slightly different
00304 
00305 //Peter Litchfield's email of 20/06/07 22:27 GMT
00306 //Real detectors
00307 //Plane pitch  FD (average) 5.946cm,  ND 5.94cm (3134)
00308 //Steel density  Both Detectors 7.847gm/cc (1431)
00309 //Steel thickness FD 2.559cm, ND 2.563cm (1529)
00310 //Scintillator 1.02cm density 1.0457gm/cc (scint+coating, 3134)
00311 //Aluminium    0.1cm  density 2.7gm/cc (PDG book)
00312 //FD average density = 3.602gm/cc
00313 //ND average density = 3.611gm/cc
00314 
00315 //In the Birch MC (3134)
00316 //Plane pitch  FD (average) 5.946cm,  ND 5.94cm
00317 //Steel density 7.87gm/cc
00318 //Steel thickness 2.54cm
00319 //Scintillator 1.02cm density 1.032gm/cc
00320 //Aluminium 0.1cm air, negligible density
00321 //FD avearge density = 3.539gm/cc
00322 //ND average density = 3.542gm/cc
00323 }

bool NuUtilities::CheckConsistency ( const TH1 *  h1,
const TH1 *  h2 
) [static]

Checks two histograms have the same binning.

This is a static function on TH1, but for some reason it's private Copied the implemention here (and made it saner) as the lesser of two evils.

(The greater of two evils, preserved for posterity, is as follows)

define CheckConsistency fgHackVar; public: static bool CheckConsistency include "TH1D.h" undef CheckConsistency

Definition at line 1459 of file NuUtilities.cxx.

References CheckBinLimits().

Referenced by NuMatrixSpectrum::FillOscCache(), and NuMatrix1D::FillOscCache().

01460 {
01461   if(h1->GetNbinsX() != h2->GetNbinsX() ||
01462      h1->GetNbinsY() != h2->GetNbinsY() ||
01463      h1->GetNbinsZ() != h2->GetNbinsZ())
01464     return false;
01465 
01466   if(h1->GetXaxis()->GetXmin() != h2->GetXaxis()->GetXmin() ||
01467      h1->GetXaxis()->GetXmax() != h2->GetXaxis()->GetXmax() ||
01468      h1->GetYaxis()->GetXmin() != h2->GetYaxis()->GetXmin() ||
01469      h1->GetYaxis()->GetXmax() != h2->GetYaxis()->GetXmax() ||
01470      h1->GetZaxis()->GetXmin() != h2->GetZaxis()->GetXmin() ||
01471      h1->GetZaxis()->GetXmax() != h2->GetZaxis()->GetXmax())
01472     return false;
01473 
01474   if(!CheckBinLimits(h1->GetXaxis()->GetXbins(), h2->GetXaxis()->GetXbins()) ||
01475      !CheckBinLimits(h1->GetYaxis()->GetXbins(), h2->GetYaxis()->GetXbins()) ||
01476      !CheckBinLimits(h1->GetZaxis()->GetXbins(), h2->GetZaxis()->GetXbins()))
01477     return false;
01478 
01479   return true;
01480 }

NuUtilities::ClassDef ( NuUtilities  ,
 
)
TGraph NuUtilities::ConvertLikelihoodSurfaceToContour ( TH2D *  hLikelihood,
Double_t  upValue 
) [static]

Definition at line 65 of file NuUtilities.cxx.

00067 {
00068   Double_t minimumLike = hLikelihood->GetMinimum();
00069   hLikelihood->SetContour(1);
00070   hLikelihood->SetContourLevel(0, minimumLike + upValue);
00071   TCanvas canvas;
00072   hLikelihood->Draw("contlist same");
00073   canvas.Update(); //This line of code embodies everything I hate about Root
00074 
00075   TObjArray* contArr = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours"); //What was Rene Brun thinking?
00076   TList* contList = (TList*) contArr->At(0);
00077   //  TGraph* contGraph68 = new TGraph(*((TGraph*)contList->First()));
00078   return *((TGraph*)contList->First());
00079 }

BeamType::BeamType_t NuUtilities::ConvertToConventionsBeamType ( const Int_t  beamType,
const Int_t  intensity 
) [static]

Definition at line 360 of file NuUtilities.cxx.

References BeamType::kL010z000i, BeamType::kL010z000i_i209, BeamType::kL010z000i_i225, BeamType::kL010z000i_i232, BeamType::kL010z000i_i259, BeamType::kL010z000i_i300, BeamType::kL010z000i_i317, BeamType::kL010z000i_i326, BeamType::kL010z000i_i380, BeamType::kL010z185i, BeamType::kL010z185i_i124, BeamType::kL010z185i_i191, BeamType::kL010z185i_i213, BeamType::kL010z185i_i224, BeamType::kL010z185i_i232, BeamType::kL010z185i_i240, BeamType::kL010z185i_i243, BeamType::kL010z185i_i257, BeamType::kL010z185i_i282, BeamType::kL010z185i_i300, BeamType::kL010z185i_i303, BeamType::kL010z185i_i324, BeamType::kL010z185i_i361, BeamType::kL010z185i_i480, BeamType::kL010z185i_i600, BeamType::kL010z185i_rev, BeamType::kL010z185i_rev_i200, BeamType::kL010z185i_rev_i277, BeamType::kL010z185i_rev_i306, BeamType::kL010z185i_rev_i312, BeamType::kL010z185i_rev_i314, BeamType::kL010z185i_rev_i348, BeamType::kL010z185i_rev_i349, BeamType::kL010z185i_rev_i353, BeamType::kL010z185i_rev_i410, BeamType::kL250z200i, BeamType::kL250z200i_i100, BeamType::kL250z200i_i114, BeamType::kL250z200i_i130, BeamType::kL250z200i_i152, BeamType::kL250z200i_i165, BeamType::kL250z200i_i194, BeamType::kL250z200i_i232, BeamType::kM000z200i_i090, BeamType::kM000z200i_i100, BeamType::kM000z200i_i240, BeamType::kM000z200i_i250, BeamType::kM000z200i_i417, BeamType::kM000z200i_i471, BeamType::kM000z200i_i490, BeamType::kM000z200i_i750, BeamType::kM000z200i_nova, BeamType::kUnknown, Msg::kWarning, and MSG.

Referenced by ReturnConventionsBeamType().

00361 {
00362   BeamType::BeamType_t originalBeamType =
00363     static_cast<BeamType::BeamType_t>(beamType);
00364   if (0==intensity){
00365     return originalBeamType;
00366   }
00367   if (BeamType::kL010z185i == originalBeamType){
00368     if (124==intensity){
00369       return BeamType::kL010z185i_i124;
00370     }
00371     else if (191==intensity){
00372       return BeamType::kL010z185i_i191;
00373     }
00374     else if (213==intensity){
00375       return BeamType::kL010z185i_i213;
00376     }
00377     else if (224==intensity){
00378       return BeamType::kL010z185i_i224;
00379     }
00380     else if (232==intensity){
00381       return BeamType::kL010z185i_i232;
00382     }
00383     // test intensity
00384     else if (240==intensity){
00385       return BeamType::kL010z185i_i240;
00386     }
00387     else if (243==intensity){
00388       return BeamType::kL010z185i_i243;
00389     }
00390     else if (257==intensity){
00391       return BeamType::kL010z185i_i257;
00392     }
00393     else if (282==intensity){
00394       return BeamType::kL010z185i_i282;
00395     }
00396     else if (300==intensity){
00397       return BeamType::kL010z185i_i300;
00398     }
00399     else if (303==intensity){
00400       return BeamType::kL010z185i_i303;
00401     }
00402     else if (324==intensity){
00403       return BeamType::kL010z185i_i324;
00404     }
00405     else if (361==intensity){
00406       return BeamType::kL010z185i_i361;
00407     }
00408     // test intensity
00409     else if (480==intensity){
00410       return BeamType::kL010z185i_i480;
00411     }
00412     else if (600==intensity){
00413       return BeamType::kL010z185i_i600;
00414     }
00415     else {
00416       MSG("NuUtilities",Msg::kWarning)
00417         << "Received an L010z185i beam type with unrecognized intensity. Intensity = "
00418         << intensity
00419         << endl;
00420       return BeamType::kUnknown;
00421     }
00422   }
00423 
00424   if (BeamType::kL010z000i == originalBeamType){
00425     if (209 == intensity){
00426       return BeamType::kL010z000i_i209;
00427     }
00428     else if (225 == intensity){
00429       return BeamType::kL010z000i_i225;
00430     }
00431     else if (232 == intensity){
00432       return BeamType::kL010z000i_i232;
00433     }
00434     else if (259 == intensity){
00435       return BeamType::kL010z000i_i259;
00436     }
00437     else if (300 == intensity){
00438       return BeamType::kL010z000i_i300;
00439     }
00440     else if (317 == intensity){
00441       return BeamType::kL010z000i_i317;
00442     }
00443     else if (326 == intensity){
00444       return BeamType::kL010z000i_i326;
00445     }
00446     else if (380 == intensity){
00447       return BeamType::kL010z000i_i380;
00448     }
00449     else {
00450       MSG("NuUtilities",Msg::kWarning)
00451         << "Received an L010z000i beam type with unrecognized intensity."
00452         << endl;
00453       return BeamType::kUnknown;
00454     }
00455   }
00456 
00457   if (BeamType::kL250z200i == originalBeamType){
00458     if (100 == intensity){
00459       return BeamType::kL250z200i_i100;
00460     }
00461     else if (114 == intensity){
00462       return BeamType::kL250z200i_i114;
00463     }
00464     else if (130 == intensity){
00465       return BeamType::kL250z200i_i130;
00466     }
00467     else if (152 == intensity){
00468       return BeamType::kL250z200i_i152;
00469     }
00470     else if (165 == intensity){
00471       return BeamType::kL250z200i_i165;
00472     }
00473     else if (194 == intensity){
00474       return BeamType::kL250z200i_i194;
00475     }
00476     else if (232 == intensity){
00477       return BeamType::kL250z200i_i232;
00478     }
00479     else {
00480       MSG("NuUtilities",Msg::kWarning)
00481         << "Received an L250z200i beam type with unrecognized intensity."
00482         << endl;
00483       return BeamType::kUnknown;
00484     }
00485   }
00486 
00487   if(BeamType::kL010z185i_rev == originalBeamType){
00488     if(277 == intensity){
00489       return BeamType::kL010z185i_rev_i277;
00490     }
00491     else if(314 == intensity){
00492       return BeamType::kL010z185i_rev_i314;
00493     }
00494     else if(349 == intensity){
00495       return BeamType::kL010z185i_rev_i349;
00496     }
00497     else if(312 == intensity){
00498       return BeamType::kL010z185i_rev_i312;
00499     }
00500     else if(348 == intensity){
00501       return BeamType::kL010z185i_rev_i348;
00502     }
00503     else if(306 == intensity){
00504       return BeamType::kL010z185i_rev_i306;
00505     }
00506     else if(353 == intensity){
00507       return BeamType::kL010z185i_rev_i353;
00508     }
00509     else if(200 == intensity){
00510       return BeamType::kL010z185i_rev_i200;
00511     }
00512     else if(410 == intensity){
00513       return BeamType::kL010z185i_rev_i410;
00514     }
00515     else {
00516       MSG("NuUtilities",Msg::kWarning)
00517         << "Received an L010z185i_rev beam type with unrecognized intensity."
00518         << endl;
00519       return BeamType::kUnknown;
00520     }
00521   }
00522 
00523   if(BeamType::kM000z200i_nova == originalBeamType){
00524     if(90 == intensity){
00525       return BeamType::kM000z200i_i090;
00526     }
00527     else if(100 == intensity){
00528       return BeamType::kM000z200i_i100;
00529     }
00530     else if(240 == intensity){
00531       return BeamType::kM000z200i_i240;
00532     }
00533     else if(250 == intensity){
00534       return BeamType::kM000z200i_i250;
00535     }
00536     else if(417 == intensity){
00537       return BeamType::kM000z200i_i417;
00538     }
00539     else if(471 == intensity){
00540       return BeamType::kM000z200i_i471;
00541     }
00542     else if(490 == intensity){
00543       return BeamType::kM000z200i_i490;
00544     }
00545     else if(750 == intensity){
00546       return BeamType::kM000z200i_i750;
00547     }
00548     else {
00549       MSG("NuUtilities",Msg::kWarning)
00550         << "Received an kM000z200i_nova beam type with unrecognized intensity."
00551         << endl;
00552       return BeamType::kUnknown;
00553     }
00554   }
00555 
00556   MSG("NuUtilities",Msg::kWarning)
00557     << "Received a non-zero intensity flag, along with a beam "
00558     << "type not configured for intensity weighting."
00559     << endl;
00560   return BeamType::kUnknown;
00561 
00562 }

static Double_t NuUtilities::DistanceTargetToND (  )  [inline, static]
void NuUtilities::FixDogwoodQP ( NuEvent nu  )  [static]

Definition at line 1292 of file NuUtilities.cxx.

References NuEvent::charge, NuReco::GetEvtEnergy(), NuLibrary::Instance(), ReleaseType::IsDogwood(), Msg::kInfo, MAXMSG, PrintRelease(), NuEvent::qp, NuEvent::qp_rangebiased, NuEvent::qp_sigqp, NuLibrary::reco, NuEvent::recoVersion, NuEvent::sigqp, and NuEvent::sigqp_qp.

Referenced by NuDSTAna::QPStudy(), and NuDSTAna::SelectorTable().

01293 {
01294   // Only need to fix dogwood NuEvent's
01295   if (!ReleaseType::IsDogwood(nu.recoVersion)) {
01296     MAXMSG("NuUtilities",Msg::kInfo,5) << "Not correcting q/p for "
01297     << PrintRelease(nu.recoVersion) << endl;
01298     return;
01299   }
01300   MAXMSG("NuUtilities",Msg::kInfo,5) << "Correcting "
01301   << PrintRelease(nu.recoVersion) << " q/p from "
01302   << nu.qp << " to " << nu.qp_rangebiased << endl;
01303 
01304   nu.qp = nu.qp_rangebiased;
01305   if (nu.sigqp == 0) nu.qp_sigqp = 0;
01306   else               nu.qp_sigqp = nu.qp_rangebiased / nu.sigqp;
01307 
01308   for(int trkIdx = 1; trkIdx <= 3; ++trkIdx){
01309     get_qp(nu, trkIdx) = get_qp_rangebiased(nu, trkIdx);
01310     if(get_sigqp(nu, trkIdx) != 0){
01311       get_qp_sigqp(nu, trkIdx) =
01312         get_qp_rangebiased(nu, trkIdx) / get_sigqp(nu, trkIdx);
01313     }
01314   }
01315 
01316   if (nu.qp_sigqp == 0) nu.sigqp_qp = 0;
01317   else                  nu.sigqp_qp = 1./nu.qp_sigqp;
01318 
01319   NuLibrary& lib=NuLibrary::Instance();
01320   lib.reco.GetEvtEnergy(nu, false);
01321 
01322   if (nu.qp_rangebiased > 0) nu.charge = 1;
01323   else                       nu.charge = -1;
01324 }

vector< Double_t > NuUtilities::GenerateBins ( int  ngroups,
double  edges[],
double  steps[] 
) [static]

Definition at line 565 of file NuUtilities.cxx.

References Munits::g.

Referenced by NuMatrixSpectrum::RebinForFit(), NuMatrixSpectrum::RebinForPlotAsFit(), NuMatrixSpectrum::RebinForPlots(), NuMatrixSpectrum::RebinToGeV(), and RecoBins().

00566 {
00567     vector<Double_t> bins;
00568     for (int g = 0; g < ngroups; g++) {
00569         Double_t lowEdge = edges[g];
00570         Double_t highEdge = edges[g+1];
00571         Double_t binWidth = steps[g];
00572         for (Double_t binEdge = lowEdge;
00573              binEdge < highEdge - (binWidth/2.0);
00574              binEdge += binWidth){
00575             bins.push_back(binEdge);
00576         }
00577     }
00578     bins.push_back(edges[ngroups]);
00579     return bins;
00580 }

Double_t NuUtilities::GetChisqFromCL ( double  cl = 0.6827,
int  n = 1 
) [static]

Definition at line 1390 of file NuUtilities.cxx.

Referenced by GetChisqFromSigma().

01391 {
01392 
01393   if(n<2) return 2*pow(TMath::ErfInverse(cl),2);
01394 
01395    // Create the function and wrap it
01396    TF1 f("C.L. from Chisq", "TMath::Gamma(0.5*[0],0.5*x)", 0, 2*n+50);
01397    f.SetParameter(0,n);
01398    f.SetNpx(4);
01399  
01400    return f.GetX(cl);
01401 
01402 }

Double_t NuUtilities::GetChisqFromSigma ( double  s = 1,
int  n = 1 
) [static]

Definition at line 1406 of file NuUtilities.cxx.

References GetChisqFromCL().

01407 {
01408 
01409   if(n<2) return s*s;
01410 
01411   double cl = TMath::Erf(s/sqrt(2));
01412   
01413   return GetChisqFromCL(cl,n);
01414 
01415 }

int NuUtilities::GetDigit ( int  num,
int  d 
) [static]

Definition at line 1437 of file NuUtilities.cxx.

Referenced by NuExtraction::ExtractCoilInfo().

01438 {
01439   int pow1 = static_cast<int>(TMath::Power(10, d));
01440   int pow2 = pow1 / 10;
01441   return (num % pow1 - num % pow2) / pow2;
01442 }

std::vector< TString > NuUtilities::GetListOfFilesInDir ( const TString &  wildcardString  )  [static]

Definition at line 1328 of file NuUtilities.cxx.

References Munits::g.

Referenced by NuFluxHelper::ConcatenateHelpers(), and NuFluxHelper::MakeHelperHistos().

01329 {
01330   std::vector<TString> fileList;
01331 
01332   glob_t g;
01333   glob(wildcardString.Data(),
01334        // GLOB_NOCHECK | // If no match return pattern
01335        GLOB_TILDE, // Expand ~'s
01336        0, &g);
01337   for(unsigned int i = 0; i < g.gl_pathc; ++i)
01338     fileList.push_back(g.gl_pathv[i]);
01339   globfree(&g);
01340 
01341   // glob output is sorted by default
01342 
01343   return fileList;
01344 }

const TH1D NuUtilities::IntegralMarginalize ( const TH2D *  surf,
const char  axis = 'y' 
) [static]

Definition at line 1483 of file NuUtilities.cxx.

References Msg::kError, and MSG.

01484 {
01485   bool doY;
01486   if (axis == 'y' || axis == 'Y')  doY = true;
01487   else if (axis == 'x' || axis == 'X') doY = false;
01488   else {
01489     MSG("NuUtilities",Msg::kError) << "Axis " << axis << "not recognized. Only x, X, y, Y are allowed axes." << endl;
01490     TH1D blank;    return blank;
01491   }
01492 
01493   TH1D * marginSurf;
01494   TString name = surf->GetName();
01495 
01496   // Use root's built in projections to do the integrals, excluding Under/overflow
01497   if (doY) {
01498     marginSurf = surf->ProjectionY(name+"_intMarginY", 1, surf->GetNbinsX());
01499     marginSurf->Scale(1./surf->GetNbinsX());
01500   }
01501   else {
01502     marginSurf = surf->ProjectionX(name+"_intMarginX", 1, surf->GetNbinsY());
01503     marginSurf->Scale(1./surf->GetNbinsY());
01504   }
01505 
01506   // Subtract off the minimum bin to get a deltaChisquared
01507   // Not *exactly* correct but should be pretty close in bins are
01508   // relatively small
01509   double allMin = marginSurf->GetMinimum();
01510   for (int b = 0; b <= marginSurf->GetNbinsX()+1; b++) {
01511     double val = marginSurf->GetBinContent(b) - allMin;
01512     marginSurf->SetBinContent(b, val);
01513   }
01514 
01515   return *marginSurf;
01516 }

Double_t NuUtilities::LogLikelihood ( Double_t  data,
Double_t  MC 
) [static]

Definition at line 1347 of file NuUtilities.cxx.

References MuELoss::e.

Referenced by NuMatrix2D::StatsLikelihood(), NuMatrix1D::StatsLikelihood(), and NuMMRun::StatsLikelihood().

01348 {
01349 
01350   if( isnan(mnu) || isnan(dnu) || dnu < 0 ){
01351     cout << "Error: MC or Data are not valid numbers!!!" << endl;
01352     return 1e12;
01353   }
01354 
01355   const Double_t MCError = 1e-12;
01356   if (dnu) {
01357     // Protection against cases where there is data but no MC?
01358     // This should not normally be possible, other than highly contrived
01359     // unphysical oscillation values.
01360     // Set the value to something lower than POT_Data / POT_MC, which at the
01361     // moment is usually 1e-3. We can justify this as an error on the MC
01362     // Set to a 2nd order expansion around MCError.
01363     // Also protects against negative MC events
01364 
01365     if (mnu < MCError){
01366       //cout << "MC Error: MC = " << mnu << endl;
01367       return 2*(mnu-dnu+dnu*log(dnu/MCError)) + dnu*(3-4*mnu/MCError+pow(mnu/MCError,2));
01368     }
01369 
01370     // We have both values. Do the proper lnL!
01371     return 2*(mnu - dnu + dnu*log(dnu/mnu));
01372   }
01373   else {
01374     // dnu is zero, mnu may or may not be zero
01375     // Protect against negative numbers by setting to a
01376     // quadratic function that matches Loglikelihood up
01377     // to 1st order at MCError and has minimum at mnu=0
01378 
01379     if (mnu < MCError){
01380       //cout << "MC Error: MC = " << mnu << endl;
01381       return mnu*mnu/MCError + MCError;
01382     }
01383 
01384     return 2*mnu;
01385   }
01386 }

const TH1D NuUtilities::MinimumMarginalize ( const TH2D *  surf,
const char  axis = 'y' 
) [static]

Definition at line 1520 of file NuUtilities.cxx.

References Msg::kError, min, and MSG.

01521 {
01522   bool doY;
01523   if (axis == 'y' || axis == 'Y')  doY = true;
01524   else if (axis == 'x' || axis == 'X') doY = false;
01525   else {
01526     MSG("NuUtilities",Msg::kError) << "Axis " << axis << "not recognized. Only x, X, y, Y are allowed axes." << endl;
01527     TH1D blank;    return blank;
01528   }
01529 
01530   TH1D * marginSurf;
01531   TString name = surf->GetName();
01532 
01533   int bKeepMax;
01534   int bMargMax;
01535   // Use root's built in projections to define the axis ranges, reset contents
01536   if (doY) {
01537     marginSurf = surf->ProjectionY(name+"_minMarginY", 1, surf->GetNbinsX());
01538     bKeepMax = surf->GetNbinsY(); // Keep Y
01539     bMargMax = surf->GetNbinsX(); // Marginalize X
01540   }
01541   else {
01542     marginSurf = surf->ProjectionX(name+"_minMarginX", 1, surf->GetNbinsY());
01543     bKeepMax = surf->GetNbinsX(); // Keep X
01544     bMargMax = surf->GetNbinsY(); // Marginalize Y
01545   }
01546   marginSurf->Reset();
01547 
01548   double allMin = 1.e10;
01549   double rowMin;
01550   int bx, by;
01551   for (int bk = 1; bk < bKeepMax; bk++) {
01552     rowMin = 1.e10;
01553     for (int bm = 1; bm < bMargMax; bm++) {
01554       if (doY) {
01555         bx = bm; // Marginalize X
01556         by = bk; // Keep Y
01557       }
01558       else {
01559         bx = bk; // Keep X
01560         by = bm; // Marginalize Y
01561       }
01562       rowMin = min(surf->GetBinContent(bx, by), rowMin);
01563       allMin = min(rowMin, allMin);
01564     }
01565     marginSurf->SetBinContent(bk, rowMin);
01566   }
01567 
01568   // Subtract off the minimum bin to get a deltaChisquared
01569   // Not *exactly* correct but should be pretty close in bins are
01570   // relatively small
01571   for (int bk = 1; bk < bKeepMax; bk++) {
01572     double val = marginSurf->GetBinContent(bk) - allMin;
01573     marginSurf->SetBinContent(bk, val);
01574   }
01575 
01576   return *marginSurf;
01577 }

void NuUtilities::OscillateJesstogram ( TH2D *  h,
double  dm2,
double  sn2 
) [static]

Definition at line 1418 of file NuUtilities.cxx.

References n, one(), NuMatrixSpectrum::Oscillate(), and NuMatrixSpectrum::Spectrum().

01419 {
01420   const int Nx = h->GetNbinsX();
01421   const int Ny = h->GetNbinsY();
01422 
01423   TH1D one("", "", Nx, h->GetXaxis()->GetXbins()->GetArray());
01424   for(int n = 0; n < Nx+2; ++n) one.SetBinContent(n, 1);
01425 
01426   NuMatrixSpectrum osc(one);
01427   osc.Oscillate(dm2, sn2);
01428 
01429   for(int x = 0; x < Nx+2; ++x){
01430     for(int y = 0; y < Ny+2; ++y){
01431       h->SetBinContent(x, y, h->GetBinContent(x, y)*osc.Spectrum()->GetBinContent(x));
01432     }
01433   }
01434 }

TString NuUtilities::PrintRelease ( int  releaseType  )  [static]

Definition at line 326 of file NuUtilities.cxx.

References bfld::AsString().

Referenced by NuAnalysis::ExtractConfig(), FixDogwoodQP(), NuPIDInterface::GetFileNameAbID(), NuPIDInterface::GetFileNamekNNID(), NuZBeamReweight::GetWeightHelium(), NuAnalysis::LIRejectionTest(), NuDSTAna::MakeMicroDstHe(), NuPIDInterface::PrintReleaseTypeEtc(), and NuAnalysis::SetAnaFlags().

00327 {
00328   char hexnum[20];
00329   sprintf(hexnum, "%x", releaseType);
00330   TString ret = ReleaseType::AsString(releaseType);
00331   ret += " (0x";
00332   ret += hexnum;
00333   ret += ", ";
00334   ret += releaseType;
00335   ret += ")";
00336   return ret;
00337 }

void NuUtilities::ProgressBar ( Int_t  entry,
Float_t  nEntriesF,
Int_t  mintime = 0 
) [static]

Prints a progress bar with ETA. Not fully finished yet, still has issues with printing when the output is directed somewhere other than the console

Definition at line 1713 of file NuUtilities.cxx.

References Munits::bar, MuELoss::e, Msg::kInfo, MSG, and stat.

Referenced by NuFCEventManager::AddFile(), NuSystFitter::Chi2ValleyDm2(), NuSystFitter::Chi2ValleySn2(), NuSystFitter::FillAlphaBeta(), NuSystFitter::FillCPT(), NuSystFitter::FillLikelihoodSurfaceCPT(), NuSystFitter::FillLikelihoodSurfaceGeneric(), NuSystFitter::FillLikelihoodSurfaceNSIDm2Eps(), NuSystFitter::FillLikelihoodSurfaceNSIDm2Sn2(), NuSystFitter::FillLikelihoodSurfaceNSISn2Eps(), NuSystFitter::FillLikelihoodSurfaceTransDm2BarGMu(), NuSystFitter::FillLikelihoodSurfaceTransDm2BarSn2Bar(), NuSystFitter::FillLikelihoodSurfaceTransDm2GMu(), NuSystFitter::FillLikelihoodSurfaceTransDm2GMuBoth(), NuSystFitter::FillLikelihoodSurfaceTransDm2Sn2(), NuSystFitter::FillLikelihoodSurfaceTransDm2Sn2Both(), NuSystFitter::FillLikelihoodSurfaceTransSn2BarGMu(), NuSystFitter::FillLikelihoodSurfaceTransSn2GMu(), NuSystFitter::FillLikelihoodSurfaceTransSn2GMuBoth(), DataMCPlots::MakeDataPlots(), FoverNHistos::MakeDataPlots(), ToFPlotter::MakeDataPlots(), DataStabilityAnalysisClass::MakePlots(), TemplateAnalysisClass::MakePlots(), FitTree::MakeVectors(), NuDSTAna::MMRereco(), and NuDSTAna::MMTransSME().

01714 {
01715   Int_t nEntries = (Int_t)nEntriesF;
01716 
01717   // Are we streaming to a file? If so, show the old style
01718   struct stat buf;
01719   fstat(fileno(stdout), &buf);
01720   // Check if we are a file, or a pipe (i.e. in case the user tees)
01721   const bool isFile = buf.st_mode & (S_IFREG | S_IFIFO) ;
01722   if (isFile) {
01723     Float_t fract = ceil(nEntries/20.);
01724     if (ceil(((Float_t)entry)/fract)==((Float_t)entry)/fract)
01725     {
01726         MSG("NuUtilities",Msg::kInfo)
01727           <<"Fraction of loop complete: "<<entry
01728           <<"/"<<nEntries<<"  ("
01729           <<(Int_t)(100.*entry/nEntries)<<"%)"<<endl;
01730     }
01731     return;
01732   }
01733 
01734 
01735   // How wide should we make the progress bar?
01736   const Int_t width = 70;
01737   // How long is the string for entries?
01738   static Int_t countlen = -1;
01739   // How long is our progress bar?
01740   static Int_t barlen = -1;
01741   // The entry number of the next bar entry
01742   static Int_t nextbar = -1;
01743   // When did we start?
01744   static time_t starttime = 0;
01745   // when do we next update?
01746   static time_t nextupdate = 0;
01747   // If we are processing the first entry, reset everything
01748   if (entry <= 1)
01749   {
01750     // Get the new length of the entry string
01751     countlen = (Int_t)TMath::Ceil(TMath::Log10(nEntries)) + 1;
01752     nextbar = -1;
01753     starttime = time(NULL);
01754 
01755     barlen = width - 14 - countlen*2 - 1;
01756 
01757     // Don't update until we get to the minimum time
01758     nextupdate = starttime + mintime;
01759   }
01760 
01761   // Check here to see if we should update; otherwise, return
01762   // Check to see if the bar would update
01763   // or, alternatively, it is time to refresh.
01764   if ((time(NULL) < nextupdate) && (entry < nextbar || (nextbar == -1)))return;
01765   nextupdate = time(NULL) + 10;
01766 
01767   // Because this is used in several places, make it here
01768   Float_t frac = (Float_t)entry / (Float_t)nEntries;
01769 
01770   // Prepare the progress bar string
01771   TString bar;
01772   if (entry <= nEntries)
01773   {
01774     // Work out how many characters we are in
01775     Int_t numeq = TMath::FloorNint(frac*barlen);
01776 
01777     // Work out when the next bar will occur
01778     nextbar = (Int_t)((Float_t)(numeq+1)/(Float_t)barlen*nEntries);
01779     //cout << "Next bar at: " << nextbar << "        " << endl;
01780     bar = TString('=', numeq);
01781     bar += TString(' ', barlen - numeq);
01782   } else if (entry > nEntries) {
01783     // We have gone over. Oh no!
01784     bar = TString('+', barlen);
01785   } else if (entry < 0) {
01786     // Somehow, we are below zero. Handle it nonetheless
01787     bar = TString('-', barlen);
01788   }
01789 
01790 
01791   // Prepare the ETA
01792   Float_t elapsed_time = (Float_t)(time(NULL) - starttime);
01793   Float_t time_left = -60;
01794   if (frac > 1e-6) {
01795     time_left = (elapsed_time / frac) - elapsed_time;
01796   }
01797   Int_t mins, seconds;
01798   mins    = (Int_t)TMath::Floor(time_left / 60.0f);
01799   seconds = (Int_t)TMath::Floor(time_left - (Float_t)(mins*60.0f));
01800   // TString ETA;
01801   ostringstream ETA;
01802 
01803   ETA << "ETA ";
01804   if ((mins < 0 || seconds < 0) || (mins == 0 && seconds == 0)) {
01805     ETA << "--:--";
01806   } else {
01807     ETA << setfill('0') << setw(2) << mins << ":" << setw(2) << seconds;
01808   }
01809 
01810   cout << " Progress: [" << bar << "] "
01811        << setw(countlen) << entry << "/" << nEntries
01812        << " " << ETA.str()
01813        << '\r'
01814        << flush;
01815   // Move to the next line, if this is the final entry!
01816   if (entry == nEntries) {
01817     cout << endl;
01818   }
01819 }

TH1D * NuUtilities::RebinHistogram ( const TH1D *  old,
NuBinningScheme::NuBinningScheme_t  scheme 
) [static]

Definition at line 1285 of file NuUtilities.cxx.

References RebinHistogram(), and RecoBins().

01286 {
01287   vector<Double_t> bins = RecoBins(scheme);
01288   return RebinHistogram(old, bins);
01289 }

TH1D * NuUtilities::RebinHistogram ( const TH1D *  old,
std::vector< Double_t > &  bins 
) [static]

Definition at line 1279 of file NuUtilities.cxx.

References RebinHistogram().

01280 {
01281   return RebinHistogram(old, bins.size()-1, &(bins[0]));
01282 }

TH1D * NuUtilities::RebinHistogram ( const TH1D *  old,
int  nbins,
const double  binedges[999] 
) [static]

Definition at line 1217 of file NuUtilities.cxx.

References count, and MuELoss::e.

Referenced by RebinHistogram(), NuMatrixSpectrum::RebinToArray(), and NuMatrixSpectrum::RebinToScheme().

01218 {
01219   static int count = 0;
01220   TString scount = "";
01221   scount += count++;
01222 
01223   TH1D* newh = new TH1D(old->GetName() + TString("_rebin") + scount, 
01224                         old->GetTitle(), nbins, binedges);
01225   bool ouwarn = true;
01226 
01227   // Floating point comparisons of bin edges don't go well otherwise
01228   const double epsilon = 1e-10;
01229 
01230   // Now, loop over the old histogram and fill the new one
01231   for(Int_t bin = 1; bin <= old->GetNbinsX(); bin++) {
01232 
01233     double oldCent = old->GetBinCenter(bin);
01234     int newbin = newh->GetXaxis()->FindFixBin(oldCent);
01235 
01236     // Make sure that bins do not cross boundaries.
01237     if (newbin > newh->GetNbinsX() || newbin == 0) {
01238       if (ouwarn) {
01239         cout << "Old bin: " << old->GetBinLowEdge(bin) << " - " << old->GetBinLowEdge(bin+1)
01240         << " and maybe others have become under/overflow" << endl;
01241         ouwarn = false;
01242       }
01243     } else if ( old->GetBinLowEdge(bin) + epsilon < newh->GetBinLowEdge(newbin) ||
01244                 old->GetBinLowEdge(bin + 1) > newh->GetBinLowEdge(newbin + 1) + epsilon) {
01245       cout << "Bin edge conflict in bin no's " << bin << ", " << newbin 
01246            << ".  No rebinning performed."
01247            << "  old bin: " << old->GetBinLowEdge(bin) << " - " << old->GetBinLowEdge(bin + 1)
01248            << ", new bin: " << newh->GetBinLowEdge(newbin) << " - " 
01249            << newh->GetBinLowEdge(newbin + 1)
01250            << endl;
01251       TH1D* old_ret = new TH1D(*old);
01252       return old_ret;
01253     }
01254 
01255     double oldCon = old->GetBinContent(bin);
01256     double oldErr = old->GetBinError(bin);
01257     double newCon = newh->GetBinContent(newbin);
01258     double newErr = newh->GetBinError(newbin);
01259 
01260     newCon += oldCon;
01261     newErr = sqrt(newErr*newErr + oldErr*oldErr);
01262     newh->SetBinContent(newbin, newCon);
01263     newh->SetBinError(newbin, newErr);
01264   }
01265 
01266   // Validate
01267   double oldint = old->Integral();
01268   double newint = newh->Integral() + newh->GetBinContent(0)
01269                  + newh->GetBinContent(newh->GetNbinsX()+1);
01270   if (abs(oldint - newint) > 1e-5) {
01271     cout << "Rebinning report: " << oldint << " entries have become " << newint << " events" << endl;
01272   }
01273   //newh->Sumw2();
01274   return newh;
01275 }

vector< Double_t > NuUtilities::RecoBins ( const NuBinningScheme::NuBinningScheme_t  binningScheme  )  [static]

Definition at line 585 of file NuUtilities.cxx.

References GenerateBins(), NuBinningScheme::k0_1GeVTo20, NuBinningScheme::k0_5GeVTo200, NuBinningScheme::kCC0325Std, NuBinningScheme::kCC3flav, NuBinningScheme::kDisplay1GevTo20, NuBinningScheme::kDisplayFD, NuBinningScheme::kDisplayFD2010, NuBinningScheme::kDisplayFD2014, NuBinningScheme::kDisplayFD7e20, NuBinningScheme::kDisplayFDRHC, NuBinningScheme::kDisplayND, Msg::kInfo, NuBinningScheme::kNuMuBar0325Std, NuBinningScheme::kNuMuBar0325Std2, NuBinningScheme::kSterile, NuBinningScheme::kUnknown, and MAXMSG.

Referenced by NuDSTAna::Contamination(), NuDSTAna::ContaminationNQ(), ToFPlotter::CreateCCHistograms(), FoverNHistos::CreateHistograms(), DataStabilityAnalysisClass::CreateHistograms(), ToFPlotter::CreateNCHistograms(), ToFPlotter::CreateRAFHistograms(), NuDSTAna::DPSystematic(), NuHistos::FillMatrixMethodHistos(), NuHistos::FillMatrixMethodNCHistos(), NuPlots::FillSpectra(), NuDSTAna::MakeResolutionBins(), NuDSTAna::NDOsc(), NuDSTAna::NewFieldAna(), NuFCExperimentFactory::NuFCExperimentFactory(), NuFCExperimentFactoryNSI::NuFCExperimentFactoryNSI(), NuMatrixMethod::NuMatrixMethod(), NuTransition::NuTransition(), RebinHistogram(), and NuShiftableUnbinnedSpectrum::Spectrum().

00586 {
00587   if (NuBinningScheme::kUnknown == binningScheme ||
00588       NuBinningScheme::k0_5GeVTo200 == binningScheme){
00589     MAXMSG("NuUtilities",Msg::kInfo,5)
00590       << "Binning reco energy in 0.5 GeV up to 200 GeV" << endl;
00591     vector<Double_t> bins;
00592     Double_t lowEdge = 0.0;
00593     Double_t highEdge = 200.0;
00594     Double_t binWidth = 0.5;
00595     for (Double_t binEdge = lowEdge;
00596          binEdge <= highEdge + (binWidth/2.0);
00597          binEdge += binWidth){
00598       bins.push_back(binEdge);
00599     }
00600     return bins;
00601   } else if (NuBinningScheme::kCC0325Std == binningScheme) {
00602     MAXMSG("NuUtilities",Msg::kInfo,5)
00603       << "Reco energy: one bin from 0.0--0.5, "
00604       << "then 0.25 GeV bins up to 200.0 GeV"
00605       << endl;
00606     vector<Double_t> bins;
00607     bins.push_back(0.0);
00608     Double_t lowEdge = 0.5;
00609     Double_t highEdge = 200.0;
00610     Double_t binWidth = 0.25;
00611     for (Double_t binEdge = lowEdge;
00612          binEdge <= highEdge + (binWidth/2.0);
00613          binEdge += binWidth){
00614       bins.push_back(binEdge);
00615     }
00616     return bins;
00617   } else if (NuBinningScheme::kNuMuBar0325Std == binningScheme) {
00618     MAXMSG("NuUtilities",Msg::kInfo,5)
00619       << "Reco energy: 0.5 GeV up to 30 GeV; 2 GeV up to 50 GeV; "
00620       << "1 bin up to 200 GeV"
00621       << endl;
00622     vector<Double_t> bins;
00623     Double_t lowEdge = 0.0;
00624     Double_t highEdge = 30.0;
00625     Double_t binWidth = 0.5;
00626     for (Double_t binEdge = lowEdge;
00627          binEdge < highEdge - (binWidth/2.0);
00628          binEdge += binWidth){
00629       bins.push_back(binEdge);
00630     }
00631     lowEdge = 30.0;
00632     highEdge = 50.0;
00633     binWidth = 2.0;
00634     for (Double_t binEdge = lowEdge;
00635          binEdge < highEdge - (binWidth/2.0);
00636          binEdge += binWidth){
00637       bins.push_back(binEdge);
00638     }
00639     bins.push_back(50.0);
00640     bins.push_back(200.0);
00641     return bins;
00642   } else if (NuBinningScheme::kNuMuBar0325Std2 == binningScheme) {
00643     MAXMSG("NuUtilities",Msg::kInfo,5)
00644       << "Reco Energy: One 0.5 GeV, then 0.25 GeV up to 20 GeV; "
00645       << "1 Gev to 30 GeV,\n 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
00646       << endl;
00647     vector<Double_t> bins;
00648     bins.push_back(0.0);
00649     Double_t lowEdge = 0.5;
00650     Double_t highEdge = 20.0;
00651     Double_t binWidth = 0.25;
00652     for (Double_t binEdge = lowEdge;
00653           binEdge < highEdge -(binWidth/2.0);
00654           binEdge += binWidth) {
00655       bins.push_back(binEdge);
00656     }
00657     lowEdge = 20.0;
00658     highEdge = 30.0;
00659     binWidth = 1.0;
00660     for (Double_t binEdge = lowEdge;
00661           binEdge < highEdge -(binWidth/2.0);
00662           binEdge += binWidth) {
00663       bins.push_back(binEdge);
00664     }
00665     lowEdge = 30.0;
00666     highEdge = 50.0;
00667     binWidth = 2.0;
00668     for (Double_t binEdge = lowEdge;
00669           binEdge < highEdge -(binWidth/2.0);
00670           binEdge += binWidth) {
00671       bins.push_back(binEdge);
00672     }
00673     bins.push_back(50.0);
00674     bins.push_back(200.0);
00675     return bins;
00676   } else if (NuBinningScheme::kCC3flav == binningScheme) {
00677     MAXMSG("NuUtilities",Msg::kInfo,5)
00678       << "Reco Energy: One 1.0 GeV, then 0.25 GeV up to 20 GeV; "
00679       << "1 Gev to 30 GeV,\n 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
00680       << endl;
00681     vector<Double_t> bins;
00682     bins.push_back(0.0);
00683     Double_t lowEdge = 1.0;
00684     Double_t highEdge = 20.0;
00685     Double_t binWidth = 0.25;
00686     for (Double_t binEdge = lowEdge;
00687           binEdge < highEdge -(binWidth/2.0);
00688           binEdge += binWidth) {
00689       bins.push_back(binEdge);
00690     }
00691     lowEdge = 20.0;
00692     highEdge = 30.0;
00693     binWidth = 1.0;
00694     for (Double_t binEdge = lowEdge;
00695           binEdge < highEdge -(binWidth/2.0);
00696           binEdge += binWidth) {
00697       bins.push_back(binEdge);
00698     }
00699     lowEdge = 30.0;
00700     highEdge = 50.0;
00701     binWidth = 2.0;
00702     for (Double_t binEdge = lowEdge;
00703           binEdge < highEdge -(binWidth/2.0);
00704           binEdge += binWidth) {
00705       bins.push_back(binEdge);
00706     }
00707     bins.push_back(50.0);
00708     bins.push_back(200.0);
00709     return bins;
00710   }else if (NuBinningScheme::kSterile == binningScheme) { //A.Devan 8/29/2012
00711     MAXMSG("NuUtilities",Msg::kInfo,5)
00712       << "Reco Energy: 0.05GeV bin between 0 and 5 GeV, then 0.25 GeV up to 20 GeV; "
00713       << "1 Gev to 30 GeV,\n 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
00714       << endl;
00715     vector<Double_t> bins;
00716     bins.push_back(0.0);
00717         Double_t lowEdge = 0.05;
00718         Double_t highEdge = 5.0;
00719         Double_t binWidth = 0.05;
00720         for (Double_t binEdge = lowEdge;
00721                   binEdge < highEdge - (binWidth/2.0);
00722                   binEdge += binWidth) {
00723           bins.push_back(binEdge);
00724         }
00725         lowEdge = 5.0;
00726     highEdge = 20.0;
00727     binWidth = 0.25;
00728     for (Double_t binEdge = lowEdge;
00729           binEdge < highEdge -(binWidth/2.0);
00730           binEdge += binWidth) {
00731       bins.push_back(binEdge);
00732     }
00733     lowEdge = 20.0;
00734     highEdge = 30.0;
00735     binWidth = 1.0;
00736     for (Double_t binEdge = lowEdge;
00737           binEdge < highEdge -(binWidth/2.0);
00738           binEdge += binWidth) {
00739       bins.push_back(binEdge);
00740     }
00741     lowEdge = 30.0;
00742     highEdge = 50.0;
00743     binWidth = 2.0;
00744     for (Double_t binEdge = lowEdge;
00745           binEdge < highEdge -(binWidth/2.0);
00746           binEdge += binWidth) {
00747       bins.push_back(binEdge);
00748     }
00749     bins.push_back(50.0);
00750     bins.push_back(200.0);
00751     return bins;
00752   } else if (NuBinningScheme::kDisplayFD == binningScheme) {
00753     MAXMSG("NuUtilities",Msg::kInfo,5)
00754     << "Reco Energy: 4 GeV Bins up to 20 GeV, then 20, 30, 50, 200"
00755     << endl;
00756     vector<Double_t> bins;
00757     Double_t lowEdge = 0.0;
00758     Double_t highEdge = 20.0;
00759     Double_t binWidth = 4;
00760     for (Double_t binEdge = lowEdge;
00761          binEdge < highEdge -(binWidth/2.0);
00762          binEdge += binWidth) {
00763       bins.push_back(binEdge);
00764     }
00765     bins.push_back(20.0);
00766     bins.push_back(30.0);
00767     bins.push_back(50.0);
00768     bins.push_back(200.0);
00769     return bins;
00770   } else if (NuBinningScheme::kDisplayND == binningScheme) {
00771     MAXMSG("NuUtilities",Msg::kInfo,5)
00772     << "Reco Energy: 1 Gev to 30 GeV, 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
00773     << endl;
00774     vector<Double_t> bins;
00775     Double_t lowEdge = 0.0;
00776     Double_t highEdge = 20.0;
00777     Double_t binWidth = 1.0;
00778     for (Double_t binEdge = lowEdge;
00779          binEdge < highEdge -(binWidth/2.0);
00780          binEdge += binWidth) {
00781       bins.push_back(binEdge);
00782     }
00783     lowEdge = 20.0;
00784     highEdge = 30.0;
00785     binWidth = 2.0;
00786     for (Double_t binEdge = lowEdge;
00787          binEdge < highEdge -(binWidth/2.0);
00788          binEdge += binWidth) {
00789       bins.push_back(binEdge);
00790     }
00791     lowEdge = 30.0;
00792     highEdge = 50.0;
00793     binWidth = 4.0;
00794     for (Double_t binEdge = lowEdge;
00795          binEdge < highEdge -(binWidth/2.0);
00796          binEdge += binWidth) {
00797       bins.push_back(binEdge);
00798     }
00799     bins.push_back(50.0);
00800     bins.push_back(200.0);
00801     return bins;
00802   } else if (NuBinningScheme::kDisplayFDRHC == binningScheme) {
00803       double edges[] = {0, 10, 20, 30,  50, 200};
00804       double steps[] = {  1, 5, 10, 20, 150};
00805       int ng = 5;
00806 
00807       std::vector<Double_t> bins = NuUtilities::GenerateBins(ng, edges, steps);
00808       return bins;
00809   } else if(NuBinningScheme::kDisplayFD2010 == binningScheme){
00810     double edges[] = {0, 1, 5, 10, 20, 30, 50, 200};
00811     double steps[] = {1/*.5*/, .25, .5, 1, 10, 20, 130};
00812     int ng = 7;
00813 
00814     vector<double> bins = NuUtilities::GenerateBins(ng, edges, steps);
00815     return bins;
00816   } else if(NuBinningScheme::kDisplayFD2014 == binningScheme){
00817     double edges[] = {0, 1.5, 10, 20, 30, 50, 200};
00818     double steps[] = {1.5, 0.5, 2, 10, 20, 130};
00819     int ng = 6;
00820 
00821     vector<double> bins = NuUtilities::GenerateBins(ng, edges, steps);
00822     return bins;
00823   } else if(NuBinningScheme::kDisplayFD2014 == binningScheme){
00824     double edges[] = {0, 1.5, 10, 20, 30, 50, 200};
00825     double steps[] = {1.5, 0.5, 2, 10, 20, 130};
00826     int ng = 6;
00827 
00828     vector<double> bins = NuUtilities::GenerateBins(ng, edges, steps);
00829     return bins;
00830   } else if(NuBinningScheme::kDisplayFD7e20 == binningScheme){
00831       double edges[] = {0, 20, 30, 50, 200};
00832       double steps[] = {  2, 5, 20, 150};
00833       int ng = 4;
00834 
00835     vector<double> bins = NuUtilities::GenerateBins(ng, edges, steps);
00836     return bins;
00837   } else if(NuBinningScheme::kDisplay1GevTo20 == binningScheme) {
00838     MAXMSG("NuUtilities", Msg::kInfo, 5)
00839     << "Reco Energy: 0 Gev to 20 GeV in 1 GeV bins, plus a single 20--200 GeV bin"
00840     << endl;
00841     vector<Double_t> bins;
00842     Double_t lowEdge = 0.0;
00843     Double_t highEdge = 20.0;
00844     Double_t binWidth = 1.0;
00845     for (Double_t binEdge = lowEdge;
00846          binEdge < highEdge - (binWidth / 2.0);
00847          binEdge += binWidth) {
00848       bins.push_back(binEdge);
00849     }
00850     bins.push_back(20.0);
00851     bins.push_back(50.0);
00852     bins.push_back(200.0);
00853 
00854     return bins;
00855   } else if (NuBinningScheme::k0_1GeVTo20 == binningScheme) {
00856     MAXMSG("NuUtilities",Msg::kInfo,5)
00857       << "Reco Energy: 0.10 GeV up to 20 GeV; "
00858       << "1 Gev to 30 GeV, 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
00859       << endl;
00860     vector<Double_t> bins;
00861     Double_t lowEdge = 0.0;
00862     Double_t highEdge = 20.0;
00863     Double_t binWidth = 0.1;
00864     for (Double_t binEdge = lowEdge;
00865           binEdge < highEdge -(binWidth/2.0);
00866           binEdge += binWidth) {
00867       bins.push_back(binEdge);
00868     }
00869     lowEdge = 20.0;
00870     highEdge = 30.0;
00871     binWidth = 1.0;
00872     for (Double_t binEdge = lowEdge;
00873           binEdge < highEdge -(binWidth/2.0);
00874           binEdge += binWidth) {
00875       bins.push_back(binEdge);
00876     }
00877     lowEdge = 30.0;
00878     highEdge = 50.0;
00879     binWidth = 2.0;
00880     for (Double_t binEdge = lowEdge;
00881           binEdge < highEdge -(binWidth/2.0);
00882           binEdge += binWidth) {
00883       bins.push_back(binEdge);
00884     }
00885     bins.push_back(50.0);
00886     bins.push_back(200.0);
00887     return bins;
00888   } else {
00889     MAXMSG("NuUtilities",Msg::kInfo,100)
00890     << "!!Invalid binning scheme (" << binningScheme << ") requested.!!" << endl
00891     << "Binning reco energy in 0.5 GeV up to 200 GeV" << endl;
00892     vector<Double_t> bins;
00893     Double_t lowEdge = 0.0;
00894     Double_t highEdge = 200.0;
00895     Double_t binWidth = 0.5;
00896     for (Double_t binEdge = lowEdge;
00897          binEdge <= highEdge + (binWidth/2.0);
00898          binEdge += binWidth){
00899       bins.push_back(binEdge);
00900     }
00901     return bins;
00902   }
00903 } // RecoBins

BeamType::BeamType_t NuUtilities::ReturnConventionsBeamType ( const NuConfig config  )  [static]

Definition at line 342 of file NuUtilities.cxx.

References NuConfig::beamType, ConvertToConventionsBeamType(), NuConfig::detector, NuConfig::intensity, SimFlag::kData, Detector::kFar, Msg::kInfo, MAXMSG, and NuConfig::simFlag.

Referenced by NuBeam::IsGoodSpillAndFillPot().

00343 {
00344   if (Detector::kFar==config.detector && SimFlag::kData==config.simFlag){
00345     MAXMSG("NuUtilities",Msg::kInfo,1)
00346       << "Detected FD data, so not combining intensity with beamType"
00347       << endl;
00348     BeamType::BeamType_t originalBeamType =
00349       static_cast<BeamType::BeamType_t>(config.beamType);
00350     return originalBeamType;
00351   }
00352   else{
00353     return NuUtilities::ConvertToConventionsBeamType(config.beamType,
00354                                                      config.intensity);
00355   }
00356 }

vector< Double_t > NuUtilities::TrueBins ( const NuBinningScheme::NuBinningScheme_t  binningScheme  )  [static]

Definition at line 907 of file NuUtilities.cxx.

References NuBinningScheme::k0_1GeVTo20, NuBinningScheme::k0_5GeVTo200, NuBinningScheme::kCC0325Std, NuBinningScheme::kCC3flav, NuBinningScheme::kDisplayFD, NuBinningScheme::kDisplayND, Msg::kInfo, NuBinningScheme::kNuMuBar0325Std, NuBinningScheme::kNuMuBar0325Std2, NuBinningScheme::kUnknown, and MAXMSG.

Referenced by FoverNHistos::CreateHistograms(), NuHistos::FillMatrixMethodHistos(), NuHistos::FillMatrixMethodNCHistos(), NuPlots::FillTrueFidEnergySpect(), NuDSTAna::NewFieldAna(), NuFCExperimentFactory::NuFCExperimentFactory(), NuFCExperimentFactoryNSI::NuFCExperimentFactoryNSI(), NuFluxHelper::NuFluxHelper(), NuMatrixMethod::NuMatrixMethod(), and NuTransition::NuTransition().

00908 {
00909   if (NuBinningScheme::kUnknown == binningScheme ||
00910       NuBinningScheme::k0_5GeVTo200 == binningScheme){
00911     MAXMSG("NuUtilities",Msg::kInfo,5)
00912       << "Binning true energy in 0.5 GeV up to 200 GeV" << endl;
00913     vector<Double_t> bins;
00914     Double_t lowEdge = 0.0;
00915     Double_t highEdge = 200.0;
00916     Double_t binWidth = 0.5;
00917     for (Double_t binEdge = lowEdge;
00918          binEdge <= highEdge + (binWidth/2.0);
00919          binEdge += binWidth){
00920       bins.push_back(binEdge);
00921     }
00922     return bins;
00923   }
00924   else if (NuBinningScheme::kCC0325Std == binningScheme){
00925     MAXMSG("NuUtilities",Msg::kInfo,5)
00926       << "True energy: one bin from 0.0--0.5, "
00927       << "then 0.25 GeV bins up to 200.0 GeV"
00928       << endl;
00929     vector<Double_t> bins;
00930     bins.push_back(0.0);
00931     Double_t lowEdge = 0.5;
00932     Double_t highEdge = 200.0;
00933     Double_t binWidth = 0.25;
00934     for (Double_t binEdge = lowEdge;
00935          binEdge <= highEdge + (binWidth/2.0);
00936          binEdge += binWidth){
00937       bins.push_back(binEdge);
00938     }
00939     return bins;
00940   }
00941   else if (NuBinningScheme::kCC3flav == binningScheme) {
00942     MAXMSG("NuUtilities",Msg::kInfo,5)
00943       << "True Energy: 0.05 GeV up to 5 GeV, then 0.25 GeV up to 20 GeV; "
00944       << "1 Gev to 30 GeV,\n 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
00945       << endl;
00946     vector<Double_t> bins;
00947     Double_t lowEdge = 0;
00948     Double_t highEdge = 0.5;
00949     Double_t binWidth = 0.05;
00950     for (Double_t binEdge = lowEdge;
00951           binEdge < highEdge -(binWidth/2.0);
00952           binEdge += binWidth) {
00953       bins.push_back(binEdge);
00954     }
00955     lowEdge = 0.5;
00956     highEdge = 5.0;
00957     binWidth = 0.05;
00958     for (Double_t binEdge = lowEdge;
00959           binEdge < highEdge -(binWidth/2.0);
00960           binEdge += binWidth) {
00961       bins.push_back(binEdge);
00962     }
00963     lowEdge = 5;
00964     highEdge = 20.0;
00965     binWidth = 0.25;
00966     for (Double_t binEdge = lowEdge;
00967           binEdge < highEdge -(binWidth/2.0);
00968           binEdge += binWidth) {
00969       bins.push_back(binEdge);
00970     }
00971     lowEdge = 20.0;
00972     highEdge = 30.0;
00973     binWidth = 1.0;
00974     for (Double_t binEdge = lowEdge;
00975           binEdge < highEdge -(binWidth/2.0);
00976           binEdge += binWidth) {
00977       bins.push_back(binEdge);
00978     }
00979     lowEdge = 30.0;
00980     highEdge = 50.0;
00981     binWidth = 2.0;
00982     for (Double_t binEdge = lowEdge;
00983           binEdge < highEdge -(binWidth/2.0);
00984           binEdge += binWidth) {
00985       bins.push_back(binEdge);
00986     }
00987     bins.push_back(50.0);
00988     bins.push_back(200.0);
00989     return bins;
00990   }
00991   else if (NuBinningScheme::kDisplayFD == binningScheme) {
00992     MAXMSG("NuUtilities",Msg::kInfo,5)
00993     << "True Energy: 4 GeV Bins up to 20 GeV, then 20, 30, 50, 200"
00994     << endl;
00995     vector<Double_t> bins;
00996     Double_t lowEdge = 0.0;
00997     Double_t highEdge = 20.0;
00998     Double_t binWidth = 4;
00999     for (Double_t binEdge = lowEdge;
01000          binEdge < highEdge -(binWidth/2.0);
01001          binEdge += binWidth) {
01002       bins.push_back(binEdge);
01003     }
01004     bins.push_back(20.0);
01005     bins.push_back(30.0);
01006     bins.push_back(50.0);
01007     bins.push_back(200.0);
01008     return bins;
01009   }
01010   else if (NuBinningScheme::kNuMuBar0325Std == binningScheme){
01011     MAXMSG("NuUtilities",Msg::kInfo,5)
01012       << "True energy: 0.5 GeV up to 30 GeV; 2 GeV up to 50 GeV; "
01013       << "1 bin up to 200 GeV"
01014       << endl;
01015     vector<Double_t> bins;
01016     Double_t lowEdge = 0.0;
01017     Double_t highEdge = 30.0;
01018     Double_t binWidth = 0.5;
01019     for (Double_t binEdge = lowEdge;
01020          binEdge < highEdge - (binWidth/2.0);
01021          binEdge += binWidth){
01022       bins.push_back(binEdge);
01023     }
01024     lowEdge = 30.0;
01025     highEdge = 50.0;
01026     binWidth = 2.0;
01027     for (Double_t binEdge = lowEdge;
01028          binEdge < highEdge - (binWidth/2.0);
01029          binEdge += binWidth){
01030       bins.push_back(binEdge);
01031     }
01032     bins.push_back(50.0);
01033     bins.push_back(200.0);
01034     return bins;
01035   }
01036   else if (NuBinningScheme::kNuMuBar0325Std2 == binningScheme) {
01037     MAXMSG("NuUtilities",Msg::kInfo,5)
01038       << "True Energy: One 0.5 GeV, then 0.25 GeV up to 20 GeV; "
01039       << "1 Gev to 30 GeV,\n 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
01040       << endl;
01041     vector<Double_t> bins;
01042     bins.push_back(0.0);
01043     Double_t lowEdge = 0.5;
01044     Double_t highEdge = 20.0;
01045     Double_t binWidth = 0.25;
01046     for (Double_t binEdge = lowEdge;
01047           binEdge < highEdge -(binWidth/2.0);
01048           binEdge += binWidth) {
01049       bins.push_back(binEdge);
01050     }
01051     lowEdge = 20.0;
01052     highEdge = 30.0;
01053     binWidth = 1.0;
01054     for (Double_t binEdge = lowEdge;
01055           binEdge < highEdge -(binWidth/2.0);
01056           binEdge += binWidth) {
01057       bins.push_back(binEdge);
01058     }
01059     lowEdge = 30.0;
01060     highEdge = 50.0;
01061     binWidth = 2.0;
01062     for (Double_t binEdge = lowEdge;
01063           binEdge < highEdge -(binWidth/2.0);
01064           binEdge += binWidth) {
01065       bins.push_back(binEdge);
01066     }
01067     bins.push_back(50.0);
01068     bins.push_back(200.0);
01069     return bins;
01070   }
01071   else if (NuBinningScheme::kDisplayFD == binningScheme) {
01072     MAXMSG("NuUtilities",Msg::kInfo,5)
01073     << "True Energy: 4 GeV Bins up to 20 GeV, then 20, 30, 50, 200"
01074     << endl;
01075     vector<Double_t> bins;
01076     Double_t lowEdge = 0.0;
01077     Double_t highEdge = 20.0;
01078     Double_t binWidth = 4;
01079     for (Double_t binEdge = lowEdge;
01080          binEdge < highEdge -(binWidth/2.0);
01081          binEdge += binWidth) {
01082       bins.push_back(binEdge);
01083     }
01084     bins.push_back(20.0);
01085     bins.push_back(30.0);
01086     bins.push_back(50.0);
01087     bins.push_back(200.0);
01088     return bins;
01089   }
01090   else if (NuBinningScheme::kDisplayND == binningScheme) {
01091     MAXMSG("NuUtilities",Msg::kInfo,5)
01092     << "Reco Energy: 1 Gev to 30 GeV, 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
01093     << endl;
01094     vector<Double_t> bins;
01095     Double_t lowEdge = 0.0;
01096     Double_t highEdge = 20.0;
01097     Double_t binWidth = 1.0;
01098     for (Double_t binEdge = lowEdge;
01099          binEdge < highEdge -(binWidth/2.0);
01100          binEdge += binWidth) {
01101       bins.push_back(binEdge);
01102     }
01103     lowEdge = 20.0;
01104     highEdge = 30.0;
01105     binWidth = 2.0;
01106     for (Double_t binEdge = lowEdge;
01107          binEdge < highEdge -(binWidth/2.0);
01108          binEdge += binWidth) {
01109       bins.push_back(binEdge);
01110     }
01111     lowEdge = 30.0;
01112     highEdge = 50.0;
01113     binWidth = 4.0;
01114     for (Double_t binEdge = lowEdge;
01115          binEdge < highEdge -(binWidth/2.0);
01116          binEdge += binWidth) {
01117       bins.push_back(binEdge);
01118     }
01119     bins.push_back(50.0);
01120     bins.push_back(200.0);
01121     return bins;
01122   } else if (NuBinningScheme::k0_1GeVTo20 == binningScheme) {
01123     MAXMSG("NuUtilities",Msg::kInfo,5)
01124       << "True Energy: 0.10 GeV up to 20 GeV; "
01125       << "1 Gev to 30 GeV, 2 GeV from 30 to 50 GeV; One 150 GeV bin to 200 GeV"
01126       << endl;
01127     vector<Double_t> bins;
01128     Double_t lowEdge = 0.0;
01129     Double_t highEdge = 20.0;
01130     Double_t binWidth = 0.1;
01131     for (Double_t binEdge = lowEdge;
01132           binEdge < highEdge -(binWidth/2.0);
01133           binEdge += binWidth) {
01134       bins.push_back(binEdge);
01135     }
01136     lowEdge = 20.0;
01137     highEdge = 30.0;
01138     binWidth = 1.0;
01139     for (Double_t binEdge = lowEdge;
01140           binEdge < highEdge -(binWidth/2.0);
01141           binEdge += binWidth) {
01142       bins.push_back(binEdge);
01143     }
01144     lowEdge = 30.0;
01145     highEdge = 50.0;
01146     binWidth = 2.0;
01147     for (Double_t binEdge = lowEdge;
01148           binEdge < highEdge -(binWidth/2.0);
01149           binEdge += binWidth) {
01150       bins.push_back(binEdge);
01151     }
01152     bins.push_back(50.0);
01153     bins.push_back(200.0);
01154     return bins;
01155  } else {
01156     MAXMSG("NuUtilities",Msg::kInfo,100)
01157     << "!!Invalid binning scheme requested.!!" << endl
01158     << "Binning true energy in 0.5 GeV up to 200 GeV" << endl;
01159     vector<Double_t> bins;
01160     Double_t lowEdge = 0.0;
01161     Double_t highEdge = 200.0;
01162     Double_t binWidth = 0.5;
01163     for (Double_t binEdge = lowEdge;
01164          binEdge <= highEdge + (binWidth/2.0);
01165          binEdge += binWidth){
01166       bins.push_back(binEdge);
01167     }
01168     return bins;
01169   }
01170 }

static Double_t NuUtilities::ValueAt ( TH1 *  h,
Double_t  val 
) [inline, static]

Definition at line 65 of file NuUtilities.h.

Referenced by NuTransSME::Reweight(), and NuTransition::Reweight().

00066     {return h->GetBinContent(h->GetXaxis()->FindFixBin(val));};

void NuUtilities::WriteHistosToFile ( const std::pair< NuMatrixSpectrum, NuMatrixSpectrum > &  vHistos,
TFile &  file 
) [static]

Definition at line 1207 of file NuUtilities.cxx.

01209 {
01210   file.cd();
01211   vHistos.first.Spectrum()->Write();
01212   vHistos.second.Spectrum()->Write();
01213 }

void NuUtilities::WriteHistosToFile ( const std::vector< NuMatrixSpectrum > &  vHistos,
TFile &  file,
bool  Quiet = false 
) [static]

Definition at line 1190 of file NuUtilities.cxx.

References it.

01192 {
01193   file.cd();
01194   for (vector<NuMatrixSpectrum>::const_iterator it = vHistos.begin();
01195        it != vHistos.end();
01196        ++it){
01197     (*it).Spectrum()->Write();
01198     if(!Quiet) cout << "Written " << (*it).GetName() << endl;
01199   }
01200 
01201   cout << "Written " << vHistos.size() << " histograms to " 
01202        << file.GetName() << endl;
01203 
01204 }

void NuUtilities::WriteHistosToFile ( const std::vector< TH1D > &  vHistos,
TFile &  file,
bool  Quiet = false 
) [static]

Definition at line 1173 of file NuUtilities.cxx.

References it.

01175 {
01176   file.cd();
01177   for (vector<TH1D>::const_iterator it = vHistos.begin();
01178        it != vHistos.end();
01179        ++it){
01180     (*it).Write();
01181     if(!Quiet) cout << "Written " << (*it).GetName() << endl;
01182   }
01183 
01184   cout << "Written " << vHistos.size() << " histograms to " 
01185        << file.GetName() << endl;
01186 
01187 }


Member Data Documentation

Definition at line 101 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 102 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 103 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 104 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 109 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 105 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 106 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 107 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 108 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().

Definition at line 110 of file NuUtilities.h.

Referenced by NuExtraction::ExtractBeamInfoDB(), and NuAnalysis::ExtractConfig().


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

Generated on 22 May 2017 for loon by  doxygen 1.6.1