CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EgammaAnalysis/ElectronTools/interface/ElectronEnergyRegressionEvaluate.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------------------------------
00002 // $Id $
00003 //
00004 // ElectronEnergyRegressionEvaluate
00005 //
00006 // Helper Class for applying electron energy regression calculation
00007 //
00008 // Authors: A.Takeda, S.Xie, E. Di Marco
00009 //--------------------------------------------------------------------------------------------------
00010 
00011 
00016 
00017 //#define STANDALONE   // <---- this line
00018 
00019 
00020 #ifndef ELECTRONENERGYREGRESSIONEVALUATE_H
00021 #define ELECTRONENERGYREGRESSIONEVALUATE_H
00022 
00023 #include "TFile.h"
00024 #include "TTree.h"
00025 
00026 // For applying regression
00027 #include "CondFormats/EgammaObjects/interface/GBRForest.h"
00028 #ifndef STANDALONE
00029 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00030 #include "EgammaAnalysis/ElectronTools/interface/SuperClusterHelper.h"
00031 //#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00032 #endif
00033 
00034 
00035 class ElectronEnergyRegressionEvaluate{
00036  public:
00037   ElectronEnergyRegressionEvaluate();
00038   ~ElectronEnergyRegressionEvaluate();
00039 
00040   enum ElectronEnergyRegressionType {
00041     kNoTrkVar,
00042     kNoTrkVarV1,
00043     kWithTrkVar,
00044     kWithTrkVarV1,
00045     kWithTrkVarV2,
00046     kWithSubCluVar
00047   };
00048 
00049   void initialize(std::string weightsFile,
00050                   ElectronEnergyRegressionEvaluate::ElectronEnergyRegressionType type);
00051 
00052   bool isInitialized() const {return fIsInitialized;}
00053                 
00054 #ifndef STANDALONE
00055   double calculateRegressionEnergy(const reco::GsfElectron *ele, 
00056           SuperClusterHelper& mySCHelper, 
00057           double rho, double nvertices, 
00058           bool printDebug = false);
00059   double calculateRegressionEnergyUncertainty(const reco::GsfElectron *ele, 
00060           SuperClusterHelper& mySCHelper,
00061           double rho, double nvertices, 
00062           bool printDebug = false);
00063 #endif
00064 
00065   // Evaluates regression without tracker variables
00066   double regressionValueNoTrkVar(
00067                                  double SCRawEnergy,
00068                                  double scEta,
00069                                  double scPhi,
00070                                  double R9,
00071                                  double etawidth,
00072                                  double phiwidth,
00073                                  double NClusters,
00074                                  double HoE,
00075                                  double rho,
00076                                  double vertices,
00077                                  double EtaSeed,
00078                                  double PhiSeed,
00079                                  double ESeed,
00080                                  double E3x3Seed,
00081                                  double E5x5Seed,
00082                                  double see,
00083                                  double spp,
00084                                  double sep,
00085                                  double EMaxSeed,
00086                                  double E2ndSeed,
00087                                  double ETopSeed,
00088                                  double EBottomSeed,
00089                                  double ELeftSeed,
00090                                  double ERightSeed,
00091                                  double E2x5MaxSeed,
00092                                  double E2x5TopSeed,
00093                                  double E2x5BottomSeed,
00094                                  double E2x5LeftSeed,
00095                                  double E2x5RightSeed,
00096                                  double IEtaSeed,
00097                                  double IPhiSeed,
00098                                  double EtaCrySeed,
00099                                  double PhiCrySeed,
00100                                  double PreShowerOverRaw,
00101                                  bool printDebug = false);
00102 
00103   // Evaluates regression without tracker variables
00104   double regressionUncertaintyNoTrkVar(
00105                                        double SCRawEnergy,
00106                                        double scEta,
00107                                        double scPhi,
00108                                        double R9,
00109                                        double etawidth,
00110                                        double phiwidth,
00111                                        double NClusters,
00112                                        double HoE,
00113                                        double rho,
00114                                        double vertices,
00115                                        double EtaSeed,
00116                                        double PhiSeed,
00117                                        double ESeed,
00118                                        double E3x3Seed,
00119                                        double E5x5Seed,
00120                                        double see,
00121                                        double spp,
00122                                        double sep,
00123                                        double EMaxSeed,
00124                                        double E2ndSeed,
00125                                        double ETopSeed,
00126                                        double EBottomSeed,
00127                                        double ELeftSeed,
00128                                        double ERightSeed,
00129                                        double E2x5MaxSeed,
00130                                        double E2x5TopSeed,
00131                                        double E2x5BottomSeed,
00132                                        double E2x5LeftSeed,
00133                                        double E2x5RightSeed,
00134                                        double IEtaSeed,
00135                                        double IPhiSeed,
00136                                        double EtaCrySeed,
00137                                        double PhiCrySeed,
00138                                        double PreShowerOverRaw,
00139                                        bool printDebug = false);
00140 
00141   // Evaluates regression without tracker variables
00142   double regressionValueNoTrkVarV1(
00143                                  double SCRawEnergy,
00144                                  double scEta,
00145                                  double scPhi,
00146                                  double R9,
00147                                  double etawidth,
00148                                  double phiwidth,
00149                                  double NClusters,
00150                                  double HoE,
00151                                  double rho,
00152                                  double vertices,
00153                                  double EtaSeed,
00154                                  double PhiSeed,
00155                                  double ESeed,
00156                                  double E3x3Seed,
00157                                  double E5x5Seed,
00158                                  double see,
00159                                  double spp,
00160                                  double sep,
00161                                  double EMaxSeed,
00162                                  double E2ndSeed,
00163                                  double ETopSeed,
00164                                  double EBottomSeed,
00165                                  double ELeftSeed,
00166                                  double ERightSeed,
00167                                  double E2x5MaxSeed,
00168                                  double E2x5TopSeed,
00169                                  double E2x5BottomSeed,
00170                                  double E2x5LeftSeed,
00171                                  double E2x5RightSeed,
00172                                  double IEtaSeed,
00173                                  double IPhiSeed,
00174                                  double EtaCrySeed,
00175                                  double PhiCrySeed,
00176                                  double PreShowerOverRaw,
00177                                  int    IsEcalDriven,
00178                                  bool printDebug = false);
00179 
00180   // Evaluates regression without tracker variables
00181   double regressionUncertaintyNoTrkVarV1(
00182                                        double SCRawEnergy,
00183                                        double scEta,
00184                                        double scPhi,
00185                                        double R9,
00186                                        double etawidth,
00187                                        double phiwidth,
00188                                        double NClusters,
00189                                        double HoE,
00190                                        double rho,
00191                                        double vertices,
00192                                        double EtaSeed,
00193                                        double PhiSeed,
00194                                        double ESeed,
00195                                        double E3x3Seed,
00196                                        double E5x5Seed,
00197                                        double see,
00198                                        double spp,
00199                                        double sep,
00200                                        double EMaxSeed,
00201                                        double E2ndSeed,
00202                                        double ETopSeed,
00203                                        double EBottomSeed,
00204                                        double ELeftSeed,
00205                                        double ERightSeed,
00206                                        double E2x5MaxSeed,
00207                                        double E2x5TopSeed,
00208                                        double E2x5BottomSeed,
00209                                        double E2x5LeftSeed,
00210                                        double E2x5RightSeed,
00211                                        double IEtaSeed,
00212                                        double IPhiSeed,
00213                                        double EtaCrySeed,
00214                                        double PhiCrySeed,
00215                                        double PreShowerOverRaw,
00216                                        int    IsEcalDriven,
00217                                        bool printDebug = false);
00218 
00219   // Evaluates regression using tracker variables
00220   // This option is now deprecated. we keep it only
00221   // for backwards compatibility
00222   double regressionValueWithTrkVar(                             
00223                                    double electronP,
00224                                    double SCRawEnergy,
00225                                    double scEta,
00226                                    double scPhi,
00227                                    double R9,
00228                                    double etawidth,
00229                                    double phiwidth,
00230                                    double NClusters,
00231                                    double HoE,
00232                                    double rho,
00233                                    double vertices,
00234                                    double EtaSeed,
00235                                    double PhiSeed,
00236                                    double ESeed,
00237                                    double E3x3Seed,
00238                                    double E5x5Seed,
00239                                    double see,
00240                                    double spp,
00241                                    double sep,
00242                                    double EMaxSeed,
00243                                    double E2ndSeed,
00244                                    double ETopSeed,
00245                                    double EBottomSeed,
00246                                    double ELeftSeed,
00247                                    double ERightSeed,
00248                                    double E2x5MaxSeed,
00249                                    double E2x5TopSeed,
00250                                    double E2x5BottomSeed,
00251                                    double E2x5LeftSeed,
00252                                    double E2x5RightSeed,
00253                                    double pt,
00254                                    double GsfTrackPIn,
00255                                    double fbrem,
00256                                    double Charge,
00257                                    double EoP,
00258                                    double IEtaSeed,
00259                                    double IPhiSeed,
00260                                    double EtaCrySeed,
00261                                    double PhiCrySeed,
00262                                    double PreShowerOverRaw,
00263                                    bool printDebug = false );
00264 
00265 
00266   // Evaluates regression using tracker variables
00267   // This option is now deprecated. we keep it only
00268   // for backwards compatibility
00269   double regressionUncertaintyWithTrkVar(                               
00270                                          double electronP,
00271                                          double SCRawEnergy,
00272                                          double scEta,
00273                                          double scPhi,
00274                                          double R9,
00275                                          double etawidth,
00276                                          double phiwidth,
00277                                          double NClusters,
00278                                          double HoE,
00279                                          double rho,
00280                                          double vertices,
00281                                          double EtaSeed,
00282                                          double PhiSeed,
00283                                          double ESeed,
00284                                          double E3x3Seed,
00285                                          double E5x5Seed,
00286                                          double see,
00287                                          double spp,
00288                                          double sep,
00289                                          double EMaxSeed,
00290                                          double E2ndSeed,
00291                                          double ETopSeed,
00292                                          double EBottomSeed,
00293                                          double ELeftSeed,
00294                                          double ERightSeed,
00295                                          double E2x5MaxSeed,
00296                                          double E2x5TopSeed,
00297                                          double E2x5BottomSeed,
00298                                          double E2x5LeftSeed,
00299                                          double E2x5RightSeed,
00300                                          double pt,
00301                                          double GsfTrackPIn,
00302                                          double fbrem,
00303                                          double Charge,
00304                                          double EoP,
00305                                          double IEtaSeed,
00306                                          double IPhiSeed,
00307                                          double EtaCrySeed,
00308                                          double PhiCrySeed,
00309                                          double PreShowerOverRaw,
00310                                          bool printDebug = false );
00311 
00312 
00313   // Evaluates regression using tracker variables
00314   double regressionValueWithTrkVarV1(                           
00315                                    double SCRawEnergy,
00316                                    double scEta,
00317                                    double scPhi,
00318                                    double R9,
00319                                    double etawidth,
00320                                    double phiwidth,
00321                                    double NClusters,
00322                                    double HoE,
00323                                    double rho,
00324                                    double vertices,
00325                                    double EtaSeed,
00326                                    double PhiSeed,
00327                                    double ESeed,
00328                                    double E3x3Seed,
00329                                    double E5x5Seed,
00330                                    double see,
00331                                    double spp,
00332                                    double sep,
00333                                    double EMaxSeed,
00334                                    double E2ndSeed,
00335                                    double ETopSeed,
00336                                    double EBottomSeed,
00337                                    double ELeftSeed,
00338                                    double ERightSeed,
00339                                    double E2x5MaxSeed,
00340                                    double E2x5TopSeed,
00341                                    double E2x5BottomSeed,
00342                                    double E2x5LeftSeed,
00343                                    double E2x5RightSeed,                                  
00344                                    double IEtaSeed,
00345                                    double IPhiSeed,
00346                                    double EtaCrySeed,
00347                                    double PhiCrySeed,
00348                                    double PreShowerOverRaw, 
00349                                    int    IsEcalDriven,
00350                                    double GsfTrackPIn,
00351                                    double fbrem,
00352                                    double Charge,
00353                                    double EoP,
00354                                    double TrackMomentumError,
00355                                    double EcalEnergyError,
00356                                    int    Classification,                           
00357                                    bool printDebug = false );
00358 
00359 
00360   // Evaluates regression using tracker variables
00361   double regressionUncertaintyWithTrkVarV1(                             
00362                                          double SCRawEnergy,
00363                                          double scEta,
00364                                          double scPhi,
00365                                          double R9,
00366                                          double etawidth,
00367                                          double phiwidth,
00368                                          double NClusters,
00369                                          double HoE,
00370                                          double rho,
00371                                          double vertices,
00372                                          double EtaSeed,
00373                                          double PhiSeed,
00374                                          double ESeed,
00375                                          double E3x3Seed,
00376                                          double E5x5Seed,
00377                                          double see,
00378                                          double spp,
00379                                          double sep,
00380                                          double EMaxSeed,
00381                                          double E2ndSeed,
00382                                          double ETopSeed,
00383                                          double EBottomSeed,
00384                                          double ELeftSeed,
00385                                          double ERightSeed,
00386                                          double E2x5MaxSeed,
00387                                          double E2x5TopSeed,
00388                                          double E2x5BottomSeed,
00389                                          double E2x5LeftSeed,
00390                                          double E2x5RightSeed,
00391                                          double IEtaSeed,
00392                                          double IPhiSeed,
00393                                          double EtaCrySeed,
00394                                          double PhiCrySeed,
00395                                          double PreShowerOverRaw,                   
00396                                          int    IsEcalDriven,
00397                                          double GsfTrackPIn,
00398                                          double fbrem,
00399                                          double Charge,
00400                                          double EoP,
00401                                          double TrackMomentumError,
00402                                          double EcalEnergyError,
00403                                          int    Classification,
00404                                          bool printDebug = false );
00405 
00406     double regressionValueWithTrkVarV1( std::vector<double> &inputvars,                                                                                  
00407                                         bool printDebug = false );
00408     double regressionUncertaintyWithTrkVarV1( std::vector<double> &inputvars,                                                                            
00409                                               bool printDebug = false );
00410     
00411 
00412   // Evaluates regression using tracker variables
00413   double regressionValueWithTrkVarV2(                           
00414                                    double SCRawEnergy,
00415                                    double scEta,
00416                                    double scPhi,
00417                                    double R9,
00418                                    double etawidth,
00419                                    double phiwidth,
00420                                    double NClusters,
00421                                    double HoE,
00422                                    double rho,
00423                                    double vertices,
00424                                    double EtaSeed,
00425                                    double PhiSeed,
00426                                    double ESeed,
00427                                    double E3x3Seed,
00428                                    double E5x5Seed,
00429                                    double see,
00430                                    double spp,
00431                                    double sep,
00432                                    double EMaxSeed,
00433                                    double E2ndSeed,
00434                                    double ETopSeed,
00435                                    double EBottomSeed,
00436                                    double ELeftSeed,
00437                                    double ERightSeed,
00438                                    double E2x5MaxSeed,
00439                                    double E2x5TopSeed,
00440                                    double E2x5BottomSeed,
00441                                    double E2x5LeftSeed,
00442                                    double E2x5RightSeed,                                  
00443                                    double IEtaSeed,
00444                                    double IPhiSeed,
00445                                    double EtaCrySeed,
00446                                    double PhiCrySeed,
00447                                    double PreShowerOverRaw, 
00448                                    int    IsEcalDriven,
00449                                    double GsfTrackPIn,
00450                                    double fbrem,
00451                                    double Charge,
00452                                    double EoP,
00453                                    double TrackMomentumError,
00454                                    double EcalEnergyError,
00455                                    int    Classification,
00456                                    double detaIn,
00457                                    double dphiIn,
00458                                    double detaCalo,
00459                                    double dphiCalo,
00460                                    double GsfTrackChiSqr,
00461                                    double KFTrackNLayers,
00462                                    double ElectronEnergyOverPout,
00463                                    bool printDebug = false );
00464 
00465 
00466   // Evaluates regression using tracker variables
00467   double regressionUncertaintyWithTrkVarV2(                             
00468                                          double SCRawEnergy,
00469                                          double scEta,
00470                                          double scPhi,
00471                                          double R9,
00472                                          double etawidth,
00473                                          double phiwidth,
00474                                          double NClusters,
00475                                          double HoE,
00476                                          double rho,
00477                                          double vertices,
00478                                          double EtaSeed,
00479                                          double PhiSeed,
00480                                          double ESeed,
00481                                          double E3x3Seed,
00482                                          double E5x5Seed,
00483                                          double see,
00484                                          double spp,
00485                                          double sep,
00486                                          double EMaxSeed,
00487                                          double E2ndSeed,
00488                                          double ETopSeed,
00489                                          double EBottomSeed,
00490                                          double ELeftSeed,
00491                                          double ERightSeed,
00492                                          double E2x5MaxSeed,
00493                                          double E2x5TopSeed,
00494                                          double E2x5BottomSeed,
00495                                          double E2x5LeftSeed,
00496                                          double E2x5RightSeed,
00497                                          double IEtaSeed,
00498                                          double IPhiSeed,
00499                                          double EtaCrySeed,
00500                                          double PhiCrySeed,
00501                                          double PreShowerOverRaw,                   
00502                                          int    IsEcalDriven,
00503                                          double GsfTrackPIn,
00504                                          double fbrem,
00505                                          double Charge,
00506                                          double EoP,
00507                                          double TrackMomentumError,
00508                                          double EcalEnergyError,
00509                                          int    Classification,
00510                                          double detaIn,
00511                                          double dphiIn,
00512                                          double detaCalo,
00513                                          double dphiCalo,
00514                                          double GsfTrackChiSqr,
00515                                          double KFTrackNLayers,
00516                                          double ElectronEnergyOverPout,
00517                                          bool printDebug = false );
00518 
00519     double regressionValueWithTrkVarV2( std::vector<double> &inputvars,                                                                                  
00520                                         bool printDebug = false );
00521     double regressionUncertaintyWithTrkVarV2( std::vector<double> &inputvars,                                                                            
00522                                               bool printDebug = false );
00523 
00524     // Evaluates regression uncertainty with subcluster variables and without track variables
00525     double regressionValueWithSubClusters(
00526                                  double SCRawEnergy,
00527                                  double scEta,
00528                                  double scPhi,
00529                                  double R9,
00530                                  double etawidth,
00531                                  double phiwidth,
00532                                  double NClusters,
00533                                  double HoE,
00534                                  double rho,
00535                                  double vertices,
00536                                  double EtaSeed,
00537                                  double PhiSeed,
00538                                  double ESeed,
00539                                  double E3x3Seed,
00540                                  double E5x5Seed,
00541                                  double see,
00542                                  double spp,
00543                                  double sep,
00544                                  double EMaxSeed,
00545                                  double E2ndSeed,
00546                                  double ETopSeed,
00547                                  double EBottomSeed,
00548                                  double ELeftSeed,
00549                                  double ERightSeed,
00550                                  double E2x5MaxSeed,
00551                                  double E2x5TopSeed,
00552                                  double E2x5BottomSeed,
00553                                  double E2x5LeftSeed,
00554                                  double E2x5RightSeed,
00555                                  double IEtaSeed,
00556                                  double IPhiSeed,
00557                                  double EtaCrySeed,
00558                                  double PhiCrySeed,
00559                                  double PreShowerOverRaw,
00560                                  double isEcalDriven,
00561                                  double isEtaGap,
00562                                  double isPhiGap,
00563                                  double isDeeGap, 
00564                                  double ESubs,
00565                                  double ESub1,
00566                                  double EtaSub1,
00567                                  double PhiSub1,
00568                                  double EMaxSub1,
00569                                  double E3x3Sub1,
00570                                  double ESub2,
00571                                  double EtaSub2,
00572                                  double PhiSub2,
00573                                  double EMaxSub2,
00574                                  double E3x3Sub2,
00575                                  double ESub3,
00576                                  double EtaSub3,
00577                                  double PhiSub3,
00578                                  double EMaxSub3,
00579                                  double E3x3Sub3,
00580                                  double NPshwClusters,
00581                                  double EPshwSubs,
00582                                  double EPshwSub1,
00583                                  double EtaPshwSub1,
00584                                  double PhiPshwSub1,
00585                                  double EPshwSub2,
00586                                  double EtaPshwSub2,
00587                                  double PhiPshwSub2,
00588                                  double EPshwSub3,
00589                                  double EtaPshwSub3,
00590                                  double PhiPshwSub3,
00591                                  bool isEB,
00592                                  bool printDebug = false);
00593 
00594   // Evaluates regression uncertainty with subcluster variables and without track variables
00595   double regressionUncertaintyWithSubClusters(
00596                                        double SCRawEnergy,
00597                                        double scEta,
00598                                        double scPhi,
00599                                        double R9,
00600                                        double etawidth,
00601                                        double phiwidth,
00602                                        double NClusters,
00603                                        double HoE,
00604                                        double rho,
00605                                        double vertices,
00606                                        double EtaSeed,
00607                                        double PhiSeed,
00608                                        double ESeed,
00609                                        double E3x3Seed,
00610                                        double E5x5Seed,
00611                                        double see,
00612                                        double spp,
00613                                        double sep,
00614                                        double EMaxSeed,
00615                                        double E2ndSeed,
00616                                        double ETopSeed,
00617                                        double EBottomSeed,
00618                                        double ELeftSeed,
00619                                        double ERightSeed,
00620                                        double E2x5MaxSeed,
00621                                        double E2x5TopSeed,
00622                                        double E2x5BottomSeed,
00623                                        double E2x5LeftSeed,
00624                                        double E2x5RightSeed,
00625                                        double IEtaSeed,
00626                                        double IPhiSeed,
00627                                        double EtaCrySeed,
00628                                        double PhiCrySeed,
00629                                        double PreShowerOverRaw,
00630                                        double isEcalDriven,
00631                                        double isEtaGap,
00632                                        double isPhiGap,
00633                                        double isDeeGap, 
00634                                        double ESubs,
00635                                        double ESub1,
00636                                        double EtaSub1,
00637                                        double PhiSub1,
00638                                        double EMaxSub1,
00639                                        double E3x3Sub1,
00640                                        double ESub2,
00641                                        double EtaSub2,
00642                                        double PhiSub2,
00643                                        double EMaxSub2,
00644                                        double E3x3Sub2,
00645                                        double ESub3,
00646                                        double EtaSub3,
00647                                        double PhiSub3,
00648                                        double EMaxSub3,
00649                                        double E3x3Sub3,
00650                                        double NPshwClusters,
00651                                        double EPshwSubs,
00652                                        double EPshwSub1,
00653                                        double EtaPshwSub1,
00654                                        double PhiPshwSub1,
00655                                        double EPshwSub2,
00656                                        double EtaPshwSub2,
00657                                        double PhiPshwSub2,
00658                                        double EPshwSub3,
00659                                        double EtaPshwSub3,
00660                                        double PhiPshwSub3,
00661                                        bool isEB,
00662                                        bool printDebug = false);
00663 
00664 
00665  private:
00666   bool fIsInitialized;
00667   ElectronEnergyRegressionEvaluate::ElectronEnergyRegressionType fVersionType;
00668   GBRForest *forestCorrection_eb;               // Pointer to the GBRForest for barrel
00669   GBRForest *forestCorrection_ee;               // Pointer to the GBRForest for endcap
00670 
00671   GBRForest *forestUncertainty_eb;      
00672   GBRForest *forestUncertainty_ee;              
00673 };
00674 
00675 #endif