7 #include "TLorentzVector.h" 62 template <
typename varType>
66 if (varposition == -1)
67 std::cerr <<
"HIPTwoBodyDecayAnalyzer::setVal -> Could not find the branch called " << bname <<
"!" << std::endl;
75 std::cerr <<
"HIPTwoBodyDecayAnalyzer::setVal -> Could not find the type " << varbranchtype
76 <<
" for branch called " << bname <<
"!" << std::endl;
102 tree =
fs->make<TTree>(
"TestTree",
"");
107 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
113 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
128 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
134 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
148 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
152 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
163 const int nTrackTypes = 4;
164 std::vector<std::string> strTrackTypes;
165 strTrackTypes.reserve(nTrackTypes);
166 strTrackTypes.push_back(
"alcareco");
167 strTrackTypes.push_back(
"refit1");
168 strTrackTypes.push_back(
"refit2");
169 strTrackTypes.push_back(
"final");
170 for (
unsigned int it = 0; it < nTrackTypes; it++) {
215 std::cerr <<
"HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " <<
btype <<
" for the branch " << bname
216 <<
" is available." << std::endl;
223 std::cout <<
"Begin HIPTwoBodyDecayAnalyzer::actuateBranches" << std::endl;
227 if (
tree !=
nullptr) {
228 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
236 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
255 std::cerr <<
"HIPTwoBodyDecayAnalyzer::actuateBranch: Failed to actuate the branches!" << std::endl;
262 using namespace reco;
299 std::cout <<
"Starting to process the track collection for " << strTrackType << std::endl;
302 using namespace reco;
307 std::cout <<
"Track collection is invalid." << std::endl;
310 if (hTrackColl->size() < 2) {
312 std::cout <<
"Track collection size<2." << std::endl;
316 unsigned int itrk = 0;
319 bool isValidPair =
true;
321 TLorentzVector trackMom[2];
322 TLorentzVector trackMomAfterZVtxFit[2];
323 TVector3 trackVtx[2];
325 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
326 trackMom[jtrk].SetXYZT(0, 0, 0, 0);
327 trackVtx[jtrk].SetXYZ(0, 0, 0);
329 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
333 itrk = (
charge > 0 ? 1 : 0);
336 trackMom[itrk].SetPtEtaPhiM(
track->pt(),
track->eta(),
track->phi(), 0.105);
343 isValidPair = (totalcharge == 0 && trackMom[0].P() != 0. && trackMom[1].P() != 0.);
345 std::cout <<
"Track collection does not contain a valid std::pair." << std::endl;
346 setVal(strTrackType +
"_present", (isValidPair ? (
short)1 : (
short)0));
348 TLorentzVector ZMom = trackMom[0] + trackMom[1];
349 setVal(strTrackType +
"_ZPt", (
float)ZMom.Pt());
350 setVal(strTrackType +
"_ZPz", (
float)ZMom.Pz());
351 setVal(strTrackType +
"_ZPhi", (
float)ZMom.Phi());
352 setVal(strTrackType +
"_ZMass", (
float)ZMom.M());
356 setVal(strTrackType +
"_ZVertex_x", (
float)ZVtx.x());
357 setVal(strTrackType +
"_ZVertex_y", (
float)ZVtx.y());
358 setVal(strTrackType +
"_ZVertex_z", (
float)ZVtx.z());
359 setVal(strTrackType +
"_ZVertex_NormChi2", (
float)ZVtx.normalizedChi2());
363 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
368 GlobalVector mom = closestIn3DSpaceState.globalMomentum();
372 itrk = (
charge > 0 ? 1 : 0);
375 trackMomAfterZVtxFit[itrk].SetXYZT(mom.
x(), mom.
y(), mom.
z(),
sqrt(
pow(0.105, 2) +
pow(mom.
mag(), 2)));
380 if (totalcharge != 0)
382 <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Something went wrong! The total charge is no longer 0!" 384 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
385 std::string strMuCore = (jtrk == 0 ?
"MuMinus" :
"MuPlus");
386 setVal(strTrackType +
"_" + strMuCore +
"Pt_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].Pt());
387 setVal(strTrackType +
"_" + strMuCore +
"Pz_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].Pz());
388 setVal(strTrackType +
"_" + strMuCore +
"Phi_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].
Phi());
390 TLorentzVector ZMom_AfterZVtxFit = trackMomAfterZVtxFit[0] + trackMomAfterZVtxFit[1];
391 setVal(strTrackType +
"_ZPt_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pt());
392 setVal(strTrackType +
"_ZPz_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pz());
393 setVal(strTrackType +
"_ZPhi_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Phi());
394 setVal(strTrackType +
"_ZMass_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.M());
396 std::cerr <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Z vertex fit failed for track collection " 397 << strTrackType << std::endl;
399 setVal(strTrackType +
"_ZVtxFitOk", (ZVtxOk ? (
short)1 : (
short)0));
400 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
401 std::string strMuCore = (jtrk == 0 ?
"MuMinus" :
"MuPlus");
402 setVal(strTrackType +
"_" + strMuCore +
"Pt", (
float)trackMom[jtrk].Pt());
403 setVal(strTrackType +
"_" + strMuCore +
"Pz", (
float)trackMom[jtrk].Pz());
404 setVal(strTrackType +
"_" + strMuCore +
"Phi", (
float)trackMom[jtrk].
Phi());
405 setVal(strTrackType +
"_" + strMuCore +
"Vertex_x", (
float)trackVtx[jtrk].
X());
406 setVal(strTrackType +
"_" + strMuCore +
"Vertex_y", (
float)trackVtx[jtrk].
Y());
407 setVal(strTrackType +
"_" + strMuCore +
"Vertex_z", (
float)trackVtx[jtrk].
Z());
415 using namespace reco;
417 std::vector<TransientTrack> t_tks;
418 for (TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
433 return stdRecoVertex;
436 return stdRecoVertex;
static const std::string kSharedResource
reco::Vertex::Point convertPos(const GlobalPoint &p)
T getParameter(std::string const &) const
float totalChiSquared() const
edm::EDGetTokenT< reco::TrackCollection > refit1_trackCollToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttkbuilderToken_
GlobalPoint position() const
GlobalError positionError() const
std::vector< Track > TrackCollection
collection of Tracks
bool bookBranch(std::string bname, BranchType btype)
std::vector< std::pair< std::string, short * > > shortBranches
float degreesOfFreedom() const
void analyze(const edm::Event &, const edm::EventSetup &) override
reco::Vertex fitDimuonVertex(const TransientTrackBuilder &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool &fitOk)
void setVal(std::string bname, varType value)
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
reco::TransientTrack build(const reco::Track *p) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::TrackCollection > alcareco_trackCollToken_
const MagneticField * field() const
math::XYZPoint Point
point in the space
#define DEFINE_FWK_MODULE(type)
const AlgebraicSymMatrix33 matrix() const
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches
HIPTwoBodyDecayAnalyzer(const edm::ParameterSet &)
BranchType searchArray(std::string branchname, int &position)
static int position[264][3]
~HIPTwoBodyDecayAnalyzer() override
edm::EDGetTokenT< reco::TrackCollection > ctf_trackCollToken_
Power< A, B >::type pow(const A &a, const B &b)
void analyzeTrackCollection(std::string strTrackType, const TransientTrackBuilder &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool verbose=false)
TrajectoryStateOnSurface impactPointState() const
edm::EDGetTokenT< reco::TrackCollection > final_trackCollToken_
void initializeBranches()