Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:18

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "DataFormats/Common/interface/AssociationVector.h"
0009 #include "DataFormats/Common/interface/RefToBaseProd.h"
0010 
0011 #include "DataFormats/TrackReco/interface/Track.h"
0012 #include "DataFormats/MuonReco/interface/Muon.h"
0013 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
0014 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
0015 #include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h"
0016 
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include <string>
0019 
0020 #include <string>
0021 
0022 using reco::isodeposit::Direction;
0023 
0024 class CandIsoDumper : public edm::one::EDAnalyzer<> {
0025 public:
0026   CandIsoDumper(const edm::ParameterSet&);
0027 
0028   virtual ~CandIsoDumper();
0029 
0030   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0031 
0032 private:
0033   edm::EDGetTokenT<reco::IsoDepositMap> srcToken_;
0034 };
0035 
0036 /// constructor with config
0037 CandIsoDumper::CandIsoDumper(const edm::ParameterSet& par)
0038     : srcToken_(consumes<reco::IsoDepositMap>(par.getParameter<edm::InputTag>("src"))) {}
0039 
0040 /// destructor
0041 CandIsoDumper::~CandIsoDumper() {}
0042 
0043 /// build deposits
0044 void CandIsoDumper::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0045   using namespace reco::isodeposit;
0046   edm::Handle<reco::IsoDepositMap> hDeps;
0047   iEvent.getByToken(srcToken_, hDeps);
0048 
0049   static uint32_t event = 0;
0050   std::cout << "Dumping event " << (++event) << std::endl;
0051 
0052   uint32_t dep;
0053   typedef reco::IsoDepositMap::const_iterator iterator_i;
0054   typedef reco::IsoDepositMap::container::const_iterator iterator_ii;
0055   iterator_i depI = hDeps->begin();
0056   iterator_i depIEnd = hDeps->end();
0057   for (; depI != depIEnd; ++depI) {
0058     std::vector<double> retV(depI.size(), 0);
0059     edm::Handle<edm::View<reco::Candidate> > candH;
0060     iEvent.get(depI.id(), candH);
0061     edm::View<reco::Candidate>::const_iterator candII;
0062 
0063     iterator_ii depII;
0064     for (dep = 0, depII = depI.begin(), candII = candH->begin(); depII != depI.end(); ++depII, ++dep, ++candII) {
0065       std::cout << "  Dumping deposit " << (dep + 1) << std::endl;
0066       const reco::Candidate& cand = *candII;
0067       const reco::IsoDeposit& val = *depII;
0068       std::cout << "      Candidate pt " << cand.pt() << ", eta " << cand.eta() << ", phi " << cand.phi() << ", energy "
0069                 << cand.energy() << std::endl;
0070       std::cout << "      Deposit within 0.4 " << val.depositWithin(0.4, true) << "\n";
0071       reco::isodeposit::Direction candDir(cand.eta(), cand.phi());
0072       AbsVetos z2v;
0073       //reco::IsoDeposit::Vetos z2vOld;
0074       //z2vOld.push_back(reco::IsoDeposit::Veto(candDir,0.2));
0075       //std::cout << "Deposit within 0.7 - 0.2: OLDV " << val.depositWithin(0.7, z2vOld) << std::endl;
0076       //std::cout << "Deposit within 0.7 - 0.2: OLDV " << val.depositWithin(0.7, z2vOld, true) << std::endl;
0077       //z2v.push_back(new ConeVeto(candDir,0.2));
0078       //std::cout << "Deposit within 0.7 - 0.2: ABSV " << val.depositWithin(0.7, z2v) << std::endl;
0079       //std::cout << "Deposit within 0.7 - 0.2: ABSV " << val.depositWithin(0.7, z2v, true) << std::endl;
0080       //z2v.push_back(new AngleConeVeto(candDir,0.2));
0081       //std::cout << "      Deposit within 0.7 - A3DV(0.2) " << val.depositWithin(0.7, z2v) << std::endl;
0082 
0083       for (size_t i = 0; i < z2v.size(); i++) {
0084         delete z2v[i];
0085       }
0086       std::cout << "      Dumping deposit contents: "
0087                 << "\n";
0088       for (reco::IsoDeposit::const_iterator it = val.begin(), ed = val.end(); it != ed; ++it) {
0089         std::cout << "        + at dR(eta, phi) = " << it->dR() << " (" << it->eta() << ", " << it->phi()
0090                   << "): value = " << it->value() << "\n";
0091       }
0092       std::cout << "      -end of deposit: " << std::endl;
0093 
0094     }  //!for (depII)
0095   }  //!for (depI)
0096 }
0097 
0098 DEFINE_FWK_MODULE(CandIsoDumper);