CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/Calibration/HcalCalibAlgos/interface/hcalCalib.h

Go to the documentation of this file.
00001 
00002 // This class skeleton has been automatically generated on
00003 // from TTree hcalCalibTree/Tree for IsoTrack Calibration
00004 // with ROOT version 5.17/02
00005 //
00006 //  TSelector-based code for getting the HCAL resp. correction
00007 //  from physics events. Works for DiJet and IsoTrack calibration.
00008 //
00009 //  Anton Anastassov (Northwestern)
00010 //  Email: aa@fnal.gov
00011 //
00012 // $Id: hcalCalib.h,v 1.5 2009/10/26 01:48:57 anastass Exp $
00013 //
00015 
00016 #ifndef hcalCalib_h
00017 #define hcalCalib_h
00018 
00019 #include <vector>
00020 #include <map>
00021 
00022 #include <TROOT.h>
00023 #include <TChain.h>
00024 #include <TFile.h>
00025 #include <TSelector.h>
00026 #include <TROOT.h>
00027 #include <TChain.h>
00028 #include <TFile.h>
00029 #include <TSelector.h>
00030 
00031 #include "TLorentzVector.h"
00032 #include "TClonesArray.h"
00033 #include "TRefArray.h"
00034 
00035 // needed to get cell coordinates
00036 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00037 
00038 
00039 class hcalCalib : public TSelector {
00040 public :
00041    TTree          *fChain;   
00042 
00043    UInt_t          eventNumber;
00044    UInt_t          runNumber;
00045    Int_t           iEtaHit;
00046    UInt_t          iPhiHit;
00047    TClonesArray    *cells;
00048    Float_t         emEnergy;
00049    Float_t         targetE;
00050    Float_t         etVetoJet;
00051  
00052    Float_t         xTrkHcal;
00053    Float_t         yTrkHcal;
00054    Float_t         zTrkHcal;
00055    Float_t         xTrkEcal;
00056    Float_t         yTrkEcal;
00057    Float_t         zTrkEcal;
00058 
00059    TLorentzVector  *tagJetP4;
00060    TLorentzVector  *probeJetP4;
00061 
00062    Float_t         tagJetEmFrac;
00063    Float_t         probeJetEmFrac;
00064 
00065    // List of branches
00066    TBranch        *b_eventNumber;   
00067    TBranch        *b_runNumber;   
00068    TBranch        *b_iEtaHit;   
00069    TBranch        *b_iPhiHit;   
00070    TBranch        *b_cells;   
00071    TBranch        *b_emEnergy;   
00072    TBranch        *b_targetE;   
00073    TBranch        *b_etVetoJet;   
00074 
00075    TBranch        *b_xTrkHcal;
00076    TBranch        *b_yTrkHcal;
00077    TBranch        *b_zTrkHcal;
00078    TBranch        *b_xTrkEcal;
00079    TBranch        *b_yTrkEcal;
00080    TBranch        *b_zTrkEcal;
00081 
00082    TBranch        *b_tagJetEmFrac;   
00083    TBranch        *b_probeJetEmFrac;   
00084 
00085    TBranch        *b_tagJetP4;   
00086    TBranch        *b_probeJetP4;   
00087 
00088 
00089    hcalCalib(TTree * /*tree*/ =0) { }
00090    virtual ~hcalCalib() { }
00091    virtual Int_t   Version() const { return 2; }
00092    virtual void    Begin(TTree *tree);
00093    //   virtual void    SlaveBegin(TTree *tree);
00094    virtual void    Init(TTree *tree);
00095    virtual Bool_t  Notify();
00096    virtual Bool_t  Process(Long64_t entry);
00097    virtual Int_t   GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
00098    virtual void    SetOption(const char *option) { fOption = option; }
00099    virtual void    SetObject(TObject *obj) { fObject = obj; }
00100    virtual void    SetInputList(TList *input) { fInput = input; }
00101    virtual TList  *GetOutputList() const { return fOutput; }
00102    //   virtual void    SlaveTerminate();
00103    virtual void    Terminate();
00104 
00105     //------------ CUTS ---------------
00106     Float_t MIN_TARGET_E;
00107     Float_t MAX_TARGET_E;
00108     
00109     Float_t MIN_CELL_E;
00110     Float_t MIN_EOVERP;
00111     Float_t MAX_EOVERP;
00112     Float_t MAX_TRK_EME;
00113 
00114     Float_t MAX_ET_THIRD_JET;
00115     Float_t MIN_DPHI_DIJETS;
00116    
00117     Bool_t  SUM_DEPTHS;
00118     Bool_t  SUM_SMALL_DEPTHS;
00119     Bool_t  COMBINE_PHI;
00120 
00121     Int_t   HB_CLUSTER_SIZE;
00122     Int_t   HE_CLUSTER_SIZE;
00123 
00124     Bool_t  USE_CONE_CLUSTERING;
00125     Float_t MAX_CONE_DIST;
00126      
00127     Int_t   CALIB_ABS_IETA_MAX;
00128     Int_t   CALIB_ABS_IETA_MIN;
00129    
00130     Float_t MAX_PROBEJET_EMFRAC;
00131     Float_t MAX_TAGJET_EMFRAC;
00132     Float_t MAX_TAGJET_ABSETA;
00133     Float_t MIN_TAGJET_ET;
00134 
00135     Float_t MIN_PROBEJET_ABSETA;
00136     
00137     TString CALIB_TYPE;  // "ISO_TRACK" or "DI_JET"
00138     TString CALIB_METHOD; // L3, matrix inversion, everage then matrix inversion,...
00139 
00140     TString PHI_SYM_COR_FILENAME;
00141     Bool_t  APPLY_PHI_SYM_COR_FLAG;
00142 
00143     TString OUTPUT_COR_COEF_FILENAME;
00144     TString HISTO_FILENAME;
00145    
00146 
00147     const CaloGeometry* theCaloGeometry;
00148 
00149 
00150     void SetMinTargetE(Float_t e)                   { MIN_TARGET_E = e; }
00151     void SetMaxTargetE(Float_t e)                   { MAX_TARGET_E = e; }
00152     void SetSumDepthsFlag(Bool_t b)                 { SUM_DEPTHS = b; }
00153     void SetSumSmallDepthsFlag(Bool_t b)            { SUM_SMALL_DEPTHS = b; }
00154     void SetCombinePhiFlag(Bool_t b)                { COMBINE_PHI = b; }
00155     void SetMinCellE(Float_t e)                     { MIN_CELL_E = e; }
00156     void SetMinEOverP(Float_t e)                    { MIN_EOVERP = e; }
00157     void SetMaxEOverP(Float_t e)                    { MAX_EOVERP = e; }
00158     void SetMaxTrkEmE(Float_t e)                    { MAX_TRK_EME = e; }
00159     void SetCalibType(TString s)                    { CALIB_TYPE = s; }
00160     void SetCalibMethod(TString s)                  { CALIB_METHOD = s; }  
00161     void SetHbClusterSize(Int_t i)                  { HB_CLUSTER_SIZE = i; }      
00162     void SetHeClusterSize(Int_t i)                  { HE_CLUSTER_SIZE = i; }  
00163 
00164     void SetUseConeClustering (Bool_t b)            { USE_CONE_CLUSTERING = b; }
00165     void SetConeMaxDist(Float_t d)                  { MAX_CONE_DIST = d; }
00166   
00167     void SetCalibAbsIEtaMax(Int_t i)                { CALIB_ABS_IETA_MAX = i; }      
00168     void SetCalibAbsIEtaMin(Int_t i)                { CALIB_ABS_IETA_MIN = i; }
00169     void SetMaxEtThirdJet(Float_t et)               { MAX_ET_THIRD_JET = et; }
00170     void SetMinDPhiDiJets(Float_t dphi)             { MIN_DPHI_DIJETS = dphi; }
00171     void SetApplyPhiSymCorFlag(Bool_t b)            { APPLY_PHI_SYM_COR_FLAG = b; }
00172     void SetPhiSymCorFileName(TString filename)     { PHI_SYM_COR_FILENAME = filename; }
00173     void SetMaxProbeJetEmFrac(Float_t f)            { MAX_PROBEJET_EMFRAC = f; }
00174     void SetMaxTagJetEmFrac(Float_t f)              { MAX_TAGJET_EMFRAC = f; }
00175     void SetMaxTagJetAbsEta(Float_t e)              { MAX_TAGJET_ABSETA = e; }
00176     void SetMinTagJetEt(Float_t e)                  { MIN_TAGJET_ET = e; }
00177     void SetMinProbeJetAbsEta(Float_t e)            { MIN_PROBEJET_ABSETA = e; }
00178     void SetOutputCorCoefFileName(TString filename) { OUTPUT_COR_COEF_FILENAME = filename; }
00179     void SetHistoFileName(TString filename)         { HISTO_FILENAME = filename; }
00180 
00181 
00182     void SetCaloGeometry (const CaloGeometry* g)    { theCaloGeometry = g; }
00183 
00184     void GetCoefFromMtrxInvOfAve();
00185 
00186     Bool_t ReadPhiSymCor();
00187 
00188     void makeTextFile();
00189 
00190  
00191     // --------- containers passed to minimizers ----------------
00192     std::vector< std::vector<Float_t> >     cellEnergies;
00193     std::vector< std::vector<UInt_t> >      cellIds;
00194     std::vector< std::pair<Int_t, UInt_t> > refIEtaIPhi;   // centroid of jet or hottest tower iEta, iPhi
00195     std::vector< Float_t>                   targetEnergies;
00196 
00197     std::map<UInt_t, Float_t>               phiSymCor;  // holds the phi symmetry corrections read from the file
00198 
00199     std::map<UInt_t, Float_t> solution;   // correction coef: solution from L3, holds final coef for hybrid methods as well
00200     std::map<Int_t, Float_t> iEtaCoefMap; // correction coef: from matrix inversion AFTER averaging, also intermediate results for hybrid methods
00201 
00202 
00203 
00204     //   ClassDef(hcalCalib,0);
00205 };
00206 
00207 #endif
00208 
00209 #ifdef hcalCalib_cxx
00210 void hcalCalib::Init(TTree *tree)
00211 {
00212    // The Init() function is called when the selector needs to initialize
00213    // a new tree or chain. Typically here the branch addresses and branch
00214    // pointers of the tree will be set.
00215    // It is normaly not necessary to make changes to the generated
00216    // code, but the routine can be extended by the user if needed.
00217    // Init() will be called many times when running on PROOF
00218    // (once per file to be processed).
00219 
00220    // Set object pointer
00221    cells = 0;
00222    tagJetP4 = 0;
00223    probeJetP4 = 0;
00224    
00225    // Set branch addresses and branch pointers
00226    if (!tree) return;
00227    fChain = tree;
00228 
00229    //      fChain->SetMakeClass(1);
00230 
00231    fChain->SetBranchAddress("eventNumber", &eventNumber, &b_eventNumber);
00232    fChain->SetBranchAddress("runNumber", &runNumber, &b_runNumber);
00233    fChain->SetBranchAddress("iEtaHit", &iEtaHit, &b_iEtaHit);
00234    fChain->SetBranchAddress("iPhiHit", &iPhiHit, &b_iPhiHit);
00235    fChain->SetBranchAddress("cells", &cells, &b_cells);
00236    fChain->SetBranchAddress("emEnergy", &emEnergy, &b_emEnergy);
00237    fChain->SetBranchAddress("targetE", &targetE, &b_targetE);
00238    fChain->SetBranchAddress("etVetoJet", &etVetoJet, &b_etVetoJet);
00239 
00240    fChain->SetBranchAddress("xTrkHcal", &xTrkHcal, &b_xTrkHcal);
00241    fChain->SetBranchAddress("yTrkHcal", &yTrkHcal, &b_yTrkHcal);
00242    fChain->SetBranchAddress("zTrkHcal", &zTrkHcal, &b_zTrkHcal);
00243    fChain->SetBranchAddress("xTrkEcal", &xTrkEcal, &b_xTrkEcal);
00244    fChain->SetBranchAddress("yTrkEcal", &yTrkEcal, &b_yTrkEcal);
00245    fChain->SetBranchAddress("zTrkEcal", &zTrkEcal, &b_zTrkEcal);
00246 
00247    fChain->SetBranchAddress("tagJetEmFrac", &tagJetEmFrac, &b_tagJetEmFrac);
00248    fChain->SetBranchAddress("probeJetEmFrac", &probeJetEmFrac, &b_probeJetEmFrac);
00249 
00250    fChain->SetBranchAddress("tagJetP4", &tagJetP4, &b_tagJetP4);  
00251    fChain->SetBranchAddress("probeJetP4", &probeJetP4, &b_probeJetP4);  
00252 
00253 
00254 
00255 }
00256 
00257 Bool_t hcalCalib::Notify()
00258 {
00259    // The Notify() function is called when a new file is opened. This
00260    // can be either for a new TTree in a TChain or when when a new TTree
00261    // is started when using PROOF. It is normaly not necessary to make changes
00262    // to the generated code, but the routine can be extended by the
00263    // user if needed. The return value is currently not used.
00264 
00265    return kTRUE;
00266 }
00267 
00268 #endif // #ifdef hcalCalib_cxx