Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:14

0001 // -*- C++ -*-
0002 //
0003 // Package:    RecoTauTag/RecoTau/rerunMVAIsolationOnMiniAOD
0004 // Class:      rerunMVAIsolationOnMiniAOD
0005 //
0006 /**\class rerunMVAIsolationOnMiniAOD rerunMVAIsolationOnMiniAOD.cc RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Alexander Nehrkorn
0015 //         Created:  Wed, 30 Mar 2016 13:39:51 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 
0031 #include "DataFormats/PatCandidates/interface/Tau.h"
0032 #include "DataFormats/PatCandidates/interface/PATTauDiscriminator.h"
0033 
0034 #include "DataFormats/TauReco/interface/PFTau.h"
0035 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0036 #include "DataFormats/TauReco/interface/PFTauDiscriminator.h"
0037 #include "DataFormats/TauReco/interface/PFTauTransverseImpactParameterAssociation.h"
0038 
0039 #include "RecoTauTag/RecoTau/interface/PFRecoTauClusterVariables.h"
0040 #include "RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h"
0041 
0042 #include "FWCore/ServiceRegistry/interface/Service.h"
0043 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0044 
0045 #include "TH1D.h"
0046 #include "TH2D.h"
0047 
0048 //
0049 // class declaration
0050 //
0051 
0052 // If the analyzer does not use TFileService, please remove
0053 // the template argument to the base class so the class inherits
0054 // from  edm::one::EDAnalyzer<> and also remove the line from
0055 // constructor "usesResource("TFileService");"
0056 // This will improve performance in multithreaded jobs.
0057 
0058 typedef edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef> >
0059     PFTauTIPAssociationByRef;
0060 
0061 class rerunMVAIsolationOnMiniAOD : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0062 public:
0063   explicit rerunMVAIsolationOnMiniAOD(const edm::ParameterSet&);
0064   ~rerunMVAIsolationOnMiniAOD();
0065 
0066   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0067 
0068 private:
0069   virtual void beginJob() override;
0070   virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
0071   virtual void endJob() override;
0072 
0073   // ----------member data ---------------------------
0074   bool verbosity_;
0075   bool additionalCollectionsAvailable_;
0076 
0077   edm::EDGetTokenT<pat::TauCollection> tauToken_;
0078   edm::EDGetTokenT<reco::PFTauCollection> pfTauToken_;
0079   edm::EDGetTokenT<reco::PFTauDiscriminator> dmfNewToken_;
0080   edm::EDGetTokenT<reco::PFTauDiscriminator> chargedIsoPtSumToken_;
0081   edm::EDGetTokenT<reco::PFTauDiscriminator> neutralIsoPtSumToken_;
0082   edm::EDGetTokenT<reco::PFTauDiscriminator> puCorrPtSumToken_;
0083   edm::EDGetTokenT<reco::PFTauDiscriminator> photonPtSumOutsideSignalConeToken_;
0084   edm::EDGetTokenT<reco::PFTauDiscriminator> footprintCorrectionToken_;
0085   edm::EDGetTokenT<reco::PFTauDiscriminator> rawElecMVA6Token_;
0086   edm::EDGetTokenT<PFTauTIPAssociationByRef> tauTIPToken_;
0087 
0088   TH1D* mvaValueAOD;
0089   TH1D* mvaValueMiniAOD;
0090   TH1D* mvaValueDiff;
0091 
0092   TH1D* differences;
0093   TH1D* differencesWeighted;
0094 
0095   TH1D* difference_dxy;
0096   TH1D* difference_dxySig;
0097   TH1D* difference_ip3d;
0098   TH1D* difference_ip3dSig;
0099   TH1D* difference_flightlengthSig;
0100   TH1D* difference_ptWeightedDetaStrip;
0101   TH1D* difference_ptWeightedDphiStrip;
0102   TH1D* difference_ptWeightedDrSignal;
0103   TH1D* difference_ptWeightedDrIso;
0104 
0105   TH2D* mvaValue;
0106   TH2D* mvaValue_vLoose;
0107   TH2D* mvaValue_Loose;
0108   TH2D* mvaValue_Medium;
0109   TH2D* mvaValue_Tight;
0110   TH2D* mvaValue_vTight;
0111   TH2D* mvaValue_vvTight;
0112 
0113   TH2D* decayMode;
0114   TH2D* chargedIsoPtSum;
0115   TH2D* neutralIsoPtSum;
0116   TH2D* puCorrPtSum;
0117   TH2D* photonPtSumOutsideSignalCone;
0118   TH2D* footprintCorrection;
0119 
0120   TH2D* decayDistMag;
0121   TH2D* dxy;
0122   TH2D* dxySig;
0123   TH2D* ip3d;
0124   TH2D* ip3dSig;
0125   TH2D* hasSV;
0126   TH2D* flightlengthSig;
0127   TH2D* nPhoton;
0128   TH2D* ptWeightedDetaStrip;
0129   TH2D* ptWeightedDphiStrip;
0130   TH2D* ptWeightedDrSignal;
0131   TH2D* ptWeightedDrIsolation;
0132   TH2D* leadTrackChi2;
0133   TH2D* eRatio;
0134   TH2D* mvaValue_antiEMVA6;
0135 };
0136 
0137 //
0138 // constants, enums and typedefs
0139 //
0140 
0141 //
0142 // static data member definitions
0143 //
0144 
0145 //
0146 // constructors and destructor
0147 //
0148 rerunMVAIsolationOnMiniAOD::rerunMVAIsolationOnMiniAOD(const edm::ParameterSet& iConfig)
0149 
0150 {
0151   //now do what ever initialization is needed
0152   tauToken_ = consumes<pat::TauCollection>(edm::InputTag("newTauIDsEmbedded"));
0153   pfTauToken_ = consumes<reco::PFTauCollection>(edm::InputTag("hpsPFTauProducer", "", "PAT"));
0154   dmfNewToken_ =
0155       consumes<reco::PFTauDiscriminator>(edm::InputTag("hpsPFTauDiscriminationByDecayModeFindingNewDMs", "", "PAT"));
0156   chargedIsoPtSumToken_ = consumes<reco::PFTauDiscriminator>(edm::InputTag("hpsPFTauChargedIsoPtSum", "", "PAT"));
0157   neutralIsoPtSumToken_ = consumes<reco::PFTauDiscriminator>(edm::InputTag("hpsPFTauNeutralIsoPtSum", "", "PAT"));
0158   puCorrPtSumToken_ = consumes<reco::PFTauDiscriminator>(edm::InputTag("hpsPFTauPUcorrPtSum", "", "PAT"));
0159   photonPtSumOutsideSignalConeToken_ =
0160       consumes<reco::PFTauDiscriminator>(edm::InputTag("hpsPFTauPhotonPtSumOutsideSignalCone", "", "PAT"));
0161   footprintCorrectionToken_ =
0162       consumes<reco::PFTauDiscriminator>(edm::InputTag("hpsPFTauFootprintCorrection", "", "PAT"));
0163   rawElecMVA6Token_ =
0164       consumes<reco::PFTauDiscriminator>(edm::InputTag("hpsPFTauDiscriminationagainstElectronMVA6Raw", "", "RECO"));
0165   tauTIPToken_ = consumes<PFTauTIPAssociationByRef>(edm::InputTag("hpsPFTauTransverseImpactParameters", "", "PAT"));
0166 
0167   verbosity_ = iConfig.getParameter<int>("verbosity");
0168   additionalCollectionsAvailable_ = iConfig.getParameter<bool>("additionalCollectionsAvailable");
0169 
0170   // book histograms
0171   edm::Service<TFileService> fileService;
0172   mvaValueAOD = fileService->make<TH1D>("mvaValueAOD", ";MVA value;", 220, -1.1, 1.1);
0173   mvaValueMiniAOD = fileService->make<TH1D>("mvaValueMiniAOD", ";MVA value;", 220, -1.1, 1.1);
0174   mvaValueDiff = fileService->make<TH1D>("mvaValueDiff", ";|AOD - MiniAOD|;", 2000, 0, 2);
0175 
0176   differences = fileService->make<TH1D>("differences", "", 24, -0.5, 23.5);
0177   differencesWeighted = fileService->make<TH1D>("differencesWeighted", "", 24, -0.5, 23.5);
0178 
0179   difference_dxy = fileService->make<TH1D>("difference_dxy", ";|AOD - MiniAOD| (dxy);", 1000, 0, 0.0005);
0180   difference_dxySig = fileService->make<TH1D>("difference_dxySig", ";|AOD - MiniAOD| (dxySig);", 1000, 0, 0.0005);
0181   difference_ip3d = fileService->make<TH1D>("difference_ip3d", ";|AOD - MiniAOD| (ip3d);", 1000, 0, 0.0005);
0182   difference_ip3dSig = fileService->make<TH1D>("difference_ip3dSig", ";|AOD - MiniAOD| (ip3dSig);", 1000, 0, 0.0005);
0183   difference_flightlengthSig =
0184       fileService->make<TH1D>("difference_flightlengthSig", ";|AOD - MiniAOD| (flightlengthSig);", 1000, 0, 0.0005);
0185   difference_ptWeightedDetaStrip = fileService->make<TH1D>(
0186       "difference_ptWeightedDetaStrip", ";|AOD - MiniAOD| (ptWeightedDetaStrip);", 1000, 0, 0.0005);
0187   difference_ptWeightedDphiStrip = fileService->make<TH1D>(
0188       "difference_ptWeightedDphiStrip", ";|AOD - MiniAOD| (ptWeightedDphiStrip);", 1000, 0, 0.0005);
0189   difference_ptWeightedDrSignal = fileService->make<TH1D>(
0190       "difference_ptWeightedDrSignal", ";|AOD - MiniAOD| (ptWeightedDrSignal);", 1000, 0, 0.0005);
0191   difference_ptWeightedDrIso =
0192       fileService->make<TH1D>("difference_ptWeightedDrIso", ";|AOD - MiniAOD| (ptWeightedDrIso);", 1000, 0, 0.0005);
0193 
0194   mvaValue = fileService->make<TH2D>("mvaValue", ";AOD;MiniAOD", 220, -1.1, 1.1, 220, -1.1, 1.1);
0195   mvaValue_vLoose = fileService->make<TH2D>("mvaValue_vLoose", ";AOD;MiniAOD", 2, -0.5, 1.5, 2, -0.5, 1.5);
0196   mvaValue_Loose = fileService->make<TH2D>("mvaValue_Loose", ";AOD;MiniAOD", 2, -0.5, 1.5, 2, -0.5, 1.5);
0197   mvaValue_Medium = fileService->make<TH2D>("mvaValue_Medium", ";AOD;MiniAOD", 2, -0.5, 1.5, 2, -0.5, 1.5);
0198   mvaValue_Tight = fileService->make<TH2D>("mvaValue_Tight", ";AOD;MiniAOD", 2, -0.5, 1.5, 2, -0.5, 1.5);
0199   mvaValue_vTight = fileService->make<TH2D>("mvaValue_vTight", ";AOD;MiniAOD", 2, -0.5, 1.5, 2, -0.5, 1.5);
0200   mvaValue_vvTight = fileService->make<TH2D>("mvaValue_vvTight", ";AOD;MiniAOD", 2, -0.5, 1.5, 2, -0.5, 1.5);
0201 
0202   decayMode =
0203       fileService->make<TH2D>("decayMode", ";decay mode (AOD);decay mode (MiniAOD)", 12, -0.5, 11.5, 12, -0.5, 11.5);
0204   chargedIsoPtSum = fileService->make<TH2D>(
0205       "chargedIsoPtSum", ";chargedIsoPtSum (AOD);chargedIsoPtSum (MiniAOD)", 500, 0, 50, 500, 0, 50);
0206   neutralIsoPtSum = fileService->make<TH2D>(
0207       "neutralIsoPtSum", ";neutralIsoPtSum (AOD);neutralIsoPtSum (MiniAOD)", 500, 0, 50, 500, 0, 50);
0208   puCorrPtSum =
0209       fileService->make<TH2D>("puCorrPtSum", ";puCorrPtSum (AOD);puCorrPtSum (MiniAOD)", 500, 0, 50, 500, 0, 50);
0210   photonPtSumOutsideSignalCone =
0211       fileService->make<TH2D>("photonPtSumOutsideSignalCone",
0212                               ";photonPtSumOutsideSignalCone (AOD);photonPtSumOutsideSignalCone (MiniAOD)",
0213                               500,
0214                               0,
0215                               50,
0216                               500,
0217                               0,
0218                               50);
0219   footprintCorrection = fileService->make<TH2D>(
0220       "footprintCorrection", ";footprintCorrection (AOD);footprintCorrection (MiniAOD)", 500, 0, 50, 500, 0, 50);
0221 
0222   decayDistMag =
0223       fileService->make<TH2D>("decayDistMag", ";decayDistMag (AOD);decayDistMag (MiniAOD)", 100, 0, 10, 100, 0, 10);
0224   dxy = fileService->make<TH2D>("dxy", ";d_{xy} (AOD);d_{xy} (MiniAOD)", 100, 0, 0.1, 100, 0, 0.1);
0225   dxySig = fileService->make<TH2D>(
0226       "dxySig", ";d_{xy} significance (AOD);d_{xy} significance (MiniAOD)", 10, -0.5, 9.5, 10, -0.5, 9.5);
0227   ip3d = fileService->make<TH2D>("ip3d", ";ip3d (AOD);ip3d (MiniAOD)", 100, 0, 10, 100, 0, 10);
0228   ip3dSig = fileService->make<TH2D>(
0229       "ip3dSig", ";ip3d significance (AOD);ip3d significance (MiniAOD)", 10, -0.5, 9.5, 10, -0.5, 9.5);
0230   hasSV = fileService->make<TH2D>("hasSV", ";has SV (AOD);has SV (MiniAOD)", 2, -0.5, 1.5, 2, -0.5, 1.5);
0231   flightlengthSig = fileService->make<TH2D>("flightlengthSig",
0232                                             ";flightlength significance (AOD);flightlength significance (MiniAOD)",
0233                                             21,
0234                                             -10.5,
0235                                             10.5,
0236                                             21,
0237                                             -10.5,
0238                                             10.5);
0239   nPhoton = fileService->make<TH2D>("nPhoton", ";nPhoton (AOD);nPhoton (MiniAOD)", 20, -0.5, 19.5, 20, -0.5, 19.5);
0240   ptWeightedDetaStrip = fileService->make<TH2D>(
0241       "ptWeightedDetaStrip", ";ptWeightedDetaStrip (AOD);ptWeightedDetaStrip (MiniAOD)", 50, 0, 0.5, 50, 0, 0.5);
0242   ptWeightedDphiStrip = fileService->make<TH2D>(
0243       "ptWeightedDphiStrip", ";ptWeightedDphiStrip (AOD);ptWeightedDphiStrip (MiniAOD)", 50, 0, 0.5, 50, 0, 0.5);
0244   ptWeightedDrSignal = fileService->make<TH2D>(
0245       "ptWeightedDrSignal", ";ptWeightedDrSignal (AOD);ptWeightedDrSignal (MiniAOD)", 50, 0, 0.5, 50, 0, 0.5);
0246   ptWeightedDrIsolation = fileService->make<TH2D>(
0247       "ptWeightedDrIsolation", ";ptWeightedDrIsolation (AOD);ptWeightedDrIsolation (MiniAOD)", 50, 0, 0.5, 50, 0, 0.5);
0248   leadTrackChi2 = fileService->make<TH2D>(
0249       "leadTrackChi2", ";leadTrackChi2 (AOD);leadTrackChi2 (MiniAOD)", 1000, 0, 100, 1000, 0, 100);
0250   eRatio = fileService->make<TH2D>("eRatio", ";eRatio (AOD);eRatio (MiniAOD)", 200, 0, 2, 200, 0, 2);
0251   mvaValue_antiEMVA6 = fileService->make<TH2D>("mvaValue_antiEMVA6", ";AOD;MiniAOD", 220, -1.1, 1.1, 220, -1.1, 1.1);
0252 }
0253 
0254 rerunMVAIsolationOnMiniAOD::~rerunMVAIsolationOnMiniAOD() {
0255   // do anything here that needs to be done at desctruction time
0256   // (e.g. close files, deallocate resources etc.)
0257 }
0258 
0259 //
0260 // member functions
0261 //
0262 
0263 // ------------ method called for each event  ------------
0264 void rerunMVAIsolationOnMiniAOD::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0265   edm::Handle<pat::TauCollection> taus;
0266   iEvent.getByToken(tauToken_, taus);
0267 
0268   std::vector<pat::TauRef> unmatchedTaus;
0269 
0270   for (unsigned iTau = 0; iTau < taus->size(); iTau++) {
0271     pat::TauRef tau(taus, iTau);
0272     float valueAOD = tau->tauID("byIsolationMVArun2v1DBoldDMwLTraw");
0273     float valueMiniAOD = tau->tauID("byIsolationMVArun2v1DBoldDMwLTrawNew");  //(*mvaIsoRaw)[tau];
0274 
0275     mvaValueAOD->Fill(valueAOD);
0276     mvaValueMiniAOD->Fill(valueMiniAOD);
0277 
0278     mvaValue->Fill(valueAOD, valueMiniAOD);
0279     mvaValue_vLoose->Fill(tau->tauID("byVLooseIsolationMVArun2v1DBoldDMwLT"),
0280                           tau->tauID("byVLooseIsolationMVArun2v1DBoldDMwLTNew"));
0281     mvaValue_Loose->Fill(tau->tauID("byLooseIsolationMVArun2v1DBoldDMwLT"),
0282                          tau->tauID("byLooseIsolationMVArun2v1DBoldDMwLTNew"));
0283     mvaValue_Medium->Fill(tau->tauID("byMediumIsolationMVArun2v1DBoldDMwLT"),
0284                           tau->tauID("byMediumIsolationMVArun2v1DBoldDMwLTNew"));
0285     mvaValue_Tight->Fill(tau->tauID("byTightIsolationMVArun2v1DBoldDMwLT"),
0286                          tau->tauID("byTightIsolationMVArun2v1DBoldDMwLTNew"));
0287     mvaValue_vTight->Fill(tau->tauID("byVTightIsolationMVArun2v1DBoldDMwLT"),
0288                           tau->tauID("byVTightIsolationMVArun2v1DBoldDMwLTNew"));
0289     mvaValue_vvTight->Fill(tau->tauID("byVVTightIsolationMVArun2v1DBoldDMwLT"),
0290                            tau->tauID("byVVTightIsolationMVArun2v1DBoldDMwLTNew"));
0291     mvaValueDiff->Fill(std::abs(valueAOD - valueMiniAOD));
0292     mvaValue_antiEMVA6->Fill(tau->tauID("againstElectronMVA6Raw"), tau->tauID("againstElectronMVA6RawNew"));
0293 
0294     if (valueAOD != valueMiniAOD)
0295       unmatchedTaus.push_back(tau);
0296   }
0297 
0298   // for the following code, four additional collections are needed:
0299   // - PFTaus
0300   // - PFTauTIPAssociationByRef (impact parameter info)
0301   // - PFCandidates
0302   // - Tracks
0303 
0304   if (additionalCollectionsAvailable_) {
0305     edm::Handle<reco::PFTauCollection> pfTaus;
0306     iEvent.getByToken(pfTauToken_, pfTaus);
0307 
0308     edm::Handle<reco::PFTauDiscriminator> dmfNew;
0309     iEvent.getByToken(dmfNewToken_, dmfNew);
0310 
0311     edm::Handle<reco::PFTauDiscriminator> chargedIso;
0312     iEvent.getByToken(chargedIsoPtSumToken_, chargedIso);
0313 
0314     edm::Handle<reco::PFTauDiscriminator> neutralIso;
0315     iEvent.getByToken(neutralIsoPtSumToken_, neutralIso);
0316 
0317     edm::Handle<reco::PFTauDiscriminator> puCorr;
0318     iEvent.getByToken(puCorrPtSumToken_, puCorr);
0319 
0320     edm::Handle<reco::PFTauDiscriminator> photonSumOutsideSignalCone;
0321     iEvent.getByToken(photonPtSumOutsideSignalConeToken_, photonSumOutsideSignalCone);
0322 
0323     edm::Handle<reco::PFTauDiscriminator> footPrint;
0324     iEvent.getByToken(footprintCorrectionToken_, footPrint);
0325 
0326     edm::Handle<PFTauTIPAssociationByRef> tauLifetimeInfos;
0327     iEvent.getByToken(tauTIPToken_, tauLifetimeInfos);
0328 
0329     for (unsigned iPFTau = 0; iPFTau < pfTaus->size(); iPFTau++) {
0330       reco::PFTauRef pfTau(pfTaus, iPFTau);
0331 
0332       if ((*dmfNew)[pfTau] < 0.5)
0333         continue;
0334 
0335       if ((float)pfTau->pt() < 18 || std::abs((float)pfTau->eta()) > 2.3)
0336         continue;
0337 
0338       for (unsigned iTau = 0; iTau < unmatchedTaus.size(); iTau++) {
0339         if ((float)pfTau->pt() != (float)unmatchedTaus.at(iTau)->pt())
0340           continue;
0341         if ((float)pfTau->eta() != (float)unmatchedTaus.at(iTau)->eta())
0342           continue;
0343         if ((float)pfTau->phi() != (float)unmatchedTaus.at(iTau)->phi())
0344           continue;
0345         if ((float)pfTau->energy() != (float)unmatchedTaus.at(iTau)->energy())
0346           continue;
0347 
0348         decayMode->Fill(pfTau->decayMode(), unmatchedTaus.at(iTau)->decayMode());
0349         chargedIsoPtSum->Fill((*chargedIso)[pfTau], unmatchedTaus.at(iTau)->tauID("chargedIsoPtSum"));
0350         neutralIsoPtSum->Fill((*neutralIso)[pfTau], unmatchedTaus.at(iTau)->tauID("neutralIsoPtSum"));
0351         puCorrPtSum->Fill((*puCorr)[pfTau], unmatchedTaus.at(iTau)->tauID("puCorrPtSum"));
0352         photonPtSumOutsideSignalCone->Fill((*photonSumOutsideSignalCone)[pfTau],
0353                                            unmatchedTaus.at(iTau)->tauID("photonPtSumOutsideSignalCone"));
0354         footprintCorrection->Fill((*footPrint)[pfTau], unmatchedTaus.at(iTau)->tauID("footprintCorrection"));
0355 
0356         const reco::PFTauTransverseImpactParameter& tauLifetimeInfo = *(*tauLifetimeInfos)[pfTau];
0357 
0358         float decayDistXAOD = tauLifetimeInfo.flightLength().x();
0359         float decayDistYAOD = tauLifetimeInfo.flightLength().y();
0360         float decayDistZAOD = tauLifetimeInfo.flightLength().z();
0361         float decayDistMagAOD =
0362             std::sqrt(decayDistXAOD * decayDistXAOD + decayDistYAOD * decayDistYAOD + decayDistZAOD * decayDistZAOD);
0363 
0364         float decayDistXMiniAOD = unmatchedTaus.at(iTau)->flightLength().x();
0365         float decayDistYMiniAOD = unmatchedTaus.at(iTau)->flightLength().y();
0366         float decayDistZMiniAOD = unmatchedTaus.at(iTau)->flightLength().z();
0367         float decayDistMagMiniAOD =
0368             std::sqrt(decayDistXMiniAOD * decayDistXMiniAOD + decayDistYMiniAOD * decayDistYMiniAOD +
0369                       decayDistZMiniAOD * decayDistZMiniAOD);
0370 
0371         decayDistMag->Fill(decayDistMagAOD, decayDistMagMiniAOD);
0372         dxy->Fill(tauLifetimeInfo.dxy(), unmatchedTaus.at(iTau)->dxy());
0373         dxySig->Fill(tauLifetimeInfo.dxy_Sig(), unmatchedTaus.at(iTau)->dxy_Sig());
0374         ip3d->Fill(tauLifetimeInfo.ip3d(), unmatchedTaus.at(iTau)->ip3d());
0375         ip3dSig->Fill(tauLifetimeInfo.ip3d_Sig(), unmatchedTaus.at(iTau)->ip3d_Sig());
0376         hasSV->Fill(tauLifetimeInfo.hasSecondaryVertex(), unmatchedTaus.at(iTau)->hasSecondaryVertex());
0377         flightlengthSig->Fill(tauLifetimeInfo.flightLengthSig(), unmatchedTaus.at(iTau)->flightLengthSig());
0378         nPhoton->Fill((float)reco::tau::n_photons_total(*pfTau),
0379                       (float)reco::tau::n_photons_total(*unmatchedTaus.at(iTau)));
0380         ptWeightedDetaStrip->Fill(
0381             reco::tau::pt_weighted_deta_strip(*pfTau, pfTau->decayMode()),
0382             reco::tau::pt_weighted_deta_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode()));
0383         ptWeightedDphiStrip->Fill(
0384             reco::tau::pt_weighted_dphi_strip(*pfTau, pfTau->decayMode()),
0385             reco::tau::pt_weighted_dphi_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode()));
0386         ptWeightedDrSignal->Fill(
0387             reco::tau::pt_weighted_dr_signal(*pfTau, pfTau->decayMode()),
0388             reco::tau::pt_weighted_dr_signal(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode()));
0389         ptWeightedDrIsolation->Fill(
0390             reco::tau::pt_weighted_dr_iso(*pfTau, pfTau->decayMode()),
0391             reco::tau::pt_weighted_dr_iso(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode()));
0392         leadTrackChi2->Fill(reco::tau::lead_track_chi2(*pfTau), unmatchedTaus.at(iTau)->leadingTrackNormChi2());
0393         eRatio->Fill(reco::tau::eratio(*pfTau), reco::tau::eratio(*unmatchedTaus.at(iTau)));
0394 
0395         if (verbosity_)
0396           std::cout << "=============================================================" << std::endl;
0397         if (pfTau->pt() != unmatchedTaus.at(iTau)->pt()) {
0398           if (verbosity_)
0399             std::cout << "pt: PF = " << pfTau->pt() << ", pat = " << unmatchedTaus.at(iTau)->pt() << std::endl;
0400           differences->Fill(0);
0401           differencesWeighted->Fill(0., std::abs(pfTau->pt() - unmatchedTaus.at(iTau)->pt()));
0402         }
0403         if (pfTau->eta() != unmatchedTaus.at(iTau)->eta()) {
0404           if (verbosity_)
0405             std::cout << "eta: PF = " << pfTau->eta() << ", pat = " << unmatchedTaus.at(iTau)->eta() << std::endl;
0406           differences->Fill(1);
0407           differencesWeighted->Fill(1, std::abs(pfTau->eta() - unmatchedTaus.at(iTau)->eta()));
0408         }
0409         if (pfTau->phi() != unmatchedTaus.at(iTau)->phi()) {
0410           if (verbosity_)
0411             std::cout << "phi: PF = " << pfTau->phi() << ", pat = " << unmatchedTaus.at(iTau)->phi() << std::endl;
0412           differences->Fill(2);
0413           differencesWeighted->Fill(2, std::abs(pfTau->phi() - unmatchedTaus.at(iTau)->phi()));
0414         }
0415         if (pfTau->energy() != unmatchedTaus.at(iTau)->energy()) {
0416           if (verbosity_)
0417             std::cout << "energy PF = " << pfTau->energy() << ", pat = " << unmatchedTaus.at(iTau)->energy()
0418                       << std::endl;
0419           differences->Fill(3);
0420           differencesWeighted->Fill(3, std::abs(pfTau->energy() - unmatchedTaus.at(iTau)->energy()));
0421         }
0422         if (pfTau->decayMode() != unmatchedTaus.at(iTau)->decayMode()) {
0423           if (verbosity_)
0424             std::cout << "decayMode: PF = " << pfTau->decayMode() << ", pat = " << unmatchedTaus.at(iTau)->decayMode()
0425                       << std::endl;
0426           differences->Fill(4);
0427           differencesWeighted->Fill(4, std::abs(pfTau->decayMode() - unmatchedTaus.at(iTau)->decayMode()));
0428         }
0429         if ((*chargedIso)[pfTau] != unmatchedTaus.at(iTau)->tauID("chargedIsoPtSum")) {
0430           if (verbosity_)
0431             std::cout << "chargedIso: PF = " << (*chargedIso)[pfTau]
0432                       << ", pat = " << unmatchedTaus.at(iTau)->tauID("chargedIsoPtSum") << std::endl;
0433           differences->Fill(5);
0434           differencesWeighted->Fill(5,
0435                                     std::abs((*chargedIso)[pfTau] - unmatchedTaus.at(iTau)->tauID("chargedIsoPtSum")));
0436         }
0437         if ((*neutralIso)[pfTau] != unmatchedTaus.at(iTau)->tauID("neutralIsoPtSum")) {
0438           if (verbosity_)
0439             std::cout << "neutralIso: PF = " << (*neutralIso)[pfTau]
0440                       << ", pat = " << unmatchedTaus.at(iTau)->tauID("neutralIsoPtSum") << std::endl;
0441           differences->Fill(6);
0442           differencesWeighted->Fill(6,
0443                                     std::abs((*neutralIso)[pfTau] - unmatchedTaus.at(iTau)->tauID("neutralIsoPtSum")));
0444         }
0445         if ((*puCorr)[pfTau] != unmatchedTaus.at(iTau)->tauID("puCorrPtSum")) {
0446           if (verbosity_)
0447             std::cout << "puCorr: PF = " << (*puCorr)[pfTau]
0448                       << ", pat = " << unmatchedTaus.at(iTau)->tauID("puCorrPtSum") << std::endl;
0449           differences->Fill(7);
0450           differencesWeighted->Fill(7, std::abs((*puCorr)[pfTau] - unmatchedTaus.at(iTau)->tauID("puCorrPtSum")));
0451         }
0452         if ((*photonSumOutsideSignalCone)[pfTau] != unmatchedTaus.at(iTau)->tauID("photonPtSumOutsideSignalCone")) {
0453           if (verbosity_)
0454             std::cout << "photonSumOutsideSignalCone: PF = " << (*photonSumOutsideSignalCone)[pfTau]
0455                       << ", pat = " << unmatchedTaus.at(iTau)->tauID("photonPtSumOutsideSignalCone") << std::endl;
0456           differences->Fill(8);
0457           differencesWeighted->Fill(8,
0458                                     std::abs((*photonSumOutsideSignalCone)[pfTau] -
0459                                              unmatchedTaus.at(iTau)->tauID("photonPtSumOutsideSignalCone")));
0460         }
0461         if ((*footPrint)[pfTau] != unmatchedTaus.at(iTau)->tauID("footprintCorrection")) {
0462           if (verbosity_)
0463             std::cout << "footPrint: PF = " << (*footPrint)[pfTau]
0464                       << ", pat = " << unmatchedTaus.at(iTau)->tauID("footprintCorrection") << std::endl;
0465           differences->Fill(9);
0466           differencesWeighted->Fill(
0467               9, std::abs((*footPrint)[pfTau] - unmatchedTaus.at(iTau)->tauID("footprintCorrection")));
0468         }
0469         if (decayDistMagAOD != decayDistMagMiniAOD) {
0470           if (verbosity_)
0471             std::cout << "decayDistMag: PF = " << decayDistMagAOD << ", pat = " << decayDistMagMiniAOD << std::endl;
0472           differences->Fill(10);
0473           differencesWeighted->Fill(10, std::abs(decayDistMagAOD - decayDistMagMiniAOD));
0474         }
0475         if (tauLifetimeInfo.dxy() != unmatchedTaus.at(iTau)->dxy()) {
0476           if (verbosity_)
0477             std::cout << "dxy: PF = " << tauLifetimeInfo.dxy() << ", pat = " << unmatchedTaus.at(iTau)->dxy()
0478                       << std::endl;
0479           differences->Fill(11);
0480           differencesWeighted->Fill(11, std::abs((float)tauLifetimeInfo.dxy() - unmatchedTaus.at(iTau)->dxy()));
0481           difference_dxy->Fill(std::abs(tauLifetimeInfo.dxy() - unmatchedTaus.at(iTau)->dxy()));
0482         }
0483         if (tauLifetimeInfo.dxy_Sig() != unmatchedTaus.at(iTau)->dxy_Sig()) {
0484           if (verbosity_)
0485             std::cout << "dxy_Sig: PF = " << tauLifetimeInfo.dxy_Sig()
0486                       << ", pat = " << unmatchedTaus.at(iTau)->dxy_Sig() << std::endl;
0487           differences->Fill(12);
0488           differencesWeighted->Fill(12, std::abs((float)tauLifetimeInfo.dxy_Sig() - unmatchedTaus.at(iTau)->dxy_Sig()));
0489           difference_dxySig->Fill(std::abs(tauLifetimeInfo.dxy_Sig() - unmatchedTaus.at(iTau)->dxy_Sig()));
0490         }
0491         if (tauLifetimeInfo.ip3d() != unmatchedTaus.at(iTau)->ip3d()) {
0492           if (verbosity_)
0493             std::cout << "ip3d PF: = " << tauLifetimeInfo.ip3d() << ", pat = " << unmatchedTaus.at(iTau)->ip3d()
0494                       << std::endl;
0495           differences->Fill(13);
0496           differencesWeighted->Fill(13, std::abs((float)tauLifetimeInfo.ip3d() - unmatchedTaus.at(iTau)->ip3d()));
0497           difference_ip3d->Fill(std::abs(tauLifetimeInfo.ip3d() - unmatchedTaus.at(iTau)->ip3d()));
0498         }
0499         if (tauLifetimeInfo.ip3d_Sig() != unmatchedTaus.at(iTau)->ip3d_Sig()) {
0500           if (verbosity_)
0501             std::cout << "ip3d_Sig: PF = " << tauLifetimeInfo.ip3d_Sig()
0502                       << ", pat = " << unmatchedTaus.at(iTau)->ip3d_Sig() << std::endl;
0503           differences->Fill(14);
0504           differencesWeighted->Fill(14,
0505                                     std::abs((float)tauLifetimeInfo.ip3d_Sig() - unmatchedTaus.at(iTau)->ip3d_Sig()));
0506           difference_ip3dSig->Fill(std::abs(tauLifetimeInfo.ip3d_Sig() - unmatchedTaus.at(iTau)->ip3d_Sig()));
0507         }
0508         if (tauLifetimeInfo.hasSecondaryVertex() != unmatchedTaus.at(iTau)->hasSecondaryVertex()) {
0509           if (verbosity_)
0510             std::cout << "hasSV: PF = " << tauLifetimeInfo.hasSecondaryVertex()
0511                       << ", pat = " << unmatchedTaus.at(iTau)->hasSecondaryVertex() << std::endl;
0512           differences->Fill(15);
0513           differencesWeighted->Fill(
0514               15, std::abs((float)tauLifetimeInfo.hasSecondaryVertex() - unmatchedTaus.at(iTau)->hasSecondaryVertex()));
0515         }
0516         if (tauLifetimeInfo.flightLengthSig() != unmatchedTaus.at(iTau)->flightLengthSig()) {
0517           if (verbosity_)
0518             std::cout << "flightlengthSig: PF = " << tauLifetimeInfo.flightLengthSig()
0519                       << ", pat = " << unmatchedTaus.at(iTau)->flightLengthSig() << std::endl;
0520           differences->Fill(16);
0521           differencesWeighted->Fill(
0522               16, std::abs((float)tauLifetimeInfo.flightLengthSig() - unmatchedTaus.at(iTau)->flightLengthSig()));
0523           difference_flightlengthSig->Fill(
0524               std::abs(tauLifetimeInfo.flightLengthSig() - unmatchedTaus.at(iTau)->flightLengthSig()));
0525         }
0526         if ((float)reco::tau::n_photons_total(*pfTau) != (float)reco::tau::n_photons_total(*unmatchedTaus.at(iTau))) {
0527           if (verbosity_)
0528             std::cout << "nPhoton PF: = " << (float)reco::tau::n_photons_total(*pfTau)
0529                       << ", pat = " << (float)reco::tau::n_photons_total(*unmatchedTaus.at(iTau)) << std::endl;
0530           differences->Fill(17);
0531           differencesWeighted->Fill(17,
0532                                     std::abs((float)reco::tau::n_photons_total(*pfTau) -
0533                                              (float)reco::tau::n_photons_total(*unmatchedTaus.at(iTau))));
0534         }
0535         if (reco::tau::pt_weighted_deta_strip(*pfTau, pfTau->decayMode()) !=
0536             reco::tau::pt_weighted_deta_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())) {
0537           if (verbosity_)
0538             std::cout << "ptWeightedDetaStrip: PF = " << reco::tau::pt_weighted_deta_strip(*pfTau, pfTau->decayMode())
0539                       << ", pat = "
0540                       << reco::tau::pt_weighted_deta_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())
0541                       << std::endl;
0542           differences->Fill(18);
0543           differencesWeighted->Fill(18,
0544                                     std::abs(reco::tau::pt_weighted_deta_strip(*pfTau, pfTau->decayMode()) -
0545                                              reco::tau::pt_weighted_deta_strip(*unmatchedTaus.at(iTau),
0546                                                                                unmatchedTaus.at(iTau)->decayMode())));
0547           difference_ptWeightedDetaStrip->Fill(std::abs(
0548               reco::tau::pt_weighted_deta_strip(*pfTau, pfTau->decayMode()) -
0549               reco::tau::pt_weighted_deta_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())));
0550         }
0551         if (reco::tau::pt_weighted_dphi_strip(*pfTau, pfTau->decayMode()) !=
0552             reco::tau::pt_weighted_dphi_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())) {
0553           if (verbosity_)
0554             std::cout << "ptWeightedDphiStrip: PF = " << reco::tau::pt_weighted_dphi_strip(*pfTau, pfTau->decayMode())
0555                       << ", pat = "
0556                       << reco::tau::pt_weighted_dphi_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())
0557                       << std::endl;
0558           differences->Fill(19);
0559           differencesWeighted->Fill(19,
0560                                     std::abs(reco::tau::pt_weighted_dphi_strip(*pfTau, pfTau->decayMode()) -
0561                                              reco::tau::pt_weighted_dphi_strip(*unmatchedTaus.at(iTau),
0562                                                                                unmatchedTaus.at(iTau)->decayMode())));
0563           difference_ptWeightedDphiStrip->Fill(std::abs(
0564               reco::tau::pt_weighted_dphi_strip(*pfTau, pfTau->decayMode()) -
0565               reco::tau::pt_weighted_dphi_strip(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())));
0566         }
0567         if (reco::tau::pt_weighted_dr_signal(*pfTau, pfTau->decayMode()) !=
0568             reco::tau::pt_weighted_dr_signal(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())) {
0569           if (verbosity_)
0570             std::cout << "ptWeightedDrSignal: PF = " << reco::tau::pt_weighted_dr_signal(*pfTau, pfTau->decayMode())
0571                       << ", pat = "
0572                       << reco::tau::pt_weighted_dr_signal(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())
0573                       << std::endl;
0574           differences->Fill(20);
0575           differencesWeighted->Fill(
0576               20,
0577               std::abs(reco::tau::pt_weighted_dr_signal(*pfTau, pfTau->decayMode()) -
0578                        reco::tau::pt_weighted_dr_signal(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())));
0579           difference_ptWeightedDrSignal->Fill(
0580               std::abs(reco::tau::pt_weighted_dr_signal(*pfTau, pfTau->decayMode()) -
0581                        reco::tau::pt_weighted_dr_signal(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())));
0582         }
0583         if (reco::tau::pt_weighted_dr_iso(*pfTau, pfTau->decayMode()) !=
0584             reco::tau::pt_weighted_dr_iso(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())) {
0585           if (verbosity_)
0586             std::cout << "ptWeightedDrIso: PF = " << reco::tau::pt_weighted_dr_iso(*pfTau, pfTau->decayMode())
0587                       << ", pat = "
0588                       << reco::tau::pt_weighted_dr_iso(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())
0589                       << std::endl;
0590           differences->Fill(21);
0591           differencesWeighted->Fill(
0592               21,
0593               std::abs(reco::tau::pt_weighted_dr_iso(*pfTau, pfTau->decayMode()) -
0594                        reco::tau::pt_weighted_dr_iso(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())));
0595           difference_ptWeightedDrIso->Fill(
0596               std::abs(reco::tau::pt_weighted_dr_iso(*pfTau, pfTau->decayMode()) -
0597                        reco::tau::pt_weighted_dr_iso(*unmatchedTaus.at(iTau), unmatchedTaus.at(iTau)->decayMode())));
0598         }
0599         if (reco::tau::lead_track_chi2(*pfTau) != unmatchedTaus.at(iTau)->leadingTrackNormChi2()) {
0600           if (verbosity_)
0601             std::cout << "leadTrackChi2: PF = " << reco::tau::lead_track_chi2(*pfTau)
0602                       << ", pat = " << unmatchedTaus.at(iTau)->leadingTrackNormChi2() << std::endl;
0603           differences->Fill(22);
0604           differencesWeighted->Fill(
0605               22, std::abs(reco::tau::lead_track_chi2(*pfTau) - unmatchedTaus.at(iTau)->leadingTrackNormChi2()));
0606         }
0607         if (reco::tau::eratio(*pfTau) != reco::tau::eratio(*unmatchedTaus.at(iTau))) {
0608           if (verbosity_)
0609             std::cout << "eRatio: PF = " << reco::tau::eratio(*pfTau)
0610                       << ", pat = " << reco::tau::eratio(*unmatchedTaus.at(iTau)) << std::endl;
0611           differences->Fill(23);
0612           differencesWeighted->Fill(23,
0613                                     std::abs(reco::tau::eratio(*pfTau) - reco::tau::eratio(*unmatchedTaus.at(iTau))));
0614         }
0615         if (verbosity_)
0616           std::cout << "=============================================================" << std::endl;
0617       }
0618     }
0619   }
0620 }
0621 
0622 // ------------ method called once each job just before starting event loop  ------------
0623 void rerunMVAIsolationOnMiniAOD::beginJob() {}
0624 
0625 // ------------ method called once each job just after ending the event loop  ------------
0626 void rerunMVAIsolationOnMiniAOD::endJob() {}
0627 
0628 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0629 void rerunMVAIsolationOnMiniAOD::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0630   //The following says we do not know what parameters are allowed so do no validation
0631   // Please change this to state exactly what you do use, even if it is no parameters
0632   edm::ParameterSetDescription desc;
0633   desc.setUnknown();
0634   descriptions.addDefault(desc);
0635 }
0636 
0637 //define this as a plug-in
0638 DEFINE_FWK_MODULE(rerunMVAIsolationOnMiniAOD);