MiniMaker Class Reference

#include <MiniMaker.h>

List of all members.

Public Member Functions

 MiniMaker ()
void AddFiles (string files)
void SetOutputFile (string name)
void Config (Registry &r)
void SetCuts (string type, int level=0)
bool EvaluateCuts (NueRecord *nr)
void RunMiniMaker ()
void SetDeltaMSquare (double dm2)
void SetUe3Square (double dUe32)
void SetTheta23 (double t23)
void SetBaseline (double bl)
void RecalculatePOT ()

Private Attributes

string outFile
bool outSet
vector< string > files
NueAnalysisCuts fCuts
double fDeltaMSquare
double fUe3Square
double fTheta23
double fBaseline
bool fReweight
string cutSet
int cutLevel
bool fOverWritePOT

Detailed Description

Definition at line 16 of file MiniMaker.h.


Constructor & Destructor Documentation

MiniMaker::MiniMaker (  ) 

Definition at line 6 of file MiniMaker.cxx.

References fBaseline, fDeltaMSquare, fOverWritePOT, fReweight, fTheta23, fUe3Square, and outSet.

00006                     { 
00007   outSet = false;
00008   fReweight = false;
00009   fBaseline = 735;
00010   fDeltaMSquare = 0.0027;
00011   fUe3Square = 0.025;
00012   fTheta23 = TMath::Pi()/4;
00013 
00014   fOverWritePOT = false;
00015 }


Member Function Documentation

void MiniMaker::AddFiles ( string  files  ) 

Definition at line 17 of file MiniMaker.cxx.

References files.

00018 {
00019    files.push_back(infiles);
00020 }

void MiniMaker::Config ( Registry r  ) 

Definition at line 28 of file MiniMaker.cxx.

References NueAnalysisCuts::Config(), and fCuts.

00029 {
00030   fCuts.Config(r);
00031 }

bool MiniMaker::EvaluateCuts ( NueRecord nr  ) 

Definition at line 190 of file MiniMaker.cxx.

References cutLevel, cutSet, Selection::kCC, Selection::kDataQual, Selection::kFid, Selection::kPre, NueConvention::NueEnergyCorrection(), NueStandard::PassesMREFiducial(), NueStandard::PassesMREPreSelection(), NueStandard::PassesNonHEPreSelection(), NueStandard::PassesSelection(), and NueStandard::PassesSysPreSelection().

Referenced by RunMiniMaker().

00191 {
00192    NueConvention::NueEnergyCorrection(nr);  
00193 
00194    if(cutSet == "Fiducial") 
00195      return NueStandard::PassesSelection(nr, Selection::kFid);
00196 
00197    if(cutSet == "Standard"){
00198       bool ret;
00199       switch(cutLevel){
00200         case 0: return NueStandard::PassesSelection(nr, Selection::kDataQual);
00201         case 1: return NueStandard::PassesSelection(nr, Selection::kFid);
00202         case 2: 
00203              ret = NueStandard::PassesSelection(nr, Selection::kFid);
00204              ret = ret &&  NueStandard::PassesNonHEPreSelection(nr);
00205              return ret;
00206         case 3: return NueStandard::PassesSelection(nr, Selection::kPre);
00207       }
00208    }
00209    if(cutSet == "MRE" || cutSet == "MRCC"){
00210       bool dq = NueStandard::PassesSelection(nr, Selection::kDataQual);
00211       bool mrefid = NueStandard::PassesMREFiducial(nr);
00212       bool mrepre = NueStandard::PassesMREPreSelection(nr) && mrefid && dq;
00213       bool ret;
00214       switch(cutLevel){
00215         case 0: return mrefid && dq;
00216         case 1: return mrepre;
00217         case 2: 
00218           return NueStandard::PassesSelection(nr, Selection::kFid) && mrepre;
00219         case 3:
00220              ret = NueStandard::PassesSelection(nr, Selection::kFid);
00221              ret = ret &&  NueStandard::PassesNonHEPreSelection(nr);
00222              return ret && mrepre;
00223         case 4: 
00224          return NueStandard::PassesSelection(nr, Selection::kPre) && mrepre;
00225       }
00226    }
00227    if(cutSet == "Presel")
00228       return NueStandard::PassesSelection(nr, Selection::kPre);
00229 
00230    if(cutSet == "PreselNoHE")
00231       return  NueStandard::PassesNonHEPreSelection(nr);
00232 
00233    if(cutSet == "Systematic")
00234       return NueStandard::PassesSysPreSelection(nr);
00235 
00236    if(cutSet == "CC")
00237       return NueStandard::PassesSelection(nr, Selection::kCC);
00238 
00239 
00240   cout<<"Invalid Cut Level for "<<cutSet<<": "<<cutLevel<<endl;
00241   return false;
00242 }

void MiniMaker::RecalculatePOT (  )  [inline]

Definition at line 32 of file MiniMaker.h.

References fOverWritePOT.

00032 {fOverWritePOT = true;}; 

void MiniMaker::RunMiniMaker (  ) 

Definition at line 38 of file MiniMaker.cxx.

References NuePOT::beamtype, BeamMon::bI, NueRecord::bmon, count, ANtpTruthInfoBeamNue::DeltamSquared23, det, EvaluateCuts(), fDeltaMSquare, files, NueMiniAna::FillMini(), ANtpTruthInfoBeamNue::fOscProb, fOverWritePOT, fReweight, fTheta23, fUe3Square, NueHeader::GetBeamType(), VldContext::GetDetector(), NueHeader::GetEventNo(), NueHeader::GetEvents(), RecRecordImp< T >::GetHeader(), NueHeader::GetRelease(), VldContext::GetSimFlag(), RecHeader::GetVldContext(), isMC, Selection::kDataQual, Selection::kFid, SimFlag::kMC, NueRecord::mctrue, n, Munits::nm, ANtpTruthInfoBeam::nonOscNuFlavor, NuePOT::nruns, NuePOT::nsnarls, ANtpTruthInfo::nuEnergy, ANtpTruthInfo::nuFlavor, Oscillate(), outFile, outSet, NueStandard::PassesDataQuality(), NueStandard::PassesSelection(), NuePOT::pot, NueRecord::srevent, ANtpTruthInfoBeamNue::Theta23, total(), ANtpTruthInfoBeamNue::Ue3Squared, ANtpEventInfo::vtxX, ANtpEventInfo::vtxY, and ANtpEventInfo::vtxZ.

00039 {
00040   NueRecord *nr = new NueRecord();
00041   NuePOT *np = new NuePOT();
00042   NuePOT *total = new NuePOT();
00043 
00044   TChain *chain = new TChain("ana_nue");
00045   chain->SetBranchAddress("NueRecord",&nr);
00046                                                                         
00047   TChain *pchain = new TChain("pottree");
00048   pchain->SetBranchAddress("NuePOT", &np);
00049  
00050   for(unsigned int i = 0; i < files.size(); i++)
00051   {
00052       chain->Add(files[i].c_str());
00053       pchain->Add(files[i].c_str());
00054   }
00055   
00056   if(!outSet){
00057      string file;
00058                                                                         
00059      if(pchain->GetEntries() > 0){
00060         pchain->GetEntry(0);
00061         total->beamtype = np->beamtype;
00062         file = pchain->GetFile()->GetName();
00063      }
00064      string minifile = file.substr(file.find_last_of("/")+1, file.find_last_of(".root")-file.find_last_of("/") - 5);
00065      minifile += "-Mini.root";
00066   
00067      outFile = minifile;
00068   }
00069   if(outFile == "-Mini.root"){
00070      cout<<"No input file found"<<endl; 
00071      return;
00072   }
00073                                                                          
00074   cout<<"Setting output to "<<outFile<<endl;
00075 
00076   // And now the actual looping
00077                                                                                 
00078   TFile *save = new TFile(outFile.c_str(),"RECREATE");
00079   save->SetCompressionLevel(9);
00080   save->cd();
00081   TTree *tree = new TTree("NueMini","NueMini");
00082   TTree::SetBranchStyle(1);
00083 
00084   if(chain->GetEntries() > 0) chain->GetEvent(0);
00085   Detector::Detector_t det = nr->GetHeader().GetVldContext().GetDetector();
00086   ReleaseType::Release_t rel = nr->GetHeader().GetRelease();
00087   BeamType::BeamType_t beam = nr->GetHeader().GetBeamType();
00088                                                                                 
00089   NueMiniAna nma;
00090                                                                                 
00091   NueMini* nm = new NueMini(beam, det, rel);
00092 
00093   TBranch* br = tree->Branch("NueMini","NueMini", &nm );
00094   br->SetAutoDelete(kFALSE);
00095                                                                         
00096   Int_t n = chain->GetEntries();
00097   int count = 0;
00098 
00099   bool isMC = false;
00100   double TotPOT = 0.0;
00101 
00102   for(int i=0;i<n;i++){
00103     if(i%10000==0) cout << 100*float(i)/float(n)
00104                        << "% done" << endl;
00105     chain->GetEvent(i);
00106 
00107     if(i == 0){
00108       SimFlag::SimFlag_t sim = nr->GetHeader().GetVldContext().GetSimFlag();
00109       isMC = (sim == SimFlag::kMC);
00110     }       
00111 
00112     if(NueStandard::PassesDataQuality(nr)) {
00113        if(nr->GetHeader().GetEventNo() == 0 ||
00114              nr->GetHeader().GetEvents() == 0){
00115           TotPOT += nr->bmon.bI;
00116           if(nr->bmon.bI < 0 && !isMC) cout<<"Unexpected behavior"<<endl;
00117        }
00118     }
00119 
00120     if(EvaluateCuts(nr)){
00121        if(fReweight && nr->mctrue.nuFlavor > -10)
00122        {
00123           int nuFlavor = nr->mctrue.nuFlavor;
00124           int  nonOsc = nr->mctrue.nonOscNuFlavor;
00125           float energy = nr->mctrue.nuEnergy;
00126                                                                                 
00127           Float_t newWeight = NueConvention::Oscillate(nuFlavor, nonOsc, energy,                                735, fDeltaMSquare, fTheta23, fUe3Square);
00128                                                                                 
00129           nr->mctrue.Ue3Squared = fUe3Square;
00130           nr->mctrue.DeltamSquared23 = fDeltaMSquare;
00131           nr->mctrue.Theta23  = fTheta23;
00132           nr->mctrue.fOscProb = newWeight;
00133        }
00134        nma.FillMini(nr, nm);
00135 
00136        tree->Fill();
00137        count++;
00138     }
00139 #ifdef DEBUG_OUTPUT
00140     else{
00141       float x = nr->srevent.vtxX;
00142       float y = nr->srevent.vtxY;
00143       float r = TMath::Sqrt(x*x+y*y);
00144 
00145       cout<<"rejecting event"<<x<<"  "<<y<<"  "<<r<<"  "
00146           <<nr->srevent.vtxZ<<"  "
00147           <<NueStandard::PassesSelection(nr, Selection::kDataQual)
00148           <<"  "<<NueStandard::PassesSelection(nr, Selection::kFid)<<endl;
00149 
00150     }
00151 #endif
00152   }
00153   cout<<count<<" of "<<n<<" entries were passed"<<endl;
00154                                                                         
00155   TTree *ptree = new TTree("pottree","pottree");
00156   TBranch* br2 = ptree->Branch("NuePOT","NuePOT", &total );
00157   br2->SetAutoDelete(kFALSE);
00158                                                                         
00159   for(int i = 0; i < pchain->GetEntries(); i++)
00160   {
00161      pchain->GetEntry(i);
00162                                                                         
00163      if(total->beamtype != np->beamtype)
00164         cerr<<"You are merging files of different beamtyp - BAD"<<endl;
00165                                                                         
00166      total->nruns +=  np->nruns;
00167      total->nsnarls +=  np->nsnarls;
00168      total->pot += np->pot;
00169   }
00170 
00171   if(fOverWritePOT && !isMC) total->pot = TotPOT;
00172 
00173   ptree->Fill();
00174                                                                         
00175   save->cd();
00176   tree->Write();
00177   ptree->Write();
00178   
00179   cout<<"Compression level of output file "<<save->GetCompressionLevel()<<"\n";
00180   
00181   cout<<"Trimming completed with "<<total->pot<<"x10^12 POT"<<endl;
00182 }

void MiniMaker::SetBaseline ( double  bl  ) 

Definition at line 36 of file MiniMaker.cxx.

References fBaseline, and fReweight.

00036 { fBaseline = bl; fReweight = true;}

void MiniMaker::SetCuts ( string  type,
int  level = 0 
)

Definition at line 184 of file MiniMaker.cxx.

References cutLevel, and cutSet.

00185 {
00186    cutSet = type;
00187    cutLevel = level;   
00188 }

void MiniMaker::SetDeltaMSquare ( double  dm2  ) 

Definition at line 33 of file MiniMaker.cxx.

References fDeltaMSquare, and fReweight.

00033 { fDeltaMSquare = dm2; fReweight = true;}

void MiniMaker::SetOutputFile ( string  name  ) 

Definition at line 22 of file MiniMaker.cxx.

References outFile, and outSet.

00023 {
00024    outSet = true;
00025    outFile = file;
00026 }   

void MiniMaker::SetTheta23 ( double  t23  ) 

Definition at line 35 of file MiniMaker.cxx.

References fReweight, and fTheta23.

00035 { fTheta23 = t23; fReweight = true;}

void MiniMaker::SetUe3Square ( double  dUe32  ) 

Definition at line 34 of file MiniMaker.cxx.

References fReweight, and fUe3Square.

00034 { fUe3Square = dUe32; fReweight = true;}


Member Data Documentation

int MiniMaker::cutLevel [private]

Definition at line 47 of file MiniMaker.h.

Referenced by EvaluateCuts(), and SetCuts().

string MiniMaker::cutSet [private]

Definition at line 46 of file MiniMaker.h.

Referenced by EvaluateCuts(), and SetCuts().

double MiniMaker::fBaseline [private]

Definition at line 43 of file MiniMaker.h.

Referenced by MiniMaker(), and SetBaseline().

Definition at line 38 of file MiniMaker.h.

Referenced by Config().

double MiniMaker::fDeltaMSquare [private]

Definition at line 40 of file MiniMaker.h.

Referenced by MiniMaker(), RunMiniMaker(), and SetDeltaMSquare().

vector<string> MiniMaker::files [private]

Definition at line 37 of file MiniMaker.h.

Referenced by AddFiles(), and RunMiniMaker().

bool MiniMaker::fOverWritePOT [private]

Definition at line 49 of file MiniMaker.h.

Referenced by MiniMaker(), RecalculatePOT(), and RunMiniMaker().

bool MiniMaker::fReweight [private]
double MiniMaker::fTheta23 [private]

Definition at line 42 of file MiniMaker.h.

Referenced by MiniMaker(), RunMiniMaker(), and SetTheta23().

double MiniMaker::fUe3Square [private]

Definition at line 41 of file MiniMaker.h.

Referenced by MiniMaker(), RunMiniMaker(), and SetUe3Square().

string MiniMaker::outFile [private]

Definition at line 32 of file MiniMaker.h.

Referenced by RunMiniMaker(), and SetOutputFile().

bool MiniMaker::outSet [private]

Definition at line 36 of file MiniMaker.h.

Referenced by MiniMaker(), RunMiniMaker(), and SetOutputFile().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1