CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/ElectroWeakAnalysis/WENu/src/WenuPlots.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    WenuPlots
00004 // Class:      WenuPlots
00005 // 
00006 /*
00007 
00008  Description: 
00009     this is an analyzer that reads pat::CompositeCandidate WenuCandidates
00010     and creates some plots
00011  Implementation:
00012     The code takes the output of the WenuCandidateFilter and
00013     * implements on them  a user defined selection 
00014     * implements the selection with one cut (configurable which cut) inverted
00015     * creates a set of basic plots with the Wenu Candidate distribution
00016       vs MET, MT etc. These plots are stored in a root file
00017     If you have several root files from different runs you have to run a macro
00018     to combine the output and have the final plots
00019 
00020     This analyser is PAT based in the sense that it reads CompositeCandidates,
00021     which are composed of a pat::MET plus a pat::Electron. You normally
00022     don't have to change this file when the CMSSW version changes because it
00023     contains only methods from the stable core of pat Objects. Most
00024     version dependent changes should be in WenuCandidateFilter.cc
00025  TO DO LIST:
00026     * more plots to be added
00027     * there should be an base Plots class from which WenuPlots and ZeePlots
00028       inherit. this makes sense since they have so many common methods
00029 
00030   Changes Log:
00031   12Feb09  First Release of the code for CMSSW_2_2_X
00032   16Sep09  tested that it works with 3_1_2 as well 
00033   09Sep09  added one extra iso with the name userIso_XX_
00034   23Feb09  added option to include extra IDs that are in CMSSW, such as
00035            categorized, likehood etc
00036            added extra variables TIP and E/P  
00037   27May10  changes to apply the Spring10 selections, relative isolations
00038            the 3 default ones, pat user isolations added in the end
00039            change to framework independent variable definitions 
00040            double->Double_t etc and math.h functions from TMath
00041   01Jul10  second electron information added
00042   Contact: 
00043   Nikolaos Rompotis  -  Nikolaos.Rompotis@Cern.ch
00044   Imperial College London
00045 
00046 
00047 */
00048 //
00049 // Original Author:  Nikolaos Rompotis
00050 
00051 
00052 #include "ElectroWeakAnalysis/WENu/interface/WenuPlots.h"
00053 #include "DataFormats/Math/interface/deltaR.h"
00054 #include "DataFormats/JetReco/interface/PFJet.h"
00055 #include "DataFormats/JetReco/interface/CaloJet.h"
00056 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00057 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00058 #include "DataFormats/VertexReco/interface/Vertex.h"
00059 //#include "RecoEcal/EgammaCoreTools/plugins/EcalClusterCrackCorrectionFunctor.h"
00060 
00061 WenuPlots::WenuPlots(const edm::ParameterSet& iConfig)
00062 
00063 {
00065 //                   I N P U T      P A R A M E T E R S
00067 //
00069 //  WENU COLLECTION   //////////////////////////////////////////////////////
00070 //
00071   
00072   wenuCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>
00073     ("wenuCollectionTag");
00074   //
00075   // code parameters
00076   //
00077   std::string outputFile_D = "histos.root";
00078   outputFile_ = iConfig.getUntrackedParameter<std::string>("outputFile", outputFile_D);
00079   WENU_VBTFselectionFileName_ = iConfig.getUntrackedParameter<std::string>("WENU_VBTFselectionFileName");
00080   WENU_VBTFpreseleFileName_ = iConfig.getUntrackedParameter<std::string>("WENU_VBTFpreseleFileName");
00081   DatasetTag_ = iConfig.getUntrackedParameter<Int_t>("DatasetTag");
00082   //
00083   // use of precalculatedID
00084   // if you use it, then no other cuts are applied
00085   usePrecalcID_ = iConfig.getUntrackedParameter<Bool_t>("usePrecalcID",false);
00086   if (usePrecalcID_) {
00087     usePrecalcIDType_ = iConfig.getUntrackedParameter<std::string>("usePrecalcIDType");    
00088     usePrecalcIDSign_ = iConfig.getUntrackedParameter<std::string>("usePrecalcIDSign","=");    
00089     usePrecalcIDValue_= iConfig.getUntrackedParameter<Double_t>("usePrecalcIDValue");
00090   }
00091   useValidFirstPXBHit_ = iConfig.getUntrackedParameter<Bool_t>("useValidFirstPXBHit",false);
00092   useConversionRejection_ = iConfig.getUntrackedParameter<Bool_t>("useConversionRejection",false);
00093   useExpectedMissingHits_ = iConfig.getUntrackedParameter<Bool_t>("useExpectedMissingHits",false);
00094 
00095   maxNumberOfExpectedMissingHits_ = iConfig.getUntrackedParameter<Int_t>("maxNumberOfExpectedMissingHits",1);
00096   if (not usePrecalcID_) {
00097     if (useValidFirstPXBHit_) std::cout << "WenuPlots: Warning: you have demanded a valid 1st layer PXB hit" << std::endl;
00098     if (useConversionRejection_) std::cout << "WenuPlots: Warning: you have demanded egamma conversion rejection criteria to be applied" << std::endl;
00099     if (useExpectedMissingHits_) std::cout << "WenuPlots: Warning: you have demanded at most " 
00100                                            <<maxNumberOfExpectedMissingHits_ << " missing inner hits "<< std::endl;
00101   }
00102   else {
00103     std::cout << "WenuPlots: Using Precalculated ID with type " << usePrecalcIDType_ 
00104               << usePrecalcIDSign_ << usePrecalcIDValue_ << std::endl;
00105   }
00106   if ((useValidFirstPXBHit_ || useExpectedMissingHits_ || useConversionRejection_) && (not usePrecalcID_)) {
00107     usePreselection_ = true;
00108   } else { usePreselection_ = false; }
00109   includeJetInformationInNtuples_ = iConfig.getUntrackedParameter<Bool_t>("includeJetInformationInNtuples", false);
00110   if (includeJetInformationInNtuples_) {
00111     caloJetCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>("caloJetCollectionTag");
00112     pfJetCollectionTag_   = iConfig.getUntrackedParameter<edm::InputTag>("pfJetCollectionTag");
00113     DRJetFromElectron_    = iConfig.getUntrackedParameter<Double_t>("DRJetFromElectron");
00114   }
00115   storeExtraInformation_ = iConfig.getUntrackedParameter<Bool_t>("storeExtraInformation");
00116   storeAllSecondElectronVariables_ = iConfig.getUntrackedParameter<Bool_t>("storeAllSecondElectronVariables", false);
00117   // primary vtx collections
00118   PrimaryVerticesCollection_=iConfig.getUntrackedParameter<edm::InputTag>
00119     ("PrimaryVerticesCollection", edm::InputTag("offlinePrimaryVertices"));
00120   PrimaryVerticesCollectionBS_=iConfig.getUntrackedParameter<edm::InputTag>
00121     ("PrimaryVerticesCollectionBS",edm::InputTag("offlinePrimaryVerticesWithBS"));
00122   //
00123   // the selection cuts:
00124   trackIso_EB_ = iConfig.getUntrackedParameter<Double_t>("trackIso_EB", 1000.);
00125   ecalIso_EB_ = iConfig.getUntrackedParameter<Double_t>("ecalIso_EB", 1000.);
00126   hcalIso_EB_ = iConfig.getUntrackedParameter<Double_t>("hcalIso_EB", 1000.);
00127   //
00128   trackIso_EE_ = iConfig.getUntrackedParameter<Double_t>("trackIso_EE", 1000.);
00129   ecalIso_EE_ = iConfig.getUntrackedParameter<Double_t>("ecalIso_EE", 1000.);
00130   hcalIso_EE_ = iConfig.getUntrackedParameter<Double_t>("hcalIso_EE", 1000.);
00131   //
00132   sihih_EB_ = iConfig.getUntrackedParameter<Double_t>("sihih_EB");
00133   dphi_EB_ = iConfig.getUntrackedParameter<Double_t>("dphi_EB");
00134   deta_EB_ = iConfig.getUntrackedParameter<Double_t>("deta_EB");
00135   hoe_EB_ = iConfig.getUntrackedParameter<Double_t>("hoe_EB");
00136   cIso_EB_ = iConfig.getUntrackedParameter<Double_t>("cIso_EB", 1000.);
00137   tip_bspot_EB_=iConfig.getUntrackedParameter<Double_t>("tip_bspot_EB", 1000.);
00138   eop_EB_=iConfig.getUntrackedParameter<Double_t>("eop_EB", 1000.);
00139   //
00140   sihih_EE_ = iConfig.getUntrackedParameter<Double_t>("sihih_EE");
00141   dphi_EE_ = iConfig.getUntrackedParameter<Double_t>("dphi_EE");
00142   deta_EE_ = iConfig.getUntrackedParameter<Double_t>("deta_EE");
00143   hoe_EE_ = iConfig.getUntrackedParameter<Double_t>("hoe_EE");
00144   cIso_EE_ = iConfig.getUntrackedParameter<Double_t>("cIso_EE", 1000.);
00145   tip_bspot_EE_=iConfig.getUntrackedParameter<Double_t>("tip_bspot_EE", 1000.);
00146   eop_EE_=iConfig.getUntrackedParameter<Double_t>("eop_EE", 1000.);
00147   //
00148   trackIsoUser_EB_ = iConfig.getUntrackedParameter<Double_t>("trackIsoUser_EB", 1000.);
00149   ecalIsoUser_EB_ = iConfig.getUntrackedParameter<Double_t>("ecalIsoUser_EB", 1000.);
00150   hcalIsoUser_EB_ = iConfig.getUntrackedParameter<Double_t>("hcalIsoUser_EB", 1000.);
00151   trackIsoUser_EE_ = iConfig.getUntrackedParameter<Double_t>("trackIsoUser_EE", 1000.);
00152   ecalIsoUser_EE_ = iConfig.getUntrackedParameter<Double_t>("ecalIsoUser_EE", 1000.);
00153   hcalIsoUser_EE_ = iConfig.getUntrackedParameter<Double_t>("hcalIsoUser_EE", 1000.);
00154   //
00155   trackIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("trackIso_EB_inv", false);
00156   ecalIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("ecalIso_EB_inv", false);
00157   hcalIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("hcalIso_EB_inv", false);
00158   //
00159   trackIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("trackIso_EE_inv", false);
00160   ecalIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("ecalIso_EE_inv", false);
00161   hcalIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("hcalIso_EE_inv", false);
00162   //
00163   sihih_EB_inv = iConfig.getUntrackedParameter<Bool_t>("sihih_EB_inv", false);
00164   dphi_EB_inv = iConfig.getUntrackedParameter<Bool_t>("dphi_EB_inv", false);
00165   deta_EB_inv = iConfig.getUntrackedParameter<Bool_t>("deta_EB_inv", false);
00166   hoe_EB_inv = iConfig.getUntrackedParameter<Bool_t>("hoe_EB_inv", false);
00167   cIso_EB_inv = iConfig.getUntrackedParameter<Bool_t>("cIso_EB_inv", false);
00168   tip_bspot_EB_inv=iConfig.getUntrackedParameter<Bool_t>("tip_bspot_EB_inv", false);
00169   eop_EB_inv=iConfig.getUntrackedParameter<Bool_t>("eop_EB_inv", false);
00170   //
00171   sihih_EE_inv = iConfig.getUntrackedParameter<Bool_t>("sihih_EE_inv", false);
00172   dphi_EE_inv = iConfig.getUntrackedParameter<Bool_t>("dphi_EE_inv", false);
00173   deta_EE_inv = iConfig.getUntrackedParameter<Bool_t>("deta_EE_inv", false);
00174   hoe_EE_inv = iConfig.getUntrackedParameter<Bool_t>("hoe_EE_inv", false);
00175   cIso_EE_inv = iConfig.getUntrackedParameter<Bool_t>("cIso_EE_inv", false);
00176   tip_bspot_EE_inv=iConfig.getUntrackedParameter<Bool_t>("tip_bspot_EE_inv", false);
00177   eop_EE_inv=iConfig.getUntrackedParameter<Bool_t>("eop_EE_inv", false);
00178   //
00179   trackIsoUser_EB_inv = iConfig.getUntrackedParameter<Bool_t>("trackIsoUser_EB_inv", false);
00180   ecalIsoUser_EB_inv = iConfig.getUntrackedParameter<Bool_t>("ecalIsoUser_EB_inv", false);
00181   hcalIsoUser_EB_inv = iConfig.getUntrackedParameter<Bool_t>("hcalIsoUser_EB_inv", false);
00182   trackIsoUser_EE_inv = iConfig.getUntrackedParameter<Bool_t>("trackIsoUser_EE_inv", false);
00183   ecalIsoUser_EE_inv = iConfig.getUntrackedParameter<Bool_t>("ecalIsoUser_EE_inv", false);
00184   hcalIsoUser_EE_inv = iConfig.getUntrackedParameter<Bool_t>("hcalIsoUser_EE_inv", false);
00185 
00186 }
00187 
00188 
00189 
00190 WenuPlots::~WenuPlots()
00191 {
00192  
00193    // do anything here that needs to be done at desctruction time
00194    // (e.g. close files, deallocate resources etc.)
00195 
00196 }
00197 
00198 
00199 //
00200 // member functions
00201 //
00202 
00203 // ------------ method called to for each event  ------------
00204 void
00205 WenuPlots::analyze(const edm::Event& iEvent, const edm::EventSetup& es)
00206 {
00207   using namespace std;
00208   //
00209   //  Get the collections here
00210   //
00211   edm::Handle<pat::CompositeCandidateCollection> WenuCands;
00212   iEvent.getByLabel(wenuCollectionTag_, WenuCands);
00213 
00214   if (not WenuCands.isValid()) {
00215     cout << "Warning: no wenu candidates in this event..." << endl;
00216     return;
00217   }
00218   const pat::CompositeCandidateCollection *wcands = WenuCands.product();
00219   const pat::CompositeCandidateCollection::const_iterator 
00220     wenuIter = wcands->begin();
00221   const pat::CompositeCandidate wenu = *wenuIter;
00222   //
00223   // get the parts of the composite candidate:
00224   const pat::Electron * myElec=
00225     dynamic_cast<const pat::Electron*> (wenu.daughter("electron"));
00226   const pat::MET * myMet=
00227     dynamic_cast<const pat::MET*> (wenu.daughter("met"));
00228   const pat::MET * myPfMet=
00229     dynamic_cast<const pat::MET*> (wenu.daughter("pfmet"));
00230   const pat::MET * myTcMet=
00231     dynamic_cast<const pat::MET*> (wenu.daughter("tcmet"));
00232   // _______________________________________________________________________
00233   //
00234   // VBTF Root tuple production --------------------------------------------
00235   // _______________________________________________________________________
00236   //
00237   // .......................................................................
00238   // vbtf  produces 2 root tuples: one that contains the highest pT electron
00239   //  that  passes a  user  defined selection  and one  other  with only the
00240   //  preselection criteria applied
00241   // .......................................................................
00242   //
00243   // fill the tree variables
00244   runNumber   = iEvent.run();
00245   eventNumber = Long64_t( iEvent.eventAuxiliary().event() );
00246   lumiSection = (Int_t) iEvent.luminosityBlock();
00247   //
00248   ele_sc_eta       = (Float_t)  myElec->superCluster()->eta();
00249   ele_sc_phi       = (Float_t)  myElec->superCluster()->phi();
00250   double scx = myElec->superCluster()->x();
00251   double scy = myElec->superCluster()->y();
00252   double scz = myElec->superCluster()->z();
00253   ele_sc_rho       = (Float_t)  sqrt( scx*scx + scy*scy + scz*scz );
00254   ele_sc_energy    = (Float_t)  myElec->superCluster()->energy();
00255   ele_sc_gsf_et    = (Float_t)  myElec->superCluster()->energy()/TMath::CosH(myElec->gsfTrack()->eta());
00256   ele_cand_eta     = (Float_t)  myElec->eta();
00257   ele_cand_phi     = (Float_t)  myElec->phi();
00258   ele_cand_et      = (Float_t)  myElec->et();
00259   //
00260   ele_iso_track    = (Float_t)  myElec->dr03IsolationVariables().tkSumPt / ele_cand_et;
00261   ele_iso_ecal     = (Float_t)  myElec->dr03IsolationVariables().ecalRecHitSumEt/ele_cand_et;
00262   ele_iso_hcal     = (Float_t)  ( myElec->dr03IsolationVariables().hcalDepth1TowerSumEt +
00263        myElec->dr03IsolationVariables().hcalDepth2TowerSumEt) / ele_cand_et;
00264   //
00265   ele_id_sihih     = (Float_t)  myElec->sigmaIetaIeta();
00266   ele_id_deta      = (Float_t)  myElec->deltaEtaSuperClusterTrackAtVtx();
00267   ele_id_dphi      = (Float_t)  myElec->deltaPhiSuperClusterTrackAtVtx();
00268   ele_id_hoe       = (Float_t)  myElec->hadronicOverEm();
00269   //
00270   ele_cr_mhitsinner= myElec->gsfTrack()->trackerExpectedHitsInner().numberOfHits();
00271   ele_cr_dcot      = myElec->convDcot();
00272   ele_cr_dist      = myElec->convDist();
00273   //
00274   ele_vx           = (Float_t) myElec->vx();
00275   ele_vy           = (Float_t) myElec->vy();
00276   ele_vz           = (Float_t) myElec->vz();
00277   // get the primary vtx information
00278   // no BS
00279   edm::Handle< std::vector<reco::Vertex> > pVtx;
00280   iEvent.getByLabel(PrimaryVerticesCollection_, pVtx);
00281   const std::vector<reco::Vertex> Vtx = *(pVtx.product());
00282   // with BS
00283   edm::Handle< std::vector<reco::Vertex> > pVtxBS;
00284   iEvent.getByLabel(PrimaryVerticesCollectionBS_, pVtxBS);
00285   const std::vector<reco::Vertex> VtxBS = *(pVtxBS.product());
00286   if (Vtx.size() > 0) {
00287     pv_x = Float_t(Vtx[0].position().x());
00288     pv_y = Float_t(Vtx[0].position().y());
00289     pv_z = Float_t(Vtx[0].position().z());
00290     ele_tip_pv = myElec->gsfTrack()->dxy(Vtx[0].position());
00291   } else {
00292     pv_x = -999999.;
00293     pv_y = -999999.;
00294     pv_z = -999999.;
00295     ele_tip_pv = -999999.;
00296   }
00297   if (VtxBS.size() > 0) {
00298     pvbs_x = Float_t(VtxBS[0].position().x());
00299     pvbs_y = Float_t(VtxBS[0].position().y());
00300     pvbs_z = Float_t(VtxBS[0].position().z());
00301     ele_tip_pvbs = myElec->gsfTrack()->dxy(VtxBS[0].position());
00302   } else {
00303     pvbs_x = -999999.;
00304     pvbs_y = -999999.;
00305     pvbs_z = -999999.;
00306     ele_tip_pvbs = -999999.;
00307   }
00308 
00309   //
00310   ele_gsfCharge    = (Int_t) myElec->gsfTrack()->charge();
00311   // must keep the ctf track collection, i.e. general track collection
00312   ele_ctfCharge    = (Int_t) myElec->closestCtfTrackRef().isNonnull() ? myElec->closestCtfTrackRef()->charge():-9999;
00313   ele_scPixCharge  = (Int_t) myElec->chargeInfo().scPixCharge;
00314   ele_eop          = (Float_t) myElec->eSuperClusterOverP();
00315   ele_tip_bs       = (Float_t) -myElec->dB();
00316   //ele_tip_pv       = myElec->userFloat("ele_tip_pv");
00317   ele_pin          = (Float_t)  myElec->trackMomentumAtVtx().R();
00318   ele_pout         = (Float_t)  myElec->trackMomentumOut().R();
00319   //
00320   event_caloMET    = (Float_t) myMet->et();
00321   event_pfMET      = (Float_t) myPfMet->et();
00322   event_tcMET      = (Float_t) myTcMet->et();
00323   event_caloMET_phi= (Float_t) myMet->phi();
00324   event_pfMET_phi  = (Float_t) myPfMet->phi();
00325   event_tcMET_phi  = (Float_t) myTcMet->phi();
00326   event_caloSumEt  = (Float_t) myMet->sumEt();
00327   event_pfSumEt  = (Float_t) myPfMet->sumEt();
00328   event_tcSumEt  = (Float_t) myTcMet->sumEt();
00329   // transverse mass for the user's convenience
00330   event_caloMT     = (Float_t) TMath::Sqrt(2.*(ele_sc_gsf_et*event_caloMET -
00331     (ele_sc_gsf_et*TMath::Cos(ele_sc_phi)*event_caloMET*TMath::Cos(event_caloMET_phi)
00332      + ele_sc_gsf_et*TMath::Sin(ele_sc_phi)*event_caloMET*TMath::Sin(event_caloMET_phi)
00333      ) )  );
00334   event_pfMT       = (Float_t) TMath::Sqrt(2.*(ele_sc_gsf_et*event_pfMET -
00335     (ele_sc_gsf_et*TMath::Cos(ele_sc_phi)*event_pfMET*TMath::Cos(event_pfMET_phi)
00336      + ele_sc_gsf_et*TMath::Sin(ele_sc_phi)*event_pfMET*TMath::Sin(event_pfMET_phi)
00337      ) )  );
00338   event_tcMT       = (Float_t) TMath::Sqrt(2.*(ele_sc_gsf_et*event_tcMET -
00339     (ele_sc_gsf_et*TMath::Cos(ele_sc_phi)*event_tcMET*TMath::Cos(event_tcMET_phi)
00340      + ele_sc_gsf_et*TMath::Sin(ele_sc_phi)*event_tcMET*TMath::Sin(event_tcMET_phi)
00341      ) )  );
00342   event_datasetTag = DatasetTag_;
00343   // jet information - only if the user asks for it
00344   // keep the 5 highest et jets of the event that are further than DR> DRJetFromElectron_
00345   if (includeJetInformationInNtuples_) {
00346     // initialize the array of the jet information
00347     for (int i=0; i<5; ++i) {
00348       calojet_et[i] = -999999;  calojet_eta[i] = -999999; calojet_phi[i] = -999999;
00349       pfjet_et[i] = -999999;    pfjet_eta[i] = -999999;   pfjet_phi[i] = -999999;
00350     }
00351     // get hold of the jet collections
00352     edm::Handle< reco::CaloJetCollection > pCaloJets;
00353     edm::Handle< reco::PFJetCollection > pPfJets;
00354     iEvent.getByLabel(caloJetCollectionTag_, pCaloJets);
00355     iEvent.getByLabel(pfJetCollectionTag_, pPfJets);
00356     //
00357     // calo jets now:
00358     if (pCaloJets.isValid()) {
00359       const  reco::CaloJetCollection  *caloJets =  pCaloJets.product();
00360       int nCaloJets = (int) caloJets->size();
00361       if (nCaloJets>0) {
00362         float *nCaloET = new float[nCaloJets];
00363         float *nCaloEta = new float[nCaloJets];
00364         float *nCaloPhi = new float[nCaloJets];
00365         reco::CaloJetCollection::const_iterator cjet = caloJets->begin();
00366         int counter = 0;
00367         for (; cjet != caloJets->end(); ++cjet) {
00368           // store them only if they are far enough from the electron
00369           Double_t DR = reco::deltaR(cjet->eta(), cjet->phi(), myElec->gsfTrack()->eta(), ele_sc_phi);
00370           if (DR > DRJetFromElectron_) {
00371             nCaloET[counter]  = cjet->et();
00372             nCaloEta[counter] = cjet->eta();
00373             nCaloPhi[counter] = cjet->phi();
00374             ++counter;
00375           }
00376         }
00377         int *caloJetSorted = new int[nCaloJets];
00378         TMath::Sort(nCaloJets, nCaloET, caloJetSorted, true);
00379         for (int i=0; i<nCaloJets; ++i) {
00380           if (i>=5) break;
00381           calojet_et[i] = nCaloET[ caloJetSorted[i] ];
00382           calojet_eta[i] = nCaloEta[ caloJetSorted[i] ];
00383           calojet_phi[i] = nCaloPhi[ caloJetSorted[i] ];
00384         }
00385         delete [] caloJetSorted;
00386         delete [] nCaloET;
00387         delete [] nCaloEta;
00388         delete [] nCaloPhi;     
00389       }
00390     } else {
00391       std::cout << "WenuPlots: Could not get caloJet collection with name " 
00392                 << caloJetCollectionTag_ << std::endl;
00393     }
00394     //
00395     // pf jets now:
00396     if (pPfJets.isValid()) {
00397       const  reco::PFJetCollection  *pfJets =  pPfJets.product();
00398       int nPfJets = (int) pfJets->size();
00399       if (nPfJets>0) {
00400         float *nPfET  = new float[nPfJets];
00401         float *nPfEta = new float[nPfJets];
00402         float *nPfPhi = new float[nPfJets];
00403         reco::PFJetCollection::const_iterator pjet = pfJets->begin();
00404         int counter = 0;
00405         for (; pjet != pfJets->end(); ++pjet) {
00406           // store them only if they are far enough from the electron
00407           Double_t DR = reco::deltaR(pjet->eta(), pjet->phi(), myElec->gsfTrack()->eta(), ele_sc_phi);
00408           if (DR > DRJetFromElectron_) {
00409             nPfET[counter]  = pjet->et();
00410             nPfEta[counter] = pjet->eta();
00411             nPfPhi[counter] = pjet->phi();
00412             ++counter;
00413           }
00414         }
00415         int *pfJetSorted = new int[nPfJets];
00416         TMath::Sort(nPfJets, nPfET, pfJetSorted, true);
00417         for (int i=0; i<nPfJets; ++i) {
00418           if (i>=5) break;
00419           pfjet_et[i]  = nPfET[ pfJetSorted[i] ];
00420           pfjet_eta[i] = nPfEta[ pfJetSorted[i] ];
00421           pfjet_phi[i] = nPfPhi[ pfJetSorted[i] ];
00422         }
00423         delete [] pfJetSorted;
00424         delete [] nPfET;
00425         delete [] nPfEta;
00426         delete [] nPfPhi;       
00427       }
00428     } else {
00429       std::cout << "WenuPlots: Could not get pfJet collection with name " 
00430                 << pfJetCollectionTag_ << std::endl;
00431     }
00432 
00433   }
00434   // second electron information - in preselected ntuple only
00435   ele2nd_sc_gsf_et = -1; // also in sele tree
00436   ele2nd_sc_eta    = -1;
00437   ele2nd_sc_phi    = -1;
00438   ele2nd_sc_rho    =  0;
00439   ele2nd_cand_eta  =  0;
00440   ele2nd_cand_phi  =  0;
00441   ele2nd_cand_et   =  0;
00442   ele2nd_pin       =  0;
00443   ele2nd_pout      =  0;
00444   ele2nd_passes_selection = -1; // also in sele tree
00445   ele2nd_ecalDriven=  0; 
00446   //
00447   // second electron selection variables: only if requested by the user
00448   //
00449   ele2nd_iso_track = 0;
00450   ele2nd_iso_ecal  = 0;
00451   ele2nd_iso_hcal  = 0;
00452   //
00453   ele2nd_id_sihih  = 0;
00454   ele2nd_id_deta   = 0;
00455   ele2nd_id_dphi   = 0;
00456   ele2nd_id_hoe    = 0;
00457   //
00458   ele2nd_cr_mhitsinner = 0;
00459   ele2nd_cr_dcot       = 0;
00460   ele2nd_cr_dist       = 0;
00461   //
00462   ele2nd_vx     = 0;
00463   ele2nd_vy     = 0;
00464   ele2nd_vz     = 0;
00465   //
00466   ele2nd_gsfCharge   = 0;
00467   // must keep the ctf track collection, i.e. general track collection
00468   ele2nd_ctfCharge   = 0;
00469   ele2nd_scPixCharge = 0;
00470   ele2nd_eop         = 0;
00471   ele2nd_tip_bs      = 0;
00472   ele2nd_tip_pv      = 0;
00473   ele2nd_hltmatched_dr = 0;
00474   //  
00475   // convention for ele2nd_passes_selection
00476   // 0 passes no selection
00477   // 1 passes WP95
00478   // 2 passes WP90
00479   // 3 passes WP85
00480   // 4 passes WP80
00481   // 5 passes WP70
00482   // 6 passes WP60
00483   if (myElec->userInt("hasSecondElectron") == 1 && storeExtraInformation_) {
00484     const pat::Electron * mySecondElec=
00485       dynamic_cast<const pat::Electron*> (wenu.daughter("secondElec"));    
00486     ele2nd_sc_gsf_et = (Float_t) mySecondElec->superCluster()->energy()/TMath::CosH(mySecondElec->gsfTrack()->eta());
00487 
00488     ele2nd_sc_eta    = (Float_t) mySecondElec->superCluster()->eta();
00489     ele2nd_sc_phi    = (Float_t) mySecondElec->superCluster()->phi();
00490     double sc2x = mySecondElec->superCluster()->x();
00491     double sc2y = mySecondElec->superCluster()->y();
00492     double sc2z = mySecondElec->superCluster()->z();
00493     ele2nd_sc_rho    = (Float_t) sqrt(sc2x*sc2x + sc2y*sc2y + sc2z*sc2z);
00494     ele2nd_cand_eta  = (Float_t) mySecondElec->eta();
00495     ele2nd_cand_phi  = (Float_t) mySecondElec->phi();
00496     ele2nd_cand_et   = (Float_t) mySecondElec->et();
00497     ele2nd_pin       = (Float_t) mySecondElec->trackMomentumAtVtx().R();;
00498     ele2nd_pout      = (Float_t) mySecondElec->trackMomentumOut().R();
00499     ele2nd_ecalDriven= (Int_t)   mySecondElec->ecalDrivenSeed();
00500     // check the selections
00501     bool isIDCalc = mySecondElec->isElectronIDAvailable("simpleEleId95relIso") &&
00502       mySecondElec->isElectronIDAvailable("simpleEleId90relIso") &&
00503       mySecondElec->isElectronIDAvailable("simpleEleId85relIso") &&
00504       mySecondElec->isElectronIDAvailable("simpleEleId80relIso") &&
00505       mySecondElec->isElectronIDAvailable("simpleEleId70relIso") &&
00506       mySecondElec->isElectronIDAvailable("simpleEleId60relIso");
00507     if (isIDCalc) {
00508       ele2nd_passes_selection = 0;
00509       if (fabs(mySecondElec->electronID("simpleEleId60relIso")-7) < 0.1) ele2nd_passes_selection = 6;
00510       else if (fabs(mySecondElec->electronID("simpleEleId70relIso")-7) < 0.1) ele2nd_passes_selection = 5;
00511       else if (fabs(mySecondElec->electronID("simpleEleId80relIso")-7) < 0.1) ele2nd_passes_selection = 4;
00512       else if (fabs(mySecondElec->electronID("simpleEleId85relIso")-7) < 0.1) ele2nd_passes_selection = 3;
00513       else if (fabs(mySecondElec->electronID("simpleEleId90relIso")-7) < 0.1) ele2nd_passes_selection = 2;
00514       else if (fabs(mySecondElec->electronID("simpleEleId95relIso")-7) < 0.1) ele2nd_passes_selection = 1;
00515     }
00516     if (storeAllSecondElectronVariables_) {
00517       ele2nd_iso_track = (Float_t)  mySecondElec->dr03IsolationVariables().tkSumPt / ele2nd_cand_et;
00518       ele2nd_iso_ecal  = (Float_t)  mySecondElec->dr03IsolationVariables().ecalRecHitSumEt/ele2nd_cand_et;
00519       ele2nd_iso_hcal  = (Float_t)  ( mySecondElec->dr03IsolationVariables().hcalDepth1TowerSumEt + 
00520                                       mySecondElec->dr03IsolationVariables().hcalDepth2TowerSumEt) / ele2nd_cand_et;
00521       ele2nd_id_sihih  = (Float_t)  mySecondElec->sigmaIetaIeta();
00522       ele2nd_id_deta   = (Float_t)  mySecondElec->deltaEtaSuperClusterTrackAtVtx();
00523       ele2nd_id_dphi   = (Float_t)  mySecondElec->deltaPhiSuperClusterTrackAtVtx();
00524       ele2nd_id_hoe    = (Float_t)  mySecondElec->hadronicOverEm();
00525 
00526       ele2nd_cr_mhitsinner = mySecondElec->gsfTrack()->trackerExpectedHitsInner().numberOfHits();
00527       ele2nd_cr_dcot       = mySecondElec->convDcot();
00528       ele2nd_cr_dist       = mySecondElec->convDist();
00529       
00530       ele2nd_vx        = (Float_t) mySecondElec->vx();
00531       ele2nd_vy        = (Float_t) mySecondElec->vy();
00532       ele2nd_vz        = (Float_t) mySecondElec->vz();
00533       ele2nd_gsfCharge   = (Int_t) mySecondElec->gsfTrack()->charge();
00534       // must keep the ctf track collection, i.e. general track collection
00535       ele2nd_ctfCharge   = (Int_t) mySecondElec->closestCtfTrackRef().isNonnull() ? mySecondElec->closestCtfTrackRef()->charge():-9999;
00536       ele2nd_scPixCharge = (Int_t) mySecondElec->chargeInfo().scPixCharge;
00537       ele2nd_eop         = (Float_t) mySecondElec->eSuperClusterOverP();
00538       ele2nd_tip_bs      = (Float_t) -mySecondElec->dB();
00539       if (Vtx.size() > 0) {
00540         ele2nd_tip_pv      =   mySecondElec->gsfTrack()->dxy(Vtx[0].position());
00541       }
00542       if (VtxBS.size() > 0) {
00543         ele2nd_tip_pvbs      =   mySecondElec->gsfTrack()->dxy(VtxBS[0].position());
00544       }
00545       ele2nd_hltmatched_dr = mySecondElec->userFloat("HLTMatchingDR");
00546     }
00547   }
00548   // some extra information
00549   event_triggerDecision = -1;
00550   ele_hltmatched_dr = -999.;
00551   VtxTracksSize.clear();
00552   VtxNormalizedChi2.clear();
00553   VtxTracksSizeBS.clear();
00554   VtxNormalizedChi2BS.clear();
00555   if (storeExtraInformation_) {
00556     if (myElec->hasUserFloat("HLTMatchingDR")) {
00557       ele_hltmatched_dr = myElec->userFloat("HLTMatchingDR");
00558     }
00559     if (myElec->hasUserInt("triggerDecision")) {
00560       event_triggerDecision = myElec->userInt("triggerDecision");
00561     }
00562     // extra information related to the primary vtx collection
00563     for (Int_t i=0; i < (Int_t) Vtx.size(); ++i) {
00564       VtxTracksSize.push_back(Vtx[i].tracksSize());
00565       VtxNormalizedChi2.push_back(Vtx[i].normalizedChi2());
00566     }
00567     for (Int_t i=0; i < (Int_t) VtxBS.size(); ++i) {
00568       VtxTracksSizeBS.push_back(VtxBS[i].tracksSize());
00569       VtxNormalizedChi2BS.push_back(VtxBS[i].normalizedChi2());
00570     }
00571   }
00572   // if the electron passes the selection
00573   // it is meant to be a precalculated selection here, in order to include
00574   // conversion rejection too
00575   if (CheckCuts(myElec) && myElec->userInt("failsSecondElectronCut") == 0) {
00576     vbtfSele_tree->Fill();
00577   }
00578   vbtfPresele_tree->Fill();
00579 
00580 
00581 
00582   //
00583   // _______________________________________________________________________
00584   //
00585   // histogram production --------------------------------------------------
00586   // _______________________________________________________________________
00587   //
00588   // if you want some preselection: Conv rejection, hit pattern 
00589   if (usePreselection_) {
00590     if (not PassPreselectionCriteria(myElec)) return;
00591   }
00592   //
00593   // some variables here
00594   Double_t scEta = myElec->superCluster()->eta();
00595   Double_t scPhi = myElec->superCluster()->phi();
00596   Double_t scEt = myElec->superCluster()->energy()/TMath::CosH(scEta);
00597   Double_t met    = myMet->et();
00598   Double_t metPhi = myMet->phi();
00599   Double_t mt  = TMath::Sqrt(2.0*scEt*met*(1.0-(TMath::Cos(scPhi)*TMath::Cos(metPhi)+TMath::Sin(scPhi)*TMath::Sin(metPhi))));
00600 
00601   Double_t trackIso = myElec->userIsolation(pat::TrackIso);
00602   Double_t ecalIso = myElec->userIsolation(pat::EcalIso);
00603   Double_t hcalIso = myElec->userIsolation(pat::HcalIso);
00604   Double_t sihih = myElec->scSigmaIEtaIEta();
00605   Double_t dphi = myElec->deltaPhiSuperClusterTrackAtVtx();
00606   Double_t deta = myElec->deltaEtaSuperClusterTrackAtVtx();
00607   Double_t HoE = myElec->hadronicOverEm();
00608   //
00609   //
00610   //
00611   // the inverted selection plots:
00612   // only if not using precalcID
00613   if (not usePrecalcID_) {
00614     if (CheckCutsInverse(myElec)){
00615       //std::cout << "-----------------INVERSION-----------passed" << std::endl;
00616       h_met_inverse->Fill(met);
00617       h_mt_inverse->Fill(mt);
00618       if(TMath::Abs(scEta)<1.479){
00619         h_met_inverse_EB->Fill(met);
00620         h_mt_inverse_EB->Fill(mt);
00621       }
00622       if(TMath::Abs(scEta)>1.479){
00623         h_met_inverse_EE->Fill(met);
00624         h_mt_inverse_EE->Fill(mt);
00625       }
00626     }
00627   }
00628   //
00630   //
00631   // N-1 plots: plot some variable so that all the other cuts are satisfied
00632   //
00633   // make these plots only if you have the normal selection, not pre-calced
00634   if (not usePrecalcID_) {
00635     if ( TMath::Abs(scEta) < 1.479) { // reminder: the precise fiducial cuts are in
00636       // in the filter
00637       if (CheckCutsNminusOne(myElec, 0)) 
00638         h_trackIso_eb_NmOne->Fill(trackIso);
00639     }
00640     else {
00641       if (CheckCutsNminusOne(myElec, 0)) 
00642         h_trackIso_ee_NmOne->Fill(trackIso);
00643     }
00644   }
00645   //
00646   // SELECTION APPLICATION
00647   //
00648   // from here on you have only events that pass the full selection
00649   if (not CheckCuts(myElec)) return;
00651 
00652   h_met->Fill(met);
00653   h_mt->Fill(mt);
00654   if(TMath::Abs(scEta)<1.479){
00655     h_met_EB->Fill(met);
00656     h_mt_EB->Fill(mt);
00657 
00658     h_EB_trkiso->Fill( trackIso );
00659     h_EB_ecaliso->Fill( ecalIso );
00660     h_EB_hcaliso->Fill( hcalIso );
00661     h_EB_sIetaIeta->Fill( sihih );
00662     h_EB_dphi->Fill( dphi );
00663     h_EB_deta->Fill( deta );
00664     h_EB_HoE->Fill( HoE );
00665 
00666   }
00667   if(TMath::Abs(scEta)>1.479){
00668     h_met_EE->Fill(met);
00669     h_mt_EE->Fill(mt);
00670 
00671     h_EE_trkiso->Fill( trackIso );
00672     h_EE_ecaliso->Fill( ecalIso );
00673     h_EE_hcaliso->Fill( hcalIso );
00674     h_EE_sIetaIeta->Fill( sihih );
00675     h_EE_dphi->Fill( dphi );
00676     h_EE_deta->Fill( deta );
00677     h_EE_HoE->Fill( HoE );
00678 
00679   }
00680   // uncomment for debugging purposes
00681   /*
00682   std::cout << "tracIso: " <<  trackIso << ", " << myElec->trackIso() << ", ecaliso: " << ecalIso 
00683             << ", " << myElec->ecalIso() << ", hcaliso: " << hcalIso << ", "  << myElec->hcalIso() 
00684             << ", mishits: " 
00685             << myElec->gsfTrack()->trackerExpectedHitsInner().numberOfHits()
00686             << std::endl;
00687   std::cout << "Electron ID: 95relIso=" << myElec->electronID("simpleEleId95relIso")  
00688             << " 90relIso=" << myElec->electronID("simpleEleId90relIso") 
00689             << " 85relIso=" << myElec->electronID("simpleEleId85relIso") 
00690             << " 80relIso=" << myElec->electronID("simpleEleId80relIso") 
00691             << " 70relIso=" << myElec->electronID("simpleEleId70relIso") 
00692             << " 60relIso=" << myElec->electronID("simpleEleId60relIso") 
00693             << " 95cIso=" << myElec->electronID("simpleEleId95cIso") 
00694             << " 90cIso=" << myElec->electronID("simpleEleId90cIso") 
00695             << " 85cIso=" << myElec->electronID("simpleEleId85cIso") 
00696             << " 80cIso=" << myElec->electronID("simpleEleId80cIso") 
00697             << " 70cIso=" << myElec->electronID("simpleEleId70cIso") 
00698             << " 60cIso=" << myElec->electronID("simpleEleId60cIso") 
00699             << std::endl;
00700   std::cout << "mySelection: " << (CheckCuts(myElec) && PassPreselectionCriteria(myElec)) << endl;
00701   */
00702   h_scEt->Fill(scEt);
00703   h_scEta->Fill(scEta);
00704   h_scPhi->Fill(scPhi);
00705 
00706 }
00707 
00708 /***********************************************************************
00709  *
00710  *  Checking Cuts and making selections:
00711  *  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
00712  *  all the available methods take input a pointer to a  pat::Electron
00713  *
00714  *  Bool_t  CheckCuts(const pat::Electron *): 
00715  *                            true if the input selection is satisfied
00716  *  Bool_t  CheckCutsInverse(const pat::Electron *ele):
00717  *            true if the cuts with inverted the ones specified in the
00718  *            cfg are satisfied
00719  *  Bool_t  CheckCutsNminusOne(const pat::Electron *ele, int jj):
00720  *             true if all the cuts with cut #jj ignored are satisfied
00721  *
00722  ***********************************************************************/
00723 Bool_t WenuPlots::CheckCuts( const pat::Electron *ele)
00724 {
00725   if (usePrecalcID_) {
00726     if (not ele-> isElectronIDAvailable(usePrecalcIDType_)) {
00727       std::cout << "Error! not existing ID with name: "
00728                 << usePrecalcIDType_ << " function will return true!"
00729                 << std::endl;
00730       return true;
00731     }
00732     Double_t val = ele->electronID(usePrecalcIDType_);
00733     if (usePrecalcIDSign_ == "<") {
00734       return val < usePrecalcIDValue_;
00735     }
00736     else if (usePrecalcIDSign_ == ">") {
00737       return val > usePrecalcIDValue_;
00738     }
00739     else { // equality: it returns 0,1,2,3 but as float
00740       return TMath::Abs(val-usePrecalcIDValue_)<0.1;
00741     }
00742   } 
00743   else {
00744     for (int i=0; i<nBarrelVars_; ++i) {
00745       if (not CheckCut(ele, i)) return false;
00746     }
00747     return true;
00748   }
00749 }
00751 
00752 Bool_t WenuPlots::CheckCutsInverse(const pat::Electron *ele)
00753 {
00754   for (int i=0; i<nBarrelVars_; ++i){
00755     if ( CheckCutInv(ele, i) == false) return false;
00756   }
00757   return true;
00758 
00759 }
00761 Bool_t WenuPlots::CheckCutsNminusOne(const pat::Electron *ele, int jj)
00762 {
00763   for (int i=0; i<nBarrelVars_; ++i){
00764     if (i==jj) continue;
00765     if ( CheckCut(ele, i) == false) return false;
00766   }
00767   return true;
00768 }
00770 Bool_t WenuPlots::CheckCut(const pat::Electron *ele, int i) {
00771   Double_t fabseta = TMath::Abs(ele->superCluster()->eta());
00772   if ( fabseta<1.479) {
00773     return TMath::Abs(ReturnCandVar(ele, i)) < CutVars_[i];
00774   }
00775   return TMath::Abs(ReturnCandVar(ele, i)) < CutVars_[i+nBarrelVars_];
00776 }
00778 Bool_t WenuPlots::CheckCutInv(const pat::Electron *ele, int i) {
00779   Double_t fabseta = TMath::Abs(ele->superCluster()->eta());
00780   if ( fabseta<1.479) {
00781     if (InvVars_[i]) 
00782     return TMath::Abs(ReturnCandVar(ele, i))>CutVars_[i];
00783     return TMath::Abs(ReturnCandVar(ele, i)) < CutVars_[i];
00784   }
00785   if (InvVars_[i+nBarrelVars_]) {
00786     if (InvVars_[i])
00787       return TMath::Abs(ReturnCandVar(ele, i))>CutVars_[i+nBarrelVars_];    
00788   }
00789   return TMath::Abs(ReturnCandVar(ele, i)) < CutVars_[i+nBarrelVars_];
00790 }
00792 Double_t WenuPlots::ReturnCandVar(const pat::Electron *ele, int i) {
00793   if (i==0) return ele->dr03TkSumPt()/ele->p4().Pt();
00794   else if (i==1) return ele->dr03EcalRecHitSumEt()/ele->p4().Pt();
00795   else if (i==2) return ele->dr03HcalTowerSumEt()/ele->p4().Pt();
00796   else if (i==3) return ele->scSigmaIEtaIEta();
00797   else if (i==4) return ele->deltaPhiSuperClusterTrackAtVtx();
00798   else if (i==5) return ele->deltaEtaSuperClusterTrackAtVtx();
00799   else if (i==6) return ele->hadronicOverEm();
00800   else if (i==7) {
00801     if (ele->isEB()){
00802       return ( ele->dr03TkSumPt()+std::max(float(0.),ele->dr03EcalRecHitSumEt()-1)
00803                + ele->dr03HcalTowerSumEt())/ele->p4().Pt(); }
00804     else { // pedestal subtraction is only in barrel
00805       return ( ele->dr03TkSumPt()+ele->dr03EcalRecHitSumEt()
00806                + ele->dr03HcalTowerSumEt())/ele->p4().Pt(); }
00807   }
00808   //  else if (i==8) return ele->gsfTrack()->dxy(bspotPosition_);
00809   else if (i==8) return fabs(ele->dB());
00810   else if (i==9) return ele->eSuperClusterOverP();
00811   else if (i==10) return ele->userIsolation(pat::TrackIso);
00812   else if (i==11) return ele->userIsolation(pat::EcalIso);
00813   else if (i==12) return ele->userIsolation(pat::HcalIso);  
00814   std::cout << "Error in WenuPlots::ReturnCandVar" << std::endl;
00815   return -1.;
00816 
00817 }
00819 Bool_t WenuPlots::PassPreselectionCriteria(const pat::Electron *ele) {
00820   Bool_t passConvRej = true;
00821   Bool_t passPXB = true;
00822   Bool_t passEMH = true;
00823   if (useConversionRejection_) {
00824     if (ele->hasUserInt("PassConversionRejection")) {
00825       //std::cout << "con rej: " << ele->userInt("PassConversionRejection") << std::endl;
00826       if (not (ele->userInt("PassConversionRejection")==1)) passConvRej = false;
00827     }
00828     else {
00829       std::cout << "WenuPlots: WARNING: Conversion Rejection Request Disregarded: "
00830                 << "you must calculate it before " << std::endl;
00831       // return true;
00832     }
00833   }
00834   if (useValidFirstPXBHit_) {
00835     if (ele->hasUserInt("PassValidFirstPXBHit")) {
00836       //std::cout << "valid1stPXB: " << ele->userInt("PassValidFirstPXBHit") << std::endl;
00837       if (not (ele->userInt("PassValidFirstPXBHit")==1)) passPXB = false;
00838     }
00839     else {
00840       std::cout << "WenuPlots: WARNING: Valid First PXB Hit Request Disregarded: "
00841                 << "you must calculate it before " << std::endl;
00842       // return true;
00843     }
00844   }
00845   if (useExpectedMissingHits_) {
00846     if (ele->hasUserInt("NumberOfExpectedMissingHits")) {
00847       //std::cout << "missing hits: " << ele->userInt("NumberOfExpectedMissingHits") << std::endl;
00848       if (ele->userInt("NumberOfExpectedMissingHits")>maxNumberOfExpectedMissingHits_) 
00849         passEMH = false;
00850     }
00851     else {
00852       std::cout << "WenuPlots: WARNING: Number of Expected Missing Hits Request Disregarded: "
00853                 << "you must calculate it before " << std::endl;
00854       // return true;
00855     }
00856   }
00857   return passConvRej && passPXB && passEMH;
00858 }
00859 // ------------ method called once each job just before starting event loop  --
00860 void 
00861 WenuPlots::beginJob()
00862 {
00863   //std::cout << "In beginJob()" << std::endl;
00864   //  Double_t Pi = TMath::Pi();
00865   //  TString histo_file = outputFile_;
00866   //  histofile = new TFile( histo_file,"RECREATE");
00867 
00868   h_met         = new TH1F("h_met",         "h_met",         200, 0, 200);
00869   h_met_inverse = new TH1F("h_met_inverse", "h_met_inverse", 200, 0, 200);
00870 
00871   h_mt         = new TH1F("h_mt",         "h_mt",         200, 0, 200);
00872   h_mt_inverse = new TH1F("h_mt_inverse", "h_mt_inverse", 200, 0, 200);
00873 
00874 
00875   h_met_EB         = new TH1F("h_met_EB",         "h_met_EB",         200, 0, 200);
00876   h_met_inverse_EB = new TH1F("h_met_inverse_EB", "h_met_inverse_EB", 200, 0, 200);
00877 
00878   h_mt_EB         = new TH1F("h_mt_EB",         "h_mt_EB",         200, 0, 200);
00879   h_mt_inverse_EB = new TH1F("h_mt_inverse_EB", "h_mt_inverse_EB", 200, 0, 200);
00880 
00881 
00882   h_met_EE         = new TH1F("h_met_EE",         "h_met_EE",         200, 0, 200);
00883   h_met_inverse_EE = new TH1F("h_met_inverse_EE", "h_met_inverse_EE", 200, 0, 200);
00884 
00885   h_mt_EE         = new TH1F("h_mt_EE",         "h_mt_EE",         200, 0, 200);
00886   h_mt_inverse_EE = new TH1F("h_mt_inverse_EE", "h_mt_inverse_EE", 200, 0, 200);
00887 
00888 
00889   h_scEt  = new TH1F("h_scEt",  "h_scEt",  200,  0, 100);
00890   h_scEta = new TH1F("h_scEta", "h_scEta", 200, -3, 3);
00891   h_scPhi = new TH1F("h_scPhi", "h_scPhi", 200, -4, 4);
00892 
00893 
00894   //VALIDATION PLOTS
00895   //EB
00896   h_EB_trkiso = new TH1F("h_EB_trkiso","h_EB_trkiso",200 , 0.0, 9.0);
00897   h_EB_ecaliso = new TH1F("h_EB_ecaliso","h_EB_ecaliso",200, 0.0 , 9.0);
00898   h_EB_hcaliso = new TH1F("h_EB_hcaliso","h_EB_hcaliso",200, 0.0 , 9.0);
00899   h_EB_sIetaIeta = new TH1F("h_EB_sIetaIeta","h_EB_sIetaIeta",200, 0.0 , 0.02 );
00900   h_EB_dphi = new TH1F("h_EB_dphi","h_EB_dphi",200, -0.03 , 0.03 );
00901   h_EB_deta = new TH1F("h_EB_deta","h_EB_deta",200, -0.01 , 0.01) ;
00902   h_EB_HoE = new TH1F("h_EB_HoE","h_EB_HoE",200, 0.0 , 0.2 );
00903   //EE
00904   h_EE_trkiso = new TH1F("h_EE_trkiso","h_EE_trkiso",200 , 0.0, 9.0);
00905   h_EE_ecaliso = new TH1F("h_EE_ecaliso","h_EE_ecaliso",200, 0.0 , 9.0);
00906   h_EE_hcaliso = new TH1F("h_EE_hcaliso","h_EE_hcaliso",200, 0.0 , 9.0);
00907   h_EE_sIetaIeta = new TH1F("h_EE_sIetaIeta","h_EE_sIetaIeta",200, 0.0 , 0.1 );
00908   h_EE_dphi = new TH1F("h_EE_dphi","h_EE_dphi",200, -0.03 , 0.03 );
00909   h_EE_deta = new TH1F("h_EE_deta","h_EE_deta",200, -0.01 , 0.01) ;
00910   h_EE_HoE = new TH1F("h_EE_HoE","h_EE_HoE",200, 0.0 , 0.2 );
00911 
00912 
00913   //
00914   //
00915   h_trackIso_eb_NmOne = 
00916     new TH1F("h_trackIso_eb_NmOne","trackIso EB N-1 plot",80,0,8);
00917   h_trackIso_ee_NmOne = 
00918     new TH1F("h_trackIso_ee_NmOne","trackIso EE N-1 plot",80,0,8);
00919 
00920   
00921   // if you add some new variable change the nBarrelVars_ accordingly
00922   // reminder: in the current implementation you must have the same number
00923   //  of vars in both barrel and endcaps
00924   nBarrelVars_ = 13;
00925   //
00926   // Put EB variables together and EE variables together
00927   // number of barrel variables = number of endcap variable
00928   // if you don't want to use some variable put a very high cut
00929   CutVars_.push_back( trackIso_EB_ );//0
00930   CutVars_.push_back( ecalIso_EB_ ); //1
00931   CutVars_.push_back( hcalIso_EB_ ); //2
00932   CutVars_.push_back( sihih_EB_ );   //3
00933   CutVars_.push_back( dphi_EB_ );    //4
00934   CutVars_.push_back( deta_EB_ );    //5
00935   CutVars_.push_back( hoe_EB_ );     //6
00936   CutVars_.push_back( cIso_EB_ );    //7
00937   CutVars_.push_back( tip_bspot_EB_);//8
00938   CutVars_.push_back( eop_EB_ );     //9
00939   CutVars_.push_back( trackIsoUser_EB_ );//10
00940   CutVars_.push_back( ecalIsoUser_EB_  );//11
00941   CutVars_.push_back( hcalIsoUser_EB_  );//12
00942   //
00943   CutVars_.push_back( trackIso_EE_);//0
00944   CutVars_.push_back( ecalIso_EE_); //1
00945   CutVars_.push_back( hcalIso_EE_); //2
00946   CutVars_.push_back( sihih_EE_);   //3
00947   CutVars_.push_back( dphi_EE_);    //4
00948   CutVars_.push_back( deta_EE_);    //5
00949   CutVars_.push_back( hoe_EE_ );    //6 
00950   CutVars_.push_back( cIso_EE_ );   //7 
00951   CutVars_.push_back(tip_bspot_EE_);//8
00952   CutVars_.push_back( eop_EE_ );    //9
00953   CutVars_.push_back( trackIsoUser_EE_ );//10
00954   CutVars_.push_back( ecalIsoUser_EE_  );//11
00955   CutVars_.push_back( hcalIsoUser_EE_  );//12
00956   //
00957   InvVars_.push_back( trackIso_EB_inv);//0
00958   InvVars_.push_back( ecalIso_EB_inv); //1
00959   InvVars_.push_back( hcalIso_EB_inv); //2
00960   InvVars_.push_back( sihih_EB_inv);   //3
00961   InvVars_.push_back( dphi_EB_inv);    //4
00962   InvVars_.push_back( deta_EB_inv);    //5
00963   InvVars_.push_back( hoe_EB_inv);     //6
00964   InvVars_.push_back( cIso_EB_inv);    //7
00965   InvVars_.push_back(tip_bspot_EB_inv);//8
00966   InvVars_.push_back( eop_EB_inv);     //9
00967   InvVars_.push_back( trackIsoUser_EB_inv );//10
00968   InvVars_.push_back( ecalIsoUser_EB_inv  );//11
00969   InvVars_.push_back( hcalIsoUser_EB_inv  );//12
00970   //
00971   InvVars_.push_back( trackIso_EE_inv);//0
00972   InvVars_.push_back( ecalIso_EE_inv); //1
00973   InvVars_.push_back( hcalIso_EE_inv); //2
00974   InvVars_.push_back( sihih_EE_inv);   //3
00975   InvVars_.push_back( dphi_EE_inv);    //4
00976   InvVars_.push_back( deta_EE_inv);    //5
00977   InvVars_.push_back( hoe_EE_inv);     //6
00978   InvVars_.push_back( cIso_EE_inv);    //7
00979   InvVars_.push_back(tip_bspot_EE_inv);//8
00980   InvVars_.push_back( eop_EE_inv);     //9
00981   InvVars_.push_back( trackIsoUser_EE_inv );//10
00982   InvVars_.push_back( ecalIsoUser_EE_inv  );//11
00983   InvVars_.push_back( hcalIsoUser_EE_inv  );//12
00984   //
00985   //
00986   // ________________________________________________________________________
00987   //
00988   // The VBTF Root Tuples ---------------------------------------------------
00989   // ________________________________________________________________________
00990   //
00991   WENU_VBTFselectionFile_ = new TFile(TString(WENU_VBTFselectionFileName_),
00992                                       "RECREATE");
00993   
00994   vbtfSele_tree = new TTree("vbtfSele_tree",
00995                "Tree to store the W Candidates that pass the VBTF selection"); 
00996   vbtfSele_tree->Branch("runNumber", &runNumber, "runNumber/I");
00997   vbtfSele_tree->Branch("eventNumber", &eventNumber, "eventNumber/L");
00998   vbtfSele_tree->Branch("lumiSection", &lumiSection, "lumiSection/I");
00999   //
01000   vbtfSele_tree->Branch("ele_sc_gsf_et", &ele_sc_gsf_et,"ele_sc_gsf_et/F");
01001   vbtfSele_tree->Branch("ele_sc_energy", &ele_sc_energy,"ele_sc_energy/F");
01002   vbtfSele_tree->Branch("ele_sc_eta", &ele_sc_eta,"ele_sc_eta/F");
01003   vbtfSele_tree->Branch("ele_sc_phi", &ele_sc_phi,"ele_sc_phi/F");
01004   vbtfSele_tree->Branch("ele_sc_rho", &ele_sc_rho,"ele_sc_rho/F");
01005   vbtfSele_tree->Branch("ele_cand_et", &ele_cand_et, "ele_cand_et/F");
01006   vbtfSele_tree->Branch("ele_cand_eta", &ele_cand_eta,"ele_cand_eta/F");
01007   vbtfSele_tree->Branch("ele_cand_phi",&ele_cand_phi,"ele_cand_phi/F");
01008   vbtfSele_tree->Branch("ele_iso_track",&ele_iso_track,"ele_iso_track/F");
01009   vbtfSele_tree->Branch("ele_iso_ecal",&ele_iso_ecal,"ele_iso_ecal/F");
01010   vbtfSele_tree->Branch("ele_iso_hcal",&ele_iso_hcal,"ele_iso_hcal/F");
01011   vbtfSele_tree->Branch("ele_id_sihih",&ele_id_sihih,"ele_id_sihih/F");
01012   vbtfSele_tree->Branch("ele_id_deta",&ele_id_deta,"ele_id_deta/F");
01013   vbtfSele_tree->Branch("ele_id_dphi",&ele_id_dphi,"ele_id_dphi/F");
01014   vbtfSele_tree->Branch("ele_id_hoe",&ele_id_hoe,"ele_id_hoe/F");
01015   vbtfSele_tree->Branch("ele_cr_mhitsinner",&ele_cr_mhitsinner,"ele_cr_mhitsinner/I");
01016   vbtfSele_tree->Branch("ele_cr_dcot",&ele_cr_dcot,"ele_cr_dcot/F");
01017   vbtfSele_tree->Branch("ele_cr_dist",&ele_cr_dist,"ele_cr_dist/F");
01018   vbtfSele_tree->Branch("ele_vx",&ele_vx,"ele_vx/F");
01019   vbtfSele_tree->Branch("ele_vy",&ele_vy,"ele_vy/F");
01020   vbtfSele_tree->Branch("ele_vz",&ele_vz,"ele_vz/F");
01021   vbtfSele_tree->Branch("pv_x",&pv_x,"pv_x/F");
01022   vbtfSele_tree->Branch("pv_y",&pv_y,"pv_y/F");
01023   vbtfSele_tree->Branch("pv_z",&pv_z,"pv_z/F");
01024   vbtfSele_tree->Branch("ele_gsfCharge",&ele_gsfCharge,"ele_gsfCharge/I");
01025   vbtfSele_tree->Branch("ele_ctfCharge",&ele_ctfCharge,"ele_ctfCharge/I");
01026   vbtfSele_tree->Branch("ele_scPixCharge",&ele_scPixCharge,"ele_scPixCharge/I");
01027   vbtfSele_tree->Branch("ele_eop",&ele_eop,"ele_eop/F");
01028   vbtfSele_tree->Branch("ele_tip_bs",&ele_tip_bs,"ele_tip_bs/F");
01029   vbtfSele_tree->Branch("ele_tip_pv",&ele_tip_pv,"ele_tip_pv/F");
01030   vbtfSele_tree->Branch("ele_pin",&ele_pin,"ele_pin/F");
01031   vbtfSele_tree->Branch("ele_pout",&ele_pout,"ele_pout/F");
01032   vbtfSele_tree->Branch("event_caloMET",&event_caloMET,"event_caloMET/F");  
01033   vbtfSele_tree->Branch("event_pfMET",&event_pfMET,"event_pfMET/F");
01034   vbtfSele_tree->Branch("event_tcMET",&event_tcMET,"event_tcMET/F");
01035   vbtfSele_tree->Branch("event_caloMT",&event_caloMT,"event_caloMT/F");  
01036   vbtfSele_tree->Branch("event_pfMT",&event_pfMT,"event_pfMT/F");
01037   vbtfSele_tree->Branch("event_tcMT",&event_tcMT,"event_tcMT/F");
01038   vbtfSele_tree->Branch("event_caloMET_phi",&event_caloMET_phi,"event_caloMET_phi/F");  
01039   vbtfSele_tree->Branch("event_pfMET_phi",&event_pfMET_phi,"event_pfMET_phi/F");
01040   vbtfSele_tree->Branch("event_tcMET_phi",&event_tcMET_phi,"event_tcMET_phi/F");
01041   //
01042   // the extra jet variables:
01043   if (includeJetInformationInNtuples_) {
01044     vbtfSele_tree->Branch("calojet_et",calojet_et,"calojet_et[5]/F");
01045     vbtfSele_tree->Branch("calojet_eta",calojet_eta,"calojet_eta[5]/F");
01046     vbtfSele_tree->Branch("calojet_phi",calojet_phi,"calojet_phi[5]/F");
01047     vbtfSele_tree->Branch("pfjet_et",pfjet_et,"pfjet_et[5]/F");
01048     vbtfSele_tree->Branch("pfjet_eta",pfjet_eta,"pfjet_eta[5]/F");
01049     vbtfSele_tree->Branch("pfjet_phi",pfjet_phi,"pfjet_phi[5]/F");
01050   }
01051   if (storeExtraInformation_) {
01052     vbtfSele_tree->Branch("ele2nd_sc_gsf_et", &ele2nd_sc_gsf_et,"ele2nd_sc_gsf_et/F");
01053     vbtfSele_tree->Branch("ele2nd_passes_selection", &ele2nd_passes_selection,"ele2nd_passes_selection/I");
01054     vbtfSele_tree->Branch("ele2nd_ecalDriven",&ele2nd_ecalDriven,"ele2nd_ecalDriven/I");
01055     vbtfSele_tree->Branch("event_caloSumEt",&event_caloSumEt,"event_caloSumEt/F");  
01056     vbtfSele_tree->Branch("event_pfSumEt",&event_pfSumEt,"event_pfSumEt/F");
01057     vbtfSele_tree->Branch("event_tcSumEt",&event_tcSumEt,"event_tcSumEt/F");
01058   }
01059   vbtfSele_tree->Branch("event_datasetTag",&event_datasetTag,"event_dataSetTag/I");  
01060   // 
01061   //
01062   // everything after preselection
01063   //
01064   WENU_VBTFpreseleFile_ = new TFile(TString(WENU_VBTFpreseleFileName_),
01065                                     "RECREATE");
01066   
01067   vbtfPresele_tree = new TTree("vbtfPresele_tree",
01068             "Tree to store the W Candidates that pass the VBTF preselection"); 
01069   vbtfPresele_tree->Branch("runNumber", &runNumber, "runNumber/I");
01070   vbtfPresele_tree->Branch("eventNumber", &eventNumber, "eventNumber/L");
01071   vbtfPresele_tree->Branch("lumiSection", &lumiSection, "lumiSection/I");
01072   //
01073   vbtfPresele_tree->Branch("ele_sc_gsf_et", &ele_sc_gsf_et,"ele_sc_gsf_et/F");
01074   vbtfPresele_tree->Branch("ele_sc_energy", &ele_sc_energy,"ele_sc_energy/F");
01075   vbtfPresele_tree->Branch("ele_sc_eta", &ele_sc_eta,"ele_sc_eta/F");
01076   vbtfPresele_tree->Branch("ele_sc_phi", &ele_sc_phi,"ele_sc_phi/F");
01077   vbtfPresele_tree->Branch("ele_sc_rho", &ele_sc_rho,"ele_sc_rho/F");
01078   vbtfPresele_tree->Branch("ele_cand_et", &ele_cand_et, "ele_cand_et/F");
01079   vbtfPresele_tree->Branch("ele_cand_eta", &ele_cand_eta,"ele_cand_eta/F");
01080   vbtfPresele_tree->Branch("ele_cand_phi",&ele_cand_phi,"ele_cand_phi/F");
01081   vbtfPresele_tree->Branch("ele_iso_track",&ele_iso_track,"ele_iso_track/F");
01082   vbtfPresele_tree->Branch("ele_iso_ecal",&ele_iso_ecal,"ele_iso_ecal/F");
01083   vbtfPresele_tree->Branch("ele_iso_hcal",&ele_iso_hcal,"ele_iso_hcal/F");
01084   vbtfPresele_tree->Branch("ele_id_sihih",&ele_id_sihih,"ele_id_sihih/F");
01085   vbtfPresele_tree->Branch("ele_id_deta",&ele_id_deta,"ele_id_deta/F");
01086   vbtfPresele_tree->Branch("ele_id_dphi",&ele_id_dphi,"ele_id_dphi/F");
01087   vbtfPresele_tree->Branch("ele_id_hoe",&ele_id_hoe,"ele_id_hoe/F");
01088   vbtfPresele_tree->Branch("ele_cr_mhitsinner",&ele_cr_mhitsinner,"ele_cr_mhitsinner/I");
01089   vbtfPresele_tree->Branch("ele_cr_dcot",&ele_cr_dcot,"ele_cr_dcot/F");
01090   vbtfPresele_tree->Branch("ele_cr_dist",&ele_cr_dist,"ele_cr_dist/F");
01091   vbtfPresele_tree->Branch("ele_vx",&ele_vx,"ele_vx/F");
01092   vbtfPresele_tree->Branch("ele_vy",&ele_vy,"ele_vy/F");
01093   vbtfPresele_tree->Branch("ele_vz",&ele_vz,"ele_vz/F");
01094   vbtfPresele_tree->Branch("pv_x",&pv_x,"pv_x/F");
01095   vbtfPresele_tree->Branch("pv_y",&pv_y,"pv_y/F");
01096   vbtfPresele_tree->Branch("pv_z",&pv_z,"pv_z/F");
01097   vbtfPresele_tree->Branch("ele_gsfCharge",&ele_gsfCharge,"ele_gsfCharge/I");
01098   vbtfPresele_tree->Branch("ele_ctfCharge",&ele_ctfCharge,"ele_ctfCharge/I");
01099   vbtfPresele_tree->Branch("ele_scPixCharge",&ele_scPixCharge,"ele_scPixCharge/I");
01100   vbtfPresele_tree->Branch("ele_eop",&ele_eop,"ele_eop/F");
01101   vbtfPresele_tree->Branch("ele_tip_bs",&ele_tip_bs,"ele_tip_bs/F");
01102   vbtfPresele_tree->Branch("ele_tip_pv",&ele_tip_pv,"ele_tip_pv/F");
01103   vbtfPresele_tree->Branch("ele_pin",&ele_pin,"ele_pin/F");
01104   vbtfPresele_tree->Branch("ele_pout",&ele_pout,"ele_pout/F");
01105   vbtfPresele_tree->Branch("event_caloMET",&event_caloMET,"event_caloMET/F");  
01106   vbtfPresele_tree->Branch("event_pfMET",&event_pfMET,"event_pfMET/F");
01107   vbtfPresele_tree->Branch("event_tcMET",&event_tcMET,"event_tcMET/F");
01108   vbtfPresele_tree->Branch("event_caloMT",&event_caloMT,"event_caloMT/F");  
01109   vbtfPresele_tree->Branch("event_pfMT",&event_pfMT,"event_pfMT/F");
01110   vbtfPresele_tree->Branch("event_tcMT",&event_tcMT,"event_tcMT/F");
01111   vbtfPresele_tree->Branch("event_caloMET_phi",&event_caloMET_phi,"event_caloMET_phi/F");  
01112   vbtfPresele_tree->Branch("event_pfMET_phi",&event_pfMET_phi,"event_pfMET_phi/F");
01113   vbtfPresele_tree->Branch("event_tcMET_phi",&event_tcMET_phi,"event_tcMET_phi/F");
01114   vbtfPresele_tree->Branch("event_caloSumEt",&event_caloSumEt,"event_caloSumEt/F");  
01115   vbtfPresele_tree->Branch("event_pfSumEt",&event_pfSumEt,"event_pfSumEt/F");
01116   vbtfPresele_tree->Branch("event_tcSumEt",&event_tcSumEt,"event_tcSumEt/F");
01117   // the extra jet variables:
01118   if (includeJetInformationInNtuples_) {
01119     vbtfPresele_tree->Branch("calojet_et",calojet_et,"calojet_et[5]/F");
01120     vbtfPresele_tree->Branch("calojet_eta",calojet_eta,"calojet_eta[5]/F");
01121     vbtfPresele_tree->Branch("calojet_phi",calojet_phi,"calojet_phi[5]/F");
01122     vbtfPresele_tree->Branch("pfjet_et",pfjet_et,"pfjet_et[5]/F");
01123     vbtfPresele_tree->Branch("pfjet_eta",pfjet_eta,"pfjet_eta[5]/F");
01124     vbtfPresele_tree->Branch("pfjet_phi",pfjet_phi,"pfjet_phi[5]/F");
01125   }
01126   if (storeExtraInformation_) {
01127     vbtfPresele_tree->Branch("ele2nd_sc_gsf_et",&ele2nd_sc_gsf_et,"ele2nd_sc_gsf_et/F");
01128     vbtfPresele_tree->Branch("ele2nd_sc_eta",&ele2nd_sc_eta,"ele2nd_sc_eta/F");
01129     vbtfPresele_tree->Branch("ele2nd_sc_phi",&ele2nd_sc_phi,"ele2nd_sc_phi/F");
01130     vbtfPresele_tree->Branch("ele2nd_sc_rho",&ele2nd_sc_rho,"ele2nd_sc_rho/F");
01131     vbtfPresele_tree->Branch("ele2nd_cand_eta",&ele2nd_cand_eta,"ele2nd_cand_eta/F");
01132     vbtfPresele_tree->Branch("ele2nd_cand_phi",&ele2nd_cand_phi,"ele2nd_cand_phi/F");
01133     vbtfPresele_tree->Branch("ele2nd_pin",&ele2nd_pin,"ele2nd_pin/F");
01134     vbtfPresele_tree->Branch("ele2nd_pout",&ele2nd_pout,"ele2nd_pout/F");
01135     vbtfPresele_tree->Branch("ele2nd_ecalDriven",&ele2nd_ecalDriven,"ele2nd_ecalDriven/I");
01136     vbtfPresele_tree->Branch("ele2nd_passes_selection",&ele2nd_passes_selection,"ele2nd_passes_selection/I");
01137     vbtfPresele_tree->Branch("ele_hltmatched_dr",&ele_hltmatched_dr,"ele_hltmatched_dr/F");
01138     vbtfPresele_tree->Branch("event_triggerDecision",&event_triggerDecision,"event_triggerDecision/I");
01139     vbtfPresele_tree->Branch("VtxTracksSize",&VtxTracksSize);
01140     vbtfPresele_tree->Branch("VtxNormalizedChi2",&VtxNormalizedChi2);
01141     vbtfPresele_tree->Branch("VtxTracksSizeBS",&VtxTracksSizeBS);
01142     vbtfPresele_tree->Branch("VtxNormalizedChi2BS",&VtxNormalizedChi2BS);
01143   }
01144   if (storeAllSecondElectronVariables_) {
01145     vbtfPresele_tree->Branch("ele2nd_cand_et",&ele2nd_cand_et,"ele2nd_cand_et/F");
01146     vbtfPresele_tree->Branch("ele2nd_iso_track",&ele2nd_iso_track ,"ele2nd_iso_track /F");
01147     vbtfPresele_tree->Branch("ele2nd_iso_ecal",&ele2nd_iso_ecal,"ele2nd_iso_ecal/F");
01148     vbtfPresele_tree->Branch("ele2nd_iso_hcal",&ele2nd_iso_hcal,"ele2nd_iso_hcal/F");
01149     vbtfPresele_tree->Branch("ele2nd_id_sihih",&ele2nd_id_sihih,"ele2nd_id_sihih/F");
01150     vbtfPresele_tree->Branch("ele2nd_id_deta",&ele2nd_id_deta,"ele2nd_id_deta/F");
01151     vbtfPresele_tree->Branch("ele2nd_id_dphi",&ele2nd_id_dphi,"ele2nd_id_dphi/F");
01152     vbtfPresele_tree->Branch("ele2nd_id_hoe",&ele2nd_id_hoe,"ele2nd_id_hoe/F");
01153     vbtfPresele_tree->Branch("ele2nd_cr_mhitsinner",&ele2nd_cr_mhitsinner,"ele2nd_cr_mhitsinner/I");
01154     vbtfPresele_tree->Branch("ele2nd_cr_dcot",&ele2nd_cr_dcot,"ele2nd_cr_dcot/F");
01155     vbtfPresele_tree->Branch("ele2nd_cr_dist",&ele2nd_cr_dist ,"ele2nd_cr_dist/F");
01156     vbtfPresele_tree->Branch("ele2nd_vx",&ele2nd_vx,"ele2nd_vx/F");
01157     vbtfPresele_tree->Branch("ele2nd_vy",&ele2nd_vy,"ele2nd_vy/F");
01158     vbtfPresele_tree->Branch("ele2nd_vz",&ele2nd_vz,"ele2nd_vz/F");
01159 
01160     vbtfPresele_tree->Branch("ele2nd_gsfCharge",&ele2nd_gsfCharge,"ele2nd_gsfCharge/I");
01161     vbtfPresele_tree->Branch("ele2nd_ctfCharge",&ele2nd_ctfCharge,"ele2nd_ctfCharge/I");
01162     vbtfPresele_tree->Branch("ele2nd_scPixCharge",&ele2nd_scPixCharge,"ele2nd_scPixCharge/I");
01163     vbtfPresele_tree->Branch("ele2nd_eop",&ele2nd_eop,"ele2nd_eop/F");
01164     vbtfPresele_tree->Branch("ele2nd_tip_bs",&ele2nd_tip_bs,"ele2nd_tip_bs/F");
01165     vbtfPresele_tree->Branch("ele2nd_tip_pv",&ele2nd_tip_pv,"ele2nd_tip_pv/F");
01166     vbtfPresele_tree->Branch("ele2nd_hltmatched_dr",&ele2nd_hltmatched_dr,"ele2nd_hltmatched_dr/F");
01167   }
01168   vbtfPresele_tree->Branch("event_datasetTag",&event_datasetTag,"event_dataSetTag/I");  
01169 
01170   //
01171   // _________________________________________________________________________
01172   //
01173   //
01174   //
01175 
01176 
01177 }
01178 
01179 // ------------ method called once each job just after ending the event loop  -
01180 void 
01181 WenuPlots::endJob() {
01182   TFile * newfile = new TFile(TString(outputFile_),"RECREATE");
01183   //
01184   // for consistency all the plots are in the root file
01185   // even though they may be empty (in the case when
01186   // usePrecalcID_== true inverted and N-1 are empty)
01187   h_met->Write();
01188   h_met_inverse->Write();
01189   h_mt->Write();
01190   h_mt_inverse->Write();
01191 
01192   h_met_EB->Write();
01193   h_met_inverse_EB->Write();
01194   h_mt_EB->Write();
01195   h_mt_inverse_EB->Write();
01196 
01197   h_met_EE->Write();
01198   h_met_inverse_EE->Write();
01199   h_mt_EE->Write();
01200   h_mt_inverse_EE->Write();
01201 
01202   h_scEt->Write();
01203   h_scEta->Write();
01204   h_scPhi->Write();
01205 
01206   h_EB_trkiso->Write();
01207   h_EB_ecaliso->Write();
01208   h_EB_hcaliso->Write();
01209   h_EB_sIetaIeta->Write();
01210   h_EB_dphi->Write();
01211   h_EB_deta->Write();
01212   h_EB_HoE->Write();
01213 
01214   h_EE_trkiso->Write();
01215   h_EE_ecaliso->Write();
01216   h_EE_hcaliso->Write();
01217   h_EE_sIetaIeta->Write();
01218   h_EE_dphi->Write();
01219   h_EE_deta->Write();
01220   h_EE_HoE->Write();
01221 
01222   //
01223   h_trackIso_eb_NmOne->Write();
01224   h_trackIso_ee_NmOne->Write();
01225   //
01226   newfile->Close();
01227   //
01228   // write the VBTF trees
01229   //
01230   WENU_VBTFpreseleFile_->Write();
01231   WENU_VBTFpreseleFile_->Close();
01232   WENU_VBTFselectionFile_->Write();
01233   WENU_VBTFselectionFile_->Close();
01234 
01235 }
01236 
01237 
01238 //define this as a plug-in
01239 DEFINE_FWK_MODULE(WenuPlots);