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

NCBeam.cxx

Go to the documentation of this file.
00001 
00002 //$Id: NCBeam.cxx,v 1.73 2009/12/18 01:30:21 rodriges Exp $
00003 //
00004 //NCBeam.cxx
00005 //
00006 //B. Rebel 3/2005
00008 
00009 #include "NCUtils/Extrapolation/NCBeam.h"
00010 
00011 #include "MessageService/MsgService.h"
00012 #include "Conventions/SimFlag.h"
00013 #include "TMath.h"
00014 
00015 #include "AnalysisNtuples/ANtpHeaderInfo.h"
00016 #include "AnalysisNtuples/ANtpBeamInfo.h"
00017 #include "AnalysisNtuples/ANtpRecoInfo.h"
00018 #include "AnalysisNtuples/ANtpTruthInfoBeam.h"
00019 #include "AnalysisNtuples/ANtpAnalysisInfo.h"
00020 
00021 #include "NCUtils/Extrapolation/NCEnergyBin.h"
00022 #include "NCUtils/Extrapolation/NCCoordinateConverter.h" // SystPars
00023 #include "NCUtils/NCOscProb.h"
00024 
00025 #include <cassert>
00026 
00027 using NCType::kNC;
00028 using NCType::kCC;
00029 
00030 
00031 ClassImp(NCBeam)
00032 
00033 CVSID("$Id: NCBeam.cxx,v 1.73 2009/12/18 01:30:21 rodriges Exp $");
00034 
00035 //-------------------------------------------------------------------
00036 NCBeam::NCBeam() : fInfo(BeamType::BeamType_t(0), NC::RunUtil::ERunType(0))
00037 {
00038   InitNulls();
00039 }
00040 
00041 
00042 //-------------------------------------------------------------------
00043 NCBeam::NCBeam(Detector::Detector_t detector,
00044                NCBeam::Info beamInfo,
00045                bool useCC, bool useNC,
00046                bool fillBins) :
00047   fInfo(beamInfo),
00048   fDetector(detector),
00049   fUseCC(useCC),
00050   fUseNC(useNC),
00051   fFillBins(fillBins)
00052 {
00053   Init();
00054 }
00055 
00056 
00057 //-------------------------------------------------------------------
00058 void NCBeam::InitNulls()
00059 {
00060   for(int nccc = kNC; nccc <= kCC; ++nccc){
00061     fDefaultMCHistogram[nccc] = 0;
00062     fMCHistogram[nccc] = 0;
00063     fMCTrueHistogram[nccc] = 0;
00064     fMCFitHistogram[nccc] = 0;
00065     fMCBackgroundHistogram[nccc] = 0;
00066     fDataGraph[nccc] = 0;
00067     fMCBackgroundHistogram[nccc] = 0;
00068     fMCNoFitNuMuToNuTau[nccc] = 0;
00069     fMCFitNuMuToNuTau[nccc] = 0;
00070     fMCNoFitNuMuToNuE[nccc] = 0;
00071     fMCFitNuMuToNuE[nccc] = 0;
00072     fMCNoFitNuEToNuE[nccc] = 0;
00073     fMCFitNuEToNuE[nccc] = 0;
00074     fDataHistogram[nccc] = 0;
00075     fMCNoFitBackgroundHistogram[nccc] = 0;
00076     fMCResidualHistogram[nccc] = 0;
00077   }
00078 }
00079 
00080 
00081 //-------------------------------------------------------------------
00082 void NCBeam::Init()
00083 {
00084   MSG("NCBeam", Msg::kDebug) << "NCBeam::Constructor" << endl;
00085 
00086   fResultHistogramsFilled = false;
00087 
00088   InitNulls();
00089 
00090   //make the energy bin objects for cc and nc events
00091   double binCentralValue = 0.;
00092   double binWidth = kEnergyBinWidthNear; //0.5;
00093   fNumEnergyBins = kNumEnergyBinsNear; //200;
00094   if(fDetector == Detector::kFar){
00095     fNumEnergyBins = kNumEnergyBinsFar; //23;
00096   }
00097 
00098   for(int i = 0; i < fNumEnergyBins; ++i){
00099 
00100     fEnergyBinBoundaries[i] = kEnergyBinsNear[i];
00101     binCentralValue = binWidth*(i*1. + 0.5);
00102 
00103     if(fDetector == Detector::kFar){
00104       fEnergyBinBoundaries[i] = kEnergyBinsFar[i];
00105       binWidth = kEnergyBinsFar[i+1] - kEnergyBinsFar[i];
00106       binCentralValue = binWidth*(0.5) + fEnergyBinBoundaries[i];
00107     }
00108 
00109     MSG("NCBeam", Msg::kDebug) << "energy bin " << i << " " << binCentralValue
00110                               << " " << binWidth << " " << fEnergyBinBoundaries[i]
00111                               << " " << fNumEnergyBins << endl;
00112 
00113     if(fUseCC || fDetector == Detector::kNear)
00114       fEnergyBins[kCC].push_back(new NCEnergyBin(binCentralValue, binWidth,
00115                                                  kCC));
00116     if(fUseNC || fDetector == Detector::kNear)
00117       fEnergyBins[kNC].push_back(new NCEnergyBin(binCentralValue, binWidth,
00118                                                  kNC));
00119   } // end for i
00120 
00121   fEnergyBinBoundaries[fNumEnergyBins] = kMaxEnergy;
00122 
00123   //make the fit result histograms
00124   TString name = "monteCarlo";
00125   TString nc = "NC";
00126   TString cc = "CC";
00127   TString fit = "Fit";
00128   TString residual = "Residual";
00129   TString noFit = "Nominal";
00130   TString bg = "Background";
00131   TString y = "Y";
00132   TString truth = "true";
00133 
00134   TString type = Detector::AsString(fDetector);
00135   type += GetInfo().GetDescription();
00136 
00137   for(int nccc = kNC; nccc <= kCC; ++nccc){
00138     TString ncccStr = nccc == kNC ? nc : cc;
00139 
00140     fMCHistogram[nccc] =
00141       NewVisEnergySpectrum(name+type+noFit+ncccStr, kRed);
00142 
00143     fMCTrueHistogram[nccc] =
00144       NewVisEnergySpectrum(name+type+truth+ncccStr, kBlack);
00145     fMCTrueHistogram[nccc]->SetXTitle("E_{Truth} (GeV)");
00146 
00147     fDefaultMCHistogram[nccc] =
00148       NewVisEnergySpectrum(name+"Default"+type+noFit+ncccStr, kBlack);
00149 
00150     fDataHistogram[nccc] =
00151       NewVisEnergySpectrum("Data_"+type+ncccStr, kBlack);
00152     fDataHistogram[nccc]->SetMarkerStyle(kFullSquare);
00153 
00154     fMCFitHistogram[nccc] =
00155       NewVisEnergySpectrum(name+type+fit+ncccStr, kBlue);
00156 
00157     fMCResidualHistogram[nccc] =
00158       NewVisEnergySpectrum(name+type+residual+ncccStr, kBlue);
00159     fMCResidualHistogram[nccc]->SetYTitle("Residual/GeV");
00160     fMCResidualHistogram[nccc]->SetLineStyle(9);
00161 
00162     fMCBackgroundHistogram[nccc] =
00163       NewVisEnergySpectrum(name+type+bg+ncccStr, kBlack, kBlack);
00164 
00165     fMCNoFitBackgroundHistogram[nccc] =
00166       NewVisEnergySpectrum(name+type+noFit+bg+ncccStr, kBlack, kBlack);
00167 
00168     fMCFitNuMuToNuTau[nccc] =
00169       NewVisEnergySpectrum(name+type+"NuMuToNuTauFit"+ncccStr, kBlack, kMagenta+2);
00170 
00171     fMCNoFitNuMuToNuTau[nccc] =
00172       NewVisEnergySpectrum(name+type+"NuMuToNuTauNoFit"+ncccStr, kBlack, kMagenta+2);
00173 
00174     fMCFitNuMuToNuE[nccc] =
00175       NewVisEnergySpectrum(name+type+"NuMuToNuEFit"+ncccStr, kBlack, kOrange-3);
00176 
00177     fMCNoFitNuMuToNuE[nccc] =
00178       NewVisEnergySpectrum(name+type+"NuMuToNuENoFit"+ncccStr, kBlack, kOrange-3);
00179 
00180     fMCFitNuEToNuE[nccc] =
00181       NewVisEnergySpectrum(name+type+"NuEToNuEFit"+ncccStr, kBlack, kGreen+2);
00182 
00183     fMCNoFitNuEToNuE[nccc] =
00184       NewVisEnergySpectrum(name+type+"NuEToNuENoFit"+ncccStr, kBlack, kGreen+2);
00185 
00186     TString data = "data";
00187     fDataGraph[nccc] = new TGraphAsymmErrors(fNumEnergyBins);
00188     fDataGraph[nccc]->SetName(data+type+ncccStr);
00189     fDataGraph[nccc]->SetTitle("");
00190     fDataGraph[nccc]->SetMarkerStyle(kFullCircle);
00191   } // end for nccc
00192 }
00193 
00194 //----------------------------------------------------------------------
00195 NCBeam::~NCBeam()
00196 {
00197   MSG("NCBeam", Msg::kDebug) << "NCBeam::Destructor" << endl;
00198 
00199   for(int nccc = kNC; nccc <= kCC; ++nccc){
00200     delete fDefaultMCHistogram[nccc];
00201     delete fMCHistogram[nccc];
00202     delete fMCTrueHistogram[nccc];
00203     delete fMCFitHistogram[nccc];
00204     delete fMCResidualHistogram[nccc];
00205     delete fMCBackgroundHistogram[nccc];
00206     delete fMCNoFitNuMuToNuTau[nccc];
00207     delete fMCFitNuMuToNuTau[nccc];
00208     delete fMCNoFitNuMuToNuE[nccc];
00209     delete fMCFitNuMuToNuE[nccc];
00210     delete fMCNoFitNuEToNuE[nccc];
00211     delete fMCFitNuEToNuE[nccc];
00212     delete fDataHistogram[nccc];
00213     delete fMCNoFitBackgroundHistogram[nccc];
00214     delete fDataGraph[nccc];
00215 
00216     for(unsigned int n = 0; n < fEnergyBins[nccc].size(); ++n)
00217       delete fEnergyBins[nccc][n];
00218   }
00219 }
00220 
00221 ClassImp(NCBeam::Info)
00222 
00223 //----------------------------------------------------------------------
00224 NCBeam::Info::Info(){}
00225 
00226 //----------------------------------------------------------------------
00227 NCBeam::Info::Info(BeamType::BeamType_t bt, NC::RunUtil::ERunType rt)
00228   : runType(rt)
00229 {
00230   beamType = bt;
00231 
00232   switch(beamType){
00233   case BeamType::kL010z185i_i124:
00234   case BeamType::kL010z185i_i191:
00235   case BeamType::kL010z185i_i213:
00236   case BeamType::kL010z185i_i224:
00237   case BeamType::kL010z185i_i232:
00238   case BeamType::kL010z185i_i243:
00239   case BeamType::kL010z185i_i257:
00240   case BeamType::kL010z185i_i282:
00241   case BeamType::kL010z185i_i303:
00242   case BeamType::kL010z185i_i324:
00243     beamType = BeamType::kL010z185i;
00244     break;
00245   case BeamType::kL010z000i_i209:
00246   case BeamType::kL010z000i_i225:
00247   case BeamType::kL010z000i_i232:
00248   case BeamType::kL010z000i_i259:
00249   case BeamType::kL010z000i_i300:
00250   case BeamType::kL010z000i_i317:
00251   case BeamType::kL010z000i_i326:
00252   case BeamType::kL010z000i_i380:
00253     beamType = BeamType::kL010z000i;
00254     break;
00255   default:
00256     break;
00257   }
00258 }
00259 
00260 NCBeam::Info::~Info()
00261 {
00262 }
00263 
00264 //----------------------------------------------------------------------
00265 bool NCBeam::Info::operator==(const Info& i) const
00266 {
00267   if(beamType != i.beamType) return false;
00268   if(runType  != i.runType)  return false;
00269 
00270   const unsigned int N = adjustedPars.size();
00271   const unsigned int M = i.adjustedPars.size();
00272 
00273   if(N != M) return false;
00274 
00275   for(unsigned int n = 0; n < N; ++n){
00276     if(adjustedPars[n] != i.adjustedPars[n]) return false;
00277     // TODO - comparing doubles, dodgy...
00278     const double eps = 1e-6;
00279     if(TMath::Abs(parShifts[n]-i.parShifts[n]) > eps) return false;
00280   }
00281 
00282   return true;
00283 }
00284 
00285 //----------------------------------------------------------------------
00286 bool NCBeam::Info::operator<(const Info& i) const
00287 {
00288 #define COMPARE_BEAMINFO(txt) \
00289 if(txt > i.txt) return false; \
00290 if(txt < i.txt) return true;
00291 
00292   COMPARE_BEAMINFO(beamType);
00293   COMPARE_BEAMINFO(runType);
00294 
00295   const int N = adjustedPars.size();
00296   const int M = i.adjustedPars.size();
00297 
00298   if(N < M) return true;
00299   if(N > M) return false;
00300 
00301   for(int n = 0; n < N; ++n){
00302     COMPARE_BEAMINFO(adjustedPars[n]);
00303 
00304     // TODO - comparing doubles, dodgy...
00305     const double eps = 1e-6;
00306     if(TMath::Abs(parShifts[n]-i.parShifts[n]) < eps) continue;
00307     COMPARE_BEAMINFO(parShifts[n]);
00308   }
00309 
00310   // Identical, therefore not less-than
00311   return false;
00312 
00313 #undef COMPARE_BEAMINFO
00314 }
00315 
00316 //----------------------------------------------------------------------
00317 void NCBeam::Info::SetSystShifts(bool* adj, double* shift)
00318 {
00319   adjustedPars.clear();
00320   parShifts.clear();
00321   for(int n = 0; n < NCType::kNumSystematicParameters; ++n){
00322     if(adj[n]){
00323       adjustedPars.push_back(NCType::EFitParam(n));
00324       parShifts.push_back(shift[n]);
00325     }
00326   }
00327 }
00328 
00329 //----------------------------------------------------------------------
00330 void NCBeam::Info::SetSystShifts(const vector<NCType::EFitParam>& adj,
00331                                  const vector<double>& shift)
00332 {
00333   adjustedPars = adj;
00334   parShifts = shift;
00335 }
00336 
00337 //----------------------------------------------------------------------
00338 void NCBeam::Info::GetSystShifts(vector<NCType::EFitParam>&  adj,
00339                                  vector<double>& shift) const
00340 {
00341   adj = adjustedPars;
00342   shift = parShifts;
00343 }
00344 
00345 //----------------------------------------------------------------------
00346 TString NCBeam::Info::GetDescription() const
00347 {
00348   TString ret = BeamType::AsString(beamType);
00349   ret += " ";
00350   switch(runType){
00351   case NC::RunUtil::kRunAll: ret += "All Runs"; break;
00352   case NC::RunUtil::kRunI: ret += "Run I"; break;
00353   case NC::RunUtil::kRunII: ret += "Run II"; break;
00354   case NC::RunUtil::kRunIII: ret += "Run III"; break;
00355   default: ret += "UNKNOWN RUN!";
00356   }
00357 
00358   for(unsigned int n = 0; n < adjustedPars.size(); ++n){
00359     ret += " ";
00360     ret += NCType::kParams[adjustedPars[n]].latexName;
00361     ret += " = ";
00362     ret += TString::Format("%lf", parShifts[n]);
00363   }
00364 
00365   return ret;
00366 }
00367 
00368 //----------------------------------------------------------------------
00369 bool NCBeam::Info::IsNominal() const
00370 {
00371   return adjustedPars.size() == 0;
00372 }
00373 
00374 //----------------------------------------------------------------------
00375 bool NCBeam::Info::IsShifted(NCType::EFitParam param, double* val) const
00376 {
00377   for(unsigned int n = 0; n < adjustedPars.size(); ++n){
00378     if(adjustedPars[n] == param){
00379       if(val) *val = parShifts[n];
00380       return true;
00381     }
00382   }
00383   return false;
00384 }
00385 
00386 //----------------------------------------------------------------------
00387 NC::RunUtil::ERunType NCBeam::Info::GetRunType() const
00388 {
00389   return runType;
00390 }
00391 
00392 //----------------------------------------------------------------------
00393 ostream& operator<<(ostream& os, const NCBeam::Info& inf)
00394 {
00395   os << inf.GetDescription();
00396   return os;
00397 }
00398 
00399 
00400 //----------------------------------------------------------------------
00401 NCEnergyBin* NCBeam::GetEnergyBin(int i, NCType::EEventType nccc) const
00402 {
00403   if(int(fEnergyBins[nccc].size()) > i)
00404     return fEnergyBins[nccc][i];
00405   else
00406     MSG("NCBeam", Msg::kWarning) << "cant find requested bin "
00407                                  << "object - returning null "
00408                                  << "pointer" << endl;
00409 
00410   return 0;
00411 }
00412 
00413 //----------------------------------------------------------------------
00414 //returns maximum energy for events used in analysis
00415 double NCBeam::GetMaximumEnergy() const
00416 {
00417   return kMaxEnergy;
00418 }
00419 
00420 //----------------------------------------------------------------------
00421 int NCBeam::GetNumberEnergyBins(NCType::EEventType nccc) const
00422 {
00423   return int(fEnergyBins[nccc].size());
00424 }
00425 
00426 //----------------------------------------------------------------------
00427 void NCBeam::GetEnergyBinBoundaries(double* bins) const
00428 {
00429   for(int i = 0; i < fNumEnergyBins; ++i)
00430     bins[i] = fEnergyBinBoundaries[i];
00431 }
00432 
00433 //----------------------------------------------------------------------
00434 Detector::Detector_t NCBeam::GetDetector() const
00435 {
00436   return fDetector;
00437 }
00438 
00439 //----------------------------------------------------------------------
00440 BeamType::BeamType_t NCBeam::GetBeamType() const
00441 {
00442   return fInfo.beamType;
00443 }
00444 
00445 //----------------------------------------------------------------------
00446 NC::RunUtil::ERunType NCBeam::GetRunType() const
00447 {
00448   return fInfo.GetRunType();
00449 }
00450 
00451 //----------------------------------------------------------------------
00452 NCBeam::Info NCBeam::GetInfo() const
00453 {
00454   return fInfo;
00455 }
00456 
00457 //----------------------------------------------------------------------
00458 void NCBeam::SetRunType(NC::RunUtil::ERunType runType)
00459 {
00460   fInfo.runType = runType;
00461 }
00462 
00463 //----------------------------------------------------------------------
00464 //if you want to use MC as data then just change the recoInfo->weight
00465 //value appropriately before passing it into this method - works for
00466 //changes in systematic parameters as well as oscillations
00467 void NCBeam::AddEvent(ANtpHeaderInfo* headerInfo,
00468                       ANtpBeamInfo* /*beamInfo*/,
00469                       ANtpRecoInfo* recoInfo,
00470                       ANtpAnalysisInfo* analysisInfo,
00471                       ANtpTruthInfoBeam* truthInfo,
00472                       bool useMCAsData,
00473                       NCType::EFileType fileType)
00474 {
00475 
00476   MSG("NCBeam", Msg::kDebug) << "In NCBeam::AddEvent" << endl;
00477 
00478   int mcCC = 0, mcNC = 0;
00479 
00480   //want to fill both nc and cc events in the near detector, but not necessarily
00481   //in the far detector
00482   const bool useNC = (fUseNC || fDetector == Detector::kNear);
00483   const bool useCC = (fUseCC || fDetector == Detector::kNear);
00484 
00485   //really no need to check on snarl or event quality as those events that don't pass
00486   //the cuts dont get put into the ntuples from the extraction code.
00487 
00488   //which reconstructed energy bin is the event in?
00489   int bin = FindEnergyBin(recoInfo->nuEnergy);
00490 
00491   if(bin < fNumEnergyBins && bin > -1){
00492     if(headerInfo->dataType == SimFlag::kData || (truthInfo && useMCAsData)){
00493 //       MAXMSG("NCBeam", Msg::kInfo, 20) << "DATA " << headerInfo->detector << "/"
00494 //                                     << (int)Detector::kNear << " "
00495 //                                     << headerInfo->dataType << "/"
00496 //                                     << (int)SimFlag::kData << " "
00497 //                                     << analysisInfo->isNC << " "
00498 //                                     << analysisInfo->isCC << " "
00499 //                                     << headerInfo->run << " "
00500 //                                     << headerInfo->snarl << " "
00501 //                                     << endl;
00502       if(analysisInfo->isNC > 0 && useNC){
00503         ++mcNC;
00504         if(fFillBins) fEnergyBins[kNC][bin]->AddEventToBin(recoInfo);
00505       }
00506       else if(analysisInfo->isCC > 0 && useCC){
00507         ++mcCC;
00508         if(fFillBins) fEnergyBins[kCC][bin]->AddEventToBin(recoInfo);
00509       }
00510     }//end if data
00511     else if(headerInfo->dataType == SimFlag::kMC){
00512 
00513 //       if(fileType == NCType::kElectronFile){
00514 //      MAXMSG("NCBeam", Msg::kInfo, 20)
00515 //        << "MC " << headerInfo->run << " " << headerInfo->snarl << " "
00516 //        << truthInfo->interactionType << " "
00517 //        << recoInfo->weight << " "
00518 //        << energy << " " << recoInfo->nuEnergy << " "
00519 //        << FindEnergyBin(energy) << endl;
00520 //       }
00521 
00522       if(analysisInfo->isNC > 0 && useNC){
00523         ++mcNC;
00524         if(fFillBins) fEnergyBins[kNC][bin]->AddEventToBin(recoInfo, truthInfo, fileType);
00525         if(truthInfo->nuFlavor == 14)
00526           fDefaultMCHistogram[kNC]->Fill(recoInfo->nuEnergy, recoInfo->weight);
00527       }
00528       else if(analysisInfo->isCC > 0 && useCC){
00529         ++mcCC;
00530         if(fFillBins) fEnergyBins[kCC][bin]->AddEventToBin(recoInfo, truthInfo, fileType);
00531         if(truthInfo->nuFlavor == 14)
00532           fDefaultMCHistogram[kCC]->Fill(recoInfo->nuEnergy, recoInfo->weight);
00533       }
00534 
00535     }//end if monte carlo
00536   }//end if acceptable value for energy bin
00537 
00538   MSG("NCBeam", Msg::kDebug) << fInfo.beamType << " mc cc = " << mcCC
00539                              << " nc = " << mcNC << endl;
00540 }
00541 
00542 //----------------------------------------------------------------------
00543 int NCBeam::FindEnergyBin(double energy)
00544 {
00545   //do a binary search to find the appropriate bin - the first entry in binBoundaries
00546   //is 0. as the binary search returns the nearest element smaller than the
00547   //desired value
00548   if(energy > kMaxEnergy) return fNumEnergyBins;
00549 
00550   return TMath::BinarySearch(fNumEnergyBins, fEnergyBinBoundaries, energy);
00551 }
00552 
00553 //----------------------------------------------------------------------
00554 void NCBeam::MakeResultPlots()
00555 {
00556 //   MSG("NCBeam", Msg::kInfo) << "NCBeam::MakeResultPlots() "
00557 //                          << " " << Detector::AsString(fDetector)
00558 //                          << " " << BeamType::AsString(fInfo.beamType)
00559 //                          << " " << fInfo.runType << endl;
00560 
00561   for(int nccc = kNC; nccc <= kCC; ++nccc){
00562     MakeMCHistogram(fMCHistogram[nccc],
00563                     fMCTrueHistogram[nccc],
00564                     fMCNoFitBackgroundHistogram[nccc],
00565                     fMCNoFitNuMuToNuTau[nccc],
00566                     fMCNoFitNuMuToNuE[nccc],
00567                     fMCNoFitNuEToNuE[nccc],
00568                     fMCFitHistogram[nccc],
00569                     fMCBackgroundHistogram[nccc],
00570                     fMCFitNuMuToNuTau[nccc],
00571                     fMCFitNuMuToNuE[nccc],
00572                     fMCFitNuEToNuE[nccc]);
00573 
00574     MakeResidualHistogram(fEnergyBins[nccc], fMCFitHistogram[nccc],
00575                           fDataHistogram[nccc], fMCResidualHistogram[nccc]);
00576   }
00577 
00578   MakeDataGraph();
00579 }
00580 
00581 //----------------------------------------------------------------------
00582 void NCBeam::MakeMCHistogram(TH1F* mc,
00583                              TH1F* mcTrue,
00584                              TH1F* noFitBg,
00585                              TH1F* noFitNuMuToNuTau,
00586                              TH1F* noFitNuMuToNuE,
00587                              TH1F* noFitNuEToNuE,
00588                              TH1F* fit,
00589                              TH1F* fitBg,
00590                              TH1F* fitNuMuToNuTau,
00591                              TH1F* fitNuMuToNuE,
00592                              TH1F* fitNuEToNuE)
00593 {
00594   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeMCHistogram()" << endl;
00595 
00596   //make a histogram to hold the baseline monte carlo
00597 
00598   double normalization = 1.;
00599   TString yTitle = "Events/ GeV";
00600   double width = 1.;
00601 
00602   //for the near detector scale the events down by 1.e3 so the axis
00603   //label looks reasonable
00604   if(fDetector == (int)Detector::kNear){
00605     normalization = 1.e3;
00606     yTitle = "10^{3} Events/GeV";
00607   }
00608 
00609   if(mc->Integral() > 0. || fit->Integral() > 0.){
00610 //     MSG("NCBeam", Msg::kInfo) << "nominal or fit histograms already filled"
00611 //                            << " do scaling" << endl;
00612     //assume if the mc histogram has some entries it is
00613     //already filled and just needs to be scaled
00614     if(mc->Integral() > 0.){
00615       mc->Scale(1./normalization);
00616       mcTrue->Scale(1./normalization);
00617       noFitBg->Scale(1./normalization);
00618 
00619       mc->SetYTitle(yTitle);
00620       mcTrue->SetYTitle(yTitle);
00621       noFitBg->SetYTitle(yTitle);
00622 
00623       //loop over the bins and divide each by the width
00624       //to put the scale in terms of events/GeV
00625       double events = 0.;
00626       for(int i = 0; i < mc->GetNbinsX(); ++i){
00627         events = mc->GetBinContent(i+1);
00628         width = mc->GetBinWidth(i+1);
00629         mc->SetBinContent(i+1, events/width);
00630 
00631         MSG("NCBeam", Msg::kDebug) << "mc histogram bin " << i+1 << "/" << mc->GetNbinsX()
00632                                    << " events " << events << " width " << width
00633                                    << " " << mc->GetBinContent(i+1) << endl;
00634       }
00635 
00636       for(int i = 0; i < mcTrue->GetNbinsX(); ++i){
00637         events = mcTrue->GetBinContent(i+1);
00638         width = mcTrue->GetBinWidth(i+1);
00639         mcTrue->SetBinContent(i+1, events/width);
00640 
00641         MSG("NCBeam", Msg::kDebug) << "mc true histogram bin " << i+1 << "/" << mcTrue->GetNbinsX()
00642                                    << " events " << events << " width " << width
00643                                    << " " << mcTrue->GetBinContent(i+1) << endl;
00644       }
00645 
00646       for(int i = 0; i < noFitBg->GetNbinsX(); ++i){
00647         events = noFitBg->GetBinContent(i+1);
00648         width = noFitBg->GetBinWidth(i+1);
00649         noFitBg->SetBinContent(i+1, events/width);
00650       }
00651 
00652       if(noFitNuMuToNuTau){
00653         noFitNuMuToNuTau->Scale(1./normalization);
00654         noFitNuMuToNuTau->SetYTitle(yTitle);
00655 
00656         for(int i = 0; i < noFitNuMuToNuTau->GetNbinsX(); ++i){
00657           events = noFitNuMuToNuTau->GetBinContent(i+1);
00658           width = noFitNuMuToNuTau->GetBinWidth(i+1);
00659           noFitNuMuToNuTau->SetBinContent(i+1, events/width);
00660         }
00661       }//end if no fit tau
00662 
00663       if(noFitNuMuToNuE){
00664         noFitNuMuToNuE->Scale(1./normalization);
00665         noFitNuMuToNuE->SetYTitle(yTitle);
00666 
00667         for(int i = 0; i < noFitNuMuToNuE->GetNbinsX(); ++i){
00668           events = noFitNuMuToNuE->GetBinContent(i+1);
00669           width = noFitNuMuToNuE->GetBinWidth(i+1);
00670           noFitNuMuToNuE->SetBinContent(i+1, events/width);
00671         }
00672       }//end if no fit electron
00673 
00674       if(noFitNuEToNuE){
00675         noFitNuEToNuE->Scale(1./normalization);
00676         noFitNuEToNuE->SetYTitle(yTitle);
00677 
00678         for(int i = 0; i < noFitNuEToNuE->GetNbinsX(); ++i){
00679           events = noFitNuEToNuE->GetBinContent(i+1);
00680           width = noFitNuEToNuE->GetBinWidth(i+1);
00681           noFitNuEToNuE->SetBinContent(i+1, events/width);
00682         }
00683       }//end if no fit electron
00684     }//end if mc->Integral > 0.
00685 
00686     //assume if the mc histogram has some entries it is
00687     //already filled and just needs to be scaled
00688     if(fit->Integral() > 0.){
00689       fit->Scale(1./normalization);
00690       fitBg->Scale(1./normalization);
00691 
00692       fit->SetYTitle(yTitle);
00693       fitBg->SetYTitle(yTitle);
00694 
00695       //loop over the bins and divide each by the width
00696       //to put the scale in terms of events/GeV
00697       double events = 0.;
00698       double width = 1.;
00699       for(int i = 0; i < fit->GetNbinsX(); ++i){
00700         events = fit->GetBinContent(i+1);
00701         width = fit->GetBinWidth(i+1);
00702         fit->SetBinContent(i+1, events/width);
00703       }
00704       for(int i = 0; i < fitBg->GetNbinsX(); ++i){
00705         events = fitBg->GetBinContent(i+1);
00706         width = fitBg->GetBinWidth(i+1);
00707         fitBg->SetBinContent(i+1, events/width);
00708       }
00709 
00710       if(fitNuMuToNuTau){
00711         fitNuMuToNuTau->Scale(1./normalization);
00712         fitNuMuToNuTau->SetYTitle(yTitle);
00713 
00714         for(int i = 0; i < fitNuMuToNuTau->GetNbinsX(); ++i){
00715           events = fitNuMuToNuTau->GetBinContent(i+1);
00716           width = fitNuMuToNuTau->GetBinWidth(i+1);
00717           fitNuMuToNuTau->SetBinContent(i+1, events/width);
00718         }
00719       }//end if fitNuMuToNuTau
00720 
00721       if(fitNuMuToNuE){
00722         fitNuMuToNuE->Scale(1./normalization);
00723         fitNuMuToNuE->SetYTitle(yTitle);
00724 
00725         for(int i = 0; i < fitNuMuToNuE->GetNbinsX(); ++i){
00726           events = fitNuMuToNuE->GetBinContent(i+1);
00727           width = fitNuMuToNuE->GetBinWidth(i+1);
00728           fitNuMuToNuE->SetBinContent(i+1, events/width);
00729         }
00730       }//end if fitNuMuToNuE
00731 
00732       if(fitNuEToNuE){
00733         fitNuEToNuE->Scale(1./normalization);
00734         fitNuEToNuE->SetYTitle(yTitle);
00735 
00736         for(int i = 0; i < fitNuEToNuE->GetNbinsX(); ++i){
00737           events = fitNuEToNuE->GetBinContent(i+1);
00738           width = fitNuEToNuE->GetBinWidth(i+1);
00739           fitNuEToNuE->SetBinContent(i+1, events/width);
00740         }
00741       }//end if no fit electron
00742 
00743     }//end if fit->Integral > 0.
00744 
00745   }//end if fit or nominal histograms have values
00746 }
00747 
00748 //----------------------------------------------------------------------
00749 void NCBeam::MakeDataHistogram(std::vector<NCEnergyBin*>& energyBins,
00750                                TH1F* data)
00751 {
00752   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeDataHistogram()" << endl;
00753 
00754   //make a histogram to hold the data
00755   double totalEvents = 0.;
00756   TString yTitle = "Events/GeV";
00757 
00758   //for the near detector scale the events down by 1.e3 so the axis
00759   //label looks reasonable
00760   if(fDetector == (int)Detector::kNear){
00761     yTitle = "10^{3} Events/GeV";
00762   }
00763 
00764   //assume if the data histogram has some entries it is
00765   //already filled and just needs to be scaled
00766 
00767   //scale the size of the entries by the inverse of the
00768   //bin width in the graph making stage
00769   if(data->Integral() > 0.){
00770     data->SetYTitle(yTitle);
00771     return;
00772   }
00773 
00774   double binCenter = 0.;
00775   for(int i = 0; i < fNumEnergyBins; ++i){
00776     if(energyBins.size() > 0){
00777       binCenter = energyBins[i]->GetBinCentralValue();
00778       totalEvents = energyBins[i]->GetSignal();
00779 
00780       //BJR - 7/18/07 - dont divide by the bin width here.
00781       //that happens in MakeGraphFromHistogram()
00782 
00783       data->Fill(binCenter, (totalEvents));
00784       data->SetBinError(i+1,TMath::Sqrt(totalEvents));
00785     }
00786   }
00787 
00788   data->SetYTitle(yTitle);
00789 }
00790 
00791 //----------------------------------------------------------------------
00792 void NCBeam::MakeResidualHistogram(std::vector<NCEnergyBin*>& energyBins,
00793                                    TH1F* fit,
00794                                    TH1F* data,
00795                                    TH1F* resid)
00796 {
00797   TString yTitle = "Residual/0.5 GeV";
00798 
00799   double mcFit = 0.;
00800   double d = 0.;
00801   double err = 1.;
00802 
00803   //for the near detector scale the events down by 1.e3 so the axis
00804   //label looks reasonable
00805   if(fDetector == (int)Detector::kNear){
00806     yTitle = "10^{3} Residual/0.5 GeV";
00807   }
00808 
00809   //assume if the mc histogram has some entries it is
00810   //already filled and just needs to be scaled
00811   if(resid->Integral() > 0.) return;
00812 
00813   for(int i = 0; i < fNumEnergyBins; ++i){
00814     err = 1.;
00815     if(energyBins.size() > 0){
00816       mcFit = fit->GetBinContent(i+1);
00817       d = data->GetBinContent(i+1);
00818       if(mcFit>0.) err = TMath::Sqrt(mcFit);
00819       resid->Fill(data->GetBinCenter(i+1),(d-mcFit)/err);
00820     }
00821   }
00822 
00823   resid->SetYTitle(yTitle);
00824 }
00825 
00826 //----------------------------------------------------------------------
00827 void NCBeam::MakeDataGraph()
00828 {
00829   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeDataGraph()" << endl;
00830 
00831   for(int nccc = kNC; nccc <= kCC; ++nccc){
00832     if(fDataHistogram[nccc]->Integral() < 1.)
00833       MakeDataHistogram(fEnergyBins[nccc], fDataHistogram[nccc]);
00834 
00835     MakeGraphFromHistogram(fDataHistogram[nccc], fDataGraph[nccc]);
00836   }
00837 }
00838 
00839 //----------------------------------------------------------------------
00840 void NCBeam::MakeGraphFromHistogram(TH1F* hist,
00841                                     TGraphAsymmErrors* graph) const
00842 {
00843   //MSG("NCBeam", Msg::kInfo) << "   NCBeam::MakeGraphFromHistogram()" << endl;
00844 
00845   //make a histogram to hold the baseline monte carlo
00846   double normalization = 1.;
00847   TString yTitle = "Events/GeV";
00848 
00849   //for the near detector scale the events down by 1.e3 so the axis
00850   //label looks reasonable
00851   if(fDetector == Detector::kNear){
00852     normalization = 1.e3;
00853     yTitle = "10^{3} Events/GeV";
00854   }
00855 
00856   const double poissonErrorsUp[] = { 1.29,  2.75,  4.25,  5.30,  6.78,
00857                                      7.81,  9.28, 10.30, 11.32, 12.79,
00858                                      13.81, 14.82, 16.29, 17.30, 18.32,
00859                                      19.32, 20.80, 21.81, 22.82, 23.82};
00860   const double poissonErrorsDown[] = { 0.00,  0.37,  0.74,  1.10,  2.34,
00861                                        2.75,  3.82,  4.25,  5.30,  6.33,
00862                                        6.78,  7.81,  8.83,  9.28, 10.30,
00863                                        11.32, 12.33, 12.79, 13.81, 14.82};
00864 
00865   for(int i = 0; i < fNumEnergyBins; ++i){
00866     const double norm = normalization*hist->GetBinWidth(i+1);
00867     const double x = hist->GetBinCenter(i+1);
00868     double y = hist->GetBinContent(i+1);
00869 
00870     MSG("NCBeam", Msg::kDebug) << hist->GetName() << " "
00871                                << x << " " << y << endl;
00872 
00873     double errorYLow, errorYHigh;
00874 
00875     if(y < 1.){
00876       errorYLow = y - poissonErrorsDown[0];
00877       errorYHigh = poissonErrorsUp[0] - y;
00878     }
00879     else if(y < 19.){
00880       errorYLow = y - poissonErrorsDown[TMath::Nint(y)];
00881       errorYHigh = poissonErrorsUp[TMath::Nint(y)] - y;
00882     }
00883     else{
00884       errorYLow = TMath::Sqrt(y);
00885       errorYHigh = errorYLow;
00886     }
00887 
00888     y /= norm;
00889     errorYLow /= norm;
00890     errorYHigh /= norm;
00891 
00892     graph->SetPoint(i, x, y);
00893     graph->SetPointEYhigh(i, errorYHigh);
00894     graph->SetPointEYlow(i, errorYLow);
00895 
00896     MSG("NCBeam", Msg::kDebug) << y << " " << TMath::Nint(y)
00897                                << " " << poissonErrorsDown[TMath::Nint(y)]
00898                                << " " << poissonErrorsUp[TMath::Nint(y)]
00899                                << " " << errorYLow << " " << errorYHigh
00900                                << endl;
00901 
00902   }//end loop over energy bins
00903 
00904   graph->GetHistogram()->SetXTitle("E_{vis} (GeV)");
00905   graph->GetHistogram()->SetYTitle(yTitle);
00906   graph->GetHistogram()->GetXaxis()->CenterTitle();
00907   graph->GetHistogram()->GetYaxis()->CenterTitle();
00908 }
00909 
00910 //----------------------------------------------------------------------
00911 const TH1F* NCBeam::GetDefaultMCHistogram(NCType::EEventType nccc) const
00912 {
00913   return fDefaultMCHistogram[nccc];
00914 }
00915 
00916 //----------------------------------------------------------------------
00917 TH1F* NCBeam::GetMCHistogram(NCType::EEventType nccc)
00918 {
00919   return fMCHistogram[nccc];
00920 }
00921 
00922 //----------------------------------------------------------------------
00923 TH1F* NCBeam::GetMCTrueHistogram(NCType::EEventType nccc)
00924 {
00925   return fMCTrueHistogram[nccc];
00926 }
00927 
00928 //----------------------------------------------------------------------
00929 TH1F* NCBeam::GetDataHistogram(NCType::EEventType nccc)
00930 {
00931   return fDataHistogram[nccc];
00932 }
00933 
00934 //----------------------------------------------------------------------
00935 TH1F* NCBeam::GetMCFitHistogram(NCType::EEventType nccc)
00936 {
00937   return fMCFitHistogram[nccc];
00938 }
00939 
00940 //----------------------------------------------------------------------
00941 TH1F* NCBeam::GetMCResidualHistogram(NCType::EEventType nccc)
00942 {
00943   return fMCResidualHistogram[nccc];
00944 }
00945 
00946 //----------------------------------------------------------------------
00947 TH1F* NCBeam::GetMCBackgroundHistogram(NCType::EEventType nccc)
00948 {
00949   return fMCBackgroundHistogram[nccc];
00950 }
00951 
00952 //----------------------------------------------------------------------
00953 TH1F* NCBeam::GetMCNoFitBackgroundHistogram(NCType::EEventType nccc)
00954 {
00955   return fMCNoFitBackgroundHistogram[nccc];
00956 }
00957 
00958 //----------------------------------------------------------------------
00959 TH1F* NCBeam::GetMCFitNuMuToNuTauHistogram(NCType::EEventType nccc)
00960 {
00961   return fMCFitNuMuToNuTau[nccc];
00962 }
00963 
00964 //----------------------------------------------------------------------
00965 TH1F* NCBeam::GetMCNoFitNuMuToNuTauHistogram(NCType::EEventType nccc)
00966 {
00967   return fMCNoFitNuMuToNuTau[nccc];
00968 }
00969 
00970 //----------------------------------------------------------------------
00971 TH1F* NCBeam::GetMCFitNuMuToNuEHistogram(NCType::EEventType nccc)
00972 {
00973   return fMCFitNuMuToNuE[nccc];
00974 }
00975 
00976 //----------------------------------------------------------------------
00977 TH1F* NCBeam::GetMCNoFitNuMuToNuEHistogram(NCType::EEventType nccc)
00978 {
00979   return fMCNoFitNuMuToNuE[nccc];
00980 }
00981 
00982 //----------------------------------------------------------------------
00983 TH1F* NCBeam::GetMCFitNuEToNuEHistogram(NCType::EEventType nccc)
00984 {
00985   return fMCFitNuEToNuE[nccc];
00986 }
00987 
00988 //----------------------------------------------------------------------
00989 TH1F* NCBeam::GetMCNoFitNuEToNuEHistogram(NCType::EEventType nccc)
00990 {
00991   return fMCNoFitNuEToNuE[nccc];
00992 }
00993 
00994 //----------------------------------------------------------------------
00995 TGraphAsymmErrors* NCBeam::GetDataGraph(NCType::EEventType nccc)
00996 {
00997   return fDataGraph[nccc];
00998 }
00999 
01000 //----------------------------------------------------------------------
01001 void NCBeam::Reset(bool data, bool mc)
01002 {
01003   for(int nccc = kNC; nccc <= kCC; ++nccc){
01004     if(data){
01005       fDataHistogram[nccc]->Reset("ICE");
01006       delete fDataGraph[nccc];
01007       fDataGraph[nccc] = new TGraphAsymmErrors;
01008     }
01009     if(mc){
01010       fDefaultMCHistogram[nccc]->Reset("ICE");
01011       fMCHistogram[nccc]->Reset("ICE");
01012       fMCTrueHistogram[nccc]->Reset("ICE");
01013       fMCFitHistogram[nccc]->Reset("ICE");
01014       fMCResidualHistogram[nccc]->Reset("ICE");
01015       fMCBackgroundHistogram[nccc]->Reset("ICE");
01016       fMCNoFitNuMuToNuTau[nccc]->Reset("ICE");
01017       fMCFitNuMuToNuTau[nccc]->Reset("ICE");
01018       fMCNoFitNuMuToNuE[nccc]->Reset("ICE");
01019       fMCFitNuMuToNuE[nccc]->Reset("ICE");
01020       fMCNoFitNuEToNuE[nccc]->Reset("ICE");
01021       fMCFitNuEToNuE[nccc]->Reset("ICE");
01022       fMCNoFitBackgroundHistogram[nccc]->Reset("ICE");
01023     }
01024 
01025     for(unsigned int n = 0; n < fEnergyBins[nccc].size(); ++n)
01026       fEnergyBins[nccc][n]->Reset(data, mc);
01027   }
01028 }
01029 
01030 //----------------------------------------------------------------------
01031 //write out all graphs and histograms
01032 void NCBeam::WriteResources()
01033 {
01034   WritePredictionResources();
01035 
01036   for(int nccc = kNC; nccc <= kCC; ++nccc){
01037     fDataHistogram[nccc]->Write();
01038     fDataGraph[nccc]->Write();
01039   }
01040 }
01041 
01042 //----------------------------------------------------------------------
01043 //write out all graphs and histograms
01044 void NCBeam::WritePredictionResources()
01045 {
01046   for(int nccc = kNC; nccc <= kCC; ++nccc){
01047     fMCHistogram[nccc]->Write();
01048     fMCTrueHistogram[nccc]->Write();
01049     fDefaultMCHistogram[nccc]->Write();
01050     fMCFitHistogram[nccc]->Write();
01051     fMCResidualHistogram[nccc]->Write();
01052     fMCBackgroundHistogram[nccc]->Write();
01053     fMCNoFitNuMuToNuTau[nccc]->Write();
01054     fMCFitNuMuToNuTau[nccc]->Write();
01055     fMCNoFitNuMuToNuE[nccc]->Write();
01056     fMCFitNuMuToNuE[nccc]->Write();
01057     fMCNoFitNuEToNuE[nccc]->Write();
01058     fMCFitNuEToNuE[nccc]->Write();
01059     fMCNoFitBackgroundHistogram[nccc]->Write();
01060   }
01061 }
01062 
01063 //----------------------------------------------------------------------
01064 /*
01065 void NCBeam::Add(const NCBeam& beam)
01066 {
01067   const bool useNC = (fUseNC || fDetector == Detector::kNear);
01068   const bool useCC = (fUseCC || fDetector == Detector::kNear);
01069 
01070   if(beam.GetBeamType() == fInfo.beamType &&
01071      beam.GetDetector() == fDetector){
01072 
01073     fDataPOT += beam.GetDataPOT();
01074     fMCPOT += beam.GetMCPOT();
01075 
01076     //loop over the energy bins in the beam and add them to the bins in this beam
01077     for(unsigned int i = 0; i < fEnergyBins[kCC].size() && useCC; ++i)
01078       fEnergyBins[kCC][i]->Add(beam.GetEnergyBin(i, kCC));
01079 
01080     for(unsigned int i = 0; i < fEnergyBins[kNC].size() && useNC; ++i)
01081       fEnergyBins[kNC][i]->Add(beam.GetEnergyBin(i, kNC));
01082 
01083     // Need to also add histograms. This is my random guess as to the ones
01084     // that we calculate internally instead of being filled externally.
01085     for(int nccc = kNC; nccc <= kCC; ++nccc){
01086       fDefaultMCHistogram[nccc]->Add(fDefaultMCHistogram[nccc]);
01087       fMCHistogram[nccc]->Add(fMCHistogram[nccc]);
01088       fMCTrueHistogram[nccc]->Add(fMCTrueHistogram[nccc]);
01089       fDataHistogram[nccc]->Add(fDataHistogram[nccc]);
01090     // Can't add a TGraphAsymmErrors...
01091     //    fDataGraph[nccc]->Add(fDataGraph[nccc]);
01092     }
01093   }
01094   else
01095     MSG("NCBeam", Msg::kWarning) << " trying to add incompatible beams "
01096                                  << BeamType::AsString(fInfo.beamType) << "/"
01097                                  << BeamType::AsString(beam.GetBeamType())
01098                                  << " " << Detector::AsString(fDetector)
01099                                  << "/" << Detector::AsString(beam.GetDetector())
01100                                  << endl;
01101 }
01102 
01103 */
01104 //----------------------------------------------------------------------
01105 TH1F* NCBeam::NewVisEnergySpectrum(TString name, int col, int fillcol) const
01106 {
01107   TH1F* ret = new TH1F(name, "", fNumEnergyBins, fEnergyBinBoundaries);
01108   ret->SetXTitle("E_{vis} (GeV)");
01109   ret->SetYTitle("Events/GeV");
01110   ret->GetXaxis()->CenterTitle();
01111   ret->GetYaxis()->CenterTitle();
01112   ret->SetLineColor(col);
01113 
01114   if(fillcol >= 0){
01115     ret->SetFillColor(fillcol);
01116     ret->SetFillStyle(3004);
01117   }
01118 
01119   return ret;
01120 }
01121 
01122 
01123 //----------------------------------------------------------------------
01124 void NCBeam::FillResultHistograms(const NC::OscProb::OscPars* oscPars,
01125                                   const NC::SystPars* systPars)
01126 {
01127   if(fResultHistogramsFilled){
01128     MSG("NCBeam", Msg::kWarning) << "Calling FillResultHistograms again on "
01129                                  << "the same beam "
01130                                  << GetInfo().GetDescription()
01131                                  << GetDetector()
01132                                  << ". Call ignored." << endl;
01133     return;
01134   }
01135   fResultHistogramsFilled = true;
01136 
01137   using NCType::EEventType;
01138   using NCType::kNC;
01139   using NCType::kCC;
01140 
01141   // These are the variables we load the event information into
01142   double trueEnergy, recoShowerE, recoMuonE, weight;
01143   int flavor;
01144 
01145   const Detector::Detector_t det = GetDetector();
01146   const double baseLine = (det == Detector::kFar) ? NCType::kBaseLineFar
01147                                                   : NCType::kBaseLineNear;
01148 
01149   //loop over NC/CC energy bins in beam
01150   for(EEventType nccc = kNC; nccc <= kCC; nccc = EEventType(int(nccc)+1)){
01151 
01152     if(nccc == kNC && det == Detector::kFar && !fUseNC) continue;
01153     if(nccc == kCC && det == Detector::kFar && !fUseCC) continue;
01154 
01155     const EEventType sigType = EEventType(nccc);
01156     const EEventType bkgType = (nccc == kNC) ? kCC : kNC;
01157 
01158     const int I = GetNumberEnergyBins(nccc);
01159     for(int i = 0; i < I; ++i){
01160       NCEnergyBin* bin = GetEnergyBin(i, nccc);
01161 
01162       const int mcSize             = bin->GetMCSignalVectorSize();
01163       const int mcSize_bkg         = bin->GetMCBackgroundVectorSize();
01164       const int mcSize_NuMuToNuTau = bin->GetMCNuTauVectorSize();
01165       const int mcSize_NuEToNuE    = bin->GetMCBeamNuEVectorSize();
01166       const int mcSize_NuMuToNuE   = bin->GetMCOscNuEVectorSize();
01167 
01168       for(int e = 0; e < mcSize; ++e){
01169         bin->GetMCInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01170         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuMu,
01171                                                              sigType,
01172                                                              baseLine,
01173                                                              trueEnergy);
01174 
01175         GetMCHistogram(sigType)->
01176           Fill(recoShowerE*systPars->ShowerScale(det)
01177                + recoMuonE*systPars->TrackScale(),
01178                weight*systPars->NormScale());
01179 
01180         GetMCTrueHistogram(sigType)->Fill(trueEnergy,weight);
01181 
01182         GetMCFitHistogram(sigType)->
01183           Fill(recoShowerE*systPars->ShowerScale(det)
01184                + recoMuonE*systPars->TrackScale(),
01185                weight*survivalProb*systPars->NormScale());
01186       }//end loop over signal
01187 
01188       for(int e = 0; e < mcSize_bkg; ++e){
01189         bin->GetMCBackgroundInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01190 
01191         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuMu,
01192                                                              bkgType,
01193                                                              baseLine,
01194                                                              trueEnergy);
01195 
01196         GetMCBackgroundHistogram(sigType)->
01197           Fill(recoShowerE*systPars->ShowerScale(det)
01198                + recoMuonE*systPars->TrackScale(),
01199                weight*survivalProb*systPars->NormScale());
01200 
01201         GetMCHistogram(sigType)->
01202           Fill(recoShowerE*systPars->ShowerScale(det)
01203                + recoMuonE*systPars->TrackScale(),
01204                weight*systPars->NormScale());
01205 
01206         GetMCFitHistogram(sigType)->
01207           Fill(recoShowerE*systPars->ShowerScale(det)
01208                + recoMuonE*systPars->TrackScale(),
01209                weight*survivalProb*systPars->NormScale());
01210       }//end loop over background
01211 
01212       //nutau
01213       for(int e = 0; e < mcSize_NuMuToNuTau; ++e){
01214         bin->GetMCNuTauInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01215 
01216         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuTau,
01217                                                              kCC,
01218                                                              baseLine,
01219                                                              trueEnergy);
01220 
01221         GetMCFitNuMuToNuTauHistogram(sigType)->
01222           Fill(recoShowerE*systPars->ShowerScale(det)
01223                + recoMuonE*systPars->TrackScale(),
01224                weight*survivalProb*systPars->NormScale());
01225 
01226         GetMCFitHistogram(sigType)->
01227           Fill(recoShowerE*systPars->ShowerScale(det)
01228                + recoMuonE*systPars->TrackScale(),
01229                weight*survivalProb*systPars->NormScale());
01230 
01231         GetMCNoFitNuMuToNuTauHistogram(sigType)->
01232           Fill(recoShowerE*systPars->ShowerScale(det)
01233                + recoMuonE*systPars->TrackScale(),
01234                weight*systPars->NormScale());
01235       }//end loop over taus
01236 
01237       //nue
01238       for(int e = 0; e < mcSize_NuEToNuE; ++e){
01239         bin->GetMCBeamNuEInformation(trueEnergy, recoShowerE, recoMuonE, weight, flavor, e);
01240 
01241         double survivalProb = oscPars->TransitionProbability(NCType::kNuEToNuE,
01242                                                              kCC,
01243                                                              baseLine,
01244                                                              trueEnergy);
01245         GetMCHistogram(sigType)->
01246           Fill(recoShowerE*systPars->ShowerScale(det)
01247                + recoMuonE*systPars->TrackScale(),
01248                weight*systPars->NormScale());
01249 
01250         GetMCFitHistogram(sigType)->
01251           Fill(recoShowerE*systPars->ShowerScale(det)
01252                + recoMuonE*systPars->TrackScale(),
01253                weight*systPars->NormScale()
01254                *survivalProb);
01255 
01256         GetMCNoFitNuEToNuEHistogram(sigType)->
01257           Fill(recoShowerE*systPars->ShowerScale(det)
01258                + recoMuonE*systPars->TrackScale(),
01259                weight*systPars->NormScale());
01260 
01261         GetMCFitNuEToNuEHistogram(sigType)->
01262           Fill(recoShowerE*systPars->ShowerScale(det)
01263                + recoMuonE*systPars->TrackScale(),
01264                weight*systPars->NormScale()
01265                *survivalProb);
01266       }//end loop over electrons
01267 
01268       //nue appearance
01269       for(int e = 0; e < mcSize_NuMuToNuE; ++e){
01270         bin->GetMCOscNuEInformation(trueEnergy, recoShowerE,
01271                                     recoMuonE, weight, flavor, e);
01272 
01273         double survivalProb = oscPars->TransitionProbability(NCType::kNuMuToNuE,
01274                                                              kCC,
01275                                                              baseLine,
01276                                                              trueEnergy);
01277 
01278         GetMCFitHistogram(sigType)->
01279           Fill(recoShowerE*systPars->ShowerScale(det)
01280                + recoMuonE*systPars->TrackScale(),
01281                weight*survivalProb*systPars->NormScale());
01282 
01283         GetMCNoFitNuMuToNuEHistogram(sigType)->
01284           Fill(recoShowerE*systPars->ShowerScale(det)
01285                + recoMuonE*systPars->TrackScale(),
01286                weight*systPars->NormScale());
01287 
01288         GetMCFitNuMuToNuEHistogram(sigType)->
01289           Fill(recoShowerE*systPars->ShowerScale(det)
01290                + recoMuonE*systPars->TrackScale(),
01291                weight*survivalProb*systPars->NormScale());
01292       }//end loop over electron appearance
01293 
01294     }//end loop over energy bins
01295 
01296   }//end loop over nc/cc
01297 }

Generated on Mon Feb 15 11:07:03 2010 for loon by  doxygen 1.3.9.1