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

MadMKAnalysis.h

Go to the documentation of this file.
00001 
00002 //
00003 // MadMKAnalysis
00004 //
00005 // Mike's MadAnalysis.  Mostly I just make a simple ntuple with it.
00006 //
00007 // Created:  M. Kordosky -- December, 2004
00008 //
00009 // $Author: gmieg $ 
00010 //
00011 // $Revision: 1.27 $
00012 // 
00013 // $Name:  $
00014 //
00015 // $Id: MadMKAnalysis.h,v 1.27 2009/02/28 21:46:13 gmieg Exp $
00016 //
00017 // $Log: MadMKAnalysis.h,v $
00018 // Revision 1.27  2009/02/28 21:46:13  gmieg
00019 // Update for GCC 4.4.0.  Mostly add #includes
00020 // for reorganized C++ headers, such as -
00021 // algorithm for: sort, find
00022 // cassert for:   assert, abort
00023 // climits for:   SHRT_MAX, INT_MAX
00024 // cstdlib for:   abs, getenv, atoi, atof, strtod, exit
00025 // cstring for:   strcmp
00026 //
00027 // Revision 1.26  2007/08/23 15:58:45  kordosky
00028 // small updates, not committed before
00029 //
00030 // Revision 1.25  2007/06/05 17:10:41  kordosky
00031 // blah
00032 //
00033 // Revision 1.24  2007/05/08 12:50:48  kordosky
00034 // support intranuke reweighting
00035 //
00036 // Revision 1.23  2007/01/30 03:17:21  rhatcher
00037 // No longer user BeamType "class" found in MCReweight, but rather the
00038 // BeamType "namespace" found in Conventions package.
00039 // Also covert to using "Detector::" rather than "DetectorType::", though
00040 // for now they are synonyms.
00041 //
00042 // Revision 1.22  2006/10/16 19:53:30  kordosky
00043 // cope with CEDAR strip indices set to -1. allow user to force beam type (useful for 150cm data). Open files with TFile::Open() to allow natural dcache access. IMPORTANT: Big change to pans. Tacking on a spill marker, looks like event=-1 with no muon or shower energy, pass and is_fid set to fail. Beam variables and nevent are correct for these entries. Modification intended to ease POT counting
00044 //
00045 // Revision 1.21  2006/03/09 19:33:30  kordosky
00046 // Properly do energy corrections in MK and DpAnalysis
00047 //
00048 // Revision 1.20  2006/02/16 19:26:09  kordosky
00049 // upgrades
00050 //
00051 // Revision 1.19  2006/01/26 23:41:34  kordosky
00052 // upgrades.
00053 //
00054 // Revision 1.18  2006/01/10 17:40:50  kordosky
00055 // Event display improvements. Now prints kinematic variables, indicates if muon stopped in detector and applies energy corrections.
00056 //
00057 // Revision 1.17  2005/12/14 20:35:59  kordosky
00058 // Updated energy corrections.
00059 //
00060 // Revision 1.16  2005/11/17 15:50:17  vahle
00061 // Added checks for track vertex in fid volume.  Switched goodbeam varible to use BMSpillAna
00062 //
00063 // Revision 1.15  2005/11/17 13:22:05  vahle
00064 // Added a count of the number of reconstructed strips and the ph of reconstructed strips that show up in another event
00065 //
00066 // Revision 1.14  2005/11/14 12:04:52  vahle
00067 // Adding Brians lowph ratio variable for cutting fd junk events to MadMKAnalysis ntuple
00068 //
00069 // Revision 1.13  2005/11/04 15:27:55  vahle
00070 // Remove all vestiges of old beam monitoring ntuple lookup, change the way track containment is decided in the FD
00071 //
00072 // Revision 1.12  2005/10/07 18:32:54  vahle
00073 // Added late activity variables to MadMKAnalysis
00074 //
00075 // Revision 1.11  2005/10/07 18:05:28  kordosky
00076 // a few changes to analysis, refinement of pdfs. MadBase not loading mcHeader correctly when GetEntry() called.  Suprisingly, it had no effect up until now.
00077 //
00078 // Revision 1.10  2005/10/06 17:29:22  vahle
00079 // Added early activity variables to MadMKAnalysis
00080 //
00081 // Revision 1.9  2005/10/06 15:03:26  kordosky
00082 // various improvements, pids finally integrated into pan construction routine, still not fully debugged though
00083 //
00084 // Revision 1.8  2005/09/23 11:48:22  kordosky
00085 //  a few additions for R1.18. code meant to handle R1.16 and R1.18 ntpshowers not working properly. only handles R1.18 correctly.
00086 //
00087 // Revision 1.7  2005/09/14 13:32:45  kordosky
00088 // DpID and NsID classes now fully working and validated with MadTestAnalysis by comparing nannpid vs. annpid and npid0 vs. pid0.  pdf files and weights stored in data subdirectory. FD pdfs needed for DpID.
00089 //
00090 //
00092 
00093 #ifndef MADMKANALYSIS
00094 #define MADMKANALYSIS
00095 
00096 #include <string>
00097 
00098 #include "Mad/MadAnalysis.h"
00099 #include "Conventions/PlaneCoverage.h"
00100 #include "Conventions/PlaneView.h"
00101 #include "Conventions/Detector.h"
00102 #include "Registry/Registry.h"
00103 
00104 #include "Conventions/BeamType.h"
00105 
00106 #include "Mad/MadNsID.h"
00107 #include "Mad/MadDpID.h"
00108 #include "Mad/MadQEID.h"
00109 
00110 class TFile;
00111 
00112 class MadMKAnalysis : public MadAnalysis {
00113 
00114  public:  
00115   void CreatePAN(std::string s, const char* bmonpath="");
00116   MadMKAnalysis(TChain *chainSR=0,TChain *chainMC=0,
00117               TChain *chainTH=0,TChain *chainEM=0);
00118   MadMKAnalysis(JobC *,string,int);
00119   virtual ~MadMKAnalysis();
00120 
00121   Float_t ClosestPointToLine(const Float_t& x1, 
00122                              const Float_t& y1,
00123                              const Float_t& x2,
00124                              const Float_t& y2,
00125                              const Float_t& xpt,
00126                              const Float_t& ypt,
00127                              Float_t& x, Float_t& y);
00128 
00129   // fiducial volume and track containment as defined by pitt group
00130   static Bool_t PittInFidVol(Float_t x, Float_t y, 
00131                              Float_t z, Float_t u, Float_t v);
00132   static Int_t PittTrkContained(Float_t x, Float_t y, 
00133                                 Float_t z, Float_t u, Float_t v);
00134 
00135   // is this strip in the partially instrumented region of the ND?
00136   static Int_t InPartialRegion(UShort_t plane, UShort_t strip);
00137   
00138   // pass back an bitfield with bits corresponding to radial cuts
00139   // Float_t rings[5]={0.1,0.25,0.5,1.0,1.5}; // in meters
00140   static Int_t NDRadialFidVol(Float_t x,Float_t y, Float_t z);
00141 
00142   void ForceMCBeam(const BeamType::BeamType_t& beam) {fMCBeam=beam;}
00143   const BeamType::BeamType_t& GetForcedMCBeam() {return fMCBeam;}
00144   void SetDataUseMCBeam(bool x) {fDataUseMCBeam=x;}
00145   void OnlyWriteFidEvents(bool x) {fOnlyWriteFidEvents=x;}
00146   void FillMCHists(TFile* fout);
00147 
00148   static int FarTrkContained(Float_t x, Float_t y, Float_t z);
00149 
00150   void DoInukeReweight(bool t){fDoInukeReweight=t;}
00151   void SetNRandomSets(int i){fNRandomSets=i;}
00152   // PID calculator objects
00153   MadNsID nsid;
00154   MadDpID dpid;
00155   MadQEID qeid;
00156   
00157  protected:
00158   // signal inside and outside of the partial plane region
00159   // for whole event and just for track portion
00160   // uses currently loaded event and track  
00161   void SigInOut(Float_t& sigfull, Float_t& sigpart, Float_t& trkfull, Float_t& trkpart);
00162   void SigInOut(Int_t trkidx, Float_t& sigfull, Float_t& sigpart, Float_t& trkfull, Float_t& trkpart);
00163 
00164 
00165   // from base class
00167 //  Float_t RecoAnalysisEnergy(Int_t event);
00168   Float_t RecoShwEnergy(int ishw, const Detector::Detector_t& det, int mode=1, bool isdata=true);
00169   Float_t RecoMKMuEnergy(Int_t& opt, Int_t itrk, bool isdata=true, Detector::Detector_t det=Detector::kNear);
00170 
00171   //  virtual Bool_t PassBasicCuts(Int_t event);
00172 
00173   // muon angle with respect to neutrino angle
00174   // it's detector dependant!
00175   virtual Float_t RecoMuDCosNeuND(Int_t itr=0, Float_t* vtx=0);
00176   virtual Float_t RecoMuDCosNeuFD(Int_t itr=0, Float_t* vtx=0);
00177   
00178   //  virtual Float_t RecoKinematics(Int_t event);
00179 
00180   virtual bool InFidVol(Int_t evidx);
00181   virtual bool InFidVol(); // assumes event already loaded,
00182                            //and that we're interested in event vertex
00183   bool InFidVol(float vx, float vy, float vz); //looks to see if vx,vy,vz 
00184                                                //is in fid. vol
00185 
00186   void SetBECFile(const char* f);
00187   Registry& GetBECRegistry() { return fBECConfig; }
00188 
00189   // number of planes in the reconstructed object
00190   // possibly with a ph cut in pes
00191   // return the sigcor, after the ph cut, in sumph
00192   Int_t NPlanesInObj(TObject *rec, TObject *obj, float phcut, float& sumph);
00193   Int_t NStripsInObj(TObject *rec, TObject *obj, float phcut, float& sumph);
00194   //GetEvtTimeChar assumesevent is already loaded
00195   void GetEvtTimeChar(double &timemin, double &timemax, double &timeln);
00196   void GetEvtTimeCharPHC(double &timemin, double &timemax, double &timeln);
00197 
00198   float MuonShowerEnergy(const NtpSREvent* evt, const NtpSRTrack* trk);
00199   
00200   void EarlyActivity(int evidx, float &earlywph, float &earlywphpw, 
00201                      float &earlywphsphere, float &ph1000, 
00202                      float &ph500, float &ph100,
00203                      float &lateph1000, 
00204                      float &lateph500, float &lateph100,
00205                      float &lateph50);
00206 
00207   //a function to count the number of reconstructed strips 
00208   //that are in this event and in some other event
00209   //(by reconstructed strips I mean CandStripSR)
00210   void DupRecoStrips(int evidx, int &nduprs, float &dupphrs);
00211   
00212   float ComputeLowPHRatio();
00213 
00214 
00215  private:
00216   
00217   // Z (m) locations in the ND (for fiducial cuts)
00218   static const Float_t kVetoEndZ;
00219   static const Float_t kTargEndZ;
00220   static const Float_t kCalorEndZ;
00221   static const Float_t kHalfCalorEndZ;
00222   static const Float_t kSpecEndZ;
00223   // xy beam center in ND
00224   static const Float_t kXcenter;
00225   static const Float_t kYcenter;
00226 
00227   //constants for EarlyActivity estimation
00228   static const Double_t fEarlyActivityWindowSize;
00229   static const Double_t fPMTTimeConstant;
00230   static const Int_t fNPlaneEarlyAct;
00231   static const Double_t fEarlyPlaneSphere;
00232 
00233 
00234   //  std::string fBECFile; // file for beam energy reweighting
00235   Registry fBECConfig; // config for beam energy reweighting
00236   BeamType::BeamType_t fMCBeam;
00237   bool fDataUseMCBeam;
00238   bool fDoInukeReweight;
00239   bool fOnlyWriteFidEvents;//only write out events reco'd inside fid. vol.
00240   int fNRandomSets; // number of random sets to generate 0= 1sigmas
00241 };
00242 
00243 #endif

Generated on Mon Feb 15 11:06:55 2010 for loon by  doxygen 1.3.9.1