Go to the documentation of this file.00001
00002
00013 #include "FWCore/Framework/interface/EDProducer.h"
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "FWCore/Utilities/interface/InputTag.h"
00017
00018 #include "DataFormats/Common/interface/ValueMap.h"
00019 #include "DataFormats/Common/interface/View.h"
00020
00021 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00022 #include "DataFormats/Candidate/interface/Candidate.h"
00023 #include "PhysicsTools/TagAndProbe/interface/ColinsSoperVariables.h"
00024 #include "TLorentzVector.h"
00025
00026
00027 class ColinsSoperVariablesComputer : public edm::EDProducer {
00028 public:
00029 explicit ColinsSoperVariablesComputer(const edm::ParameterSet & iConfig);
00030 virtual ~ColinsSoperVariablesComputer() ;
00031
00032 virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup);
00033
00034 private:
00035 edm::InputTag parentBoson_;
00036 };
00037
00038 ColinsSoperVariablesComputer::ColinsSoperVariablesComputer(const edm::ParameterSet & iConfig) :
00039 parentBoson_(iConfig.getParameter<edm::InputTag>("parentBoson"))
00040 {
00041 produces<edm::ValueMap<float> >("costheta");
00042 produces<edm::ValueMap<float> >("sin2theta");
00043 produces<edm::ValueMap<float> >("tanphi");
00044 }
00045
00046
00047 ColinsSoperVariablesComputer::~ColinsSoperVariablesComputer()
00048 {
00049 }
00050
00051 void
00052 ColinsSoperVariablesComputer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) {
00053 using namespace edm;
00054
00055
00056 Handle<View<reco::Candidate> > bosons;
00057 iEvent.getByLabel(parentBoson_, bosons);
00058
00059
00060
00061 std::vector<float> values;
00062 std::vector<float> values2;
00063 std::vector<float> values3;
00064
00065
00066 double costheta = -10.0;
00067 double sin2theta = -10.0;
00068 double tanphi = -10.0;
00069
00070 const reco::Candidate* daughter1=NULL;
00071 const reco::Candidate* daughter2=NULL;
00072 TLorentzVector mu (0., 0., 0., 0.);
00073 TLorentzVector mubar (0., 0., 0., 0.);
00074 bool isOS = false;
00075 int charge1=0, charge2 =0;
00076 double res[3] = { -10., -10., -10.};
00077
00078 View<reco::Candidate>::const_iterator boson, endbosons = bosons->end();
00079
00080 for (boson = bosons->begin(); boson != endbosons; ++boson) {
00081
00082 daughter1 = boson->daughter(0);
00083 daughter2 = boson->daughter(1);
00084
00085 if( !(0==daughter1 || 0==daughter2) ) {
00086 isOS = false;
00087 charge1 = daughter1->charge();
00088 charge2 = daughter2->charge();
00089 isOS = charge1*charge2<0;
00090 if(isOS && charge1<0) {
00091 mu.SetPxPyPzE( daughter1->px(), daughter1->py(), daughter1->pz(), daughter1->energy() );
00092 mubar.SetPxPyPzE( daughter2->px(), daughter2->py(), daughter2->pz(), daughter2->energy() );
00093 }
00094 if(isOS && charge1>0) {
00095 mu.SetPxPyPzE( daughter2->px(), daughter2->py(), daughter2->pz(), daughter2->energy() );
00096 mubar.SetPxPyPzE( daughter1->px(), daughter1->py(), daughter1->pz(), daughter1->energy() );
00097 }
00098 }
00099
00100
00101 calCSVariables(mu, mubar, res, boson->pz()<0.0);
00102
00103 costheta = res[0];
00104 sin2theta = res[1];
00105 tanphi = res[2];
00106
00107 values.push_back(costheta);
00108 values2.push_back(sin2theta);
00109 values3.push_back(tanphi);
00110 }
00111
00112
00113
00114 std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
00115 ValueMap<float>::Filler filler(*valMap);
00116 filler.insert(bosons, values.begin(), values.end());
00117 filler.fill();
00118 iEvent.put(valMap, "costheta");
00119
00120
00121
00122 std::auto_ptr<ValueMap<float> > valMap2(new ValueMap<float>());
00123 ValueMap<float>::Filler filler2(*valMap2);
00124 filler2.insert(bosons, values2.begin(), values2.end());
00125 filler2.fill();
00126 iEvent.put(valMap2, "sin2theta");
00127
00128
00129 std::auto_ptr<ValueMap<float> > valMap3(new ValueMap<float>());
00130 ValueMap<float>::Filler filler3(*valMap3);
00131 filler3.insert(bosons, values3.begin(), values3.end());
00132 filler3.fill();
00133 iEvent.put(valMap3, "tanphi");
00134
00135 }
00136
00137
00138 #include "FWCore/Framework/interface/MakerMacros.h"
00139 DEFINE_FWK_MODULE(ColinsSoperVariablesComputer);