CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoEgamma/Examples/plugins/DQMAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    RecoEgamma/Examples
00004 // Class:      GsfElectronDataAnalyzer
00005 //
00013 //
00014 // Original Author:  Ursula Berthon
00015 //         Created:  Mon Mar 27 13:22:06 CEST 2006
00016 // $Id: DQMAnalyzer.cc,v 1.5 2010/10/19 17:34:56 wmtan Exp $
00017 //
00018 //
00019 
00020 // user include files
00021 #include "RecoEgamma/Examples/plugins/DQMAnalyzer.h"
00022 
00023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00024 #include "FWCore/Framework/interface/EDAnalyzer.h"
00025 #include "FWCore/Framework/interface/Event.h"
00026 #include "FWCore/Framework/interface/MakerMacros.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028 #include "FWCore/Common/interface/TriggerNames.h"
00029 
00030 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00031 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00032 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00033 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00034 #include "DataFormats/EgammaReco/interface/ElectronSeed.h"
00035 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
00036 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00037 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00038 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00039 #include "DataFormats/Common/interface/TriggerResults.h"
00040 
00041 #include "HLTrigger/HLTfilters/interface/HLTHighLevel.h"
00042 
00043 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00044 #include <iostream>
00045 #include "TMath.h"
00046 #include "TFile.h"
00047 #include "TH1F.h"
00048 #include "TH1I.h"
00049 #include "TH2F.h"
00050 #include "TProfile.h"
00051 #include "TTree.h"
00052 #include <iostream>
00053 #include <cassert>
00054 
00055 using namespace reco;
00056 
00057 
00058 DQMAnalyzer::DQMAnalyzer(const edm::ParameterSet& conf)
00059 {
00060 
00061   outputFile_ = conf.getParameter<std::string>("outputFile");
00062   electronCollection_=conf.getParameter<edm::InputTag>("electronCollection");
00063   matchingObjectCollection_ = conf.getParameter<edm::InputTag>("matchingObjectCollection");
00064   matchingCondition_ = conf.getParameter<std::string>("matchingCondition");
00065   readAOD_ = conf.getParameter<bool>("readAOD");
00066 
00067   histfile_ = new TFile(outputFile_.c_str(),"RECREATE");
00068 
00069   // currently only one possible matching conditions
00070   assert(matchingCondition_=="Cone") ;
00071   maxPtMatchingObject_ = conf.getParameter<double>("MaxPtMatchingObject");
00072   maxAbsEtaMatchingObject_ = conf.getParameter<double>("MaxAbsEtaMatchingObject");
00073   deltaR_ = conf.getParameter<double>("DeltaR");
00074 
00075   Selection_ = conf.getParameter<int>("Selection");
00076   massLow_        = conf.getParameter< double >("MassLow");
00077   massHigh_       = conf.getParameter< double >("MassHigh");
00078   TPchecksign_ = conf.getParameter<bool>("TPchecksign");
00079   TAGcheckclass_ = conf.getParameter<bool>("TAGcheckclass");
00080   PROBEetcut_ = conf.getParameter<bool>("PROBEetcut");
00081   PROBEcheckclass_ = conf.getParameter<bool>("PROBEcheckclass");
00082 
00083   minEt_ = conf.getParameter<double>("MinEt");
00084   minPt_ = conf.getParameter<double>("MinPt");
00085   maxAbsEta_ = conf.getParameter<double>("MaxAbsEta");
00086   isEB_ = conf.getParameter<bool>("SelectEB");
00087   isEE_ = conf.getParameter<bool>("SelectEE");
00088   isNotEBEEGap_ = conf.getParameter<bool>("SelectNotEBEEGap");
00089   isEcalDriven_ = conf.getParameter<bool>("SelectEcalDriven");
00090   isTrackerDriven_ = conf.getParameter<bool>("SelectTrackerDriven");
00091   eOverPMinBarrel_ = conf.getParameter<double>("MinEOverPBarrel");
00092   eOverPMaxBarrel_ = conf.getParameter<double>("MaxEOverPBarrel");
00093   eOverPMinEndcaps_ = conf.getParameter<double>("MinEOverPEndcaps");
00094   eOverPMaxEndcaps_ = conf.getParameter<double>("MaxEOverPEndcaps");
00095   dEtaMinBarrel_ = conf.getParameter<double>("MinDetaBarrel");
00096   dEtaMaxBarrel_ = conf.getParameter<double>("MaxDetaBarrel");
00097   dEtaMinEndcaps_ = conf.getParameter<double>("MinDetaEndcaps");
00098   dEtaMaxEndcaps_ = conf.getParameter<double>("MaxDetaEndcaps");
00099   dPhiMinBarrel_ = conf.getParameter<double>("MinDphiBarrel");
00100   dPhiMaxBarrel_ = conf.getParameter<double>("MaxDphiBarrel");
00101   dPhiMinEndcaps_ = conf.getParameter<double>("MinDphiEndcaps");
00102   dPhiMaxEndcaps_ = conf.getParameter<double>("MaxDphiEndcaps");
00103   sigIetaIetaMinBarrel_ = conf.getParameter<double>("MinSigIetaIetaBarrel");
00104   sigIetaIetaMaxBarrel_ = conf.getParameter<double>("MaxSigIetaIetaBarrel");
00105   sigIetaIetaMinEndcaps_ = conf.getParameter<double>("MinSigIetaIetaEndcaps");
00106   sigIetaIetaMaxEndcaps_ = conf.getParameter<double>("MaxSigIetaIetaEndcaps");
00107   hadronicOverEmMaxBarrel_ = conf.getParameter<double>("MaxHoEBarrel");
00108   hadronicOverEmMaxEndcaps_ = conf.getParameter<double>("MaxHoEEndcaps");
00109   mvaMin_ = conf.getParameter<double>("MinMVA");
00110   tipMaxBarrel_ = conf.getParameter<double>("MaxTipBarrel");
00111   tipMaxEndcaps_ = conf.getParameter<double>("MaxTipEndcaps");
00112   tkIso03Max_ = conf.getParameter<double>("MaxTkIso03");
00113   hcalIso03Depth1MaxBarrel_ = conf.getParameter<double>("MaxHcalIso03Depth1Barrel");
00114   hcalIso03Depth1MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth1Endcaps");
00115   hcalIso03Depth2MaxEndcaps_ = conf.getParameter<double>("MaxHcalIso03Depth2Endcaps");
00116   ecalIso03MaxBarrel_ = conf.getParameter<double>("MaxEcalIso03Barrel");
00117   ecalIso03MaxEndcaps_ = conf.getParameter<double>("MaxEcalIso03Endcaps");
00118 
00119   triggerResults_ = conf.getParameter<edm::InputTag>("triggerResults");
00120   HLTPathsByName_= conf.getParameter<std::vector<std::string > >("hltPaths");
00121   HLTPathsByIndex_.resize(HLTPathsByName_.size());
00122 
00123   edm::ParameterSet pset =
00124    conf.getParameter<edm::ParameterSet>("HistosConfigurationData") ;
00125 
00126   etamin=pset.getParameter<double>("Etamin");
00127   etamax=pset.getParameter<double>("Etamax");
00128   phimin=pset.getParameter<double>("Phimin");
00129   phimax=pset.getParameter<double>("Phimax");
00130   ptmax=pset.getParameter<double>("Ptmax");
00131   pmax=pset.getParameter<double>("Pmax");
00132   eopmax=pset.getParameter<double>("Eopmax");
00133   eopmaxsht=pset.getParameter<double>("Eopmaxsht");
00134   detamin=pset.getParameter<double>("Detamin");
00135   detamax=pset.getParameter<double>("Detamax");
00136   dphimin=pset.getParameter<double>("Dphimin");
00137   dphimax=pset.getParameter<double>("Dphimax");
00138   detamatchmin=pset.getParameter<double>("Detamatchmin");
00139   detamatchmax=pset.getParameter<double>("Detamatchmax");
00140   dphimatchmin=pset.getParameter<double>("Dphimatchmin");
00141   dphimatchmax=pset.getParameter<double>("Dphimatchmax");
00142   fhitsmax=pset.getParameter<double>("Fhitsmax");
00143   lhitsmax=pset.getParameter<double>("Lhitsmax");
00144   nbineta=pset.getParameter<int>("Nbineta");
00145   nbineta2D=pset.getParameter<int>("Nbineta2D");
00146   nbinp=pset.getParameter<int>("Nbinp");
00147   nbinpt=pset.getParameter<int>("Nbinpt");
00148   nbinp2D=pset.getParameter<int>("Nbinp2D");
00149   nbinpt2D=pset.getParameter<int>("Nbinpt2D");
00150   nbinpteff=pset.getParameter<int>("Nbinpteff");
00151   nbinphi=pset.getParameter<int>("Nbinphi");
00152   nbinphi2D=pset.getParameter<int>("Nbinphi2D");
00153   nbineop=pset.getParameter<int>("Nbineop");
00154   nbineop2D=pset.getParameter<int>("Nbineop2D");
00155   nbinfhits=pset.getParameter<int>("Nbinfhits");
00156   nbinlhits=pset.getParameter<int>("Nbinlhits");
00157   nbinxyz=pset.getParameter<int>("Nbinxyz");
00158   nbindeta=pset.getParameter<int>("Nbindeta");
00159   nbindphi=pset.getParameter<int>("Nbindphi");
00160   nbindetamatch=pset.getParameter<int>("Nbindetamatch");
00161   nbindphimatch=pset.getParameter<int>("Nbindphimatch");
00162   nbindetamatch2D=pset.getParameter<int>("Nbindetamatch2D");
00163   nbindphimatch2D=pset.getParameter<int>("Nbindphimatch2D");
00164   nbinpoptrue= pset.getParameter<int>("Nbinpoptrue");
00165   poptruemin=pset.getParameter<double>("Poptruemin");
00166   poptruemax=pset.getParameter<double>("Poptruemax");
00167   nbinmee= pset.getParameter<int>("Nbinmee");
00168   meemin=pset.getParameter<double>("Meemin");
00169   meemax=pset.getParameter<double>("Meemax");
00170   nbinhoe= pset.getParameter<int>("Nbinhoe");
00171   hoemin=pset.getParameter<double>("Hoemin");
00172   hoemax=pset.getParameter<double>("Hoemax");
00173 
00174 }
00175 
00176 
00177 DQMAnalyzer::~DQMAnalyzer()
00178 {
00179 
00180   // do anything here that needs to be done at desctruction time
00181   // (e.g. close files, deallocate resources etc.)
00182   histfile_->Write();
00183   histfile_->Close();
00184 }
00185 
00186 void
00187 DQMAnalyzer::beginJob(){
00188 
00189   histfile_->cd();
00190 
00191   nEvents_ = 0;
00192   nAfterTrigger_ = 0;
00193 
00194   // matching object
00195   std::string::size_type locSC = matchingObjectCollection_.label().find( "SuperCluster", 0 );
00196   std::string type ;
00197   if ( locSC != std::string::npos ) {
00198     std::cout << "Matching objects are SuperClusters "<< std::endl;
00199     type = "SC";
00200   } else {
00201     std::cout << "Didn't recognize input matching objects!! " << std::endl;
00202   }
00203 
00204   //==================================================
00205   // matching object distributions
00206   //==================================================
00207 
00208   std::string htitle, hlabel;
00209   hlabel="h_"+type+"Num"; htitle="# "+type+"s";
00210   h_matchingObjectNum              = new TH1F( hlabel.c_str(), htitle.c_str(),    nbinfhits,0.,fhitsmax );
00211   hlabel="h_"+type+"_eta"; htitle=type+" #eta";
00212   h_matchingObjectEta             = new TH1F( hlabel.c_str(), htitle.c_str(), nbineta,etamin,etamax);
00213   hlabel="h_"+type+"_abseta"; htitle=type+" |#eta|";
00214   h_matchingObjectAbsEta             = new TH1F( hlabel.c_str(), htitle.c_str(), nbineta/2,0.,etamax);
00215   hlabel="h_"+type+"_P"; htitle=type+" p";
00216   h_matchingObjectP               = new TH1F( hlabel.c_str(), htitle.c_str(),              nbinp,0.,pmax);
00217   hlabel="h_"+type+"_Pt"; htitle=type+" pt";
00218   h_matchingObjectPt               = new TH1F( hlabel.c_str(),htitle.c_str(),            nbinpteff,5.,ptmax);
00219   hlabel="h_"+type+"_phi"; htitle=type+" phi";
00220   h_matchingObjectPhi               = new TH1F( hlabel.c_str(), htitle.c_str(),        nbinphi,phimin,phimax);
00221   hlabel="h_"+type+"_z"; htitle=type+" z";
00222   h_matchingObjectZ      = new TH1F( hlabel.c_str(), htitle.c_str(),   nbinxyz , -25, 25 );
00223 
00224   h_matchingObjectNum->GetXaxis()-> SetTitle("N_{SC}");
00225   h_matchingObjectNum->GetYaxis()-> SetTitle("Events");
00226   h_matchingObjectEta->GetXaxis()-> SetTitle("#eta_{SC}");
00227   h_matchingObjectEta->GetYaxis()-> SetTitle("Events");
00228   h_matchingObjectP->GetXaxis()-> SetTitle("E_{SC} (GeV)");
00229   h_matchingObjectP->GetYaxis()-> SetTitle("Events");
00230 
00231   h_ele_matchingObjectEta_matched      = new TH1F( "h_ele_matchingObjectEta_matched",      "Efficiency vs matching SC #eta",    nbineta,etamin,etamax);
00232   h_ele_matchingObjectEta_matched->Sumw2();
00233   h_ele_matchingObjectAbsEta_matched      = new TH1F( "h_ele_matchingObjectAbsEta_matched",      "Efficiency vs matching SC |#eta|",    nbineta/2,0.,2.5);
00234   h_ele_matchingObjectAbsEta_matched->Sumw2();
00235   h_ele_matchingObjectPt_matched       = new TH1F( "h_ele_matchingObjectPt_matched",       "Efficiency vs matching SC E_{T}",  nbinpteff,5.,ptmax);
00236   h_ele_matchingObjectPt_matched->Sumw2();
00237   h_ele_matchingObjectPhi_matched               = new TH1F( "h_ele_matchingObjectPhi_matched", "Efficiency vs matching SC phi",        nbinphi,phimin,phimax);
00238   h_ele_matchingObjectPhi_matched->Sumw2();
00239   h_ele_matchingObjectZ_matched      = new TH1F( "h_ele_matchingObjectZ_matched",      "Efficiency vs matching SC z",    nbinxyz,-25,25);
00240   h_ele_matchingObjectZ_matched->Sumw2();
00241 
00242   //==================================================
00243   // caractéristique particule
00244   //==================================================
00245 
00246   h_ele_vertexPt = new TH1F( "h_ele_vertexPt","ele transverse momentum",nbinpt,0.,ptmax);
00247   h_ele_Et       = new TH1F( "h_ele_Et",       "ele SC transverse energy",  nbinpt,0.,ptmax);
00248   h_ele_vertexEta = new TH1F( "h_ele_vertexEta","ele momentum eta",nbineta,etamin,etamax);
00249   h_ele_vertexPhi = new TH1F( "h_ele_vertexPhi","ele  momentum #phi",nbinphi,phimin,phimax);
00250   h_ele_vertexX = new TH1F( "h_ele_vertexX","ele vertex x",nbinxyz,-0.1,0.1 );
00251   h_ele_vertexY = new TH1F( "h_ele_vertexY","ele vertex y",nbinxyz,-0.1,0.1 );
00252   h_ele_vertexZ = new TH1F( "h_ele_vertexZ","ele vertex z",nbinxyz,-25, 25 );
00253   h_ele_vertexTIP = new TH1F( "h_ele_vertexTIP","ele transverse impact parameter (wrt bs)",90,0.,0.15);
00254   h_ele_charge = new TH1F( "h_ele_charge","ele charge",5,-2.,2.);
00255 
00256   h_ele_charge->GetXaxis()-> SetTitle("charge");
00257   h_ele_charge->GetYaxis()-> SetTitle("Events");
00258 
00259   h_ele_vertexPt->GetXaxis()-> SetTitle("p_{T vertex} (GeV/c)");
00260   h_ele_vertexPt->GetYaxis()-> SetTitle("Events");
00261 
00262   h_ele_Et->GetXaxis()-> SetTitle("E_{T} (GeV)");
00263   h_ele_Et->GetYaxis()-> SetTitle("Events");
00264 
00265   h_ele_vertexEta->GetXaxis()-> SetTitle("#eta");
00266   h_ele_vertexEta->GetYaxis()-> SetTitle("Events");
00267   h_ele_vertexPhi->GetXaxis()-> SetTitle("#phi (rad)");
00268   h_ele_vertexPhi->GetYaxis()-> SetTitle("Events");
00269 
00270   h_ele_vertexX-> GetXaxis()-> SetTitle("x (cm)");
00271   h_ele_vertexX-> GetYaxis()-> SetTitle("Events");
00272   h_ele_vertexY-> GetXaxis()-> SetTitle("y (cm)");
00273   h_ele_vertexY-> GetYaxis()-> SetTitle("Events");
00274   h_ele_vertexZ-> GetXaxis()-> SetTitle("z (cm)");
00275   h_ele_vertexZ-> GetYaxis()-> SetTitle("Events");
00276 
00277   h_ele_vertexTIP-> GetXaxis()-> SetTitle("TIP (cm)");
00278   h_ele_vertexTIP-> GetYaxis()-> SetTitle("Events");
00279 
00280   //==================================================
00281   // # rec electrons
00282   //==================================================
00283 
00284   histNum_= new TH1F("h_recEleNum","# rec electrons",20, 0.,20.);
00285 
00286   histNum_-> GetXaxis()-> SetTitle("N_{ele}");
00287   histNum_-> GetYaxis()-> SetTitle("Events");
00288 
00289   //==================================================
00290   // SuperClusters
00291   //==================================================
00292 
00293   histSclEn_ = new TH1F("h_scl_energy","ele supercluster energy",nbinp,0.,pmax);
00294   histSclEt_ = new TH1F("h_scl_et","ele supercluster transverse energy",nbinpt,0.,ptmax);
00295   histSclEta_ = new TH1F("h_scl_eta","ele supercluster eta",nbineta,etamin,etamax);
00296   histSclPhi_ = new TH1F("h_scl_phi","ele supercluster phi",nbinphi,phimin,phimax);
00297   histSclSigEtaEta_ =  new TH1F("h_scl_sigetaeta","ele supercluster sigma eta eta",100,0.,0.05);
00298 
00299   //==================================================
00300   // electron track
00301   //==================================================
00302 
00303   h_ele_ambiguousTracks      = new TH1F( "h_ele_ambiguousTracks", "ele # ambiguous tracks",  5,0.,5.);
00304   h_ele_ambiguousTracksVsEta      = new TH2F( "h_ele_ambiguousTracksVsEta","ele # ambiguous tracks  vs eta",  nbineta2D,etamin,etamax,5,0.,5.);
00305   h_ele_ambiguousTracksVsPhi      = new TH2F( "h_ele_ambiguousTracksVsPhi", "ele # ambiguous tracks  vs phi",  nbinphi2D,phimin,phimax,5,0.,5.);
00306   h_ele_ambiguousTracksVsPt      = new TH2F( "h_ele_ambiguousTracksVsPt", "ele # ambiguous tracks vs pt",  nbinpt2D,0.,ptmax,5,0.,5.);
00307   h_ele_foundHits      = new TH1F( "h_ele_foundHits",      "ele track # found hits",      nbinfhits,0.,fhitsmax);
00308   h_ele_foundHitsVsEta      = new TH2F( "h_ele_foundHitsVsEta",      "ele track # found hits vs eta",  nbineta2D,etamin,etamax,nbinfhits,0.,fhitsmax);
00309   h_ele_foundHitsVsPhi      = new TH2F( "h_ele_foundHitsVsPhi",      "ele track # found hits vs phi",  nbinphi2D,phimin,phimax,nbinfhits,0.,fhitsmax);
00310   h_ele_foundHitsVsPt      = new TH2F( "h_ele_foundHitsVsPt",      "ele track # found hits vs pt",  nbinpt2D,0.,ptmax,nbinfhits,0.,fhitsmax);
00311   h_ele_lostHits       = new TH1F( "h_ele_lostHits",       "ele track # lost hits",       5,0.,5.);
00312   h_ele_lostHitsVsEta       = new TH2F( "h_ele_lostHitsVsEta",       "ele track # lost hits vs eta",   nbineta2D,etamin,etamax,nbinlhits,0.,lhitsmax);
00313   h_ele_lostHitsVsPhi       = new TH2F( "h_ele_lostHitsVsPhi",       "ele track # lost hits vs eta",   nbinphi2D,phimin,phimax,nbinlhits,0.,lhitsmax);
00314   h_ele_lostHitsVsPt       = new TH2F( "h_ele_lostHitsVsPt",       "ele track # lost hits vs eta",   nbinpt2D,0.,ptmax,nbinlhits,0.,lhitsmax);
00315   h_ele_chi2           = new TH1F( "h_ele_chi2",           "ele track #chi^{2}",         100,0.,15.);
00316   h_ele_chi2VsEta           = new TH2F( "h_ele_chi2VsEta",           "ele track #chi^{2} vs eta",  nbineta2D,etamin,etamax,50,0.,15.);
00317   h_ele_chi2VsPhi           = new TH2F( "h_ele_chi2VsPhi",           "ele track #chi^{2} vs phi",  nbinphi2D,phimin,phimax,50,0.,15.);
00318   h_ele_chi2VsPt           = new TH2F( "h_ele_chi2VsPt",           "ele track #chi^{2} vs pt",  nbinpt2D,0.,ptmax,50,0.,15.);
00319 
00320   h_ele_foundHits->GetXaxis()-> SetTitle("N_{hits}");
00321   h_ele_foundHits->GetYaxis()-> SetTitle("Events");
00322   h_ele_lostHits->GetXaxis()-> SetTitle("N_{lost hits}");
00323   h_ele_lostHits->GetYaxis()-> SetTitle("Events");
00324   h_ele_chi2->GetXaxis()-> SetTitle("#Chi^{2}");
00325   h_ele_chi2->GetYaxis()-> SetTitle("Events");
00326 
00327   //==================================================
00328   // electron matching and ID
00329   //==================================================
00330 
00331   h_ele_EoP            = new TH1F( "h_ele_EoP",            "ele E/P_{vertex}",        nbineop,0.,eopmax);
00332 //  h_ele_EoPout         = new TH1F( "h_ele_EoPout",         "ele E/P_{out}",           nbineop,0.,eopmax);
00333   h_ele_EeleOPout         = new TH1F( "h_ele_EeleOPout",         "ele E_{ele}/P_{out}",           nbineop,0.,eopmax);
00334   h_ele_dEtaSc_propVtx = new TH1F( "h_ele_dEtaSc_propVtx", "ele #eta_{sc} - #eta_{tr}, prop from vertex",      nbindetamatch,detamatchmin,detamatchmax);
00335   h_ele_dPhiSc_propVtx = new TH1F( "h_ele_dPhiSc_propVtx", "ele #phi_{sc} - #phi_{tr}, prop from vertex",      nbindphimatch,dphimatchmin,dphimatchmax);
00336   h_ele_dEtaCl_propOut = new TH1F( "h_ele_dEtaCl_propOut", "ele #eta_{cl} - #eta_{tr}, prop from outermost",   nbindetamatch,detamatchmin,detamatchmax);
00337   h_ele_dPhiCl_propOut = new TH1F( "h_ele_dPhiCl_propOut", "ele #phi_{cl} - #phi_{tr}, prop from outermost",   nbindphimatch,dphimatchmin,dphimatchmax);
00338   h_ele_dEtaEleCl_propOut = new TH1F( "h_ele_dEtaEleCl_propOut", "ele #eta_{EleCl} - #eta_{tr}, prop from outermost",   nbindetamatch,detamatchmin,detamatchmax);
00339   h_ele_dPhiEleCl_propOut = new TH1F( "h_ele_dPhiEleCl_propOut", "ele #phi_{EleCl} - #phi_{tr}, prop from outermost",   nbindphimatch,dphimatchmin,dphimatchmax);
00340   h_ele_HoE = new TH1F("h_ele_HoE", "ele hadronic energy / em energy", nbinhoe, hoemin, hoemax) ;
00341   h_ele_outerP = new TH1F( "h_ele_outerP",         "ele track outer p, mean",          nbinp,0.,pmax);
00342   h_ele_outerP_mode = new TH1F( "h_ele_outerP_mode",         "ele track outer p, mode",          nbinp,0.,pmax);
00343   h_ele_outerPt = new TH1F( "h_ele_outerPt",        "ele track outer p_{T}, mean",      nbinpt,0.,ptmax);
00344   h_ele_outerPt_mode = new TH1F( "h_ele_outerPt_mode",        "ele track outer p_{T}, mode",      nbinpt,0.,ptmax);
00345 
00346   h_ele_PinMnPout      = new TH1F( "h_ele_PinMnPout",      "ele track inner p - outer p, mean"   ,nbinp,0.,200.);
00347   h_ele_PinMnPout_mode      = new TH1F( "h_ele_PinMnPout_mode",      "ele track inner p - outer p, mode"   ,nbinp,0.,100.);
00348 
00349   h_ele_mva = new TH1F( "h_ele_mva","ele identification mva",100,-1.,1.);
00350   h_ele_provenance = new TH1F( "h_ele_provenance","ele provenance",5,-2.,3.);
00351 
00352   h_ele_PinMnPout->GetXaxis()-> SetTitle("P_{vertex} - P_{out} (GeV/c)");
00353   h_ele_PinMnPout->GetYaxis()-> SetTitle("Events");
00354   h_ele_PinMnPout_mode->GetXaxis()-> SetTitle("P_{vertex} - P_{out}, mode (GeV/c)");
00355   h_ele_PinMnPout_mode->GetYaxis()-> SetTitle("Events");
00356 
00357   h_ele_outerP->GetXaxis()-> SetTitle("P_{out} (GeV/c)");
00358   h_ele_outerP->GetYaxis()-> SetTitle("Events");
00359   h_ele_outerP_mode->GetXaxis()-> SetTitle("P_{out} (GeV/c)");
00360   h_ele_outerP_mode->GetYaxis()-> SetTitle("Events");
00361 
00362   h_ele_outerPt->GetXaxis()-> SetTitle("P_{T out} (GeV/c)");
00363   h_ele_outerPt->GetYaxis()-> SetTitle("Events");
00364   h_ele_outerPt_mode->GetXaxis()-> SetTitle("P_{T out} (GeV/c)");
00365   h_ele_outerPt_mode->GetYaxis()-> SetTitle("Events");
00366 
00367   h_ele_EoP->GetXaxis()-> SetTitle("E/P_{vertex}");
00368   h_ele_EoP->GetYaxis()-> SetTitle("Events");
00369 
00370 //  h_ele_EoPout->GetXaxis()-> SetTitle("E_{seed}/P_{out}");
00371 //  h_ele_EoPout->GetYaxis()-> SetTitle("Events");
00372   h_ele_EeleOPout->GetXaxis()-> SetTitle("E_{ele}/P_{out}");
00373   h_ele_EeleOPout->GetYaxis()-> SetTitle("Events");
00374 
00375   h_ele_dEtaSc_propVtx-> GetXaxis()-> SetTitle("#eta_{sc} - #eta_{tr}");
00376   h_ele_dEtaSc_propVtx-> GetYaxis()-> SetTitle("Events");
00377   h_ele_dEtaCl_propOut-> GetXaxis()-> SetTitle("#eta_{seedcl} - #eta_{tr}");
00378   h_ele_dEtaCl_propOut-> GetYaxis()-> SetTitle("Events");
00379   h_ele_dEtaEleCl_propOut-> GetXaxis()-> SetTitle("#eta_{elecl} - #eta_{tr}");
00380   h_ele_dEtaEleCl_propOut-> GetYaxis()-> SetTitle("Events");
00381   h_ele_dPhiSc_propVtx-> GetXaxis()-> SetTitle("#phi_{sc} - #phi_{tr} (rad)");
00382   h_ele_dPhiSc_propVtx-> GetYaxis()-> SetTitle("Events");
00383   h_ele_dPhiCl_propOut-> GetXaxis()-> SetTitle("#phi_{seedcl} - #phi_{tr} (rad)");
00384   h_ele_dPhiCl_propOut-> GetYaxis()-> SetTitle("Events");
00385   h_ele_dPhiEleCl_propOut-> GetXaxis()-> SetTitle("#phi_{elecl} - #phi_{tr} (rad)");
00386   h_ele_dPhiEleCl_propOut-> GetYaxis()-> SetTitle("Events");
00387   h_ele_HoE-> GetXaxis()-> SetTitle("H/E") ;
00388   h_ele_HoE-> GetYaxis()-> SetTitle("Events") ;
00389 
00390   //==================================================
00391   // isolation
00392   //==================================================
00393 
00394   h_ele_tkSumPt_dr03 = new TH1F("h_ele_tkSumPt_dr03","tk isolation sum, dR=0.3",100,0.0,20.);
00395   h_ele_ecalRecHitSumEt_dr03= new TH1F("h_ele_ecalRecHitSumEt_dr03","ecal isolation sum, dR=0.3",100,0.0,20.);
00396   h_ele_hcalDepth1TowerSumEt_dr03= new TH1F("h_ele_hcalDepth1TowerSumEt_dr03","hcal depth1 isolation sum, dR=0.3",100,0.0,20.);
00397   h_ele_hcalDepth2TowerSumEt_dr03= new TH1F("h_ele_hcalDepth2TowerSumEt_dr03","hcal depth2 isolation sum, dR=0.3",100,0.0,20.);
00398   h_ele_tkSumPt_dr04= new TH1F("h_ele_tkSumPt_dr04","hcal isolation sum",100,0.0,20.);
00399   h_ele_ecalRecHitSumEt_dr04= new TH1F("h_ele_ecalRecHitSumEt_dr04","ecal isolation sum, dR=0.4",100,0.0,20.);
00400   h_ele_hcalDepth1TowerSumEt_dr04= new TH1F("h_ele_hcalDepth1TowerSumEt_dr04","hcal depth1 isolation sum, dR=0.4",100,0.0,20.);
00401   h_ele_hcalDepth2TowerSumEt_dr04= new TH1F("h_ele_hcalDepth2TowerSumEt_dr04","hcal depth2 isolation sum, dR=0.4",100,0.0,20.);
00402 
00403   //==================================================
00404   // T&P
00405   //==================================================
00406   h_ele_mee_os      = new TH1F( "h_ele_mee_os", "ele pairs invariant mass, opposite sign", nbinmee, meemin, meemax );
00407 
00408 
00409   //==================================================
00410   // OBSOLETE
00411   //==================================================
00412 
00413   //  h_ele_PtoPtmatchingObject_matched        = new TH1F( "h_ele_PtoPtmatchingObject_matched",        "ele trans momentum / matching SC trans energy", nbinpoptrue,poptruemin,poptruemax);
00414   //  h_ele_PtoPtmatchingObject_barrel_matched         = new TH1F( "h_ele_PtoPmatchingObject_barrel_matched",        "ele trans momentum / matching SC trans energy, barrel",nbinpoptrue,poptruemin,poptruemax);
00415   //  h_ele_PtoPtmatchingObject_endcaps_matched        = new TH1F( "h_ele_PtoPmatchingObject_endcaps_matched",        "ele trans momentum / matching SC trans energy, endcaps",nbinpoptrue,poptruemin,poptruemax);
00416   //  h_ele_PoPmatchingObject_matched        = new TH1F( "h_ele_PoPmatchingObject_matched",        "ele momentum / matching SC energy", nbinpoptrue,poptruemin,poptruemax);
00417   //  h_ele_PoPmatchingObject_barrel_matched         = new TH1F( "h_ele_PoPmatchingObject_barrel_matched",        "ele momentum / matching SC energy, barrel",nbinpoptrue,poptruemin,poptruemax);
00418   //  h_ele_PoPmatchingObject_endcaps_matched        = new TH1F( "h_ele_PoPmatchingObject_endcaps_matched",        "ele momentum / matching SC energy, endcaps",nbinpoptrue,poptruemin,poptruemax);
00419   //  // h_ele_PtoPtmatchingObject_matched        = new TH1F( "h_ele_PtoPtmatchingObject_matched",        "ele trans momentum / matching SC trans energy", nbinpoptrue,poptruemin,poptruemax);
00420   //  h_ele_EtaMnEtamatchingObject_matched   = new TH1F( "h_ele_EtaMnEtamatchingObject_matched",   "ele momentum eta - matching SC eta",nbindeta,detamin,detamax);
00421   //  h_ele_PhiMnPhimatchingObject_matched   = new TH1F( "h_ele_PhiMnPhimatchingObject_matched",   "ele momentum phi - matching SC phi",nbindphi,dphimin,dphimax);
00422   //  h_ele_PhiMnPhimatchingObject2_matched   = new TH1F( "h_ele_PhiMnPhimatchingObject2_matched",   "ele momentum phi - matching SC phi",nbindphimatch2D,dphimatchmin,dphimatchmax);
00423 
00424   //  h_ele_PoPmatchingObject_matched->GetXaxis()-> SetTitle("P/E_{SC}");
00425   //  h_ele_PoPmatchingObject_matched->GetYaxis()-> SetTitle("Events");
00426   //  h_ele_PoPmatchingObject_barrel_matched->GetXaxis()-> SetTitle("P/E_{SC}");
00427   //  h_ele_PoPmatchingObject_barrel_matched->GetYaxis()-> SetTitle("Events");
00428   //  h_ele_PoPmatchingObject_endcaps_matched->GetXaxis()-> SetTitle("P/E_{SC}");
00429   //  h_ele_PoPmatchingObject_endcaps_matched->GetYaxis()-> SetTitle("Events");
00430   //  h_ele_PtoPtmatchingObject_matched->GetXaxis()-> SetTitle("P_{T}/E_{T}^{SC}");
00431   //  h_ele_PtoPtmatchingObject_matched->GetYaxis()-> SetTitle("Events");
00432   //  h_ele_PtoPtmatchingObject_barrel_matched->GetXaxis()-> SetTitle("P_{T}/E_{T}^{SC}");
00433   //  h_ele_PtoPtmatchingObject_barrel_matched->GetYaxis()-> SetTitle("Events");
00434   //  h_ele_PtoPtmatchingObject_endcaps_matched->GetXaxis()-> SetTitle("P_{T}/E_{T}^{SC}");
00435   //  h_ele_PtoPtmatchingObject_endcaps_matched->GetYaxis()-> SetTitle("Events");
00436   //
00437   //  h_ele_EtaMnEtamatchingObject_matched->GetXaxis()-> SetTitle("#eta_{rec} - #eta_{SC}");
00438   //  h_ele_EtaMnEtamatchingObject_matched->GetYaxis()-> SetTitle("Events");
00439   //  h_ele_PhiMnPhimatchingObject_matched->GetXaxis()-> SetTitle("#phi_{rec} - #phi_{SC} (rad)");
00440   //  h_ele_PhiMnPhimatchingObject_matched->GetYaxis()-> SetTitle("Events");
00441   //  h_ele_EtaMnEtamatchingObject_matched->GetXaxis()-> SetTitle("#eta_{rec} - #eta_{SC}");
00442   //  h_ele_EtaMnEtamatchingObject_matched->GetYaxis()-> SetTitle("Events");
00443   //  h_ele_PhiMnPhimatchingObject_matched->GetXaxis()-> SetTitle("#phi_{rec} - #phi_{SC} (rad)");
00444   //  h_ele_PhiMnPhimatchingObject_matched->GetYaxis()-> SetTitle("Events");
00445  }
00446 
00447 
00448 void
00449 DQMAnalyzer::endJob(){
00450 
00451   histfile_->cd();
00452   std::cout << "efficiency calculation " << std::endl;
00453 
00454   // efficiency vs pt
00455   TH1F *h_ele_ptEff = (TH1F*)h_ele_matchingObjectPt_matched->Clone("h_ele_ptEff");
00456   h_ele_ptEff->Reset();
00457   h_ele_ptEff->Divide(h_ele_matchingObjectPt_matched,h_matchingObjectPt,1,1,"b");
00458   h_ele_ptEff->GetXaxis()->SetTitle("p_{T} (GeV/c)");
00459   h_ele_ptEff->GetYaxis()->SetTitle("Efficiency");
00460 
00461   // efficiency vs eta
00462   TH1F *h_ele_etaEff = (TH1F*)h_ele_matchingObjectEta_matched->Clone("h_ele_etaEff");
00463   h_ele_etaEff->Reset();
00464   h_ele_etaEff->Divide(h_ele_matchingObjectEta_matched,h_matchingObjectEta,1,1,"b");
00465   h_ele_etaEff->Print();
00466   h_ele_etaEff->GetXaxis()->SetTitle("#eta");
00467   h_ele_etaEff->GetYaxis()->SetTitle("Efficiency");
00468 
00469   // efficiency vs |eta|
00470   TH1F *h_ele_absetaEff = (TH1F*)h_ele_matchingObjectAbsEta_matched->Clone("h_ele_absetaEff");
00471   h_ele_absetaEff->Reset();
00472   h_ele_absetaEff->Divide(h_ele_matchingObjectAbsEta_matched,h_matchingObjectAbsEta,1,1,"b");
00473   h_ele_absetaEff->GetXaxis()->SetTitle("|#eta|");
00474   h_ele_absetaEff->GetYaxis()->SetTitle("Efficiency");
00475 
00476   // efficiency vs phi
00477   TH1F *h_ele_phiEff = (TH1F*)h_ele_matchingObjectPhi_matched->Clone("h_ele_phiEff");
00478   h_ele_phiEff->Reset();
00479   h_ele_phiEff->Divide(h_ele_matchingObjectPhi_matched,h_matchingObjectPhi,1,1,"b");
00480   h_ele_phiEff->GetXaxis()->SetTitle("#phi (rad)");
00481   h_ele_phiEff->GetYaxis()->SetTitle("Efficiency");
00482 
00483   // efficiency vs z
00484   TH1F *h_ele_zEff = (TH1F*)h_ele_matchingObjectZ_matched->Clone("h_ele_zEff");
00485   h_ele_zEff->Reset();
00486   h_ele_zEff->Divide(h_ele_matchingObjectZ_matched,h_matchingObjectZ,1,1,"b");
00487   h_ele_zEff->Print();
00488   h_ele_zEff->GetXaxis()->SetTitle("z (cm)");
00489   h_ele_zEff->GetYaxis()->SetTitle("Efficiency");
00490 
00491 
00492 
00493   // classes
00494 
00495 
00496   // fbrem
00497 
00498   //profiles from 2D histos
00499 
00500   // mc truth
00501 
00502   h_matchingObjectNum->Write();
00503 
00504   // rec event
00505 
00506   histNum_->Write();
00507 
00508   // mc
00509   h_matchingObjectEta->Write();
00510   h_matchingObjectAbsEta->Write();
00511   h_matchingObjectP->Write();
00512   h_matchingObjectPt->Write();
00513   h_matchingObjectPhi->Write();
00514   h_matchingObjectZ->Write();
00515 
00516 
00517 
00518   // matched electrons
00519   h_ele_charge->Write();
00520 
00521   //h_ele_vertexP->Write();
00522   h_ele_vertexPt->Write();
00523   h_ele_vertexEta->Write();
00524   h_ele_vertexPhi->Write();
00525   h_ele_vertexX->Write();
00526   h_ele_vertexY ->Write();
00527   h_ele_vertexZ->Write();
00528 
00529   h_ele_vertexTIP->Write();
00530 
00531   h_ele_Et->Write();
00532 
00533   h_ele_matchingObjectPt_matched->Write();
00534   h_ele_matchingObjectAbsEta_matched->Write();
00535   h_ele_matchingObjectEta_matched->Write();
00536   h_ele_matchingObjectPhi_matched->Write();
00537   h_ele_matchingObjectZ_matched->Write();
00538 
00539 //  h_ele_PoPmatchingObject_matched->Write();
00540 //  h_ele_PtoPtmatchingObject_matched->Write();
00541 //  h_ele_PoPmatchingObject_barrel_matched ->Write();
00542 //  h_ele_PoPmatchingObject_endcaps_matched->Write();
00543 //  h_ele_PtoPtmatchingObject_barrel_matched ->Write();
00544 //  h_ele_PtoPtmatchingObject_endcaps_matched->Write();
00545 //  h_ele_EtaMnEtamatchingObject_matched->Write();
00546 //  h_ele_PhiMnPhimatchingObject_matched ->Write();
00547 //  h_ele_PhiMnPhimatchingObject2_matched ->Write();
00548 
00549 
00550   // matched electron, superclusters
00551   histSclEn_->Write();
00552   histSclEt_->Write();
00553   histSclEta_->Write();
00554   histSclPhi_->Write();
00555   histSclSigEtaEta_->Write();
00556 
00557   // matched electron, gsf tracks
00558   h_ele_ambiguousTracks->Write();
00559   h_ele_ambiguousTracksVsEta->Write();
00560   h_ele_ambiguousTracksVsPhi->Write();
00561   h_ele_ambiguousTracksVsPt->Write();
00562 
00563   h_ele_foundHits->Write();
00564   h_ele_foundHitsVsEta->Write();
00565   h_ele_foundHitsVsPhi->Write();
00566   h_ele_foundHitsVsPt->Write();
00567 
00568   h_ele_lostHits->Write();
00569   h_ele_lostHitsVsEta->Write();
00570   h_ele_lostHitsVsPhi->Write();
00571   h_ele_lostHitsVsPt->Write();
00572 
00573   h_ele_chi2 ->Write();
00574   h_ele_chi2VsEta ->Write();
00575   h_ele_chi2VsPhi ->Write();
00576   h_ele_chi2VsPt->Write();
00577 
00578   h_ele_PinMnPout->Write();
00579   h_ele_PinMnPout_mode->Write();
00580   h_ele_outerP ->Write();
00581   h_ele_outerP_mode->Write();
00582   h_ele_outerPt->Write();
00583   h_ele_outerPt_mode ->Write();
00584 
00585   // matched electrons, matching
00586   h_ele_EoP ->Write();
00587 //  h_ele_EoPout->Write();
00588   h_ele_EeleOPout->Write();
00589   h_ele_dEtaSc_propVtx->Write();
00590   h_ele_dPhiSc_propVtx->Write();
00591   h_ele_dEtaCl_propOut->Write();
00592   h_ele_dPhiCl_propOut->Write();
00593   h_ele_dEtaEleCl_propOut->Write();
00594   h_ele_dPhiEleCl_propOut->Write();
00595   h_ele_HoE->Write();
00596 
00597 
00598 
00599   h_ele_mee_os-> GetXaxis()-> SetTitle("m_{e^{+}e^{-}} (GeV/c^{2})");
00600   h_ele_mee_os-> GetYaxis()-> SetTitle("Events");
00601   h_ele_mee_os->Write();
00602 
00603   // classes
00604 
00605   // fbrem
00606 
00607   // Eff
00608   h_ele_etaEff->Write();
00609   h_ele_zEff->Write();
00610   h_ele_phiEff->Write();
00611   h_ele_absetaEff->Write();
00612   h_ele_ptEff->Write();
00613 
00614 
00615   // e/g et pflow electrons
00616   h_ele_mva->Write();
00617   h_ele_provenance->Write();
00618 
00619   // isolation
00620   h_ele_tkSumPt_dr03->GetXaxis()->SetTitle("TkIsoSum, cone 0.3 (GeV/c)");
00621   h_ele_tkSumPt_dr03->GetYaxis()->SetTitle("Events");
00622   h_ele_ecalRecHitSumEt_dr03->GetXaxis()->SetTitle("EcalIsoSum, cone 0.3 (GeV)");
00623   h_ele_ecalRecHitSumEt_dr03->GetYaxis()->SetTitle("Events");
00624   h_ele_hcalDepth1TowerSumEt_dr03->GetXaxis()->SetTitle("Hcal1IsoSum, cone 0.3 (GeV)");
00625   h_ele_hcalDepth1TowerSumEt_dr03->GetYaxis()->SetTitle("Events");
00626   h_ele_hcalDepth2TowerSumEt_dr03->GetXaxis()->SetTitle("Hcal2IsoSum, cone 0.3 (GeV)");
00627   h_ele_hcalDepth2TowerSumEt_dr03->GetYaxis()->SetTitle("Events");
00628   h_ele_tkSumPt_dr04->GetXaxis()->SetTitle("TkIsoSum, cone 0.4 (GeV/c)");
00629   h_ele_tkSumPt_dr04->GetYaxis()->SetTitle("Events");
00630   h_ele_ecalRecHitSumEt_dr04->GetXaxis()->SetTitle("EcalIsoSum, cone 0.4 (GeV)");
00631   h_ele_ecalRecHitSumEt_dr04->GetYaxis()->SetTitle("Events");
00632   h_ele_hcalDepth1TowerSumEt_dr04->GetXaxis()->SetTitle("Hcal1IsoSum, cone 0.4 (GeV)");
00633   h_ele_hcalDepth1TowerSumEt_dr04->GetYaxis()->SetTitle("Events");
00634   h_ele_hcalDepth2TowerSumEt_dr04->GetXaxis()->SetTitle("Hcal2IsoSum, cone 0.4 (GeV)");
00635   h_ele_hcalDepth2TowerSumEt_dr04->GetYaxis()->SetTitle("Events");
00636 
00637   h_ele_tkSumPt_dr03->Write();
00638   h_ele_ecalRecHitSumEt_dr03->Write();
00639   h_ele_hcalDepth1TowerSumEt_dr03->Write();
00640   h_ele_hcalDepth2TowerSumEt_dr03->Write();
00641   h_ele_tkSumPt_dr04->Write();
00642   h_ele_ecalRecHitSumEt_dr04->Write();
00643   h_ele_hcalDepth1TowerSumEt_dr04->Write();
00644   h_ele_hcalDepth2TowerSumEt_dr04->Write();
00645 
00646  }
00647 
00648 
00649 void
00650 DQMAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00651  {
00652   edm::LogInfo("DQMAnalyzer::analyze")<<"Treating event "<<iEvent.id() ;
00653   nEvents_++ ;
00654   if (!trigger(iEvent)) return ;
00655   nAfterTrigger_++ ;
00656   edm::LogInfo("DQMAnalyzer::analyze")<<"Trigger OK" ;
00657   edm::Handle<reco::GsfElectronCollection> gsfElectrons;
00658   iEvent.getByLabel(electronCollection_,gsfElectrons);
00659   edm::LogInfo("DQMAnalyzer::analyze")<<"Event has "<<gsfElectrons.product()->size()<<" electrons" ;
00660   edm::Handle<reco::SuperClusterCollection> recoClusters;
00661   iEvent.getByLabel(matchingObjectCollection_,recoClusters);
00662   edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00663   iEvent.getByType(recoBeamSpotHandle);
00664   const reco::BeamSpot bs = *recoBeamSpotHandle;
00665   histNum_->Fill((*gsfElectrons).size());
00666 
00667   // selected rec electrons
00668   reco::GsfElectronCollection::const_iterator gsfIter ;
00669   for
00670    ( gsfIter=gsfElectrons->begin() ;
00671      gsfIter!=gsfElectrons->end();
00672      gsfIter++ )
00673    {
00674     // vertex TIP
00675     double vertexTIP =
00676      (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
00677      (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
00678     vertexTIP = sqrt(vertexTIP) ;
00679 
00680     // select electrons
00681     if (!selected(gsfIter,vertexTIP)) continue ;
00682 
00683     // electron related distributions
00684     h_ele_charge->Fill( gsfIter->charge() );
00685     //h_ele_vertexP->Fill( gsfIter->p() );
00686     h_ele_vertexPt->Fill( gsfIter->pt() );
00687     h_ele_Et->Fill( gsfIter->superCluster()->energy()/cosh( gsfIter->superCluster()->eta()) );
00688     h_ele_vertexEta->Fill( gsfIter->eta() );
00689     h_ele_vertexPhi->Fill( gsfIter->phi() );
00690     h_ele_vertexX->Fill( gsfIter->vertex().x() );
00691     h_ele_vertexY->Fill( gsfIter->vertex().y() );
00692     h_ele_vertexZ->Fill( gsfIter->vertex().z() );
00693     h_ele_vertexTIP->Fill( vertexTIP );
00694 
00695     // supercluster related distributions
00696     reco::SuperClusterRef sclRef = gsfIter->superCluster() ;
00697     // ALREADY DONE IN GSF ELECTRON CORE
00698     //    if (!gsfIter->ecalDrivenSeed()&&gsfIter->trackerDrivenSeed())
00699     //      sclRef = gsfIter->pflowSuperCluster() ;
00700     histSclEn_->Fill(sclRef->energy());
00701     double R=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y() +sclRef->z()*sclRef->z());
00702     double Rt=TMath::Sqrt(sclRef->x()*sclRef->x() + sclRef->y()*sclRef->y());
00703     histSclEt_->Fill(sclRef->energy()*(Rt/R));
00704     histSclEta_->Fill(sclRef->eta());
00705     histSclPhi_->Fill(sclRef->phi());
00706     histSclSigEtaEta_->Fill(gsfIter->scSigmaEtaEta());
00707 
00708     // track related distributions
00709     h_ele_ambiguousTracks->Fill( gsfIter->ambiguousGsfTracksSize() );
00710     h_ele_ambiguousTracksVsEta->Fill( gsfIter->eta(), gsfIter->ambiguousGsfTracksSize() );
00711     h_ele_ambiguousTracksVsPhi->Fill( gsfIter->phi(), gsfIter->ambiguousGsfTracksSize() );
00712     h_ele_ambiguousTracksVsPt->Fill( gsfIter->pt(), gsfIter->ambiguousGsfTracksSize() );
00713     if (!readAOD_)
00714      { // track extra does not exist in AOD
00715       h_ele_foundHits->Fill( gsfIter->gsfTrack()->numberOfValidHits() );
00716       h_ele_foundHitsVsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->numberOfValidHits() );
00717       h_ele_foundHitsVsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->numberOfValidHits() );
00718       h_ele_foundHitsVsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->numberOfValidHits() );
00719       h_ele_lostHits->Fill( gsfIter->gsfTrack()->numberOfLostHits() );
00720       h_ele_lostHitsVsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->numberOfLostHits() );
00721       h_ele_lostHitsVsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->numberOfLostHits() );
00722       h_ele_lostHitsVsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->numberOfLostHits() );
00723       h_ele_chi2->Fill( gsfIter->gsfTrack()->normalizedChi2() );
00724       h_ele_chi2VsEta->Fill( gsfIter->eta(), gsfIter->gsfTrack()->normalizedChi2() );
00725       h_ele_chi2VsPhi->Fill( gsfIter->phi(), gsfIter->gsfTrack()->normalizedChi2() );
00726       h_ele_chi2VsPt->Fill( gsfIter->pt(), gsfIter->gsfTrack()->normalizedChi2() );
00727      }
00728 
00729           // from gsf track interface, hence using mean
00730     if (!readAOD_)
00731      { // track extra does not exist in AOD
00732       h_ele_PinMnPout->Fill( gsfIter->gsfTrack()->innerMomentum().R() - gsfIter->gsfTrack()->outerMomentum().R() );
00733       h_ele_outerP->Fill( gsfIter->gsfTrack()->outerMomentum().R() );
00734       h_ele_outerPt->Fill( gsfIter->gsfTrack()->outerMomentum().Rho() );
00735      }
00736 
00737     // from electron interface, hence using mode
00738     h_ele_PinMnPout_mode->Fill( gsfIter->trackMomentumAtVtx().R() - gsfIter->trackMomentumOut().R() );
00739     h_ele_outerP_mode->Fill( gsfIter->trackMomentumOut().R() );
00740     h_ele_outerPt_mode->Fill( gsfIter->trackMomentumOut().Rho() );
00741 
00742     /*
00743     if (!readAOD_) { // track extra does not exist in AOD
00744             edm::RefToBase<TrajectorySeed> seed = gsfIter->gsfTrack()->extra()->seedRef();
00745       ElectronSeedRef elseed=seed.castTo<ElectronSeedRef>();
00746       h_ele_seed_dphi2_-> Fill(elseed->dPhi2());
00747             h_ele_seed_dphi2VsEta_-> Fill(gsfIter->eta(), elseed->dPhi2());
00748             h_ele_seed_dphi2VsPt_-> Fill(gsfIter->pt(), elseed->dPhi2()) ;
00749             h_ele_seed_drz2_-> Fill(elseed->dRz2());
00750             h_ele_seed_drz2VsEta_-> Fill(gsfIter->eta(), elseed->dRz2());
00751             h_ele_seed_drz2VsPt_-> Fill(gsfIter->pt(), elseed->dRz2());
00752             h_ele_seed_subdet2_-> Fill(elseed->subDet2());
00753           }
00754     */
00755 
00756     // match distributions
00757     h_ele_EoP->Fill( gsfIter->eSuperClusterOverP() );
00758     h_ele_EeleOPout->Fill( gsfIter->eEleClusterOverPout() );
00759     h_ele_dEtaSc_propVtx->Fill(gsfIter->deltaEtaSuperClusterTrackAtVtx());
00760     h_ele_dPhiSc_propVtx->Fill(gsfIter->deltaPhiSuperClusterTrackAtVtx());
00761     h_ele_dEtaCl_propOut->Fill(gsfIter->deltaEtaSeedClusterTrackAtCalo());
00762     h_ele_dPhiCl_propOut->Fill(gsfIter->deltaPhiSeedClusterTrackAtCalo());
00763     h_ele_dEtaEleCl_propOut->Fill(gsfIter->deltaEtaEleClusterTrackAtCalo());
00764     h_ele_dPhiEleCl_propOut->Fill(gsfIter->deltaPhiEleClusterTrackAtCalo());
00765     h_ele_HoE->Fill(gsfIter->hadronicOverEm());
00766 
00767     //classes
00768 
00769     //fbrem
00770 
00771     h_ele_mva->Fill(gsfIter->mva()) ;
00772     if (gsfIter->ecalDrivenSeed()) h_ele_provenance->Fill(1.) ;
00773     if (gsfIter->trackerDrivenSeed()) h_ele_provenance->Fill(-1.) ;
00774     if (gsfIter->trackerDrivenSeed()||gsfIter->ecalDrivenSeed()) h_ele_provenance->Fill(0.);
00775     if (gsfIter->trackerDrivenSeed()&&!gsfIter->ecalDrivenSeed()) h_ele_provenance->Fill(-2.);
00776     if (!gsfIter->trackerDrivenSeed()&&gsfIter->ecalDrivenSeed()) h_ele_provenance->Fill(2.);
00777 
00778     h_ele_tkSumPt_dr03->Fill(gsfIter->dr03TkSumPt());
00779     h_ele_ecalRecHitSumEt_dr03->Fill(gsfIter->dr03EcalRecHitSumEt());
00780     h_ele_hcalDepth1TowerSumEt_dr03->Fill(gsfIter->dr03HcalDepth1TowerSumEt());
00781     h_ele_hcalDepth2TowerSumEt_dr03->Fill(gsfIter->dr03HcalDepth2TowerSumEt());
00782     h_ele_tkSumPt_dr04->Fill(gsfIter->dr04TkSumPt());
00783     h_ele_ecalRecHitSumEt_dr04->Fill(gsfIter->dr04EcalRecHitSumEt());
00784     h_ele_hcalDepth1TowerSumEt_dr04->Fill(gsfIter->dr04HcalDepth1TowerSumEt());
00785     h_ele_hcalDepth2TowerSumEt_dr04->Fill(gsfIter->dr04HcalDepth2TowerSumEt());
00786    }
00787 
00788   // association matching object-reco electrons
00789   int matchingObjectNum=0 ;
00790   reco::SuperClusterCollection::const_iterator moIter ;
00791   for
00792    ( moIter=recoClusters->begin() ;
00793      moIter!=recoClusters->end() ;
00794      moIter++ )
00795    {
00796     // number of matching objects
00797     matchingObjectNum++;
00798 
00799     if
00800      ( moIter->energy()/cosh(moIter->eta())>maxPtMatchingObject_ ||
00801        fabs(moIter->eta())> maxAbsEtaMatchingObject_ )
00802      { continue ; }
00803 
00804     // suppress the endcaps
00805     //if (fabs(moIter->eta()) > 1.5) continue;
00806     // select central z
00807     //if ( fabs((*mcIter)->production_vertex()->position().z())>50.) continue;
00808 
00809     h_matchingObjectEta->Fill( moIter->eta() );
00810     h_matchingObjectAbsEta->Fill( fabs(moIter->eta()) );
00811     h_matchingObjectP->Fill( moIter->energy() );
00812     h_matchingObjectPt->Fill( moIter->energy()/cosh(moIter->eta()) );
00813     h_matchingObjectPhi->Fill( moIter->phi() );
00814     h_matchingObjectZ->Fill(  moIter->z() );
00815 
00816     // find best matched electron
00817     bool okGsfFound = false;
00818     double gsfOkRatio = 999999.;
00819     reco::GsfElectron bestGsfElectron ;
00820     reco::GsfElectronCollection::const_iterator gsfIter ;
00821     for
00822      ( gsfIter=gsfElectrons->begin() ;
00823        gsfIter!=gsfElectrons->end() ;
00824        gsfIter++ )
00825      {
00826       double vertexTIP =
00827        (gsfIter->vertex().x()-bs.position().x()) * (gsfIter->vertex().x()-bs.position().x()) +
00828        (gsfIter->vertex().y()-bs.position().y()) * (gsfIter->vertex().y()-bs.position().y()) ;
00829       vertexTIP = sqrt(vertexTIP) ;
00830 
00831       // select electrons
00832       if (!selected(gsfIter,vertexTIP)) continue ;
00833 
00834       if (Selection_ >= 4)
00835        {
00836         reco::GsfElectronCollection::const_iterator gsfIter2 ;
00837         for
00838          ( gsfIter2=gsfIter+1 ;
00839            gsfIter2!=gsfElectrons->end() ;
00840            gsfIter2++ )
00841          {
00842           math::XYZTLorentzVector p12 = (*gsfIter).p4()+(*gsfIter2).p4() ;
00843           float mee2 = p12.Dot(p12) ;
00844           bool opsign = (gsfIter->charge()*gsfIter2->charge()<0.) ;
00845           float invMass = sqrt(mee2) ;
00846 
00847           if (TPchecksign_ && !opsign) break ;
00848 
00849           // conditions Tag
00850           if(TAGcheckclass_ && (gsfIter->classification()==GsfElectron::SHOWERING || gsfIter->isGap())) break;
00851 
00852           // conditions Probe
00853           if(PROBEetcut_ && (gsfIter2->superCluster()->energy()/cosh(gsfIter2->superCluster()->eta())<minEt_)) continue;
00854           if(PROBEcheckclass_ && (gsfIter2->classification()==GsfElectron::SHOWERING || gsfIter2->isGap())) continue;
00855 
00856           if( invMass < massLow_ || invMass > massHigh_ ) continue ;
00857 
00858           h_ele_mee_os->Fill(invMass) ;
00859           bestGsfElectron =* gsfIter2 ;
00860           okGsfFound = true ;
00861          }
00862        }
00863       else
00864        {
00865         reco::GsfElectronCollection::const_iterator gsfIter2 ;
00866         for
00867          ( gsfIter2=gsfIter+1;
00868            gsfIter2!=gsfElectrons->end() ;
00869            gsfIter2++ )
00870          {
00871           math::XYZTLorentzVector p12 = (*gsfIter).p4()+(*gsfIter2).p4() ;
00872           float mee2 = p12.Dot(p12) ;
00873           //bool opsign = (gsfIter->charge()*gsfIter2->charge()<0.) ;
00874           float invMass = sqrt(mee2) ;
00875           h_ele_mee_os->Fill(invMass) ;
00876          }
00877 
00878         // matching with a cone in eta phi
00879         if ( matchingCondition_ == "Cone" )
00880          {
00881           double dphi = gsfIter->phi()-moIter->phi() ;
00882           if (fabs(dphi)>CLHEP::pi)
00883            { dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi ; }
00884           double deltaR = sqrt(std::pow((moIter->eta()-gsfIter->eta()),2) + std::pow(dphi,2)) ;
00885           if ( deltaR < deltaR_ )
00886            {
00887             //if ( (genPc->pdg_id() == 11) && (gsfIter->charge() < 0.) || (genPc->pdg_id() == -11) &&
00888             //(gsfIter->charge() > 0.) ){
00889             double tmpGsfRatio = gsfIter->p()/moIter->energy();
00890             if ( fabs(tmpGsfRatio-1) < fabs(gsfOkRatio-1) && Selection_ != 4 )
00891              {
00892               gsfOkRatio = tmpGsfRatio;
00893               bestGsfElectron=*gsfIter;
00894               okGsfFound = true;
00895              }
00896             //}
00897            }
00898          }
00899        }
00900      } // loop over rec ele to look for the best one
00901 
00902     // analysis when the matching object is matched by a rec electron
00903     if (okGsfFound)
00904      {
00905       // generated distributions for matched electrons
00906       h_ele_matchingObjectPt_matched->Fill( moIter->energy()/cosh(moIter->eta()) );
00907       h_ele_matchingObjectPhi_matched->Fill( moIter->phi() );
00908       h_ele_matchingObjectAbsEta_matched->Fill( fabs(moIter->eta()) );
00909       h_ele_matchingObjectEta_matched->Fill( moIter->eta() );
00910       h_ele_matchingObjectZ_matched->Fill( moIter->z() );
00911 
00912 // OBSOLETE
00913       //      // comparison electron vs matching object
00914 //      h_ele_EtaMnEtamatchingObject_matched->Fill( bestGsfElectron.eta()-moIter->eta());
00915 //
00916 //      h_ele_PhiMnPhimatchingObject_matched->Fill( bestGsfElectron.phi()-moIter->phi());
00917 //      h_ele_PhiMnPhimatchingObject2_matched->Fill( bestGsfElectron.phi()-moIter->phi());
00918 //
00919 //      h_ele_PoPmatchingObject_matched->Fill( bestGsfElectron.p()/moIter->energy());
00920 //      h_ele_PtoPtmatchingObject_matched->Fill( bestGsfElectron.pt()/moIter->energy()/cosh(moIter->eta()));
00921 //
00922 //      if (bestGsfElectron.isEB()) h_ele_PoPmatchingObject_barrel_matched->Fill( bestGsfElectron.p()/moIter->energy());
00923 //      if (bestGsfElectron.isEE()) h_ele_PoPmatchingObject_endcaps_matched->Fill( bestGsfElectron.p()/moIter->energy());
00924 //      if (bestGsfElectron.isEB()) h_ele_PtoPtmatchingObject_barrel_matched->Fill( bestGsfElectron.pt()/moIter->energy()/cosh(moIter->eta()));
00925 //      if (bestGsfElectron.isEE()) h_ele_PtoPtmatchingObject_endcaps_matched->Fill( bestGsfElectron.pt()/moIter->energy()/cosh(moIter->eta()));
00926 
00927       reco::SuperClusterRef sclRef = bestGsfElectron.superCluster() ;
00928 
00929       // add here distributions for matched electrons as for all electrons
00930       //..
00931      } // gsf electron found
00932 
00933    } // loop overmatching object
00934 
00935   h_matchingObjectNum->Fill(matchingObjectNum) ;
00936 
00937  }
00938 
00939 bool DQMAnalyzer::trigger( const edm::Event & e )
00940  {
00941   // retreive TriggerResults from the event
00942   edm::Handle<edm::TriggerResults> triggerResults ;
00943   e.getByLabel(triggerResults_,triggerResults) ;
00944 
00945   bool accept = false ;
00946 
00947   if (triggerResults.isValid())
00948    {
00949     //std::cout << "TriggerResults found, number of HLT paths: " << triggerResults->size() << std::endl;
00950 
00951     // get trigger names
00952     const edm::TriggerNames & triggerNames = e.triggerNames(*triggerResults);
00953     if (nEvents_==1)
00954      {
00955       for (unsigned int i=0; i<triggerNames.size(); i++)
00956        {
00957 //            std::cout << "trigger path= " << triggerNames.triggerName(i) << std::endl;
00958        }
00959      }
00960 
00961     unsigned int n = HLTPathsByName_.size() ;
00962     for (unsigned int i=0; i!=n; i++)
00963      {
00964       HLTPathsByIndex_[i]=triggerNames.triggerIndex(HLTPathsByName_[i]) ;
00965      }
00966 
00967     // empty input vectors (n==0) means any trigger paths
00968     if (n==0)
00969      {
00970       n=triggerResults->size() ;
00971       HLTPathsByName_.resize(n) ;
00972       HLTPathsByIndex_.resize(n) ;
00973       for ( unsigned int i=0 ; i!=n ; i++)
00974        {
00975               HLTPathsByName_[i]=triggerNames.triggerName(i) ;
00976               HLTPathsByIndex_[i]=i ;
00977        }
00978      }
00979 
00980 //    if (nEvents_==1)
00981 //     {
00982 //      if (n>0)
00983 //       {
00984 //            std::cout << "HLT trigger paths requested: index, name and valididty:" << std::endl;
00985 //            for (unsigned int i=0; i!=n; i++)
00986 //             {
00987 //              bool validity = HLTPathsByIndex_[i]<triggerResults->size();
00988 //              std::cout
00989 //                << " " << HLTPathsByIndex_[i]
00990 //                << " " << HLTPathsByName_[i]
00991 //                << " " << validity << std::endl;
00992 //             }
00993 //       }
00994 //     }
00995 
00996     // count number of requested HLT paths which have fired
00997     unsigned int fired=0 ;
00998     for ( unsigned int i=0 ; i!=n ; i++ )
00999      {
01000       if (HLTPathsByIndex_[i]<triggerResults->size())
01001        {
01002         if (triggerResults->accept(HLTPathsByIndex_[i]))
01003          {
01004           fired++ ;
01005           //std::cout << "Fired HLT path= " << HLTPathsByName_[i] << std::endl ;
01006           accept = true ;
01007          }
01008        }
01009      }
01010 
01011    }
01012 
01013   return accept ;
01014  }
01015 
01016 bool DQMAnalyzer::selected( const reco::GsfElectronCollection::const_iterator & gsfIter , double vertexTIP )
01017  {
01018   if ((Selection_>0)&&generalCut(gsfIter)) return false ;
01019   if ((Selection_>=1)&&etCut(gsfIter)) return false ;
01020   if ((Selection_>=2)&&isolationCut(gsfIter,vertexTIP)) return false ;
01021   if ((Selection_>=3)&&idCut(gsfIter)) return false ;
01022   return true ;
01023  }
01024 
01025 bool DQMAnalyzer::generalCut( const reco::GsfElectronCollection::const_iterator & gsfIter)
01026  {
01027   if (fabs(gsfIter->eta())>maxAbsEta_) return true ;
01028   if (gsfIter->pt()<minPt_) return true ;
01029 
01030   if (gsfIter->isEB() && isEE_) return true ;
01031   if (gsfIter->isEE() && isEB_) return true ;
01032   if (gsfIter->isEBEEGap() && isNotEBEEGap_) return true ;
01033 
01034   if (gsfIter->ecalDrivenSeed() && isTrackerDriven_) return true ;
01035   if (gsfIter->trackerDrivenSeed() && isEcalDriven_) return true ;
01036 
01037   return false ;
01038  }
01039 
01040 bool DQMAnalyzer::etCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
01041  {
01042   if (gsfIter->superCluster()->energy()/cosh(gsfIter->superCluster()->eta())<minEt_) return true ;
01043 
01044   return false ;
01045  }
01046 
01047 bool DQMAnalyzer::isolationCut( const reco::GsfElectronCollection::const_iterator & gsfIter, double vertexTIP )
01048  {
01049   if (gsfIter->isEB() && vertexTIP > tipMaxBarrel_) return true ;
01050   if (gsfIter->isEE() && vertexTIP > tipMaxEndcaps_) return true ;
01051 
01052   if (gsfIter->dr03TkSumPt() > tkIso03Max_) return true ;
01053   if (gsfIter->isEB() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxBarrel_) return true ;
01054   if (gsfIter->isEE() && gsfIter->dr03HcalDepth1TowerSumEt() > hcalIso03Depth1MaxEndcaps_) return true ;
01055   if (gsfIter->isEE() && gsfIter->dr03HcalDepth2TowerSumEt() > hcalIso03Depth2MaxEndcaps_) return true ;
01056   if (gsfIter->isEB() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxBarrel_) return true ;
01057   if (gsfIter->isEE() && gsfIter->dr03EcalRecHitSumEt() > ecalIso03MaxEndcaps_) return true ;
01058 
01059   return false ;
01060  }
01061 
01062 bool DQMAnalyzer::idCut( const reco::GsfElectronCollection::const_iterator & gsfIter )
01063  {
01064   if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() < eOverPMinBarrel_) return true ;
01065   if (gsfIter->isEB() && gsfIter->eSuperClusterOverP() > eOverPMaxBarrel_) return true ;
01066   if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() < eOverPMinEndcaps_) return true ;
01067   if (gsfIter->isEE() && gsfIter->eSuperClusterOverP() > eOverPMaxEndcaps_) return true ;
01068   if (gsfIter->isEB() && fabs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinBarrel_) return true ;
01069   if (gsfIter->isEB() && fabs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxBarrel_) return true ;
01070   if (gsfIter->isEE() && fabs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) < dEtaMinEndcaps_) return true ;
01071   if (gsfIter->isEE() && fabs(gsfIter->deltaEtaSuperClusterTrackAtVtx()) > dEtaMaxEndcaps_) return true ;
01072   if (gsfIter->isEB() && fabs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinBarrel_) return true ;
01073   if (gsfIter->isEB() && fabs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxBarrel_) return true ;
01074   if (gsfIter->isEE() && fabs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) < dPhiMinEndcaps_) return true ;
01075   if (gsfIter->isEE() && fabs(gsfIter->deltaPhiSuperClusterTrackAtVtx()) > dPhiMaxEndcaps_) return true ;
01076   if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinBarrel_) return true ;
01077   if (gsfIter->isEB() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxBarrel_) return true ;
01078   if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() < sigIetaIetaMinEndcaps_) return true ;
01079   if (gsfIter->isEE() && gsfIter->scSigmaIEtaIEta() > sigIetaIetaMaxEndcaps_) return true ;
01080   if (gsfIter->isEB() && gsfIter->hadronicOverEm() > hadronicOverEmMaxBarrel_) return true ;
01081   if (gsfIter->isEE() && gsfIter->hadronicOverEm() > hadronicOverEmMaxEndcaps_) return true ;
01082 
01083   return false ;
01084  }
01085