16 #include "TLorentzVector.h"
26 LogDebug(
"Alignment") <<
"> applying two body decay Trackfilter ...";
27 theMassrangeSwitch =
cfg.getParameter<
bool>(
"applyMassrangeFilter");
28 if (theMassrangeSwitch) {
29 theMinMass =
cfg.getParameter<
double>(
"minXMass");
30 theMaxMass =
cfg.getParameter<
double>(
"maxXMass");
31 theDaughterMass =
cfg.getParameter<
double>(
"daughterMass");
32 theCandNumber =
cfg.getParameter<
unsigned int>(
"numberOfCandidates");
33 secThrBool =
cfg.getParameter<
bool>(
"applySecThreshold");
34 thesecThr =
cfg.getParameter<
double>(
"secondThreshold");
35 LogDebug(
"Alignment") <<
"> Massrange min,max : " << theMinMass <<
"," << theMaxMass
36 <<
"\n> Mass of daughter Particle : " << theDaughterMass;
43 theChargeSwitch =
cfg.getParameter<
bool>(
"applyChargeFilter");
44 if (theChargeSwitch) {
46 theUnsignedSwitch =
cfg.getParameter<
bool>(
"useUnsignedCharge");
47 if (theUnsignedSwitch)
49 LogDebug(
"Alignment") <<
"> Desired Charge, unsigned: " <<
theCharge <<
" , " << theUnsignedSwitch;
52 theUnsignedSwitch =
true;
54 theMissingETSwitch =
cfg.getParameter<
bool>(
"applyMissingETFilter");
55 if (theMissingETSwitch) {
58 LogDebug(
"Alignment") <<
"> missing Et Source: " << theMissingETSource;
60 theAcoplanarityFilterSwitch =
cfg.getParameter<
bool>(
"applyAcoplanarityFilter");
61 if (theAcoplanarityFilterSwitch) {
62 theAcoplanarDistance =
cfg.getParameter<
double>(
"acoplanarDistance");
63 LogDebug(
"Alignment") <<
"> Acoplanar Distance: " << theAcoplanarDistance;
73 return theMassrangeSwitch || theChargeSwitch || theAcoplanarityFilterSwitch;
83 if (theMassrangeSwitch) {
84 if (theMissingETSwitch)
90 LogDebug(
"Alignment") <<
"> TwoBodyDecay tracks all,kept: " <<
tracks.size() <<
"," <<
result.size();
100 if (
cands.size() < 2)
103 TLorentzVector track0;
104 TLorentzVector track1;
105 TLorentzVector mother;
106 typedef pair<const reco::Track*, const reco::Track*> constTrackPair;
107 typedef pair<double, constTrackPair> candCollectionItem;
108 vector<candCollectionItem> candCollection;
110 for (
unsigned int iCand = 0; iCand <
cands.size(); iCand++) {
111 track0.SetXYZT(
cands.at(iCand)->px(),
112 cands.at(iCand)->py(),
113 cands.at(iCand)->pz(),
114 sqrt(
cands.at(iCand)->p() *
cands.at(iCand)->p() + theDaughterMass * theDaughterMass));
116 for (
unsigned int jCand = iCand + 1; jCand <
cands.size(); jCand++) {
117 track1.SetXYZT(
cands.at(jCand)->px(),
118 cands.at(jCand)->py(),
119 cands.at(jCand)->pz(),
120 sqrt(
cands.at(jCand)->p() *
cands.at(jCand)->p() + theDaughterMass * theDaughterMass));
121 if (secThrBool ==
true && track1.Pt() < thesecThr && track0.Pt() < thesecThr)
123 mother = track0 + track1;
128 bool correctCharge =
true;
132 bool acoplanarTracks =
true;
133 if (theAcoplanarityFilterSwitch)
134 acoplanarTracks = this->checkAcoplanarity(trk1, trk2);
136 if (mother.M() > theMinMass && mother.M() < theMaxMass && correctCharge && acoplanarTracks) {
137 candCollection.push_back(candCollectionItem(mother.Pt(), constTrackPair(trk1, trk2)));
142 if (candCollection.empty())
145 sort(candCollection.begin(), candCollection.end(), [](
auto&
a,
auto&
b) {
return a.first >
b.first; });
147 std::map<const reco::Track*, unsigned int> uniqueTrackIndex;
148 std::map<const reco::Track*, unsigned int>::iterator it;
149 for (
unsigned int i = 0;
i < candCollection.size() &&
i < theCandNumber;
i++) {
150 constTrackPair& trackPair = candCollection[
i].second;
152 it = uniqueTrackIndex.find(trackPair.first);
153 if (it == uniqueTrackIndex.end()) {
154 result.push_back(trackPair.first);
155 uniqueTrackIndex[trackPair.first] =
i;
158 it = uniqueTrackIndex.find(trackPair.second);
159 if (it == uniqueTrackIndex.end()) {
160 result.push_back(trackPair.second);
161 uniqueTrackIndex[trackPair.second] =
i;
178 TLorentzVector
track;
180 TLorentzVector mother;
183 iEvent.getByToken(theMissingETToken, missingET);
185 LogError(
"Alignment") <<
"@SUB=AlignmentTwoBodyDecayTrackSelector::checkMETMass"
186 <<
"> could not optain missingET Collection!";
190 typedef pair<double, const reco::Track*> candCollectionItem;
191 vector<candCollectionItem> candCollection;
193 for (reco::CaloMETCollection::const_iterator itMET = missingET->begin(); itMET != missingET->end(); ++itMET) {
194 met4.SetXYZT((*itMET).px(), (*itMET).py(), (*itMET).pz(), (*itMET).p());
196 for (
unsigned int iCand = 0; iCand <
cands.size(); iCand++) {
198 cands.at(iCand)->py(),
199 cands.at(iCand)->pz(),
200 sqrt(
cands.at(iCand)->p() *
cands.at(iCand)->p() + theDaughterMass * theDaughterMass));
202 mother =
track + met4;
207 bool correctCharge =
true;
211 bool acoplanarTracks =
true;
212 if (theAcoplanarityFilterSwitch)
213 acoplanarTracks = this->checkMETAcoplanarity(trk,
met);
215 if (mother.M() > theMinMass && mother.M() < theMaxMass && correctCharge && acoplanarTracks) {
216 candCollection.push_back(candCollectionItem(mother.Pt(), trk));
221 if (candCollection.empty())
224 sort(candCollection.begin(), candCollection.end(), [](
auto&
a,
auto&
b) {
return a.first >
b.first; });
226 std::map<const reco::Track*, unsigned int> uniqueTrackIndex;
227 std::map<const reco::Track*, unsigned int>::iterator it;
228 for (
unsigned int i = 0;
i < candCollection.size() &&
i < theCandNumber;
i++) {
229 it = uniqueTrackIndex.find(candCollection[
i].
second);
230 if (it == uniqueTrackIndex.end()) {
232 uniqueTrackIndex[candCollection[
i].second] =
i;
241 int sumCharge = trk1->
charge();
243 sumCharge += trk2->
charge();
244 if (theUnsignedSwitch)
270 LogDebug(
"Alignment") <<
">......................................";
271 for (Tracks::const_iterator it =
col.begin(); it <
col.end(); ++it, ++
count) {
272 LogDebug(
"Alignment") <<
"> Track No. " <<
count <<
": p = (" << (*it)->px() <<
"," << (*it)->py() <<
","
273 << (*it)->pz() <<
")\n"
274 <<
"> pT = " << (*it)->pt() <<
" eta = " << (*it)->eta()
275 <<
" charge = " << (*it)->charge();
277 LogDebug(
"Alignment") <<
">......................................";