CMS 3D CMS Logo

ColinsSoperVariablesComputer.cc
Go to the documentation of this file.
1 //
2 
16 
19 
23 #include "TLorentzVector.h"
24 
26 public:
27  explicit ColinsSoperVariablesComputer(const edm::ParameterSet& iConfig);
29 
30  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
31 
32 private:
34 };
35 
37  : parentBosonToken_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("parentBoson"))) {
38  produces<edm::ValueMap<float>>("costheta");
39  produces<edm::ValueMap<float>>("sin2theta");
40  produces<edm::ValueMap<float>>("tanphi");
41 }
42 
44 
46  using namespace edm;
47 
48  // read input
50  iEvent.getByToken(parentBosonToken_, bosons);
51 
52  // prepare vector for output
53  std::vector<float> values;
54  std::vector<float> values2;
55  std::vector<float> values3;
56 
57  // fill: use brute force
58  double costheta = -10.0;
59  double sin2theta = -10.0;
60  double tanphi = -10.0;
61 
62  const reco::Candidate* daughter1 = nullptr;
63  const reco::Candidate* daughter2 = nullptr;
64  TLorentzVector mu(0., 0., 0., 0.);
65  TLorentzVector mubar(0., 0., 0., 0.);
66  bool isOS = false;
67  int charge1 = 0, charge2 = 0;
68  double res[3] = {-10., -10., -10.};
69 
70  View<reco::Candidate>::const_iterator boson, endbosons = bosons->end();
71 
72  for (boson = bosons->begin(); boson != endbosons; ++boson) {
73  daughter1 = boson->daughter(0);
74  daughter2 = boson->daughter(1);
75 
76  if (!(nullptr == daughter1 || nullptr == daughter2)) {
77  isOS = false;
78  charge1 = daughter1->charge();
79  charge2 = daughter2->charge();
80  isOS = charge1 * charge2 < 0;
81  if (isOS && charge1 < 0) {
82  mu.SetPxPyPzE(daughter1->px(), daughter1->py(), daughter1->pz(), daughter1->energy());
83  mubar.SetPxPyPzE(daughter2->px(), daughter2->py(), daughter2->pz(), daughter2->energy());
84  }
85  if (isOS && charge1 > 0) {
86  mu.SetPxPyPzE(daughter2->px(), daughter2->py(), daughter2->pz(), daughter2->energy());
87  mubar.SetPxPyPzE(daughter1->px(), daughter1->py(), daughter1->pz(), daughter1->energy());
88  }
89  }
90 
91  calCSVariables(mu, mubar, res, boson->pz() < 0.0);
92 
93  costheta = res[0];
94  sin2theta = res[1];
95  tanphi = res[2];
96 
97  values.push_back(costheta);
98  values2.push_back(sin2theta);
99  values3.push_back(tanphi);
100  }
101 
102  // convert into ValueMap and store
103  auto valMap = std::make_unique<ValueMap<float>>();
105  filler.insert(bosons, values.begin(), values.end());
106  filler.fill();
107  iEvent.put(std::move(valMap), "costheta");
108 
109  // ---> same for sin2theta
110  auto valMap2 = std::make_unique<ValueMap<float>>();
111  ValueMap<float>::Filler filler2(*valMap2);
112  filler2.insert(bosons, values2.begin(), values2.end());
113  filler2.fill();
114  iEvent.put(std::move(valMap2), "sin2theta");
115 
116  // ---> same for tanphi
117  auto valMap3 = std::make_unique<ValueMap<float>>();
118  ValueMap<float>::Filler filler3(*valMap3);
119  filler3.insert(bosons, values3.begin(), values3.end());
120  filler3.fill();
121  iEvent.put(std::move(valMap3), "tanphi");
122 }
123 
reco::Candidate::energy
virtual double energy() const =0
energy
reco::Candidate::daughter
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
ColinsSoperVariablesComputer
Definition: ColinsSoperVariablesComputer.cc:25
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
EDProducer.h
sistrip::View
View
Definition: ConstantsForView.h:26
ColinsSoperVariablesComputer::parentBosonToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > parentBosonToken_
Definition: ColinsSoperVariablesComputer.cc:33
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
ColinsSoperVariablesComputer::~ColinsSoperVariablesComputer
~ColinsSoperVariablesComputer() override
Definition: ColinsSoperVariablesComputer.cc:43
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
calCSVariables
void calCSVariables(TLorentzVector mu, TLorentzVector mubar, double *res, bool swap)
Definition: ColinsSoperVariables.h:10
edm::Handle
Definition: AssociativeIterator.h:50
ColinsSoperVariables.h
CandidateFwd.h
MakerMacros.h
reco::Candidate::pz
virtual double pz() const =0
z coordinate of momentum vector
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::Candidate::charge
virtual int charge() const =0
electric charge
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
reco::Candidate::py
virtual double py() const =0
y coordinate of momentum vector
ColinsSoperVariablesComputer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: ColinsSoperVariablesComputer.cc:45
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
RPCpg::mubar
const int mubar
Definition: Constants.h:23
res
Definition: Electron.h:6
InputTag.h
reco::Candidate
Definition: Candidate.h:27
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::Candidate::px
virtual double px() const =0
x coordinate of momentum vector
edm::ValueMap
Definition: ValueMap.h:107
edm::EDProducer
Definition: EDProducer.h:35
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
Candidate.h
View.h
ParameterSet.h
edm::Event
Definition: Event.h:73
ColinsSoperVariablesComputer::ColinsSoperVariablesComputer
ColinsSoperVariablesComputer(const edm::ParameterSet &iConfig)
Definition: ColinsSoperVariablesComputer.cc:36