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

MiniMakerPID Class Reference

#include <MiniMakerPID.h>

List of all members.

Public Member Functions

 MiniMakerPID ()
void AddFiles (string files)
void SetOutputFile (string name)
void Config (Registry &r)
void SetCuts (string type, int level=0)
bool EvaluateCuts (NueRecord *nr, NueMiniPID *nm)
void SetIsMRCC (int ismrcc=0)
void RunMiniMakerPID ()
void SetDeltaMSquare (double dm2)
void SetUe3Square (double dUe32)
void SetTheta23 (double t23)
void SetBaseline (double bl)
void RecalculatePOT ()
void SetReweight (int e=0)

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
int fIsMRCC


Constructor & Destructor Documentation

MiniMakerPID::MiniMakerPID  ) 
 

Definition at line 9 of file MiniMakerPID.cxx.

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

00009                           { 
00010   outSet = false;
00011   fReweight = false;
00012   fBaseline = 735;
00013   fDeltaMSquare = 0.0027;
00014   fUe3Square = 0.025;
00015   fTheta23 = TMath::Pi()/4;
00016 
00017   fOverWritePOT = false;
00018   
00019   fIsMRCC=0;
00020 }


Member Function Documentation

void MiniMakerPID::AddFiles string  files  ) 
 

Definition at line 22 of file MiniMakerPID.cxx.

References files.

00023 {
00024    files.push_back(infiles);
00025 }

void MiniMakerPID::Config Registry r  ) 
 

Definition at line 33 of file MiniMakerPID.cxx.

References NueAnalysisCuts::Config(), and fCuts.

00034 {
00035   fCuts.Config(r);
00036 }

bool MiniMakerPID::EvaluateCuts NueRecord nr,
NueMiniPID nm
 

Definition at line 240 of file MiniMakerPID.cxx.

References NueMiniPID::contained, cutLevel, cutSet, fIsMRCC, NueMiniPID::fPOT, NueMiniPID::infid, NueMiniPID::mrcc_s, NueConvention::NueEnergyCorrection(), NueStandard::PassesMREFiducial(), NueStandard::PassesMREPreSelection(), NueStandard::PassesNonHEPreSelection(), NueStandard::PassesSelection(), and NueStandard::PassesSysPreSelection().

Referenced by RunMiniMakerPID().

00241 {
00242    NueConvention::NueEnergyCorrection(nr);  
00243 
00244    if(cutSet == "Fiducial") 
00245      return NueStandard::PassesSelection(nr, Selection::kFid);
00246 
00247    if(cutSet == "Standard"){
00248       bool ret;
00249       switch(cutLevel){
00250         case 0: return NueStandard::PassesSelection(nr, Selection::kDataQual);
00251         case 1: return NueStandard::PassesSelection(nr, Selection::kFid);
00252         case 2: 
00253              ret = NueStandard::PassesSelection(nr, Selection::kFid);
00254              ret = ret &&  NueStandard::PassesNonHEPreSelection(nr);
00255              return ret;
00256         case 3: return NueStandard::PassesSelection(nr, Selection::kPre);
00257         case 4: return nm->infid && nm->contained && ( fIsMRCC ? nm->mrcc_s : 1 );
00258         case 6: return NueStandard::PassesSelection(nr, Selection::kDataQual) && ((nm->infid && nm->contained ) || NueStandard::PassesSelection(nr, Selection::kFid) ) || nm->fPOT;
00259 
00260 
00261       }
00262    }
00263    if(cutSet == "MRE" || cutSet == "MRCC"){
00264       bool dq = NueStandard::PassesSelection(nr, Selection::kDataQual);
00265       bool mrefid = NueStandard::PassesMREFiducial(nr);
00266       bool mrepre = NueStandard::PassesMREPreSelection(nr) && mrefid && dq;
00267       bool ret;
00268       switch(cutLevel){
00269         case 0: return mrefid && dq;
00270         case 1: return mrepre;
00271         case 2: 
00272           return NueStandard::PassesSelection(nr, Selection::kFid) && mrepre;
00273         case 3:
00274              ret = NueStandard::PassesSelection(nr, Selection::kFid);
00275              ret = ret &&  NueStandard::PassesNonHEPreSelection(nr);
00276              return ret && mrepre;
00277         case 4: 
00278          return NueStandard::PassesSelection(nr, Selection::kPre) && mrepre;
00279       }
00280    }
00281    if(cutSet == "Presel")
00282       return NueStandard::PassesSelection(nr, Selection::kPre);
00283 
00284    if(cutSet == "PreselNoHE")
00285       return  NueStandard::PassesNonHEPreSelection(nr);
00286 
00287    if(cutSet == "Systematic")
00288       return NueStandard::PassesSysPreSelection(nr);
00289 
00290    if(cutSet == "CC")
00291       return NueStandard::PassesSelection(nr, Selection::kCC);
00292 
00293 
00294   cout<<"Invalid Cut Level for "<<cutSet<<": "<<cutLevel<<endl;
00295   return false;
00296 }

void MiniMakerPID::RecalculatePOT  )  [inline]
 

Definition at line 38 of file MiniMakerPID.h.

00038 {fOverWritePOT = true;}; 

void MiniMakerPID::RunMiniMakerPID  ) 
 

Definition at line 43 of file MiniMakerPID.cxx.

References AnnAna::Analyze(), NuePOT::beamtype, BeamMon::bI, NueRecord::bmon, count, ANtpTruthInfoBeamNue::DeltamSquared23, det, EvaluateCuts(), NueRecord::eventq, files, NueMiniAnaPID::FillMini(), fIsMRCC, ANtpTruthInfoBeamNue::fOscProb, fOverWritePOT, NueMiniPID::fPOT, fReweight, NueHeader::GetBeamType(), VldContext::GetDetector(), NueHeader::GetEventNo(), NueHeader::GetEvents(), RecRecordImp< T >::GetHeader(), NueStandard::GetOscWeight(), NueHeader::GetRelease(), VldContext::GetSimFlag(), RecHeader::GetVldContext(), DataUtil::IsGoodData(), isMC, NueRecord::mctrue, ANtpTruthInfoBeam::nonOscNuFlavor, NuePOT::nruns, NuePOT::nsnarls, ANtpTruthInfo::nuEnergy, ANtpTruthInfo::nuFlavor, outFile, NueStandard::PassesPOTStandards(), EventQual::passFarDetQuality, EventQual::passNearDetQuality, NuePOT::pot, NueStandard::SetDefaultOscParam(), NueStandard::SetOscNoMatter(), ANtpTruthInfoBeamNue::Theta23, total(), and ANtpTruthInfoBeamNue::Ue3Squared.

00044 {
00045   NueRecord *nr = new NueRecord();
00046   NuePOT *np = new NuePOT();
00047   NuePOT *total = new NuePOT();
00048 
00049   TChain *chain = new TChain("ana_nue");
00050   chain->SetBranchAddress("NueRecord",&nr);
00051                                                                         
00052   TChain *pchain = new TChain("pottree");
00053   pchain->SetBranchAddress("NuePOT", &np);
00054  
00055   int nchain=0;
00056   int npchain=0;
00057 
00058   for(unsigned int i = 0; i < files.size(); i++)
00059   {
00060       nchain += chain->Add(files[i].c_str());
00061       npchain += pchain->Add(files[i].c_str());
00062   }
00063 
00064 
00065   if(nchain != npchain || !nchain || !npchain)
00066   {   
00067       printf("missing tree in input file.... exiting with error!\n");
00068       exit(1);
00069   }
00070 
00071   if(pchain->GetEntries() > 0){
00072         pchain->GetEntry(0);
00073     total->beamtype = np->beamtype;
00074   }
00075   
00076   if(!outSet){
00077      string file;
00078                                                                         
00079      if(pchain->GetEntries() > 0){
00080         pchain->GetEntry(0);
00081         total->beamtype = np->beamtype;
00082         file = pchain->GetFile()->GetName();
00083      }
00084      string minifile = file.substr(file.find_last_of("/")+1, file.find_last_of(".root")-file.find_last_of("/") - 5);
00085      minifile += "-Mini.root";
00086   
00087      outFile = minifile;
00088   }
00089   if(outFile == "-Mini.root"){
00090      cout<<"No input file found"<<endl; 
00091      return;
00092   }
00093                                                                          
00094   cout<<"Setting output to "<<outFile<<endl;
00095 
00096   // And now the actual looping
00097                                                                                 
00098   TFile *save = new TFile(outFile.c_str(),"RECREATE");
00099   save->SetCompressionLevel(9);
00100   save->cd();
00101   TTree *tree = new TTree("NueMiniPID","NueMiniPID");
00102   TTree::SetBranchStyle(1);
00103 
00104   if(chain->GetEntries() > 0) chain->GetEvent(0);
00105   Detector::Detector_t det = nr->GetHeader().GetVldContext().GetDetector();
00106   ReleaseType::Release_t rel = nr->GetHeader().GetRelease();
00107   BeamType::BeamType_t beam = nr->GetHeader().GetBeamType();
00108                                                                                 
00109   NueMiniAnaPID nma;
00110                                                                                 
00111   NueMiniPID* nm = new NueMiniPID(beam, det, rel);
00112 
00113   TBranch* br = tree->Branch("NueMiniPID","NueMiniPID", &nm );
00114   br->SetAutoDelete(kFALSE);
00115                                                                         
00116   Int_t n = chain->GetEntries();
00117   int count = 0;
00118 
00119   bool isMC = false;
00120   double TotPOT = 0.0;
00121 
00122         NueStandard::SetDefaultOscParam();
00123         NueStandard::SetOscNoMatter(); 
00124 
00125   for(int i=0;i<n;i++){
00126     if(i%10000==0) cout << 100*float(i)/float(n)
00127                        << "% done" << endl;
00128     chain->GetEvent(i);
00129 
00130     if(i == 0){
00131       SimFlag::SimFlag_t sim = nr->GetHeader().GetVldContext().GetSimFlag();
00132       isMC = (sim == SimFlag::kMC);
00133     }       
00134 
00135         //reset it here
00136         nm->fPOT=0;
00137 
00138 
00139 
00140     nr->eventq.passFarDetQuality = DataUtil::IsGoodData(nr->GetHeader().GetVldContext());
00141     nr->eventq.passNearDetQuality = nr->eventq.passFarDetQuality;
00142     if( NueStandard::PassesPOTStandards(nr))
00143         {
00144     //if(NueStandard::PassesDataQuality(nr)) {
00145        if(nr->GetHeader().GetEventNo() == 0 ||
00146              nr->GetHeader().GetEvents() == 0){
00147                 TotPOT += nr->bmon.bI;
00148                 nm->fPOT=nr->bmon.bI;
00149           if(nr->bmon.bI < 0 && !isMC)
00150           {
00151                 cout<<"Unexpected behavior"<<endl;
00152                 exit(2);
00153           }       
00154         }
00155     }
00156 
00157 
00158         //recalculate the ann to get ann14
00159         AnnAna z(*nr);
00160         z.Analyze();
00161 
00162 
00163         //fill it now, so the variables are available to EvaluateCuts
00164         nma.FillMini(nr, nm, fIsMRCC);
00165 
00166         
00167     if(EvaluateCuts(nr,nm)){
00168 
00169        if(fReweight && nr->mctrue.nuFlavor > -10)
00170        {
00171           //int nuFlavor = nr->mctrue.nuFlavor;
00172           //int  nonOsc = nr->mctrue.nonOscNuFlavor;
00173           //float energy = nr->mctrue.nuEnergy;
00174                                                                                 
00175           Float_t newWeight = NueStandard::GetOscWeight(nr->mctrue.nuFlavor,nr->mctrue.nonOscNuFlavor,nr->mctrue.nuEnergy);//NueConvention::Oscillate(nuFlavor, nonOsc, energy,                                735, fDeltaMSquare, fTheta23, fUe3Square);
00176                                                                                 
00177           nr->mctrue.Ue3Squared = fUe3Square;
00178           nr->mctrue.DeltamSquared23 = fDeltaMSquare;
00179           nr->mctrue.Theta23  = fTheta23;
00180           nr->mctrue.fOscProb = newWeight;
00181                 
00182                   //fill again to pick up oscillation changes
00183               nma.FillMini(nr, nm, fIsMRCC);
00184        }
00185        
00186                 
00187        tree->Fill();
00188        count++;
00189     }else{
00190  /*    float x = nr->srevent.vtxX;
00191       float y = nr->srevent.vtxY;
00192       float r = TMath::Sqrt(x*x+y*y);
00193 
00194       cout<<"rejecting event"<<x<<"  "<<y<<"  "<<r<<"  "
00195           <<nr->srevent.vtxZ<<"  "
00196           <<NueStandard::PassesSelection(nr, Selection::kDataQual)
00197           <<"  "<<NueStandard::PassesSelection(nr, Selection::kFid)<<endl;
00198 */
00199     }
00200   }
00201   cout<<count<<" of "<<n<<" entries were passed"<<endl;
00202                                                                         
00203   TTree *ptree = new TTree("pottree","pottree");
00204   TBranch* br2 = ptree->Branch("NuePOT","NuePOT", &total );
00205   br2->SetAutoDelete(kFALSE);
00206                                                                         
00207   for(int i = 0; i < pchain->GetEntries(); i++)
00208   {
00209      pchain->GetEntry(i);
00210         
00211        cout <<"bt "<<total->beamtype <<" "<<np->beamtype<<"\n";                                                                 
00212      if(total->beamtype != np->beamtype)
00213         cerr<<"You are merging files of different beamtyp - BAD"<<endl;
00214                                                                         
00215      total->nruns +=  np->nruns;
00216      total->nsnarls +=  np->nsnarls;
00217      total->pot += np->pot;
00218   }
00219 
00220   if(fOverWritePOT && !isMC) total->pot = TotPOT;
00221 
00222   ptree->Fill();
00223                                                                         
00224   save->cd();
00225   tree->Write();
00226   ptree->Write();
00227  
00228   cout<<"Compression level of output file "<<save->GetCompressionLevel()<<"\n";
00229   
00230   cout<<"Trimming completed with "<<total->pot<<"x10^12 POT"<<endl;
00231   save->Close();
00232 }

void MiniMakerPID::SetBaseline double  bl  ) 
 

Definition at line 41 of file MiniMakerPID.cxx.

References fBaseline, and fReweight.

00041 { fBaseline = bl; fReweight = true;}

void MiniMakerPID::SetCuts string  type,
int  level = 0
 

Definition at line 234 of file MiniMakerPID.cxx.

References cutLevel, and cutSet.

00235 {
00236    cutSet = type;
00237    cutLevel = level;   
00238 }

void MiniMakerPID::SetDeltaMSquare double  dm2  ) 
 

Definition at line 38 of file MiniMakerPID.cxx.

References fDeltaMSquare, and fReweight.

00038 { fDeltaMSquare = dm2; fReweight = true;}

void MiniMakerPID::SetIsMRCC int  ismrcc = 0  )  [inline]
 

Definition at line 30 of file MiniMakerPID.h.

00030 {fIsMRCC=ismrcc;};

void MiniMakerPID::SetOutputFile string  name  ) 
 

Definition at line 27 of file MiniMakerPID.cxx.

References outFile, and outSet.

00028 {
00029    outSet = true;
00030    outFile = file;
00031 }   

void MiniMakerPID::SetReweight int  e = 0  )  [inline]
 

Definition at line 39 of file MiniMakerPID.h.

00039 {  fReweight = e;};

void MiniMakerPID::SetTheta23 double  t23  ) 
 

Definition at line 40 of file MiniMakerPID.cxx.

References fReweight, and fTheta23.

00040 { fTheta23 = t23; fReweight = true;}

void MiniMakerPID::SetUe3Square double  dUe32  ) 
 

Definition at line 39 of file MiniMakerPID.cxx.

References fReweight, and fUe3Square.

00039 { fUe3Square = dUe32; fReweight = true;}


Member Data Documentation

int MiniMakerPID::cutLevel [private]
 

Definition at line 54 of file MiniMakerPID.h.

Referenced by EvaluateCuts(), and SetCuts().

string MiniMakerPID::cutSet [private]
 

Definition at line 53 of file MiniMakerPID.h.

Referenced by EvaluateCuts(), and SetCuts().

double MiniMakerPID::fBaseline [private]
 

Definition at line 50 of file MiniMakerPID.h.

Referenced by MiniMakerPID(), and SetBaseline().

NueAnalysisCuts MiniMakerPID::fCuts [private]
 

Definition at line 45 of file MiniMakerPID.h.

Referenced by Config().

double MiniMakerPID::fDeltaMSquare [private]
 

Definition at line 47 of file MiniMakerPID.h.

Referenced by MiniMakerPID(), and SetDeltaMSquare().

vector<string> MiniMakerPID::files [private]
 

Definition at line 44 of file MiniMakerPID.h.

Referenced by AddFiles(), and RunMiniMakerPID().

int MiniMakerPID::fIsMRCC [private]
 

Definition at line 57 of file MiniMakerPID.h.

Referenced by EvaluateCuts(), MiniMakerPID(), and RunMiniMakerPID().

bool MiniMakerPID::fOverWritePOT [private]
 

Definition at line 56 of file MiniMakerPID.h.

Referenced by MiniMakerPID(), and RunMiniMakerPID().

bool MiniMakerPID::fReweight [private]
 

Definition at line 51 of file MiniMakerPID.h.

Referenced by MiniMakerPID(), RunMiniMakerPID(), SetBaseline(), SetDeltaMSquare(), SetTheta23(), and SetUe3Square().

double MiniMakerPID::fTheta23 [private]
 

Definition at line 49 of file MiniMakerPID.h.

Referenced by MiniMakerPID(), and SetTheta23().

double MiniMakerPID::fUe3Square [private]
 

Definition at line 48 of file MiniMakerPID.h.

Referenced by MiniMakerPID(), and SetUe3Square().

string MiniMakerPID::outFile [private]
 

Definition at line 42 of file MiniMakerPID.h.

Referenced by RunMiniMakerPID(), and SetOutputFile().

bool MiniMakerPID::outSet [private]
 

Definition at line 43 of file MiniMakerPID.h.

Referenced by MiniMakerPID(), and SetOutputFile().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:09:35 2010 for loon by  doxygen 1.3.9.1