7 #include "TLorentzVector.h"
59 template <
typename varType>
63 if (varposition == -1)
64 std::cerr <<
"HIPTwoBodyDecayAnalyzer::setVal -> Could not find the branch called " << bname <<
"!" << std::endl;
72 std::cerr <<
"HIPTwoBodyDecayAnalyzer::setVal -> Could not find the type " << varbranchtype
73 <<
" for branch called " << bname <<
"!" << std::endl;
96 tree = fs->
make<TTree>(
"TestTree",
"");
101 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
107 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
122 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
128 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
142 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
146 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
157 const int nTrackTypes = 4;
158 std::vector<std::string> strTrackTypes;
159 strTrackTypes.reserve(nTrackTypes);
160 strTrackTypes.push_back(
"alcareco");
161 strTrackTypes.push_back(
"refit1");
162 strTrackTypes.push_back(
"refit2");
163 strTrackTypes.push_back(
"final");
164 for (
unsigned int it = 0; it < nTrackTypes; it++) {
209 std::cerr <<
"HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " <<
btype <<
" for the branch " << bname
210 <<
" is available." << std::endl;
217 std::cout <<
"Begin HIPTwoBodyDecayAnalyzer::actuateBranches" << std::endl;
221 if (
tree !=
nullptr) {
222 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
230 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
249 std::cerr <<
"HIPTwoBodyDecayAnalyzer::actuateBranch: Failed to actuate the branches!" << std::endl;
256 using namespace reco;
295 std::cout <<
"Starting to process the track collection for " << strTrackType << std::endl;
298 using namespace reco;
303 std::cout <<
"Track collection is invalid." << std::endl;
306 if (hTrackColl->size() < 2) {
308 std::cout <<
"Track collection size<2." << std::endl;
312 unsigned int itrk = 0;
315 bool isValidPair =
true;
317 TLorentzVector trackMom[2];
318 TLorentzVector trackMomAfterZVtxFit[2];
319 TVector3 trackVtx[2];
321 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
322 trackMom[jtrk].SetXYZT(0, 0, 0, 0);
323 trackVtx[jtrk].SetXYZ(0, 0, 0);
325 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
329 itrk = (
charge > 0 ? 1 : 0);
332 trackMom[itrk].SetPtEtaPhiM(
track->pt(),
track->eta(),
track->phi(), 0.105);
339 isValidPair = (totalcharge == 0 && trackMom[0].P() != 0. && trackMom[1].P() != 0.);
341 std::cout <<
"Track collection does not contain a valid std::pair." << std::endl;
342 setVal(strTrackType +
"_present", (isValidPair ? (
short)1 : (
short)0));
344 TLorentzVector ZMom = trackMom[0] + trackMom[1];
345 setVal(strTrackType +
"_ZPt", (
float)ZMom.Pt());
346 setVal(strTrackType +
"_ZPz", (
float)ZMom.Pz());
347 setVal(strTrackType +
"_ZPhi", (
float)ZMom.Phi());
348 setVal(strTrackType +
"_ZMass", (
float)ZMom.M());
352 setVal(strTrackType +
"_ZVertex_x", (
float)ZVtx.x());
353 setVal(strTrackType +
"_ZVertex_y", (
float)ZVtx.y());
354 setVal(strTrackType +
"_ZVertex_z", (
float)ZVtx.z());
355 setVal(strTrackType +
"_ZVertex_NormChi2", (
float)ZVtx.normalizedChi2());
359 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
364 GlobalVector mom = closestIn3DSpaceState.globalMomentum();
368 itrk = (
charge > 0 ? 1 : 0);
371 trackMomAfterZVtxFit[itrk].SetXYZT(mom.
x(), mom.
y(), mom.
z(),
sqrt(
pow(0.105, 2) +
pow(mom.
mag(), 2)));
376 if (totalcharge != 0)
378 <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Something went wrong! The total charge is no longer 0!"
380 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
381 std::string strMuCore = (jtrk == 0 ?
"MuMinus" :
"MuPlus");
382 setVal(strTrackType +
"_" + strMuCore +
"Pt_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].Pt());
383 setVal(strTrackType +
"_" + strMuCore +
"Pz_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].Pz());
384 setVal(strTrackType +
"_" + strMuCore +
"Phi_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].
Phi());
386 TLorentzVector ZMom_AfterZVtxFit = trackMomAfterZVtxFit[0] + trackMomAfterZVtxFit[1];
387 setVal(strTrackType +
"_ZPt_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pt());
388 setVal(strTrackType +
"_ZPz_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pz());
389 setVal(strTrackType +
"_ZPhi_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Phi());
390 setVal(strTrackType +
"_ZMass_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.M());
392 std::cerr <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Z vertex fit failed for track collection "
393 << strTrackType << std::endl;
395 setVal(strTrackType +
"_ZVtxFitOk", (ZVtxOk ? (
short)1 : (
short)0));
396 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
397 std::string strMuCore = (jtrk == 0 ?
"MuMinus" :
"MuPlus");
398 setVal(strTrackType +
"_" + strMuCore +
"Pt", (
float)trackMom[jtrk].Pt());
399 setVal(strTrackType +
"_" + strMuCore +
"Pz", (
float)trackMom[jtrk].Pz());
400 setVal(strTrackType +
"_" + strMuCore +
"Phi", (
float)trackMom[jtrk].
Phi());
401 setVal(strTrackType +
"_" + strMuCore +
"Vertex_x", (
float)trackVtx[jtrk].
X());
402 setVal(strTrackType +
"_" + strMuCore +
"Vertex_y", (
float)trackVtx[jtrk].
Y());
403 setVal(strTrackType +
"_" + strMuCore +
"Vertex_z", (
float)trackVtx[jtrk].
Z());
411 using namespace reco;
413 std::vector<TransientTrack> t_tks;
414 for (TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
426 stdVertex.totalChiSquared(),
427 stdVertex.degreesOfFreedom(),
429 return stdRecoVertex;
432 return stdRecoVertex;