Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "DPGAnalysis/Skims/interface/TagProbeMassProducer.h"
00023
00024 #include "DataFormats/Candidate/interface/Candidate.h"
00025 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00026 #include "DataFormats/Common/interface/AssociationMap.h"
00027
00028 #include "DataFormats/Math/interface/deltaR.h"
00029
00030
00031
00032 #include "FWCore/Framework/interface/MakerMacros.h"
00033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00034
00035 #include "Math/GenVector/VectorUtil.h"
00036
00037 TagProbeMassProducer::TagProbeMassProducer(const edm::ParameterSet& iConfig)
00038 {
00039 tagCollection_ = iConfig.getParameter<edm::InputTag>("TagCollection");
00040 probeCollection_ = iConfig.getParameter<edm::InputTag>("ProbeCollection");
00041 passingProbeCollection_ = iConfig.getParameter<edm::InputTag>("PassingProbeCollection");
00042
00043 massMinCut_ = iConfig.getUntrackedParameter<double>("MassMinCut",50.0);
00044 massMaxCut_ = iConfig.getUntrackedParameter<double>("MassMaxCut",120.0);
00045 delRMinCut_ = iConfig.getUntrackedParameter<double>("DelRMinCut",0.0);
00046 delRMaxCut_ = iConfig.getUntrackedParameter<double>("DelRMaxCut",10000.0);
00047
00048 requireOS_ = iConfig.getUntrackedParameter<bool>("RequireOS",true);
00049
00050 produces<std::vector<float> >("TPmass");
00051 }
00052
00053
00054 TagProbeMassProducer::~TagProbeMassProducer()
00055 {
00056
00057 }
00058
00059
00060
00061
00062
00063
00064
00065 void
00066 TagProbeMassProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00067 {
00068
00069
00070 std::auto_ptr<std::vector<float> > TPmass( new std::vector<float>);
00071
00072 if ( !iEvent.getByLabel( tagCollection_, tags ) ) {
00073 edm::LogWarning("TagProbe") << "Could not extract tag muons with input tag "
00074 << tagCollection_;
00075 }
00076
00077 if ( !iEvent.getByLabel( probeCollection_, probes ) ) {
00078 edm::LogWarning("TagProbe") << "Could not extract probe muons with input tag "
00079 << probeCollection_;
00080 }
00081
00082 if ( !iEvent.getByLabel( passingProbeCollection_, passingProbes ) ) {
00083 edm::LogWarning("TagProbe") << "Could not extract passing probe muons with input tag "
00084 << passingProbeCollection_;
00085 }
00086
00087
00088 if( tags.isValid() && probes.isValid() )
00089 {
00090 const edm::RefToBaseVector<reco::Candidate>& vtags = tags->refVector();
00091 const edm::RefToBaseVector<reco::Candidate>& vprobes = probes->refVector();
00092
00093 int itag = 0;
00094 edm::RefToBaseVector<reco::Candidate>::const_iterator tag = vtags.begin();
00095 for( ; tag != vtags.end(); ++tag, ++itag )
00096 {
00097 int iprobe = 0;
00098 edm::RefToBaseVector<reco::Candidate>::const_iterator probe = vprobes.begin();
00099 for( ; probe != vprobes.end(); ++probe, ++iprobe )
00100 {
00101
00102 double invMass = ROOT::Math::VectorUtil::InvariantMass((*tag)->p4(), (*probe)->p4());
00103 if( invMass < massMinCut_ ) continue;
00104 if( invMass > massMaxCut_ ) continue;
00105
00106
00107 double delR = reco::deltaR<double>((*tag)->eta(),(*tag)->phi(),(*probe)->eta(),(*probe)->phi());
00108 if( delR < delRMinCut_ ) continue;
00109 if( delR > delRMaxCut_ ) continue;
00110
00111
00112 int sign = (*tag)->charge() * (*probe)->charge();
00113 if( requireOS_ && sign > 0 ) continue;
00114
00115 bool isPassing = isPassingProbe (iprobe);
00116
00117 if (isPassing) TPmass->push_back(invMass);
00118 }
00119 }
00120 }
00121
00122
00123 iEvent.put( TPmass,"TPmass" );
00124 }
00125
00126
00127 void
00128 TagProbeMassProducer::beginJob()
00129 {
00130 }
00131
00132
00133 void
00134 TagProbeMassProducer::endJob() {
00135 }
00136
00137
00138 bool TagProbeMassProducer::isPassingProbe (const unsigned int iProbe) const {
00139
00140 if (iProbe > probes->size()) return false;
00141
00142 edm::RefToBase<reco::Candidate> probeRef = probes->refAt(iProbe);
00143 edm::RefToBase<reco::Candidate> passingProbeRef;
00144
00145 unsigned int numPassingProbes = passingProbes->size();
00146
00147 for (unsigned int iPassProbe = 0; iPassProbe < numPassingProbes; ++iPassProbe) {
00148 passingProbeRef = passingProbes->refAt(iPassProbe);
00149 if (passingProbeRef == probeRef) {
00150 return true;
00151 }
00152 }
00153 return false;
00154 }
00155
00156
00157 DEFINE_FWK_MODULE(TagProbeMassProducer);