Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "DataFormats/Common/interface/Handle.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 
0010 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0011 #include "DataFormats/TrackReco/interface/Track.h"
0012 
0013 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
0014 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
0015 
0016 using namespace std;
0017 
0018 class MuIsoDepositAnalyzer : public edm::EDAnalyzer {
0019 public:
0020   MuIsoDepositAnalyzer(const edm::ParameterSet& conf);
0021   ~MuIsoDepositAnalyzer();
0022   virtual void beginJob();
0023   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0024   virtual void endJob() {}
0025 
0026 private:
0027   edm::InputTag theMuonLabel;
0028   std::vector<edm::InputTag> theIsoDepositInputTags;
0029   unsigned long theEventCount;
0030 };
0031 
0032 MuIsoDepositAnalyzer::MuIsoDepositAnalyzer(const edm::ParameterSet& conf)
0033     : theMuonLabel(conf.getUntrackedParameter<edm::InputTag>("MuonCollectionLabel")),
0034       theIsoDepositInputTags(conf.getUntrackedParameter<std::vector<edm::InputTag> >("DepositInputTags")),
0035       theEventCount(0) {
0036   LogDebug("MuIsoDepositAnalyzer") << " CTOR" << endl;
0037 }
0038 
0039 MuIsoDepositAnalyzer::~MuIsoDepositAnalyzer() {}
0040 
0041 void MuIsoDepositAnalyzer::beginJob() {}
0042 
0043 void MuIsoDepositAnalyzer::analyze(const edm::Event& ev, const edm::EventSetup& es) {
0044   LogDebug("MuIsoDepositAnalyzer::analyze") << " ============== analysis of event: " << ++theEventCount;
0045   edm::Handle<reco::TrackCollection> trackCollection;
0046   ev.getByLabel(theMuonLabel, trackCollection);
0047 
0048   unsigned int nDeps = theIsoDepositInputTags.size();
0049   std::vector<edm::Handle<reco::IsoDepositMap> > isoDeposits(nDeps);
0050   for (unsigned int iDep = 0; iDep < nDeps; ++iDep) {
0051     ev.getByLabel(theIsoDepositInputTags[iDep], isoDeposits[iDep]);
0052   }
0053 
0054   const reco::TrackCollection& muons = *(trackCollection.product());
0055   typedef reco::TrackCollection::const_iterator IT;
0056   unsigned int iMu = 0;
0057   for (IT it = muons.begin(), itEnd = muons.end(); it < itEnd; ++it) {
0058     LogTrace("") << "muon pt=" << (*it).pt();
0059     reco::TrackRef muRef(trackCollection, iMu);
0060     ++iMu;
0061     for (unsigned int iDep = 0; iDep < isoDeposits.size(); ++iDep) {
0062       const reco::IsoDeposit& dep = (*isoDeposits[iDep])[muRef];
0063       LogTrace("") << theIsoDepositInputTags[iDep] << dep.print();
0064     }
0065     for (int i = 0; i < 10; ++i) {
0066       float coneSize = 0.1 * i;
0067       LogTrace("") << " dR cone: " << coneSize << " isolationvariables: ";
0068       for (unsigned int iDep = 0; iDep < isoDeposits.size(); ++iDep) {
0069         const reco::IsoDeposit& dep = (*isoDeposits[iDep])[muRef];
0070         LogTrace("") << theIsoDepositInputTags[iDep] << " (eta, phi)= (" << dep.eta() << ", " << dep.phi()
0071                      << ") V(eta, phi)= (" << dep.veto().vetoDir.eta() << ", " << dep.veto().vetoDir.phi()
0072                      << ") muE= " << dep.candEnergy() << " " << dep.depositWithin(coneSize);
0073       }
0074     }
0075   }
0076 }
0077 
0078 DEFINE_FWK_MODULE(MuIsoDepositAnalyzer);