CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/HLTrigger/HLTanalyzers/src/HLTEgamma.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <sstream>
00003 #include <istream>
00004 #include <fstream>
00005 #include <iomanip>
00006 #include <string>
00007 #include <cmath>
00008 #include <functional>
00009 #include <cstdlib>
00010 #include <cstring>
00011 
00012 #include "DataFormats/EgammaReco/interface/ElectronSeed.h"
00013 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
00014 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" 
00015 #include "HLTrigger/HLTanalyzers/interface/HLTEgamma.h"
00016 
00017 
00018 
00019 #include "RecoEgamma/EgammaTools/interface/ECALPositionCalculator.h"
00020 
00021 #include "FWCore/Framework/interface/EventSetup.h"
00022 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00023 #include "MagneticField/Engine/interface/MagneticField.h"
00024 
00025 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00026 
00027 #include "HLTMessages.h"
00028 
00029 static const size_t kMaxEl     = 10000;
00030 static const size_t kMaxPhot   = 10000;
00031 static const size_t kMaxhPhot  =   500;
00032 static const size_t kMaxhEle   =   500;
00033 
00034 HLTEgamma::HLTEgamma() {
00035 }
00036 
00037 /*  Setup the analysis to put the branch-variables size_to the tree. */
00038 void HLTEgamma::setup(const edm::ParameterSet& pSet, TTree* HltTree)
00039 {
00040         elpt              = new float[kMaxEl];
00041         elphi             = new float[kMaxEl];
00042         eleta             = new float[kMaxEl];
00043         elet              = new float[kMaxEl];
00044         ele               = new float[kMaxEl];
00045         eleId             = new int[kMaxEl];// RL  + 2*RT + 4*L +  4*T 
00046         elIP              = new float[kMaxEl];  
00047         elNLostHits       = new int[kMaxEl];  
00048         elTrkChi2NDF      = new float[kMaxEl];        
00049         elTrkIsoR03       = new float[kMaxEl];  
00050         elECaloIsoR03     = new float[kMaxEl];  
00051         elHCaloIsoR03     = new float[kMaxEl];  
00052         elIsEcalDriven    = new bool[kMaxEl];  
00053         elFbrem           = new float[kMaxEl];      
00054         elmishits         = new int[kMaxEl]; 
00055         eldist            = new float[kMaxEl]; 
00056         eldcot            = new float[kMaxEl]; 
00057         eltrkiso          = new float[kMaxEl]; 
00058         elecaliso         = new float[kMaxEl]; 
00059         elhcaliso         = new float[kMaxEl]; 
00060         elsigmaietaieta   = new float[kMaxEl]; 
00061         eldeltaPhiIn      = new float[kMaxEl]; 
00062         eldeltaEtaIn      = new float[kMaxEl]; 
00063         elhOverE          = new float[kMaxEl]; 
00064         elscEt            = new float[kMaxEl]; 
00065         eld0corr          = new float[kMaxEl]; 
00066         elqGsfCtfScPixConsistent = new bool[kMaxEl]; 
00067 
00068         photonpt          = new float[kMaxPhot];
00069         photonphi         = new float[kMaxPhot];
00070         photoneta         = new float[kMaxPhot];
00071         photonet          = new float[kMaxPhot];
00072         photone           = new float[kMaxPhot];
00073         photontrkiso      = new float[kMaxPhot];
00074         photonecaliso     = new float[kMaxPhot];
00075         photonhcaliso     = new float[kMaxPhot];
00076         photonhovere      = new float[kMaxPhot];
00077         photonClusShap    = new float[kMaxPhot];
00078         photonr9id        = new float[kMaxPhot];
00079 
00080         hphotet           = new float[kMaxhPhot];
00081         hphoteta          = new float[kMaxhPhot];
00082         hphotphi          = new float[kMaxhPhot];
00083         hphoteiso         = new float[kMaxhPhot];
00084         hphothiso         = new float[kMaxhPhot];
00085         hphottiso         = new float[kMaxhPhot];
00086         hphotl1iso        = new int[kMaxhPhot];
00087         hphotClusShap     = new float[kMaxhPhot];
00088         hphotR9           = new float[kMaxhPhot]; 
00089         hphothovereh      = new float[kMaxhPhot];
00090         hphotR9ID         = new float[kMaxhPhot];
00091 
00092   hecalactivet           = new float[kMaxhPhot];
00093   hecalactiveta          = new float[kMaxhPhot];
00094   hecalactivphi          = new float[kMaxhPhot];
00095   hecalactiveiso         = new float[kMaxhPhot];
00096   hecalactivhiso         = new float[kMaxhPhot];
00097   hecalactivtiso         = new float[kMaxhPhot];
00098   hecalactivl1iso        = new int[kMaxhPhot];
00099   hecalactivClusShap     = new float[kMaxhPhot];
00100   hecalactivR9           = new float[kMaxhPhot]; 
00101   hecalactivhovereh      = new float[kMaxhPhot];
00102   hecalactivR9ID         = new float[kMaxhPhot];
00103 
00104         heleet            = new float[kMaxhEle];
00105         heleeta           = new float[kMaxhEle];
00106         helephi           = new float[kMaxhEle];
00107         helevtxz          = new float[kMaxhEle];
00108         heleE             = new float[kMaxhEle];
00109         helep             = new float[kMaxhEle];
00110         helehiso          = new float[kMaxhEle];
00111         heleeiso          = new float[kMaxhEle];
00112         heletiso          = new float[kMaxhEle];
00113         helel1iso         = new int[kMaxhEle];
00114         helePixelSeeds    = new int[kMaxhEle];
00115         heleNewSC         = new int[kMaxhEle];
00116         heleClusShap      = new float[kMaxhEle];
00117         heleDeta          = new float[kMaxhEle];
00118         heleDphi          = new float[kMaxhEle];
00119         heleR9            = new float[kMaxhEle]; 
00120         helehovereh       = new float[kMaxhEle];
00121         heleR9ID          = new float[kMaxhEle];
00122 
00123         hhfelept          = new float[kMaxhEle];
00124         hhfeleeta         = new float[kMaxhEle]; 
00125         hhfclustere9e25   = new float[kMaxhEle];
00126         hhfclustere1e9    = new float[kMaxhEle];
00127         hhfclustereCOREe9 = new float[kMaxhEle];
00128         hhfclustereSeL    = new float[kMaxhEle];
00129         hhfcluster2Dcut   = new float[kMaxhEle]; 
00130         hhfclustereta     = new float[kMaxhEle];  
00131         hhfclusterphi     = new float[kMaxhEle];  
00132 
00133 
00134         nele        = 0;
00135         nphoton     = 0;
00136         nhltecalactiv     = 0;
00137         nhltgam     = 0;
00138         nhltele     = 0;
00139         nhlthfele   = 0;
00140         nhlthfeclus = 0;
00141 
00142         // Egamma-specific branches of the tree
00143         HltTree->Branch("NrecoElec",          & nele,             "NrecoElec/I");
00144         HltTree->Branch("recoElecPt",         elpt,               "recoElecPt[NrecoElec]/F");
00145         HltTree->Branch("recoElecPhi",        elphi,              "recoElecPhi[NrecoElec]/F");
00146         HltTree->Branch("recoElecEta",        eleta,              "recoElecEta[NrecoElec]/F");
00147         HltTree->Branch("recoElecEt",         elet,               "recoElecEt[NrecoElec]/F");
00148         HltTree->Branch("recoElecE",          ele,                "recoElecE[NrecoElec]/F");
00149         HltTree->Branch("recoElecEleID",      eleId,              "recoElecEleID[NrecoElec]/I");
00150         HltTree->Branch("recoElecIP",           elIP,            "recoElecIP[NrecoElec]/F");  
00151         HltTree->Branch("recoElecNLostHits",    elNLostHits,     "recoElecNLostHits[NrecoElec]/I");  
00152         HltTree->Branch("recoElecChi2NDF",      elTrkChi2NDF,    "recoElecChi2NDF[NrecoElec]/F");  
00153         HltTree->Branch("recoElecTrkIsoR03",    elTrkIsoR03,     "recoElecTrkIsoR03[NrecoElec]/F");  
00154         HltTree->Branch("recoElecECaloIsoR03",  elECaloIsoR03,   "recoElecECaloIsoR03[NrecoElec]/F");  
00155         HltTree->Branch("recoElecHCaloIsoR03",  elHCaloIsoR03,   "recoElecHCaloIsoR03[NrecoElec]/F");  
00156         HltTree->Branch("recoElecIsEcalDriven", elIsEcalDriven,  "recoElecIsEcalDriven[NrecoElec]/O");        
00157         HltTree->Branch("recoElecFbrem",        elFbrem,         "recoElecFbrem[NrecoElec]/F");  
00158         HltTree->Branch("recoElecmishits",                  elmishits,                "recoElecmishits[NrecoElec]/I"); 
00159         HltTree->Branch("recoElecdist",                     eldist,                   "recoElecdist[NrecoElec]/F"); 
00160         HltTree->Branch("recoElecdcot",                     eldcot,                   "recoElecdcot[NrecoElec]/F"); 
00161         HltTree->Branch("recoElectrkiso",                   eltrkiso,                 "recoElectrkiso[NrecoElec]/F"); 
00162         HltTree->Branch("recoElececaliso",                  elecaliso,                "recoElececaliso[NrecoElec]/F"); 
00163         HltTree->Branch("recoElechcaliso",                  elhcaliso,                "recoElechcaliso[NrecoElec]/F"); 
00164         HltTree->Branch("recoElecsigmaietaieta",            elsigmaietaieta,          "recoElecsigmaietaieta[NrecoElec]/F"); 
00165         HltTree->Branch("recoElecdeltaPhiIn",               eldeltaPhiIn,             "recoElecdeltaPhiIn[NrecoElec]/F"); 
00166         HltTree->Branch("recoElecdeltaEtaIn",               eldeltaEtaIn,             "recoElecdeltaEtaIn[NrecoElec]/F"); 
00167         HltTree->Branch("recoElechOverE",                   elhOverE,                 "recoElechOverE[NrecoElec]/F"); 
00168         HltTree->Branch("recoElecscEt",                     elscEt,                   "recoElecscEt[NrecoElec]/F"); 
00169         HltTree->Branch("recoElecd0corr",                   eld0corr,                 "recoElecd0corr[NrecoElec]/F"); 
00170         HltTree->Branch("recoElecqGsfCtfScPixConsistent",   elqGsfCtfScPixConsistent, "recoElecqGsfCtfScPixConsistent[NrecoElec]/O");  
00171 
00172         HltTree->Branch("NrecoPhot",          &nphoton,           "NrecoPhot/I");
00173         HltTree->Branch("recoPhotPt",         photonpt,           "recoPhotPt[NrecoPhot]/F");
00174         HltTree->Branch("recoPhotPhi",        photonphi,          "recoPhotPhi[NrecoPhot]/F");
00175         HltTree->Branch("recoPhotEta",        photoneta,          "recoPhotEta[NrecoPhot]/F");
00176         HltTree->Branch("recoPhotEt",         photonet,           "recoPhotEt[NrecoPhot]/F");
00177         HltTree->Branch("recoPhotE",          photone,            "recoPhotE[NrecoPhot]/F");
00178         HltTree->Branch("recoPhotTiso",       photontrkiso,            "recoPhotTiso[NrecoPhot]/F");
00179         HltTree->Branch("recoPhotEiso",       photonecaliso,            "recoPhotEiso[NrecoPhot]/F");
00180         HltTree->Branch("recoPhotHiso",       photonhcaliso,            "recoPhotHiso[NrecoPhot]/F");
00181         HltTree->Branch("recoPhotHoverE",     photonhovere,            "recoPhotHoverE[NrecoPhot]/F");
00182         HltTree->Branch("recoPhotClusShap",   photonClusShap,          "recoPhotClusShap[NrecoPhot]/F");
00183         HltTree->Branch("recoPhotR9ID",       photonr9id,              "recoPhotR9ID[NrecoPhot]/F");
00184 
00185         HltTree->Branch("NohPhot",            & nhltgam,          "NohPhot/I");
00186         HltTree->Branch("ohPhotEt",           hphotet,            "ohPhotEt[NohPhot]/F");
00187         HltTree->Branch("ohPhotEta",          hphoteta,           "ohPhotEta[NohPhot]/F");
00188         HltTree->Branch("ohPhotPhi",          hphotphi,           "ohPhotPhi[NohPhot]/F");
00189         HltTree->Branch("ohPhotEiso",         hphoteiso,          "ohPhotEiso[NohPhot]/F");
00190         HltTree->Branch("ohPhotHiso",         hphothiso,          "ohPhotHiso[NohPhot]/F");
00191         HltTree->Branch("ohPhotTiso",         hphottiso,          "ohPhotTiso[NohPhot]/F");
00192         HltTree->Branch("ohPhotL1iso",        hphotl1iso,         "ohPhotL1iso[NohPhot]/I");
00193         HltTree->Branch("ohPhotClusShap",     hphotClusShap,      "ohPhotClusShap[NohPhot]/F");
00194         HltTree->Branch("ohPhotR9",           hphotR9,            "ohPhotR9[NohPhot]/F");  
00195         HltTree->Branch("ohPhotHforHoverE",   hphothovereh,       "ohPhotHforHoverE[NohPhot]/F");   
00196         HltTree->Branch("ohPhotR9ID",         hphotR9ID,          "ohPhotR9ID[NohPhot]/F");
00197 
00198   HltTree->Branch("NohEcalActiv",            & nhltecalactiv,          "NohEcalActiv/I");
00199   HltTree->Branch("ohEcalActivEt",           hecalactivet,            "ohEcalActivEt[NohEcalActiv]/F");
00200   HltTree->Branch("ohEcalActivEta",          hecalactiveta,           "ohEcalActivEta[NohEcalActiv]/F");
00201   HltTree->Branch("ohEcalActivPhi",          hecalactivphi,           "ohEcalActivPhi[NohEcalActiv]/F");
00202   HltTree->Branch("ohEcalActivEiso",         hecalactiveiso,          "ohEcalActivEiso[NohEcalActiv]/F");
00203   HltTree->Branch("ohEcalActivHiso",         hecalactivhiso,          "ohEcalActivHiso[NohEcalActiv]/F");
00204   HltTree->Branch("ohEcalActivTiso",         hecalactivtiso,          "ohEcalActivTiso[NohEcalActiv]/F");
00205   HltTree->Branch("ohEcalActivL1iso",        hecalactivl1iso,         "ohEcalActivL1iso[NohEcalActiv]/I");
00206   HltTree->Branch("ohEcalActivClusShap",     hecalactivClusShap,      "ohEcalActivClusShap[NohEcalActiv]/F");
00207   HltTree->Branch("ohEcalActivR9",           hecalactivR9,            "ohEcalActivR9[NohEcalActiv]/F");  
00208   HltTree->Branch("ohEcalActivHforHoverE",   hecalactivhovereh,       "ohEcalActivHforHoverE[NohEcalActiv]/F");   
00209   HltTree->Branch("ohEcalActivR9ID",         hecalactivR9ID,          "ohEcalActivR9ID[NohEcalActiv]/F");
00210 
00211         HltTree->Branch("NohEle",             & nhltele,          "NohEle/I");
00212         HltTree->Branch("ohEleEt",            heleet,             "ohEleEt[NohEle]/F");
00213         HltTree->Branch("ohEleEta",           heleeta,            "ohEleEta[NohEle]/F");
00214         HltTree->Branch("ohElePhi",           helephi,            "ohElePhi[NohEle]/F");
00215         HltTree->Branch("ohEleVtxZ",          helevtxz,           "ohEleVtxZ[NohEle]/F");
00216         HltTree->Branch("ohEleE",             heleE,              "ohEleE[NohEle]/F");
00217         HltTree->Branch("ohEleP",             helep,              "ohEleP[NohEle]/F");
00218         HltTree->Branch("ohEleHiso",          helehiso,           "ohEleHiso[NohEle]/F");
00219         HltTree->Branch("ohEleTiso",          heletiso,           "ohEleTiso[NohEle]/F");
00220         HltTree->Branch("ohEleEiso",          heleeiso,           "ohEleEiso[NohEle]/F"); 
00221         HltTree->Branch("ohEleL1iso",         helel1iso,          "ohEleLiso[NohEle]/I");
00222         HltTree->Branch("ohElePixelSeeds",    helePixelSeeds,     "ohElePixelSeeds[NohEle]/I");
00223         HltTree->Branch("ohEleNewSC",         heleNewSC,          "ohEleNewSC[NohEle]/I");
00224         HltTree->Branch("ohEleClusShap",      heleClusShap,       "ohEleClusShap[NohEle]/F");
00225         HltTree->Branch("ohEleDeta",          heleDeta,           "ohEleDeta[NohEle]/F");
00226         HltTree->Branch("ohEleDphi",          heleDphi,           "ohEleDphi[NohEle]/F");
00227         HltTree->Branch("ohEleR9",            heleR9,             "ohEleR9[NohEle]/F");  
00228         HltTree->Branch("ohEleHforHoverE",    helehovereh,        "ohEleHforHoverE[NohEle]/F");    
00229         HltTree->Branch("ohEleR9ID",          heleR9ID,           "ohEleR9ID[NohEle]/F");
00230         HltTree->Branch("NohHFEle",           &nhlthfele ,        "NohHFEle/I"); 
00231         HltTree->Branch("ohHFElePt",          hhfelept,           "ohHFElePt[NohHFEle]/F");
00232         HltTree->Branch("ohHFEleEta",         hhfeleeta,          "ohHFEleEta[NohHFEle]/F");  
00233         HltTree->Branch("NohHFECALClus",      &nhlthfeclus,       "NohHFECALClus/I"); 
00234         
00235     HltTree->Branch("ohHFEleClustere9e25",   hhfclustere9e25,   "ohHFEleClustere9e25[NohHFECALClus]/F");
00236     HltTree->Branch("ohHFEleClustere1e9",    hhfclustere1e9,    "ohHFEleClustere1e9[NohHFECALClus]/F");
00237     HltTree->Branch("ohHFEleClustereCOREe9", hhfclustereCOREe9, "ohHFEleClustereCOREe9[NohHFECALClus]/F");
00238     HltTree->Branch("ohHFEleClustereSeL",    hhfclustereSeL,    "ohHFEleClustereSeL[NohHFECALClus]/F");
00239     HltTree->Branch("ohHFEleCluster2Dcut",   hhfcluster2Dcut,   "ohHFEleCluster2Dcut[NohHFECALClus]/F");
00240     HltTree->Branch("ohHFEleClusterEta",     hhfclustereta,     "ohHFEleClusterEta[NohHFECALClus]/F");
00241     HltTree->Branch("ohHFEleClusterPhi",     hhfclusterphi,     "ohHFEleClusterPhi[NohHFECALClus]/F");
00242 }
00243 
00244 void HLTEgamma::clear(void)
00245 {
00246         std::memset(elpt,             '\0', kMaxEl     * sizeof(float));
00247         std::memset(elphi,            '\0', kMaxEl     * sizeof(float));
00248         std::memset(eleta,            '\0', kMaxEl     * sizeof(float));
00249         std::memset(elet,             '\0', kMaxEl     * sizeof(float));
00250         std::memset(ele,              '\0', kMaxEl     * sizeof(float));
00251         std::memset(ele,              '\0', kMaxEl     * sizeof(int));
00252         std::memset(elIP,             '\0', kMaxEl     * sizeof(float));  
00253         std::memset(elNLostHits,      '\0', kMaxEl     * sizeof(int));  
00254         std::memset(elTrkChi2NDF,     '\0', kMaxEl     * sizeof(float));     
00255         std::memset(elTrkIsoR03,      '\0', kMaxEl     * sizeof(float));  
00256         std::memset(elECaloIsoR03,    '\0', kMaxEl     * sizeof(float));  
00257         std::memset(elHCaloIsoR03,    '\0', kMaxEl     * sizeof(float));  
00258         std::memset(elIsEcalDriven,   '\0', kMaxEl     * sizeof(bool));  
00259         std::memset(elFbrem,          '\0', kMaxEl     * sizeof(float));  
00260 
00261         std::memset(photonpt,         '\0', kMaxPhot   * sizeof(float));
00262         std::memset(photonphi,        '\0', kMaxPhot   * sizeof(float));
00263         std::memset(photoneta,        '\0', kMaxPhot   * sizeof(float));
00264         std::memset(photonet,         '\0', kMaxPhot   * sizeof(float));
00265         std::memset(photone,          '\0', kMaxPhot   * sizeof(float));
00266         std::memset(photontrkiso,     '\0', kMaxPhot   * sizeof(float));
00267         std::memset(photonecaliso,    '\0', kMaxPhot   * sizeof(float));
00268         std::memset(photonhcaliso,    '\0', kMaxPhot   * sizeof(float));
00269         std::memset(photonhovere,     '\0', kMaxPhot   * sizeof(float));
00270         std::memset(photonClusShap,   '\0', kMaxPhot   * sizeof(float));
00271         std::memset(photonr9id,       '\0', kMaxPhot   * sizeof(float));
00272 
00273         std::memset(hphotet,          '\0', kMaxhPhot  * sizeof(float));
00274         std::memset(hphoteta,         '\0', kMaxhPhot  * sizeof(float));
00275         std::memset(hphotphi,         '\0', kMaxhPhot  * sizeof(float));
00276         std::memset(helevtxz,         '\0', kMaxhEle   * sizeof(float));
00277         std::memset(hphoteiso,        '\0', kMaxhPhot  * sizeof(float));
00278         std::memset(hphothiso,        '\0', kMaxhPhot  * sizeof(float));
00279         std::memset(hphottiso,        '\0', kMaxhPhot  * sizeof(float));
00280         std::memset(hphotl1iso,       '\0', kMaxhPhot  * sizeof(int));
00281         std::memset(hphotClusShap,    '\0', kMaxhPhot  * sizeof(float));
00282 
00283         std::memset(heleet,           '\0', kMaxhEle   * sizeof(float));
00284         std::memset(heleeta,          '\0', kMaxhEle   * sizeof(float));
00285         std::memset(helephi,          '\0', kMaxhEle   * sizeof(float));
00286         std::memset(heleE,            '\0', kMaxhEle   * sizeof(float));
00287         std::memset(helep,            '\0', kMaxhEle   * sizeof(float));
00288         std::memset(helehiso,         '\0', kMaxhEle   * sizeof(float));
00289         std::memset(heletiso,         '\0', kMaxhEle   * sizeof(float));
00290         std::memset(heleeiso,         '\0', kMaxhEle   * sizeof(float)); 
00291         std::memset(helehovereh,      '\0', kMaxhEle   * sizeof(float));
00292         std::memset(helel1iso,        '\0', kMaxhEle   * sizeof(int));
00293         std::memset(helePixelSeeds,   '\0', kMaxhEle   * sizeof(int));
00294         std::memset(heleNewSC,        '\0', kMaxhEle   * sizeof(int));
00295         std::memset(heleClusShap,     '\0', kMaxhEle  * sizeof(float));
00296         std::memset(heleDeta,         '\0', kMaxhEle  * sizeof(float));
00297         std::memset(heleDphi,         '\0', kMaxhEle  * sizeof(float));
00298 
00299         std::memset(hhfelept,         '\0', kMaxhEle  * sizeof(float));
00300         std::memset(hhfeleeta,        '\0', kMaxhEle  * sizeof(float));
00301         
00302     std::memset(hhfclustere9e25,    '\0', kMaxhEle  * sizeof(float));
00303     std::memset(hhfclustere1e9,     '\0', kMaxhEle  * sizeof(float));
00304     std::memset(hhfclustereCOREe9,  '\0', kMaxhEle  * sizeof(float));
00305     std::memset(hhfclustereSeL,     '\0', kMaxhEle  * sizeof(float));
00306     std::memset(hhfcluster2Dcut,    '\0', kMaxhEle  * sizeof(float));
00307     std::memset(hhfclustereta,      '\0', kMaxhEle  * sizeof(float));
00308     std::memset(hhfclusterphi,      '\0', kMaxhEle  * sizeof(float));
00309         
00310         nele      = 0;
00311         nphoton   = 0;
00312         nhltgam   = 0;
00313         nhltele   = 0;
00314         nhlthfele   = 0; 
00315         nhlthfeclus = 0; 
00316 }
00317 
00318 /* **Analyze the event** */
00319 void HLTEgamma::analyze(const edm::Handle<reco::GsfElectronCollection>         & electrons,
00320                 const edm::Handle<reco::PhotonCollection>              & photons,
00321                 const edm::Handle<reco::ElectronCollection>            & electronIsoHandle,
00322                 const edm::Handle<reco::ElectronCollection>            & electronNonIsoHandle,
00323                 const edm::Handle<reco::ElectronIsolationMap>          & NonIsoTrackEleIsolMap,
00324                 const edm::Handle<reco::ElectronIsolationMap>          & TrackEleIsolMap,
00325                 const edm::Handle<reco::ElectronSeedCollection>        & L1IsoPixelSeedsMap,
00326                 const edm::Handle<reco::ElectronSeedCollection>        & L1NonIsoPixelSeedsMap,
00327                 const edm::Handle<reco::RecoEcalCandidateCollection>   & recoIsolecalcands,
00328                 const edm::Handle<reco::RecoEcalCandidateCollection>   & recoNonIsolecalcands,
00329                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & EcalIsolMap,
00330                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & EcalNonIsolMap,
00331                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalEleIsolMap,
00332                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalEleNonIsolMap,
00333                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalIsolMap,
00334                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalNonIsolMap,
00335                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & TrackIsolMap,
00336                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & TrackNonIsolMap,
00337                 EcalClusterLazyTools& lazyTools,
00338                 const edm::ESHandle<MagneticField>& theMagField,
00339                 reco::BeamSpot::Point & BSPosition, 
00340                 std::vector<edm::Handle<edm::ValueMap<float> > > & eIDValueMap,
00341                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IsoMap,   
00342                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9NonIsoMap,   
00343                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IsoMap,   
00344                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9NonIsoMap,   
00345                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHIsoMap,      
00346                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHNonIsoMap,       
00347                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDIsoMap,
00348                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDNonIsoMap,
00349                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDIsoMap,
00350                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDNonIsoMap,
00351                 const edm::Handle<reco::SuperClusterCollection>        & electronHFECALClusters,  
00352                 const edm::Handle<reco::RecoEcalCandidateCollection>   & electronHFElectrons,   
00353                 const edm::Handle<reco::HFEMClusterShapeAssociationCollection> & electronHFClusterAssociation, 
00354     const edm::Handle<reco::RecoEcalCandidateCollection>   & activityECAL,   
00355     const edm::Handle<reco::RecoEcalCandidateIsolationMap> & activityEcalIsoMap,
00356     const edm::Handle<reco::RecoEcalCandidateIsolationMap> & activityHcalIsoMap,
00357     const edm::Handle<reco::RecoEcalCandidateIsolationMap> & activityTrackIsoMap,
00358     const edm::Handle<reco::RecoEcalCandidateIsolationMap> & activityR9Map,
00359     const edm::Handle<reco::RecoEcalCandidateIsolationMap> & activityR9IDMap,
00360     const edm::Handle<reco::RecoEcalCandidateIsolationMap> & activityHoverEHMap,
00361                 TTree* HltTree)
00362 {
00363         // reset the tree variables
00364         clear();
00365 
00366         if (electrons.isValid()) {  
00367                 reco::GsfElectronCollection myelectrons( electrons->begin(), electrons->end() );  
00368                 nele = myelectrons.size();  
00369                 std::sort(myelectrons.begin(), myelectrons.end(), EtGreater());  
00370                 int iel = 0;  
00371                 for (reco::GsfElectronCollection::const_iterator i = myelectrons.begin(); i != myelectrons.end(); i++) {  
00372                         elpt[iel]  = i->pt();  
00373                         elphi[iel] = i->phi();  
00374                         eleta[iel] = i->eta();  
00375                         elet[iel]  = i->et();  
00376                         ele[iel]   = i->energy();  
00377 
00378                         if(i->gsfTrack().isNonnull()){  
00379                                 elNLostHits[iel]   = i->gsfTrack()->trackerExpectedHitsInner().numberOfLostHits();  
00380                                 elIP[iel]          = i->gsfTrack()->dxy(BSPosition);    
00381                                 elTrkChi2NDF[iel]  = i->gsfTrack()->normalizedChi2();  
00382                         }  
00383                         else {  
00384                                 elNLostHits[iel]  = -99.;  
00385                                 elIP[iel]         = -99.;  
00386                                 elTrkChi2NDF[iel] = -99.;  
00387                         }  
00388 
00389                         elTrkIsoR03[iel]     = i->dr03TkSumPt();  
00390                         elECaloIsoR03[iel]   = i->dr03EcalRecHitSumEt();  
00391                         elHCaloIsoR03[iel]   = i->dr03HcalTowerSumEt();  
00392                         elIsEcalDriven[iel]  = i->ecalDrivenSeed();  
00393                         elFbrem[iel]         = i->fbrem();  
00394                         elscEt[iel] = i->superCluster()->energy()*sin((2*atan(exp(-i->superCluster()->eta())))); 
00395                         elhOverE[iel] = i->hadronicOverEm(); 
00396                         elsigmaietaieta[iel] = i->sigmaIetaIeta(); 
00397                         eldeltaPhiIn[iel] = i->deltaPhiSuperClusterTrackAtVtx(); 
00398                         eldeltaEtaIn[iel] = i->deltaEtaSuperClusterTrackAtVtx(); 
00399                         elmishits[iel] = i->gsfTrack()->trackerExpectedHitsInner().numberOfHits(); 
00400                         eltrkiso[iel] = i->dr03TkSumPt(); 
00401                         elecaliso[iel] = i->dr03EcalRecHitSumEt(); 
00402                         elhcaliso[iel] = i->dr03HcalTowerSumEt(); 
00403                         eld0corr[iel]= - (i->gsfTrack()->dxy(BSPosition)); 
00404                         elqGsfCtfScPixConsistent[iel]=i->isGsfCtfScPixChargeConsistent();; 
00405 
00406                         // conversion info will be available after 3_10_X 
00407                         eldist[iel] = 0;// fabs(i->convDist()); 
00408                         eldcot[iel] = 0; //fabs(i->convDcot()); 
00409 
00410                         iel++;  
00411                 }  
00412         } else {  
00413                 nele = 0;  
00414         }
00415 
00416         if (photons.isValid()) {
00417                 reco::PhotonCollection myphotons(* photons);
00418                 nphoton = myphotons.size();
00419                 std::sort(myphotons.begin(), myphotons.end(), EtGreater());
00420                 int ipho = 0;
00421                 for (reco::PhotonCollection::const_iterator i = myphotons.begin(); i!= myphotons.end(); i++) {
00422                         photonpt[ipho] = i->pt();
00423                         photonphi[ipho] = i->phi();
00424                         photoneta[ipho] = i->eta();
00425                         photonet[ipho] = i->et();
00426                         photone[ipho] = i->energy();
00427                         photontrkiso[ipho] = i->trkSumPtSolidConeDR04(); 
00428                         photonecaliso[ipho] = i->ecalRecHitSumEtConeDR04(); 
00429                         photonhcaliso[ipho] = i->hcalTowerSumEtConeDR04(); 
00430                         photonhovere[ipho] = i->hadronicOverEm(); 
00431                         photonClusShap[ipho] = i->sigmaIetaIeta();
00432                         photonr9id[ipho] = i->r9(); 
00433                         ipho++;
00434                 }
00435         } else {
00436                 nphoton = 0;
00437         }
00438 
00440 
00442         std::vector<OpenHLTPhoton> theHLTPhotons;
00443         MakeL1IsolatedPhotons(
00444                         theHLTPhotons,
00445                         recoIsolecalcands,
00446                         EcalIsolMap,
00447                         HcalIsolMap,
00448                         TrackIsolMap,
00449                         photonR9IsoMap,
00450                         photonHoverEHIsoMap,
00451                         photonR9IDIsoMap,
00452                         lazyTools);
00453         MakeL1NonIsolatedPhotons(
00454                         theHLTPhotons,
00455                         recoNonIsolecalcands,
00456                         EcalNonIsolMap,
00457                         HcalNonIsolMap,
00458                         TrackNonIsolMap,
00459                         photonR9NonIsoMap,
00460                         photonHoverEHNonIsoMap,
00461                         photonR9IDNonIsoMap,
00462                         lazyTools);
00463 
00464         std::sort(theHLTPhotons.begin(), theHLTPhotons.end(), EtGreater());
00465         nhltgam = theHLTPhotons.size();
00466 
00467         for (int u = 0; u < nhltgam; u++) {
00468                 hphotet[u]    = theHLTPhotons[u].Et;
00469                 hphoteta[u]   = theHLTPhotons[u].eta;
00470                 hphotphi[u]   = theHLTPhotons[u].phi;
00471                 hphoteiso[u]  = theHLTPhotons[u].ecalIsol;
00472                 hphothiso[u]  = theHLTPhotons[u].hcalIsol;
00473                 hphottiso[u]  = theHLTPhotons[u].trackIsol;
00474                 hphotl1iso[u] = theHLTPhotons[u].L1Isolated;
00475                 hphotClusShap[u] = theHLTPhotons[u].clusterShape;
00476                 hphothovereh[u] = theHLTPhotons[u].hovereh; 
00477                 hphotR9[u] = theHLTPhotons[u].r9;
00478                 hphotR9ID[u] = theHLTPhotons[u].r9ID;
00479         }
00480   // Activity
00481   std::vector<OpenHLTPhoton> theHLTActivityPhotons;
00482   MakeL1NonIsolatedPhotons(
00483      theHLTActivityPhotons,
00484      activityECAL,
00485      activityEcalIsoMap,
00486      activityHcalIsoMap,
00487      activityTrackIsoMap,
00488      activityR9Map,
00489      activityHoverEHMap,
00490      activityR9IDMap,
00491      lazyTools);
00492 
00493  std::sort(theHLTActivityPhotons.begin(), theHLTActivityPhotons.end(), EtGreater());
00494  nhltecalactiv = theHLTActivityPhotons.size();
00495 
00496  for (int u = 0; u < nhltecalactiv; u++) {
00497     hecalactivet[u]    = theHLTActivityPhotons[u].Et;
00498     hecalactiveta[u]   = theHLTActivityPhotons[u].eta;
00499     hecalactivphi[u]   = theHLTActivityPhotons[u].phi;
00500     hecalactiveiso[u]  = theHLTActivityPhotons[u].ecalIsol;
00501     hecalactivhiso[u]  = theHLTActivityPhotons[u].hcalIsol;
00502     hecalactivtiso[u]  = theHLTActivityPhotons[u].trackIsol;
00503     hecalactivl1iso[u] = theHLTActivityPhotons[u].L1Isolated;
00504     hecalactivClusShap[u] = theHLTActivityPhotons[u].clusterShape;
00505     hecalactivhovereh[u] = theHLTActivityPhotons[u].hovereh; 
00506     hecalactivR9[u] = theHLTActivityPhotons[u].r9;
00507     hecalactivR9ID[u] = theHLTActivityPhotons[u].r9ID;
00508    }
00509    
00511         std::vector<OpenHLTElectron> theHLTElectrons;
00512         MakeL1IsolatedElectrons(
00513                         theHLTElectrons,
00514                         electronIsoHandle,
00515                         recoIsolecalcands,
00516                         HcalEleIsolMap,
00517                         L1IsoPixelSeedsMap,
00518                         TrackEleIsolMap,
00519                         electronR9IsoMap,
00520                         photonHoverEHIsoMap, 
00521                         EcalIsolMap, 
00522                         electronR9IDIsoMap,
00523                         lazyTools,
00524                         theMagField,
00525                         BSPosition);
00526         MakeL1NonIsolatedElectrons(
00527                         theHLTElectrons,
00528                         electronNonIsoHandle,
00529                         recoNonIsolecalcands,
00530                         HcalEleNonIsolMap,
00531                         L1NonIsoPixelSeedsMap,
00532                         NonIsoTrackEleIsolMap,
00533                         electronR9NonIsoMap,  
00534                         photonHoverEHNonIsoMap, 
00535                         EcalNonIsolMap, 
00536                         electronR9IDNonIsoMap,
00537                         lazyTools,
00538                         theMagField,
00539                         BSPosition);
00540 
00541         std::sort(theHLTElectrons.begin(), theHLTElectrons.end(), EtGreater());
00542         nhltele = theHLTElectrons.size();
00543 
00544         for (int u = 0; u < nhltele; u++) {
00545                 heleet[u]         = theHLTElectrons[u].Et;
00546                 heleeta[u]        = theHLTElectrons[u].eta;
00547                 helephi[u]        = theHLTElectrons[u].phi;
00548                 helevtxz[u]       = theHLTElectrons[u].vtxZ;
00549                 heleE[u]          = theHLTElectrons[u].E;
00550                 helep[u]          = theHLTElectrons[u].p;
00551                 helehiso[u]       = theHLTElectrons[u].hcalIsol;
00552                 helePixelSeeds[u] = theHLTElectrons[u].pixelSeeds;
00553                 heletiso[u]       = theHLTElectrons[u].trackIsol;
00554                 heleeiso[u]       = theHLTElectrons[u].ecalIsol; 
00555                 helel1iso[u]      = theHLTElectrons[u].L1Isolated;
00556                 heleNewSC[u]      = theHLTElectrons[u].newSC;
00557                 heleClusShap[u]   = theHLTElectrons[u].clusterShape;
00558                 heleDeta[u]       = theHLTElectrons[u].Deta;
00559                 heleDphi[u]       = theHLTElectrons[u].Dphi;
00560                 heleR9[u]         = theHLTElectrons[u].r9;  
00561                 helehovereh[u]    = theHLTElectrons[u].hovereh;
00562                 heleR9ID[u]       = theHLTElectrons[u].r9ID;
00563         }
00564 
00565     if(electronHFElectrons.isValid()) {
00566         for (reco::RecoEcalCandidateCollection::const_iterator hfelecand = electronHFElectrons->begin(); hfelecand!=electronHFElectrons->end(); hfelecand++) {
00567             hhfelept[nhlthfele] = hfelecand->pt();
00568             hhfeleeta[nhlthfele] = hfelecand->eta();
00569 
00570             nhlthfele++;
00571 
00572             if(electronHFECALClusters.isValid()) {
00573 
00574                 const reco::RecoEcalCandidate& HFcan = (*hfelecand);
00575                 reco::SuperClusterRef theClusRef=HFcan.superCluster();
00576                 const reco::SuperCluster& hfECALSuperCluster=*theClusRef;
00577                 const reco::HFEMClusterShapeRef clusShapeRef=(*electronHFClusterAssociation).find(theClusRef)->val;
00578                 const reco::HFEMClusterShape& clusShape=*clusShapeRef;
00579 
00580 
00581                 float hfCluster2Dcut   =(clusShape.eCOREe9()-(clusShape.eSeL()*1.125));
00582                 float hfClustere9e25   = clusShape.eLong3x3()/clusShape.eLong5x5();
00583                 float hfClustere1e9    = clusShape.eLong1x1()/clusShape.eLong3x3();
00584                 float hfClustereCOREe9 = clusShape.eCOREe9();
00585                 float hfClustereSeL    = clusShape.eSeL();
00586 
00587                 hhfcluster2Dcut[nhlthfeclus]   = hfCluster2Dcut;
00588                 hhfclustere9e25[nhlthfeclus]   = hfClustere9e25;
00589                 hhfclustere1e9[nhlthfeclus]    = hfClustere1e9;
00590                 hhfclustereCOREe9[nhlthfeclus] = hfClustereCOREe9;
00591                 hhfclustereSeL[nhlthfeclus]    = hfClustereSeL;
00592                 hhfclustereta[nhlthfeclus]     = hfECALSuperCluster.eta();
00593                 hhfclusterphi[nhlthfeclus]     = hfECALSuperCluster.phi();
00594 
00595             } else {
00596 
00597                 hhfcluster2Dcut[nhlthfeclus]   = 0.0;
00598                 hhfclustere9e25[nhlthfeclus]   = 0.0;
00599                 hhfclustere1e9[nhlthfeclus]    = 0.0;
00600                 hhfclustereCOREe9[nhlthfeclus] = 0.0;
00601                 hhfclustereSeL[nhlthfeclus]    = 0.0;
00602                 hhfclustereta[nhlthfeclus]     = 0.0;
00603                 hhfclusterphi[nhlthfeclus]     = 0.0;
00604 
00605             }
00606 
00607             nhlthfeclus++;
00608         }
00609     }
00610 }
00611 
00612         void HLTEgamma::MakeL1IsolatedPhotons(
00613                         std::vector<OpenHLTPhoton> & theHLTPhotons,
00614                         const edm::Handle<reco::RecoEcalCandidateCollection>   & recoIsolecalcands,
00615                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & EcalIsolMap,
00616                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalIsolMap,
00617                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & TrackIsolMap,
00618                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IsoMap,    
00619                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHIsoMap,     
00620                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDIsoMap,
00621                         EcalClusterLazyTools& lazyTools )
00622         {
00623                 // Iterator to the isolation-map
00624                 reco::RecoEcalCandidateIsolationMap::const_iterator mapi;
00625 
00626                 if (recoIsolecalcands.isValid()) {
00627                         // loop over SuperCluster and fill the HLTPhotons
00628 
00629 
00630                         for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoIsolecalcands->begin();
00631                                         recoecalcand!= recoIsolecalcands->end(); recoecalcand++) {
00632 
00633                                 OpenHLTPhoton pho;
00634                                 pho.ecalIsol   = -999;
00635                                 pho.hcalIsol   = -999;
00636                                 pho.trackIsol  = -999;
00637                                 pho.clusterShape = -999;
00638                                 pho.L1Isolated = true;
00639                                 pho.Et         = recoecalcand->et();
00640                                 pho.eta        = recoecalcand->eta();
00641                                 pho.phi        = recoecalcand->phi();
00642                                 pho.r9         = -999.;
00643                                 pho.hovereh    = -999.;
00644                                 pho.r9ID       = -999.;
00645 
00646                                 //Get the cluster shape
00647                                 //      std::vector<float> vCov = lazyTools.covariances( *(recoecalcand->superCluster()->seed()) );
00648                                 std::vector<float> vCov = lazyTools.localCovariances( *(recoecalcand->superCluster()->seed()) );
00649                                 double sigmaee = sqrt(vCov[0]);
00650                                 //      float EtaSC = fabs(recoecalcand->eta());
00651                                 //      if(EtaSC > 1.479 ) {//Endcap
00652                                 //        sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
00653                                 //      }
00654                                 pho.clusterShape = sigmaee;
00655 
00656                                 // Method to get the reference to the candidate
00657                                 reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand));
00658 
00659                                 // First/Second member of the Map: Ref-to-Candidate(mapi)/Isolation(->val)
00660                                 // fill the ecal Isolation
00661                                 if (EcalIsolMap.isValid()) {
00662                                         mapi = (*EcalIsolMap).find(ref);
00663                                         if (mapi !=(*EcalIsolMap).end()) { pho.ecalIsol = mapi->val;}
00664                                 }
00665                                 // fill the hcal Isolation
00666                                 if (HcalIsolMap.isValid()) {
00667                                         mapi = (*HcalIsolMap).find(ref);
00668                                         if (mapi !=(*HcalIsolMap).end()) { pho.hcalIsol = mapi->val;}
00669                                 }
00670                                 // fill the track Isolation
00671                                 if (TrackIsolMap.isValid()) {
00672                                         mapi = (*TrackIsolMap).find(ref);
00673                                         if (mapi !=(*TrackIsolMap).end()) { pho.trackIsol = mapi->val;}
00674                                 }
00675                                 // fill the R9
00676                                 if (photonR9IsoMap.isValid()) {
00677                                         mapi = (*photonR9IsoMap).find(ref); 
00678                                         if (mapi !=(*photonR9IsoMap).end()) { pho.r9 = mapi->val;} 
00679                                 }
00680                                 // fill the H for H/E
00681                                 if (photonHoverEHIsoMap.isValid()) {
00682                                         mapi = (*photonHoverEHIsoMap).find(ref);  
00683                                         if (mapi !=(*photonHoverEHIsoMap).end()) { pho.hovereh = mapi->val;}
00684                                 }
00685                                 // fill the R9ID
00686                                 if (photonR9IDIsoMap.isValid()) {
00687                                         mapi = (*photonR9IDIsoMap).find(ref);
00688                                         if (mapi !=(*photonR9IDIsoMap).end()) { pho.r9ID = mapi->val;}
00689                                 }
00690 
00691                                 // store the photon into the vector
00692                                 theHLTPhotons.push_back(pho);
00693                         }
00694                 }
00695         }
00696 
00697         void HLTEgamma::MakeL1NonIsolatedPhotons(
00698                         std::vector<OpenHLTPhoton> & theHLTPhotons,
00699                         const edm::Handle<reco::RecoEcalCandidateCollection>   & recoNonIsolecalcands,
00700                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & EcalNonIsolMap,
00701                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalNonIsolMap,
00702                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & TrackNonIsolMap,
00703                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9NonIsoMap,     
00704                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHNonIsoMap,      
00705                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonR9IDNonIsoMap,
00706                         EcalClusterLazyTools& lazyTools )
00707         {
00708                 reco::RecoEcalCandidateIsolationMap::const_iterator mapi;
00709 
00710                 if (recoNonIsolecalcands.isValid()) {
00711                         for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoNonIsolecalcands->begin();
00712                                         recoecalcand!= recoNonIsolecalcands->end(); recoecalcand++) {
00713                                 // loop over SuperCluster and fill the HLTPhotons
00714                                 OpenHLTPhoton pho;
00715                                 pho.ecalIsol   = -999;
00716                                 pho.hcalIsol   = -999;
00717                                 pho.trackIsol  = -999;
00718                                 pho.clusterShape = -999;
00719                                 pho.L1Isolated = false;
00720                                 pho.Et         = recoecalcand->et();
00721                                 pho.eta        = recoecalcand->eta();
00722                                 pho.phi        = recoecalcand->phi();
00723                                 pho.r9         = -999; 
00724                                 pho.hovereh    = -999.;
00725                                 pho.r9ID       = -999.;
00726 
00727                                 //Get the cluster shape
00728                                 //      std::vector<float> vCov = lazyTools.covariances( *(recoecalcand->superCluster()->seed()) );
00729                                 std::vector<float> vCov = lazyTools.localCovariances( *(recoecalcand->superCluster()->seed()) );
00730                                 double sigmaee = sqrt(vCov[0]);
00731                                 //      float EtaSC = fabs(recoecalcand->eta());
00732                                 //      if(EtaSC > 1.479 ) {//Endcap
00733                                 //        sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
00734                                 //      }
00735                                 pho.clusterShape = sigmaee;
00736 
00737                                 reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand));
00738 
00739                                 // fill the ecal Isolation
00740                                 if (EcalNonIsolMap.isValid()) {
00741                                         mapi = (*EcalNonIsolMap).find(ref);
00742                                         if (mapi !=(*EcalNonIsolMap).end()) { pho.ecalIsol = mapi->val;}
00743                                 }
00744                                 // fill the hcal Isolation
00745                                 if (HcalNonIsolMap.isValid()) {
00746                                         mapi = (*HcalNonIsolMap).find(ref);
00747                                         if (mapi !=(*HcalNonIsolMap).end()) { pho.hcalIsol = mapi->val;}
00748                                 }
00749                                 // fill the track Isolation
00750                                 if (TrackNonIsolMap.isValid()) {
00751                                         mapi = (*TrackNonIsolMap).find(ref);
00752                                         if (mapi !=(*TrackNonIsolMap).end()) { pho.trackIsol = mapi->val;}
00753                                 }
00754                                 // fill the R9 
00755                                 if (photonR9NonIsoMap.isValid()) { 
00756                                         mapi = (*photonR9NonIsoMap).find(ref);  
00757                                         if (mapi !=(*photonR9NonIsoMap).end()) { pho.r9 = mapi->val;}  
00758                                 } 
00759                                 // fill the H for H/E 
00760                                 if (photonHoverEHNonIsoMap.isValid()) { 
00761                                         mapi = (*photonHoverEHNonIsoMap).find(ref);   
00762                                         if (mapi !=(*photonHoverEHNonIsoMap).end()) { pho.hovereh = mapi->val;} 
00763                                 } 
00764                                 // fill the R9ID
00765                                 if (photonR9IDNonIsoMap.isValid()) {
00766                                         mapi = (*photonR9IDNonIsoMap).find(ref);
00767                                         if (mapi !=(*photonR9IDNonIsoMap).end()) { pho.r9ID = mapi->val;}
00768                                 }
00769 
00770                                 // store the photon into the vector
00771                                 theHLTPhotons.push_back(pho);
00772                         }
00773                 }
00774         }
00775 
00776         void HLTEgamma::MakeL1IsolatedElectrons(
00777                         std::vector<OpenHLTElectron> & theHLTElectrons,
00778                         const edm::Handle<reco::ElectronCollection>            & electronIsoHandle,
00779                         const edm::Handle<reco::RecoEcalCandidateCollection>   & recoIsolecalcands,
00780                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalEleIsolMap,
00781                         const edm::Handle<reco::ElectronSeedCollection>        & L1IsoPixelSeedsMap,
00782                         const edm::Handle<reco::ElectronIsolationMap>          & TrackEleIsolMap,
00783                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IsoMap,     
00784                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHIsoMap,      
00785                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & EcalIsolMap, 
00786                         const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDIsoMap,
00787                         EcalClusterLazyTools& lazyTools,
00788                         const edm::ESHandle<MagneticField>& theMagField,
00789                         reco::BeamSpot::Point & BSPosition )
00790         {
00791                 // if there are electrons, then the isolation maps and the SC should be in the event; if not it is an error
00792                 if (recoIsolecalcands.isValid()) {
00793                         for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoIsolecalcands->begin();
00794                                         recoecalcand!= recoIsolecalcands->end(); recoecalcand++) {
00795                                 // get the ref to the SC:
00796                                 reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand));
00797                                 reco::SuperClusterRef recrSC = ref->superCluster();
00798                                 //reco::SuperClusterRef recrSC = recoecalcand->superCluster();
00799 
00800                                 OpenHLTElectron ele;
00801                                 ele.hcalIsol   = -999;
00802                                 ele.trackIsol  = -999;
00803                                 ele.ecalIsol   = -999;
00804                                 ele.L1Isolated = true;
00805                                 ele.p          = -999;
00806                                 ele.pixelSeeds = -999;
00807                                 ele.newSC      = true;
00808                                 ele.clusterShape = -999;
00809                                 ele.Dphi = 700; 
00810                                 ele.Deta = 700;
00811                                 ele.hovereh = -999;
00812                                 ele.Et         = recoecalcand->et();
00813                                 ele.eta        = recoecalcand->eta();
00814                                 ele.phi        = recoecalcand->phi();
00815                                 ele.E          = recrSC->energy();
00816                                 //Get the cluster shape
00817                                 //      std::vector<float> vCov = lazyTools.covariances( *(recrSC->seed()) );
00818                                 std::vector<float> vCov = lazyTools.localCovariances( *(recrSC->seed()) );
00819                                 double sigmaee = sqrt(vCov[0]);
00820                                 //      float EtaSC = fabs(recoecalcand->eta());
00821                                 //      if(EtaSC > 1.479 ) {//Endcap
00822                                 //      sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
00823                                 //      }
00824                                 ele.clusterShape = sigmaee;
00825                                 ele.r9 = -999.;
00826                                 ele.r9ID = -999.;
00827 
00828                                 // fill the ecal Isolation 
00829                                 if (EcalIsolMap.isValid()) { 
00830                                         reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*EcalIsolMap).find(ref); 
00831                                         if (mapi !=(*EcalIsolMap).end()) { ele.ecalIsol = mapi->val;} 
00832                                 } 
00833                                 // fill the hcal Isolation
00834                                 if (HcalEleIsolMap.isValid()) {
00835                                         //reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( reco::RecoEcalCandidateRef(recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand)) );
00836                                         reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( ref );
00837                                         if (mapi !=(*HcalEleIsolMap).end()) { ele.hcalIsol = mapi->val; }
00838                                 }
00839                                 // fill the R9   
00840                                 if (electronR9IsoMap.isValid()) {   
00841                                         reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9IsoMap).find( ref );   
00842                                         if (mapi !=(*electronR9IsoMap).end()) { ele.r9 = mapi->val; }   
00843                                 }   
00844                                 // fill the H for H/E 
00845                                 if (photonHoverEHIsoMap.isValid()) { 
00846                                         reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*photonHoverEHIsoMap).find(ref);   
00847                                         if (mapi !=(*photonHoverEHIsoMap).end()) { ele.hovereh = mapi->val;} 
00848                                 } 
00849                                 // fill the R9ID
00850                                 if (electronR9IDIsoMap.isValid()) {
00851                                         reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9IDIsoMap).find( ref );
00852                                         if (mapi !=(*electronR9IDIsoMap).end()) { ele.r9ID = mapi->val; }
00853                                 }
00854 
00855                                 // look if the SC has associated pixelSeeds
00856                                 int nmatch = 0;
00857 
00858                                 if (L1IsoPixelSeedsMap.isValid()) {
00859                                         for (reco::ElectronSeedCollection::const_iterator it = L1IsoPixelSeedsMap->begin();
00860                                                         it != L1IsoPixelSeedsMap->end(); it++) {
00861                                                 edm::RefToBase<reco::CaloCluster> caloCluster = it->caloCluster() ;
00862                                                 reco::SuperClusterRef scRef = caloCluster.castTo<reco::SuperClusterRef>() ;
00863                                                 if (&(*recrSC) ==  &(*scRef)) { nmatch++; }
00864                                         }
00865                                 }
00866 
00867                                 ele.pixelSeeds = nmatch;
00868 
00869                                 // look if the SC was promoted to an electron:
00870                                 if (electronIsoHandle.isValid()) {
00871                                         bool FirstElectron = true;
00872                                         reco::ElectronRef electronref;
00873                                         for (reco::ElectronCollection::const_iterator iElectron = electronIsoHandle->begin();
00874                                                         iElectron != electronIsoHandle->end(); iElectron++) {
00875                                                 // 1) find the SC from the electron
00876                                                 electronref = reco::ElectronRef(electronIsoHandle, iElectron - electronIsoHandle->begin());
00877                                                 const reco::SuperClusterRef theClus = electronref->superCluster(); // SC from the electron;
00878                                                 if (&(*recrSC) ==  &(*theClus)) {     // ref is the RecoEcalCandidateRef corresponding to the electron
00879                                                         if (FirstElectron) {                // the first electron is stored in ele, keeping the ele.newSC = true
00880                                                                 FirstElectron = false;
00881                                                                 ele.p = electronref->track()->momentum().R();
00882                                                                 ele.vtxZ = electronref->track()->vertex().z();
00883                                                                 float deta=-100, dphi=-100;
00884                                                                 CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
00885                                                                 ele.Dphi=dphi; ele.Deta=deta;
00886                                                                 // fill the track Isolation
00887                                                                 if (TrackEleIsolMap.isValid()) {
00888                                                                         reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find(electronref);
00889                                                                         if (mapTr != (*TrackEleIsolMap).end()) { ele.trackIsol = mapTr->val; }
00890                                                                 }
00891                                                         }
00892                                                         else {
00893                                                                 // FirstElectron is false, i.e. the SC of this electron is common to another electron.
00894                                                                 // A new  OpenHLTElectron is inserted in the theHLTElectrons vector setting newSC = false
00895                                                                 OpenHLTElectron ele2;
00896                                                                 ele2.hcalIsol  = ele.hcalIsol;
00897                                                                 ele2.trackIsol = -999;
00898                                                                 ele2.Dphi = 700; 
00899                                                                 ele2.Deta = 700;
00900                                                                 ele2.Et  = ele.Et;
00901                                                                 ele2.eta = ele.eta;
00902                                                                 ele2.phi = ele.phi;
00903                                                                 ele2.vtxZ = electronref->track()->vertex().z();
00904                                                                 ele2.E   = ele.E;
00905                                                                 ele2.L1Isolated = ele.L1Isolated;
00906                                                                 ele2.pixelSeeds = ele.pixelSeeds;
00907                                                                 ele2.clusterShape = ele.clusterShape;
00908                                                                 ele2.newSC = false;
00909                                                                 ele2.p = electronref->track()->momentum().R();
00910                                                                 ele2.r9 = ele.r9;
00911                                                                 ele2.hovereh = ele.hovereh;
00912                                                                 ele2.ecalIsol = ele.ecalIsol;
00913                                                                 ele2.r9ID = ele.r9ID;
00914                                                                 float deta=-100, dphi=-100;
00915                                                                 CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
00916                                                                 ele2.Dphi=dphi; ele2.Deta=deta;
00917                                                                 // fill the track Isolation
00918                                                                 if (TrackEleIsolMap.isValid()) {
00919                                                                         reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find( electronref);
00920                                                                         if (mapTr !=(*TrackEleIsolMap).end()) { ele2.trackIsol = mapTr->val;}
00921                                                                 }
00922                                                                 theHLTElectrons.push_back(ele2);
00923                                                         }
00924                                                 }
00925                                         } // end of loop over electrons
00926                                 } // end of if (electronIsoHandle) {
00927 
00928                                 //store the electron into the vector
00929                                 theHLTElectrons.push_back(ele);
00930                         } // end of loop over ecalCandidates
00931                         } // end of if (recoIsolecalcands) {
00932                 }
00933 
00934 
00935                 void HLTEgamma::MakeL1NonIsolatedElectrons(
00936                                 std::vector<OpenHLTElectron> & theHLTElectrons,
00937                                 const edm::Handle<reco::ElectronCollection>            & electronNonIsoHandle,
00938                                 const edm::Handle<reco::RecoEcalCandidateCollection>   & recoNonIsolecalcands,
00939                                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & HcalEleIsolMap,
00940                                 const edm::Handle<reco::ElectronSeedCollection>   & L1NonIsoPixelSeedsMap,
00941                                 const edm::Handle<reco::ElectronIsolationMap>          & TrackEleIsolMap,
00942                                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9NonIsoMap,     
00943                                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & photonHoverEHNonIsoMap,      
00944                                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & EcalNonIsolMap, 
00945                                 const edm::Handle<reco::RecoEcalCandidateIsolationMap> & electronR9IDNonIsoMap,
00946                                 EcalClusterLazyTools& lazyTools,
00947                                 const edm::ESHandle<MagneticField>& theMagField,
00948                                 reco::BeamSpot::Point & BSPosition  )
00949                 {
00950                         // if there are electrons, then the isolation maps and the SC should be in the event; if not it is an error
00951                         if (recoNonIsolecalcands.isValid()) {
00952                                 for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand = recoNonIsolecalcands->begin();
00953                                                 recoecalcand!= recoNonIsolecalcands->end(); recoecalcand++) {
00954                                         //get the ref to the SC:
00955                                         reco::RecoEcalCandidateRef ref = reco::RecoEcalCandidateRef(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand));
00956                                         reco::SuperClusterRef recrSC = ref->superCluster();
00957                                         //reco::SuperClusterRef recrSC = recoecalcand->superCluster();
00958 
00959                                         OpenHLTElectron ele;
00960                                         ele.hcalIsol   = -999;
00961                                         ele.trackIsol  = -999;
00962                                         ele.ecalIsol   = -999; 
00963                                         ele.L1Isolated = false;
00964                                         ele.p          = -999;
00965                                         ele.pixelSeeds = -999;
00966                                         ele.newSC      = true;
00967                                         ele.clusterShape = -999;
00968                                         ele.Dphi = 700; 
00969                                         ele.Deta = 700;
00970                                         ele.r9 = -999.;
00971                                         ele.r9ID = -999.;
00972                                         ele.hovereh = -999; 
00973                                         ele.Et         = recoecalcand->et();
00974                                         ele.eta        = recoecalcand->eta();
00975                                         ele.phi        = recoecalcand->phi();
00976                                         ele.E          = recrSC->energy();
00977                                         //Get the cluster shape
00978                                         //      std::vector<float> vCov = lazyTools.covariances( *(recrSC->seed()) );
00979                                         std::vector<float> vCov = lazyTools.localCovariances( *(recrSC->seed()) );
00980                                         double sigmaee = sqrt(vCov[0]);
00981                                         //      float EtaSC = fabs(recoecalcand->eta());
00982                                         //      if(EtaSC > 1.479 ) {//Endcap
00983                                         //      sigmaee = sigmaee - 0.02*(EtaSC - 2.3);
00984                                         //      }
00985                                         ele.clusterShape = sigmaee;
00986 
00987                                         // fill the ecal Isolation 
00988                                         if (EcalNonIsolMap.isValid()) { 
00989                                                 reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*EcalNonIsolMap).find(ref); 
00990                                                 if (mapi !=(*EcalNonIsolMap).end()) { ele.ecalIsol = mapi->val;} 
00991                                         } 
00992                                         // fill the hcal Isolation
00993                                         if (HcalEleIsolMap.isValid()) {
00994                                                 // reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( reco::RecoEcalCandidateRef(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand)) );
00995                                                 reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*HcalEleIsolMap).find( ref );
00996                                                 if (mapi !=(*HcalEleIsolMap).end()) {ele.hcalIsol = mapi->val;}
00997                                         }
00998                                         // fill the R9    
00999                                         if (electronR9NonIsoMap.isValid()) {    
01000                                                 reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9NonIsoMap).find( ref );    
01001                                                 if (mapi !=(*electronR9NonIsoMap).end()) { ele.r9 = mapi->val; }    
01002                                         }    
01003                                         // fill the H for H/E 
01004                                         if (photonHoverEHNonIsoMap.isValid()) { 
01005                                                 reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*photonHoverEHNonIsoMap).find(ref);   
01006                                                 if (mapi !=(*photonHoverEHNonIsoMap).end()) { ele.hovereh = mapi->val;} 
01007                                         } 
01008                                         // fill the R9ID
01009                                         if (electronR9IDNonIsoMap.isValid()) {
01010                                                 reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*electronR9IDNonIsoMap).find( ref );
01011                                                 if (mapi !=(*electronR9IDNonIsoMap).end()) { ele.r9ID = mapi->val; }
01012                                         }
01013 
01014                                         // look if the SC has associated pixelSeeds
01015                                         int nmatch = 0;
01016 
01017                                         if (L1NonIsoPixelSeedsMap.isValid()) {
01018                                                 for (reco::ElectronSeedCollection::const_iterator it = L1NonIsoPixelSeedsMap->begin();
01019                                                                 it != L1NonIsoPixelSeedsMap->end(); it++) {
01020                                                         edm::RefToBase<reco::CaloCluster> caloCluster = it->caloCluster() ;
01021                                                         reco::SuperClusterRef scRef = caloCluster.castTo<reco::SuperClusterRef>() ;
01022                                                         if (&(*recrSC) == &(*scRef)) { nmatch++;}
01023                                                 }
01024                                         }
01025 
01026                                         ele.pixelSeeds = nmatch;
01027 
01028                                         // look if the SC was promoted to an electron:
01029                                         if (electronNonIsoHandle.isValid()) {
01030                                                 bool FirstElectron = true;
01031                                                 reco::ElectronRef electronref;
01032                                                 for (reco::ElectronCollection::const_iterator iElectron = electronNonIsoHandle->begin(); 
01033                                                                 iElectron != electronNonIsoHandle->end();iElectron++) {
01034                                                         // 1) find the SC from the electron
01035                                                         electronref = reco::ElectronRef(electronNonIsoHandle, iElectron - electronNonIsoHandle->begin());
01036                                                         const reco::SuperClusterRef theClus = electronref->superCluster(); //SC from the electron;
01037                                                         if (&(*recrSC) ==  &(*theClus)) { // ref is the RecoEcalCandidateRef corresponding to the electron
01038                                                                 if (FirstElectron) { //the first electron is stored in ele, keeping the ele.newSC = true
01039                                                                         FirstElectron = false;
01040                                                                         ele.p = electronref->track()->momentum().R();
01041                                                                         ele.vtxZ = electronref->track()->dz();
01042                                                                         float deta=-100, dphi=-100;
01043                                                                         CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
01044                                                                         ele.Dphi=dphi; ele.Deta=deta;
01045 
01046                                                                         // fill the track Isolation
01047                                                                         if (TrackEleIsolMap.isValid()) {
01048                                                                                 reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find( electronref);
01049                                                                                 if (mapTr !=(*TrackEleIsolMap).end()) { ele.trackIsol = mapTr->val;}
01050                                                                         }
01051                                                                 } else {
01052                                                                         // FirstElectron is false, i.e. the SC of this electron is common to another electron.
01053                                                                         // A new OpenHLTElectron is inserted in the theHLTElectrons vector setting newSC = false
01054                                                                         OpenHLTElectron ele2;
01055                                                                         ele2.hcalIsol   = ele.hcalIsol;
01056                                                                         ele2.trackIsol  =-999;
01057                                                                         ele2.ecalIsol = ele.ecalIsol;
01058                                                                         ele2.Dphi = 700; 
01059                                                                         ele2.Deta = 700;
01060                                                                         ele2.Et         = ele.Et;
01061                                                                         ele2.eta        = ele.eta;
01062                                                                         ele2.phi        = ele.phi;
01063                                                                         ele2.vtxZ       = electronref->track()->dz();
01064                                                                         ele2.E          = ele.E;
01065                                                                         ele2.L1Isolated = ele.L1Isolated;
01066                                                                         ele2.pixelSeeds = ele.pixelSeeds;
01067                                                                         ele2.clusterShape = ele.clusterShape;
01068                                                                         ele2.newSC      = false;
01069                                                                         ele2.p          = electronref->track()->momentum().R();
01070                                                                         ele2.r9         = ele.r9;
01071                                                                         ele2.hovereh = ele.hovereh; 
01072                                                                         ele2.r9ID       = ele.r9ID;
01073                                                                         float deta=-100, dphi=-100;
01074                                                                         CalculateDetaDphi(theMagField,BSPosition , electronref , deta, dphi, false);
01075                                                                         ele2.Dphi=dphi; ele2.Deta=deta;
01076 
01077                                                                         // fill the track Isolation
01078                                                                         if (TrackEleIsolMap.isValid()) {
01079                                                                                 reco::ElectronIsolationMap::const_iterator mapTr = (*TrackEleIsolMap).find( electronref);
01080                                                                                 if (mapTr !=(*TrackEleIsolMap).end()) { ele2.trackIsol = mapTr->val;}
01081                                                                         }
01082                                                                         theHLTElectrons.push_back(ele2);
01083                                                                 }
01084                                                         }
01085                                                 } // end of loop over electrons
01086                                         } // end of if (electronNonIsoHandle) {
01087 
01088                                         // store the electron into the vector
01089                                         theHLTElectrons.push_back(ele);
01090                                 } // end of loop over ecalCandidates
01091                                 } // end of if (recoNonIsolecalcands) {
01092                         }
01093 
01094                         void HLTEgamma::CalculateDetaDphi(const edm::ESHandle<MagneticField>& theMagField, 
01095                                         reco::BeamSpot::Point & BSPosition, 
01096                                         const reco::ElectronRef eleref, 
01097                                         float& deltaeta, 
01098                                         float& deltaphi, bool useTrackProjectionToEcal )
01099                         {
01100 
01101                                 const reco::SuperClusterRef theClus = eleref->superCluster();
01102                                 math::XYZVector scv(theClus->x(), theClus->y(), theClus->z());
01103 
01104                                 const math::XYZVector trackMom =  eleref->track()->momentum();
01105 
01106                                 math::XYZPoint SCcorrPosition(theClus->x()-BSPosition.x(), theClus->y()-BSPosition.y() , theClus->z()-eleref->track()->vz() );
01107                                 deltaeta = SCcorrPosition.eta()-eleref->track()->eta();
01108 
01109                                 if(useTrackProjectionToEcal){
01110                                         ECALPositionCalculator posCalc;
01111                                         const math::XYZPoint vertex(BSPosition.x(),BSPosition.y(),eleref->track()->vz());
01112 
01113                                         float phi1= posCalc.ecalPhi(theMagField.product(),trackMom,vertex,1);
01114                                         float phi2= posCalc.ecalPhi(theMagField.product(),trackMom,vertex,-1);
01115 
01116                                         float deltaphi1=fabs( phi1 - theClus->position().phi() );
01117                                         if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308;
01118                                         if(deltaphi1>3.141592654) deltaphi1 = 6.283185308-deltaphi1;
01119 
01120                                         float deltaphi2=fabs( phi2 - theClus->position().phi() );
01121                                         if(deltaphi2>6.283185308) deltaphi2 -= 6.283185308;
01122                                         if(deltaphi2>3.141592654) deltaphi2 = 6.283185308-deltaphi2;
01123 
01124                                         deltaphi = deltaphi1;
01125                                         if(deltaphi2<deltaphi1){ deltaphi = deltaphi2;}
01126                                 }
01127                                 else {
01128                                         deltaphi=fabs(eleref->track()->outerPosition().phi()-theClus->phi());
01129                                         if(deltaphi>6.283185308) deltaphi -= 6.283185308;
01130                                         if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
01131                                 }
01132 
01133                         }