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

NtpStTrimmer.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // FILL_IN: [Document your code!!]
00004 //
00005 // boehm@physics.harvard.edu
00007 #include "TH1F.h"
00008 #include "TFile.h"
00009 #include "Conventions/Detector.h"
00010 #include "NueAna/NueRecord.h"
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "MessageService/MsgService.h"
00014 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00015 #include "HistMan/HistMan.h"
00016 #include <fstream>
00017 #include "AnalysisNtuples/ANtpDefaultValue.h"                                   
00018 #include "TClass.h"
00019 #include "TDataType.h"
00020 #include "TDataMember.h"
00021 #include "TRealData.h"
00022 #include <string>
00023 #include "NtpStTrimmer.h"
00024 #include "NueAna/NueAnalysisCuts.h"
00025 #include "CandNtupleSR/NtpSRRecord.h"
00026 
00027 
00028 const int CALend=110;
00029 const int SM1end=230;
00030 const int SM2end=484;
00031 
00032 JOBMODULE(NtpStTrimmer, "NtpStTrimmer",
00033           "Reduce the file size of AnaNue files by filtering out events");
00034 CVSID("$Id: NtpStTrimmer.cxx,v 1.3 2008/11/19 18:22:51 rhatcher Exp $");
00035 //......................................................................
00036 
00037 NtpStTrimmer::NtpStTrimmer():
00038   counter(0),
00039   kOutputFile("TrimmedOut.root"),
00040   kReWeight(0),
00041   kTheta23(1.0),
00042   kUe3Square(0.01),
00043   kDeltaMSquare(0.0025)
00044 {}
00045 
00046 //......................................................................
00047 
00048 NtpStTrimmer::~NtpStTrimmer()
00049 {}
00050 
00051 //......................................................................
00052 void NtpStTrimmer::BeginJob()
00053 {
00054   kept = 0;
00055 //  fCuts.Reset();
00056   if(counter%1000==0){
00057     cout<<"On entry "<<counter<<endl;
00058   }
00059 }
00060 
00061 
00062 JobCResult NtpStTrimmer::Reco(MomNavigator* mom)
00063 {
00064    bool foundST=false;
00065                                                                                 
00066    VldContext vc;
00067    //first ask mom for a NtpStRecord
00068    NtpStRecord *str=dynamic_cast<NtpStRecord *>(mom->GetFragment("NtpStRecord","Primary"));
00069    if(str){
00070      foundST=true;
00071      vc=str->GetHeader().GetVldContext();
00072    }
00073 
00074    cout<<"whats up"<<endl; 
00075    if(!foundST){
00076        MSG("NtpStTrimmer",Msg::kError)<<"This code ONLY runs on NtpSt"<<endl;
00077    }
00078 
00079    Int_t evtn = 0;
00080    if(foundST){
00081      evtn=str->evthdr.nevent;
00082    }
00083 
00084    str->SetName("NtpSt_junk");
00085    
00086    for(int i = 0; i < evtn; i++)
00087    {
00088       cout<<"looking at event "<<i<<endl;
00089       fCuts.SetInfoObject(i, str);
00090       if(PassesCuts()) {
00091           MSG("NtpStTrimmer",Msg::kDebug)<<"Excellent a NueRecord survives"
00092                     <<" Snarl "<<str->GetHeader().GetSnarl()
00093                     <<" Event "<<i<<endl;
00094                                                                                 
00095           str->SetName("NtpSt_trim");
00096           kept++;
00097       }
00098    }
00099    if(counter%1000==0){
00100       cout<<"On entry "<<counter<<endl;
00101    }
00102    counter++;
00103    
00104    return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00105 }
00106 
00108 void NtpStTrimmer::EndJob()
00109 {
00110   cout<<counter<<" events processed and "<<kept<<" were output"<<endl;
00111 
00112   //fCuts.Report();
00113 //Now i have to output the tree
00114   // Here is where all of the writeout work will be done, first the tree and then the histos
00115 
00116   //If we are oscillating the files, then the effective exposure is only one third per file
00117   //    if you are not using an equal number of files from each type I accept no responsibility
00118   //    for the nature of your results
00119 
00120 }
00121 
00122 const Registry& NtpStTrimmer::DefaultConfig() const
00123 {
00124 //======================================================================
00125 // Supply the default configuration for the module
00126 //======================================================================
00127    MSG("NtpStTrimmer",Msg::kDebug)<<"In Trimmer::DefaultConfig"<<endl;
00128 
00129   static Registry r = fCuts.DefaultConfig();
00130  
00131   // Set name of config
00132   std::string name = this->GetName();
00133   name += ".config.default";
00134   r.SetName(name.c_str());
00135                                                                                 
00136   // Set values in configuration
00137   r.UnLockValues();
00138   r.Set("OutputFile", "TrimmedNtuple.root");
00139 
00140   r.Set("DeltaMSquare", 0.0025);
00141   r.Set("Theta23", TMath::Pi()/4);
00142   r.Set("Ue3Square", 0.01);
00143   r.Set("ReWeight", 0);
00144   
00145   r.LockValues();
00146                                                                                 
00147   return r;
00148 }
00149 
00150 void NtpStTrimmer::Config(const Registry& r)
00151 {
00152 //======================================================================
00153 // Configure the module given the Registry r
00154 //======================================================================
00155   MSG("NtpStTrimmer",Msg::kDebug)<<"In Trimmer::Config"<<endl;
00156   
00157   fCuts.Config(r);
00158                                                                                
00159   //  const char* tmps;
00160   int imps;
00161   if(r.Get("ReWeight", imps)) {kReWeight = imps;}
00162   
00163   double fmps;
00164   if(r.Get("DeltaMSquare", fmps)) {kDeltaMSquare = fmps;}
00165   if(r.Get("Ue3Square", fmps))    {kUe3Square = fmps;}
00166   if(r.Get("Theta23", fmps))  {kTheta23 = fmps;}
00167 
00168   const char* tmps;
00169   if(r.Get("OutputFile", tmps)) {kOutputFile = tmps;}
00170   
00171 }
00172 
00173 bool NtpStTrimmer::PassesCuts()
00174 {
00175     bool passes = true;   
00176     if(!fCuts.PassesFiducialVolume())    passes = false;
00177     if(!fCuts.PassesFullContainment())  passes = false;   
00178      
00179     if(!fCuts.PassesAllCuts()) passes = false;
00180 //    if(!fCuts.PassesFileCut())  passes = false;
00181 
00182      // Cut on min Total pulse height per prong (sigcor)
00183 //     if((nr->srevent.planes<1.05||nr->srevent.planes>16) ||
00184 //         (nr->hitcalc.fHitLongEnergy<30||nr->hitcalc.fHitLongEnergy>5000)||
00185 //         (nr->shwfit.uv_molrad_vert<0||nr->shwfit.uv_molrad_vert>5.51)||
00186 //        (nr->shwfit.par_b<0.315||nr->shwfit.par_b>1.47)) passes=false;
00187 
00188    return passes;
00189 }
00190 

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