Trimmer Class Reference

#include <Trimmer.h>

List of all members.

Public Member Functions

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

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
bool separatebyRunPeriod
bool isRHC

Detailed Description

Definition at line 16 of file Trimmer.h.


Constructor & Destructor Documentation

Trimmer::Trimmer (  ) 

Definition at line 6 of file Trimmer.cxx.

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

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   separatebyRunPeriod = false;
00016   isRHC = false;
00017 }


Member Function Documentation

void Trimmer::AddFiles ( string  files  ) 

Definition at line 19 of file Trimmer.cxx.

References files.

00020 {
00021    files.push_back(infiles);
00022 }

void Trimmer::Config ( Registry r  ) 

Definition at line 30 of file Trimmer.cxx.

References NueAnalysisCuts::Config(), and fCuts.

00031 {
00032   fCuts.Config(r);
00033 }

bool Trimmer::EvaluateCuts ( NueRecord nr  ) 

Definition at line 634 of file Trimmer.cxx.

References cutLevel, cutSet, NueStandard::GetPIDValue(), NueStandard::IsGoodRun(), NueStandard::IsInFid(), Selection::kANN2PE, Selection::kBasic, Selection::kCC, Selection::kDataQual, Selection::kFid, Selection::kMCNN, Selection::kPre, NueStandard::PassesMRCCFiducial(), NueStandard::PassesMRCCPreSelection(), NueStandard::PassesMREFiducial(), NueStandard::PassesNonHEPreSelection(), NueStandard::PassesPreSelectionTrackCuts(), NueStandard::PassesSelection(), NueStandard::PassesSysPreSelection(), and NueStandard::PassesSysPreSelectionNoHE().

Referenced by RunTrimmer().

00635 {
00636         //just for merging files!
00637    if(cutSet == "Merge")
00638         return true;
00639 
00640    if(cutSet == "Fiducial") 
00641      return NueStandard::IsInFid(nr);
00642 
00643    if(cutSet == "Standard"){
00644       bool ret;
00645       switch(cutLevel){
00646         case 0: return NueStandard::PassesSelection(nr, Selection::kDataQual);
00647         case 1: return NueStandard::PassesSelection(nr, Selection::kFid);
00648         case 2: return NueStandard::PassesSelection(nr, Selection::kBasic);
00649         case 3: 
00650              ret = NueStandard::PassesSelection(nr, Selection::kBasic);
00651              ret = ret && NueStandard::PassesPreSelectionTrackCuts(nr);
00652              return ret;
00653         case 4: 
00654              ret = NueStandard::PassesSelection(nr, Selection::kBasic);
00655              ret = ret &&  NueStandard::PassesNonHEPreSelection(nr);
00656              return ret;
00657         case 5: return NueStandard::PassesSelection(nr, Selection::kPre);
00658       }
00659    }
00660    if(cutSet == "MRE" || cutSet == "MRCC"){
00661       bool dq = NueStandard::PassesSelection(nr, Selection::kDataQual);
00662       bool mrefid = NueStandard::PassesMREFiducial(nr);
00663       bool ret;
00664       switch(cutLevel){
00665         case 0: return dq && NueStandard::IsInFid(nr);
00666         case 1: return mrefid && dq && NueStandard::IsInFid(nr);
00667         case 2: 
00668           return NueStandard::PassesSelection(nr, Selection::kFid);//includes mrcc presel & mrcc fiducial
00669         case 3: return NueStandard::PassesSelection(nr,Selection::kBasic);
00670         case 4:
00671              ret = NueStandard::PassesSelection(nr,Selection::kBasic);
00672              ret = ret && NueStandard::PassesPreSelectionTrackCuts(nr);
00673              return ret;
00674         case 5:
00675              ret = NueStandard::PassesSelection(nr, Selection::kBasic);
00676              ret = ret &&  NueStandard::PassesNonHEPreSelection(nr);
00677              return ret;
00678         case 6: 
00679          return NueStandard::PassesSelection(nr, Selection::kPre);
00680       }
00681    }
00682    if(cutSet == "Presel")
00683       return NueStandard::PassesSelection(nr, Selection::kPre);
00684 
00685    if(cutSet == "PreselNoHE")
00686       return  NueStandard::PassesNonHEPreSelection(nr);
00687 
00688    if(cutSet == "Systematic"){
00689       // O - standard systematic envelope
00690       // 1 - standard systematic w/out HE cut
00691       if(!NueStandard::IsInFid(nr)) return false;
00692 
00693       switch(cutLevel){
00694         case 0: return NueStandard::PassesSysPreSelection(nr);
00695         case 1: return NueStandard::PassesSysPreSelectionNoHE(nr);
00696       }
00697    }
00698 
00699 
00700    if(cutSet == "CC")
00701       return NueStandard::PassesSelection(nr, Selection::kCC);
00702    
00703    if(cutSet == "GoodRun")
00704      return NueStandard::IsGoodRun(nr);
00705    
00706    if(cutSet == "AntiANN11")
00707    {
00708      if(NueStandard::PassesSelection(nr, Selection::kPre) && NueStandard::GetPIDValue(nr,Selection::kANN2PE)<0.55)
00709      {
00710        return true;
00711      }
00712      else
00713      {
00714        return false;
00715      }
00716    }
00717    
00718    if(cutSet == "AntiMCNN")
00719    {
00720      if(NueStandard::PassesSelection(nr, Selection::kPre) && NueStandard::GetPIDValue(nr,Selection::kMCNN)<0.55)
00721      {
00722        return true;
00723      }
00724      else
00725      {
00726        return false;
00727      }
00728    }
00729    if(cutSet=="MRCuts")
00730    {
00731      if(NueStandard::PassesSelection(nr, Selection::kDataQual) && NueStandard::PassesMRCCFiducial(nr) && NueStandard::PassesMRCCPreSelection(nr))
00732      {
00733        return true;
00734      }
00735      return false;
00736    }
00737    
00738   cout<<"Invalid Cut Level for "<<cutSet<<": "<<cutLevel<<endl;
00739   return false;
00740 }

void Trimmer::RecalculatePOT (  )  [inline]

Definition at line 32 of file Trimmer.h.

References fOverWritePOT.

00032 {fOverWritePOT = true;};

void Trimmer::RunTrimmer (  ) 

Definition at line 40 of file Trimmer.cxx.

References NueRecord::anainfo, base, beamtype, NuePOT::beamtype, BeamMon::bI, NueRecord::bmon, count, ANtpTruthInfoBeamNue::DeltamSquared23, det, EvaluateCuts(), NueRecord::eventq, fDeltaMSquare, files, ANtpTruthInfoBeamNue::fOscProb, fOverWritePOT, fReweight, fTheta23, fUe3Square, NueHeader::GetBeamType(), VldContext::GetDetector(), NueHeader::GetEventNo(), NueHeader::GetEvents(), RecRecordImp< T >::GetHeader(), NueStandard::GetIntensityBeamWeight(), MCInfo::GetMCPoT(), NueStandard::GetNDDataWeights(), NueHeader::GetRelease(), NueHeader::GetRun(), VldContext::GetSimFlag(), RecHeader::GetVldContext(), DataUtil::IsGoodData(), isMC, AnalysisInfoNue::isRHC, isRHC, NueStandard::IsRun1(), NueStandard::IsRun11(), NueStandard::IsRun12(), NueStandard::IsRun13(), NueStandard::IsRun2(), NueStandard::IsRun3(), Detector::kFar, SimFlag::kMC, Detector::kNear, NueRecord::mctrue, n, ANtpTruthInfoBeam::nonOscNuFlavor, NuePOT::nruns, NuePOT::nsnarls, NueConvention::NueEnergyCorrection(), ANtpTruthInfo::nuEnergy, ANtpTruthInfo::nuFlavor, Oscillate(), outFile, outSet, NueStandard::PassesPOTStandards(), EventQual::passFarDetQuality, EventQual::passNearDetQuality, NuePOT::pot, NuePOT::pot_nocut, NueConvention::RHCNueEnergyCorrection(), separatebyRunPeriod, NueStandard::SetE50PID(), ANtpTruthInfoBeamNue::Theta23, and ANtpTruthInfoBeamNue::Ue3Squared.

00041 {
00042   
00043   NueRecord *nr = new NueRecord();
00044   NuePOT *np = new NuePOT();
00045 
00046   TChain *chain = new TChain("ana_nue");
00047   chain->SetBranchAddress("NueRecord",&nr);
00048                                                                         
00049   TChain *pchain = new TChain("pottree");
00050   pchain->SetBranchAddress("NuePOT", &np);
00051  
00052   for(unsigned int i = 0; i < files.size(); i++)
00053   {
00054       chain->Add(files[i].c_str());
00055       pchain->Add(files[i].c_str());
00056   }
00057   
00058   if(!outSet){
00059      string file;
00060                                                                         
00061      if(pchain->GetEntries() > 0){
00062         pchain->GetEntry(0);
00063         file = pchain->GetFile()->GetName();
00064      }
00065      string minifile = file.substr(file.find_last_of("/")+1, file.find_last_of(".root")-file.find_last_of("/") - 5);
00066      minifile += "-Trim.root";
00067   
00068      outFile = minifile;
00069   }
00070   if(outFile == "-Trim.root"){
00071      cout<<"No input file found"<<endl; 
00072      return;
00073   }
00074   
00075   string out1,out2,out3,out11,out12,out13;
00076   if(separatebyRunPeriod)
00077   {
00078     string base = outFile.substr(0,outFile.size()-5);//strip off '.root' and add label for run period
00079     out1 = base + "_RunPeriod1.root";
00080     out2 = base + "_RunPeriod2.root";
00081     out3 = base + "_RunPeriod3.root";
00082     out11 = base + "_RunPeriod11.root";
00083     out12 = base + "_RunPeriod12.root";
00084     out13 = base + "_RunPeriod13.root";
00085     cout<<"Setting output to:"<<endl;
00086     cout<<out1<<endl;
00087     cout<<out2<<endl;
00088     cout<<out3<<endl;
00089     cout<<out11<<endl;
00090     cout<<out12<<endl;
00091     cout<<out13<<endl;
00092 
00093 
00094   }
00095   else
00096   {
00097     cout<<"Setting output to "<<outFile<<endl;
00098     out1 = outFile;
00099   }
00100 
00101   // And now the actual looping
00102   
00103   TFile *f1 = new TFile(out1.c_str(),"RECREATE");
00104   TFile *f2=0,*f3=0, *f11=0, *f12=0, *f13=0;
00105   if(separatebyRunPeriod)
00106   {
00107     f2 = new TFile(out2.c_str(),"RECREATE");
00108     f3 = new TFile(out3.c_str(),"RECREATE");
00109 
00110     f11 = new TFile(out11.c_str(),"RECREATE");
00111     f12 = new TFile(out12.c_str(),"RECREATE");
00112     f13 = new TFile(out13.c_str(),"RECREATE");
00113 
00114   }
00115   
00116   f1->cd();
00117   TTree *tree1 = new TTree("ana_nue","ana_nue");
00118   TTree::SetBranchStyle(1);
00119   TBranch* br1 = tree1->Branch("NueRecord","NueRecord", &nr );
00120   br1->SetAutoDelete(kFALSE);
00121   
00122   TTree *tree2=0;
00123   TTree *tree3=0;
00124   TBranch* br2=0;
00125   TBranch* br3=0;
00126 
00127   TTree *tree11=0;
00128   TTree *tree12=0;
00129   TTree *tree13=0;
00130   TBranch* br11=0;
00131   TBranch* br12=0;
00132   TBranch* br13=0;
00133 
00134 
00135 
00136   if(separatebyRunPeriod)
00137   {
00138     f2->cd();
00139     tree2 = new TTree("ana_nue","ana_nue");
00140     br2 = tree2->Branch("NueRecord","NueRecord", &nr );
00141     br2->SetAutoDelete(kFALSE);
00142     
00143     f3->cd();
00144     tree3 = new TTree("ana_nue","ana_nue");
00145     br3 = tree3->Branch("NueRecord","NueRecord", &nr );
00146     br3->SetAutoDelete(kFALSE);
00147 
00148     
00149     f11->cd();
00150     tree11 = new TTree("ana_nue","ana_nue");
00151     br11 = tree11->Branch("NueRecord","NueRecord", &nr );
00152     br11->SetAutoDelete(kFALSE);
00153     
00154     f12->cd();
00155     tree12 = new TTree("ana_nue","ana_nue");
00156     br12 = tree12->Branch("NueRecord","NueRecord", &nr );
00157     br12->SetAutoDelete(kFALSE);
00158     
00159     f13->cd();
00160     tree13 = new TTree("ana_nue","ana_nue");
00161     br13 = tree13->Branch("NueRecord","NueRecord", &nr );
00162     br13->SetAutoDelete(kFALSE);
00163 
00164   }
00165   
00166   bool isRunPeriod1=false;
00167   bool isRunPeriod2=false;
00168   bool isRunPeriod3=false;
00169   bool isRunPeriod11=false;
00170   bool isRunPeriod12=false;
00171   bool isRunPeriod13=false;
00172   
00173   Int_t n = chain->GetEntries();
00174   int count = 0;
00175 
00176   bool isMC = false;
00177   
00178   //for recalculating the pot tree for each run period
00179   double TotPOT1 = 0.0,TotPOT2 = 0.0,TotPOT3 = 0.0,TotPOT11 = 0.0, TotPOT12 = 0.0, TotPOT13 = 0.0;
00180   double TotPOT1_nocut = 0.0,TotPOT2_nocut = 0.0,TotPOT3_nocut = 0.0,TotPOT11_nocut = 0.0,TotPOT12_nocut = 0.0,TotPOT13_nocut = 0.0;
00181   Int_t nruns=0;
00182   Int_t nsnarls1=0,nsnarls2=0,nsnarls3=0;
00183   Int_t nsnarls11=0,nsnarls12=0,nsnarls13=0;
00184  
00185   int lastrun=-1;
00186 
00187   double potweight;
00188   double nddataweight;
00189   
00190   chain->GetEntry(0);
00191   ReleaseType::Release_t rel = nr->GetHeader().GetRelease();
00192   BeamType::BeamType_t beamtype = nr->GetHeader().GetBeamType();
00193   Detector::Detector_t det = nr->GetHeader().GetVldContext().GetDetector();
00194   
00195   for(int i=0;i<n;i++){
00196     if(i%10000==0) cout << 100*float(i)/float(n)
00197                        << "% done" << endl;
00198     chain->GetEvent(i);
00199     
00200     NueConvention::NueEnergyCorrection(nr);
00201     if(isRHC) NueConvention::RHCNueEnergyCorrection(nr);
00202     
00203     nr->anainfo.isRHC = isRHC;
00204     
00205     //NueStandard::ModifyANNPID(nr);
00206     NueStandard::SetE50PID(nr);    
00207 
00208 
00209     nr->eventq.passFarDetQuality = DataUtil::IsGoodData(nr->GetHeader().GetVldContext());
00210     nr->eventq.passNearDetQuality = nr->eventq.passFarDetQuality;
00211     
00212     if(i == 0){
00213       SimFlag::SimFlag_t sim = nr->GetHeader().GetVldContext().GetSimFlag();
00214       isMC = (sim == SimFlag::kMC);
00215     }
00216     
00217     if(separatebyRunPeriod && !isMC)
00218     {
00219       cout<<"'separatebyRunPeriod' option is not meant to be used for data - pottree would not be calculated correctly for data.  Qutting..."<<endl;
00220       return;
00221     }
00222     
00223     //sanity check
00224     if(NueStandard::PassesPOTStandards(nr))
00225     {
00226       if(nr->GetHeader().GetEventNo() == 0 || nr->GetHeader().GetEvents() == 0)
00227       {
00228         if(nr->bmon.bI < 0 && !isMC) cout<<"Unexpected behavior"<<endl;
00229       }
00230     }
00231    
00232     isRunPeriod1=false;
00233     isRunPeriod2=false;
00234     isRunPeriod3=false;
00235     isRunPeriod11=false;
00236     isRunPeriod12=false;
00237     isRunPeriod13=false;
00238 
00239     if(separatebyRunPeriod)
00240     {
00241       if(NueStandard::IsRun1(nr))
00242       {
00243         isRunPeriod1=true;
00244       }
00245       if(NueStandard::IsRun2(nr))
00246       {
00247         isRunPeriod2=true;
00248       }
00249       if(NueStandard::IsRun3(nr))
00250       {
00251         isRunPeriod3=true;
00252       }
00253 
00254       if(NueStandard::IsRun11(nr))
00255       {
00256         isRunPeriod11=true;
00257       }
00258       if(NueStandard::IsRun12(nr))
00259       {
00260         isRunPeriod12=true;
00261       }
00262       if(NueStandard::IsRun13(nr))
00263       {
00264         isRunPeriod13=true;
00265       }
00266     }
00267     
00268     if(separatebyRunPeriod)//recalculating pottree; this part works only for MC
00269     {
00270       if(nr->GetHeader().GetEventNo() == 0 || nr->GetHeader().GetEvents() == 0)//for each snarl
00271       {
00272         if(isRunPeriod1)
00273         {
00274           if(det==Detector::kNear)//this only works for ND MC
00275           {
00276             TotPOT1_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00277             TotPOT1 += MCInfo::GetMCPoT(det, beamtype, rel);
00278           }
00279           
00280           nsnarls1++;//count the snarls per run period
00281         }
00282         if(isRunPeriod2)
00283         {
00284           if(det==Detector::kNear)//this only works for ND MC
00285           {
00286             TotPOT2_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00287             TotPOT2 += MCInfo::GetMCPoT(det, beamtype, rel);
00288           }
00289           
00290           nsnarls2++;
00291         }
00292         if(isRunPeriod3)
00293         {
00294           if(det==Detector::kNear)//this only works for ND MC
00295           {
00296             potweight = NueStandard::GetIntensityBeamWeight(nr);
00297             TotPOT3_nocut += (potweight*MCInfo::GetMCPoT(det, beamtype, rel));
00298             TotPOT3 += (potweight*MCInfo::GetMCPoT(det, beamtype, rel));
00299           }
00300           
00301           nsnarls3++;
00302         }
00303 
00304 
00305       if(isRunPeriod11)
00306         {
00307           if(det==Detector::kNear)//this only works for ND MC
00308           {
00309             TotPOT11_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00310             TotPOT11 += MCInfo::GetMCPoT(det, beamtype, rel);
00311           }
00312           
00313           nsnarls11++;//count the snarls per run period
00314         }
00315         if(isRunPeriod12)
00316         {
00317           if(det==Detector::kNear)//this only works for ND MC
00318           {
00319             TotPOT12_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00320             TotPOT12 += MCInfo::GetMCPoT(det, beamtype, rel);
00321           }
00322           
00323           nsnarls12++;
00324         }
00325         if(isRunPeriod13)
00326         {
00327           if(det==Detector::kNear)//this only works for ND MC
00328           {
00329             TotPOT13_nocut += (MCInfo::GetMCPoT(det, beamtype, rel));
00330             TotPOT13 += (MCInfo::GetMCPoT(det, beamtype, rel));
00331           }
00332           
00333           nsnarls13++;
00334         }
00335 
00336 
00337       }
00338       
00339       if(nr->GetHeader().GetRun()!=lastrun)//counting runs - BUT not counting separately for each run period!!
00340       {
00341         lastrun = nr->GetHeader().GetRun();
00342         nruns++;
00343         
00344         if(det==Detector::kFar)//in FD MC, each run is a single file, and GetMCPoT returns pot/file
00345         {
00346           if(isRunPeriod1)
00347           {
00348             TotPOT1_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00349             TotPOT1 += MCInfo::GetMCPoT(det, beamtype, rel);
00350           }
00351           if(isRunPeriod2)
00352           {
00353             TotPOT2_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00354             TotPOT2 += MCInfo::GetMCPoT(det, beamtype, rel);
00355           }
00356           if(isRunPeriod3)
00357           {
00358             TotPOT3_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00359             TotPOT3 += MCInfo::GetMCPoT(det, beamtype, rel);
00360           }
00361           if(isRunPeriod11)
00362           {
00363             TotPOT11_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00364             TotPOT11 += MCInfo::GetMCPoT(det, beamtype, rel);
00365           }
00366           if(isRunPeriod12)
00367           {
00368             TotPOT12_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00369             TotPOT12 += MCInfo::GetMCPoT(det, beamtype, rel);
00370           }
00371           if(isRunPeriod13)
00372           {
00373             TotPOT13_nocut += MCInfo::GetMCPoT(det, beamtype, rel);
00374             TotPOT13 += MCInfo::GetMCPoT(det, beamtype, rel);
00375           }
00376 
00377         }
00378       }
00379     }
00380     
00381     if(fOverWritePOT && !isMC)//recalculating POT for data
00382     {
00383       if(NueStandard::PassesPOTStandards(nr))
00384       {
00385         if(nr->GetHeader().GetEventNo() == 0 || nr->GetHeader().GetEvents() == 0)
00386         {
00387           if(det==Detector::kNear)
00388           {
00389             nddataweight = NueStandard::GetNDDataWeights(nr);
00390             TotPOT1 += (nr->bmon.bI*nddataweight);
00391           }
00392           else//FD
00393           {
00394             TotPOT1 += nr->bmon.bI;
00395           }
00396         }
00397       }
00398     }
00399     
00400     if(EvaluateCuts(nr)){
00401        if(fReweight && nr->mctrue.nuFlavor > -10)
00402        {
00403           int nuFlavor = nr->mctrue.nuFlavor;
00404           int  nonOsc = nr->mctrue.nonOscNuFlavor;
00405           float energy = nr->mctrue.nuEnergy;
00406                                                                                 
00407           Float_t newWeight = NueConvention::Oscillate(nuFlavor, nonOsc, energy,735, fDeltaMSquare, fTheta23, fUe3Square);
00408                                                                                 
00409           nr->mctrue.Ue3Squared = fUe3Square;
00410           nr->mctrue.DeltamSquared23 = fDeltaMSquare;
00411           nr->mctrue.Theta23  = fTheta23;
00412           nr->mctrue.fOscProb = newWeight;
00413        }
00414        
00415        if(separatebyRunPeriod)
00416        {
00417          if(isRunPeriod1)
00418          {
00419            tree1->Fill();
00420          }
00421          if(isRunPeriod2)
00422          {
00423            tree2->Fill();
00424          }
00425          if(isRunPeriod3)
00426          {
00427            tree3->Fill();
00428          }
00429          if(isRunPeriod11)
00430          {
00431            tree11->Fill();
00432          }
00433          if(isRunPeriod12)
00434          {
00435            tree12->Fill();
00436          }
00437          if(isRunPeriod13)
00438          {
00439            tree13->Fill();
00440          }
00441        }
00442        else
00443        {
00444          tree1->Fill();
00445        }
00446        count++;
00447     }
00448   }
00449   cout<<count<<" of "<<n<<" entries were passed"<<endl;
00450   
00451   f1->cd();
00452   NuePOT *total1 = new NuePOT();
00453   TTree *ptree1 = new TTree("pottree","pottree");
00454   TBranch* brp1 = ptree1->Branch("NuePOT","NuePOT", &total1 );
00455   brp1->SetAutoDelete(kFALSE);
00456   
00457   NuePOT *total2=0,*total3=0,*total11=0,*total12=0,*total13=0;
00458   TTree *ptree2=0,*ptree3=0,*ptree11=0,*ptree12=0,*ptree13=0;
00459   TBranch *brp2=0,*brp3=0,*brp11=0,*brp12=0,*brp13=0;
00460   if(separatebyRunPeriod)
00461   {
00462     f2->cd();
00463     total2 = new NuePOT();
00464     ptree2 = new TTree("pottree","pottree");
00465     brp2 = ptree2->Branch("NuePOT","NuePOT", &total2 );
00466     brp2->SetAutoDelete(kFALSE);
00467     
00468     f3->cd();
00469     total3 = new NuePOT();
00470     ptree3 = new TTree("pottree","pottree");
00471     brp3 = ptree3->Branch("NuePOT","NuePOT", &total3 );
00472     brp3->SetAutoDelete(kFALSE);
00473 
00474 
00475     f11->cd();
00476     total11 = new NuePOT();
00477     ptree11 = new TTree("pottree","pottree");
00478     brp11 = ptree11->Branch("NuePOT","NuePOT", &total11 );
00479     brp11->SetAutoDelete(kFALSE);
00480 
00481     f12->cd();
00482     total12 = new NuePOT();
00483     ptree12 = new TTree("pottree","pottree");
00484     brp12 = ptree12->Branch("NuePOT","NuePOT", &total12 );
00485     brp12->SetAutoDelete(kFALSE);
00486     
00487     f13->cd();
00488     total13 = new NuePOT();
00489     ptree13 = new TTree("pottree","pottree");
00490     brp13 = ptree13->Branch("NuePOT","NuePOT", &total13 );
00491     brp13->SetAutoDelete(kFALSE);
00492 
00493 
00494   }
00495   
00496   if(pchain->GetEntries() > 0){
00497     pchain->GetEntry(0);
00498     total1->beamtype = np->beamtype;
00499     if(separatebyRunPeriod)
00500     {
00501       total2->beamtype = np->beamtype;
00502       total3->beamtype = np->beamtype;
00503       total11->beamtype = np->beamtype;
00504       total12->beamtype = np->beamtype;
00505       total13->beamtype = np->beamtype;
00506 
00507 
00508     }
00509   }
00510   
00511   cout << pchain->GetEntries() << endl;
00512   cout << np->nsnarls << endl;
00513 
00514   for(int i = 0; i < pchain->GetEntries(); i++)
00515   {
00516      pchain->GetEntry(i);
00517      
00518      if(total1->beamtype != np->beamtype)
00519      {
00520        cerr<<"You are merging files of different beamtype - BAD"<<endl;
00521      }
00522      
00523      total1->nruns +=  np->nruns;
00524      total1->nsnarls +=  np->nsnarls;
00525      total1->pot += np->pot;
00526      total1->pot_nocut += np->pot_nocut;
00527   }
00528 
00529   if(fOverWritePOT && !isMC) total1->pot = TotPOT1;
00530   
00531   if(separatebyRunPeriod)//recalculating pottree
00532   {
00533     total1->pot = TotPOT1;
00534     total2->pot = TotPOT2;
00535     total3->pot = TotPOT3;
00536     
00537     total1->pot_nocut = TotPOT1_nocut;
00538     total2->pot_nocut = TotPOT2_nocut;
00539     total3->pot_nocut = TotPOT3_nocut;
00540     
00541     total1->nruns = nruns;
00542     total2->nruns = nruns;
00543     total3->nruns = nruns;
00544     
00545     total1->nsnarls = nsnarls1;
00546     total2->nsnarls = nsnarls2;
00547     total3->nsnarls = nsnarls3;
00548 
00549 
00550     total11->pot = TotPOT11;
00551     total12->pot = TotPOT12;
00552     total13->pot = TotPOT13;
00553     
00554     total11->pot_nocut = TotPOT11_nocut;
00555     total12->pot_nocut = TotPOT12_nocut;
00556     total13->pot_nocut = TotPOT13_nocut;
00557     
00558     total11->nruns = nruns;
00559     total12->nruns = nruns;
00560     total13->nruns = nruns;
00561     
00562     total11->nsnarls = nsnarls11;
00563     total12->nsnarls = nsnarls12;
00564     total13->nsnarls = nsnarls13;
00565 
00566 
00567   }
00568   
00569   //fill the pottree
00570   ptree1->Fill();
00571   if(separatebyRunPeriod)
00572   {
00573     ptree2->Fill();
00574     ptree3->Fill();
00575 
00576     ptree11->Fill();
00577     ptree12->Fill();
00578     ptree13->Fill();
00579 
00580 
00581   }
00582   
00583   //save the file(s)
00584   f1->cd();
00585   tree1->Write("ana_nue",TObject::kWriteDelete);
00586   ptree1->Write("pottree",TObject::kWriteDelete);
00587   if(separatebyRunPeriod)
00588   {
00589     f2->cd();
00590     tree2->Write("ana_nue",TObject::kWriteDelete);
00591     ptree2->Write("pottree",TObject::kWriteDelete);
00592     
00593     f3->cd();
00594     tree3->Write("ana_nue",TObject::kWriteDelete);
00595     ptree3->Write("pottree",TObject::kWriteDelete);
00596 
00597 
00598     f11->cd();
00599     tree11->Write("ana_nue",TObject::kWriteDelete);
00600     ptree11->Write("pottree",TObject::kWriteDelete);
00601 
00602     f12->cd();
00603     tree12->Write("ana_nue",TObject::kWriteDelete);
00604     ptree12->Write("pottree",TObject::kWriteDelete);
00605     
00606     f13->cd();
00607     tree13->Write("ana_nue",TObject::kWriteDelete);
00608     ptree13->Write("pottree",TObject::kWriteDelete);
00609 
00610   }
00611   
00612   f1->Close();
00613   if(separatebyRunPeriod)
00614   {
00615     f2->Close();
00616     f3->Close();
00617 
00618     f11->Close();
00619     f12->Close();
00620     f13->Close();
00621 
00622   }
00623   
00624   
00625   cout<<"Trimming completed with "<<np->pot<<"x10^12 POT"<<endl;
00626 }

void Trimmer::SeparatebyRunPeriod (  )  [inline]

Definition at line 33 of file Trimmer.h.

References separatebyRunPeriod.

00033 {separatebyRunPeriod = true;};

void Trimmer::SetBaseline ( double  bl  ) 

Definition at line 38 of file Trimmer.cxx.

References fBaseline, and fReweight.

00038 { fBaseline = bl; fReweight = true;}

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

Definition at line 628 of file Trimmer.cxx.

References cutLevel, and cutSet.

00629 {
00630    cutSet = type;
00631    cutLevel = level;   
00632 }

void Trimmer::SetDeltaMSquare ( double  dm2  ) 

Definition at line 35 of file Trimmer.cxx.

References fDeltaMSquare, and fReweight.

00035 { fDeltaMSquare = dm2; fReweight = true;}

void Trimmer::SetOutputFile ( string  name  ) 

Definition at line 24 of file Trimmer.cxx.

References outFile, and outSet.

00025 {
00026    outSet = true;
00027    outFile = file;
00028 }

void Trimmer::SetRHC (  )  [inline]

Definition at line 34 of file Trimmer.h.

References isRHC.

00034 {isRHC = true;};

void Trimmer::SetTheta23 ( double  t23  ) 

Definition at line 37 of file Trimmer.cxx.

References fReweight, and fTheta23.

00037 { fTheta23 = t23; fReweight = true;}

void Trimmer::SetUe3Square ( double  dUe32  ) 

Definition at line 36 of file Trimmer.cxx.

References fReweight, and fUe3Square.

00036 { fUe3Square = dUe32; fReweight = true;}


Member Data Documentation

int Trimmer::cutLevel [private]

Definition at line 49 of file Trimmer.h.

Referenced by EvaluateCuts(), and SetCuts().

string Trimmer::cutSet [private]

Definition at line 48 of file Trimmer.h.

Referenced by EvaluateCuts(), and SetCuts().

double Trimmer::fBaseline [private]

Definition at line 45 of file Trimmer.h.

Referenced by SetBaseline(), and Trimmer().

Definition at line 40 of file Trimmer.h.

Referenced by Config().

double Trimmer::fDeltaMSquare [private]

Definition at line 42 of file Trimmer.h.

Referenced by RunTrimmer(), SetDeltaMSquare(), and Trimmer().

vector<string> Trimmer::files [private]

Definition at line 39 of file Trimmer.h.

Referenced by AddFiles(), and RunTrimmer().

bool Trimmer::fOverWritePOT [private]

Definition at line 51 of file Trimmer.h.

Referenced by RecalculatePOT(), RunTrimmer(), and Trimmer().

bool Trimmer::fReweight [private]

Definition at line 46 of file Trimmer.h.

Referenced by RunTrimmer(), SetBaseline(), SetDeltaMSquare(), SetTheta23(), SetUe3Square(), and Trimmer().

double Trimmer::fTheta23 [private]

Definition at line 44 of file Trimmer.h.

Referenced by RunTrimmer(), SetTheta23(), and Trimmer().

double Trimmer::fUe3Square [private]

Definition at line 43 of file Trimmer.h.

Referenced by RunTrimmer(), SetUe3Square(), and Trimmer().

bool Trimmer::isRHC [private]

Definition at line 53 of file Trimmer.h.

Referenced by RunTrimmer(), SetRHC(), and Trimmer().

string Trimmer::outFile [private]

Definition at line 34 of file Trimmer.h.

Referenced by RunTrimmer(), and SetOutputFile().

bool Trimmer::outSet [private]

Definition at line 38 of file Trimmer.h.

Referenced by RunTrimmer(), SetOutputFile(), and Trimmer().

Definition at line 52 of file Trimmer.h.

Referenced by RunTrimmer(), SeparatebyRunPeriod(), and Trimmer().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1