CMS 3D CMS Logo

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