SusyNtuple
SusyNtuple/SusyNtAna.h
00001 #ifndef SusyNtuple_SusyNtAna_h
00002 #define SusyNtuple_SusyNtAna_h
00003 
00004 #include "TSelector.h"
00005 #include "TTree.h"
00006 #include "TStopwatch.h"
00007 
00008 #include "SusyNtuple/SusyNtObject.h"
00009 #include "SusyNtuple/SusyNtTools.h"
00010 #include "SusyNtuple/MCWeighter.h"
00011 #include "SusyNtuple/SusyNtSys.h"
00012 #include "SusyNtuple/TauId.h"
00013 
00014 #include <fstream>
00015 #include <map>
00016 #include <set>
00017 
00018 
00019 // To debug events in input file 
00020 typedef std::map< unsigned int, std::set<unsigned int>* > RunEventMap;
00021 
00022 
00024 class SusyNtAna : public TSelector
00025 {
00026 
00027   public:
00028 
00030     SusyNtAna();
00031     virtual ~SusyNtAna(){};
00032 
00034     Susy::SusyNtObject nt;
00036     SusyNtTools m_nttools;
00037     inline void setAnaType(AnalysisType v){ m_nttools.setAnaType(v); }
00038     /*const*/ SusyNtTools& nttools() /*const*/ { return m_nttools; } // DG should be const
00039 
00040     //
00041     // TSelector methods
00042     //
00043 
00045     virtual void    Init(TTree *tree);
00047     virtual void    Begin(TTree *tree);
00049     virtual Bool_t  Notify() { return kTRUE; }
00051     virtual void    Terminate();
00053     virtual Int_t   Version() const {
00054       return 2;
00055     }
00056 
00058     virtual Bool_t  Process(Long64_t entry);
00059 
00062     virtual Int_t   GetEntry(Long64_t e, Int_t getall = 0) {
00063       m_entry=e;
00064       return kTRUE;
00065     }
00066 
00067     // Object selection
00068     void clearObjects();
00069     void selectObjects(Susy::NtSys::SusyNtSys sys = Susy::NtSys::NOM,
00070                        TauId signalTauID=TauId::Medium);
00071 
00072     // Cleaning cuts
00073     int cleaningCutFlags();
00074 
00075     // Event and object dumps
00076     void dumpEvent();
00077     void dumpNtupleObjects();
00078     void dumpBaselineObjects();
00079     void dumpBaselineLeptons();
00080     void dumpBaselineJets();
00081     void dumpSignalObjects();
00082     void dumpSignalLeptons();
00083     void dumpSignalJets();
00084 
00086     void setSelectTaus(bool doIt) { m_selectTaus = doIt; }
00087 
00089     void setPrintFreq(int freq) { m_printFreq = freq; }
00090 
00092     void setDebug(int dbg) { m_dbg = dbg; m_mcWeighter.setVerbose(dbg); }
00093     int dbg() { return m_dbg; }
00094 
00095     void toggleCheckDuplicates(bool b=true) { m_duplicate = b; }
00096     bool checkDuplicate() { return m_duplicate; }
00097     
00098     void setEvtDebug() { m_dbgEvt = true; }
00099     bool dbgEvt() const { return m_dbgEvt; }
00100     void loadEventList(const std::string filename="debugEvents.txt");
00101     bool processThisEvent(unsigned int run, unsigned int event);
00102     bool checkRunEvent(const RunEventMap &runEventMap, unsigned int run, unsigned int event);
00103     bool checkAndAddRunEvent(RunEventMap &runEventMap, unsigned int run, unsigned int event);
00104     void addRunEvent(RunEventMap &runEventMap, unsigned int run, unsigned int event) 
00105     { checkAndAddRunEvent(runEventMap, run, event); }
00106 
00107     bool isDuplicate(unsigned int run, unsigned int event);
00108 
00109     // Sample name - can be used however you like
00110     std::string sampleName() const { return m_sample; }
00111     void setSampleName(std::string s) { m_sample = s; }
00112 
00114     MCWeighter& mcWeighter() { return m_mcWeighter; }
00115 
00117     void dumpTimer();
00118 
00120     TTree* getTree() { return m_tree; }
00121 
00122     ClassDef(SusyNtAna, 1);
00123 
00124   protected:
00125 
00126     //
00127     // General
00128     //
00129 
00130     TTree* m_tree;              
00131 
00132     Long64_t m_entry;           
00133     Long64_t m_chainEntry;      
00134 
00135     bool m_selectTaus;          
00136 
00137     int   m_printFreq;          
00138     int   m_dbg;                
00139     bool  m_dbgEvt;             
00140     bool  m_duplicate;          
00141     
00142     std::string m_sample;       
00143 
00144     // To debug events in input file 
00145     RunEventMap m_eventList;          
00146     RunEventMap m_eventListDuplicate; 
00147 
00148     MCWeighter m_mcWeighter;   // provides MC normalization and event weight
00149 
00150 
00151     //
00152     // Object collections
00153     //
00154 
00155     ElectronVector      m_preElectrons;         
00156     MuonVector          m_preMuons;             
00157     LeptonVector        m_preLeptons;       
00158     JetVector           m_preJets;              
00159     TauVector           m_preTaus;
00160 
00161     ElectronVector      m_baseElectrons;        
00162     MuonVector          m_baseMuons;            
00163     LeptonVector        m_baseLeptons;          
00164     TauVector           m_baseTaus;             
00165     JetVector           m_baseJets;             
00166 
00167     ElectronVector      m_signalElectrons;      
00168     MuonVector          m_signalMuons;          
00169     LeptonVector        m_signalLeptons;        
00170     TauVector           m_signalTaus;           
00171     JetVector           m_signalJets;           
00172     JetVector           m_signalJets2Lep;       
00173 
00174     // New organization of tau selections
00175     TauVector           m_mediumTaus;           
00176     TauVector           m_tightTaus;            
00177 
00178     const Susy::Met*    m_met;                  
00179     const Susy::TrackMet*    m_trackMet;        
00180 
00182     TStopwatch          m_timer;
00183 
00184 };
00185 
00186 
00187 
00188 #endif
 All Classes Functions Variables Typedefs Enumerations Enumerator