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;
99 tree =
fs->make<TTree>(
"TestTree",
"");
104 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
110 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
125 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
131 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
145 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
149 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
160 const int nTrackTypes = 4;
161 std::vector<std::string> strTrackTypes;
162 strTrackTypes.reserve(nTrackTypes);
163 strTrackTypes.push_back(
"alcareco");
164 strTrackTypes.push_back(
"refit1");
165 strTrackTypes.push_back(
"refit2");
166 strTrackTypes.push_back(
"final");
167 for (
unsigned int it = 0;
it < nTrackTypes;
it++) {
212 std::cerr <<
"HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " <<
btype <<
" for the branch " << bname
213 <<
" is available." << std::endl;
220 std::cout <<
"Begin HIPTwoBodyDecayAnalyzer::actuateBranches" << std::endl;
224 if (
tree !=
nullptr) {
225 for (
unsigned short el = 0; el <
shortBranches.size(); el++) {
233 for (
unsigned int el = 0; el <
intBranches.size(); el++) {
252 std::cerr <<
"HIPTwoBodyDecayAnalyzer::actuateBranch: Failed to actuate the branches!" << std::endl;
259 using namespace reco;
296 std::cout <<
"Starting to process the track collection for " << strTrackType << std::endl;
299 using namespace reco;
304 std::cout <<
"Track collection is invalid." << std::endl;
307 if (hTrackColl->size() < 2) {
309 std::cout <<
"Track collection size<2." << std::endl;
313 unsigned int itrk = 0;
316 bool isValidPair =
true;
318 TLorentzVector trackMom[2];
319 TLorentzVector trackMomAfterZVtxFit[2];
320 TVector3 trackVtx[2];
322 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
323 trackMom[jtrk].SetXYZT(0, 0, 0, 0);
324 trackVtx[jtrk].SetXYZ(0, 0, 0);
326 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
330 itrk = (
charge > 0 ? 1 : 0);
333 trackMom[itrk].SetPtEtaPhiM(
track->pt(),
track->eta(),
track->phi(), 0.105);
340 isValidPair = (totalcharge == 0 && trackMom[0].P() != 0. && trackMom[1].P() != 0.);
342 std::cout <<
"Track collection does not contain a valid std::pair." << std::endl;
343 setVal(strTrackType +
"_present", (isValidPair ? (
short)1 : (
short)0));
345 TLorentzVector ZMom = trackMom[0] + trackMom[1];
346 setVal(strTrackType +
"_ZPt", (
float)ZMom.Pt());
347 setVal(strTrackType +
"_ZPz", (
float)ZMom.Pz());
348 setVal(strTrackType +
"_ZPhi", (
float)ZMom.Phi());
349 setVal(strTrackType +
"_ZMass", (
float)ZMom.M());
353 setVal(strTrackType +
"_ZVertex_x", (
float)ZVtx.x());
354 setVal(strTrackType +
"_ZVertex_y", (
float)ZVtx.y());
355 setVal(strTrackType +
"_ZVertex_z", (
float)ZVtx.z());
356 setVal(strTrackType +
"_ZVertex_NormChi2", (
float)ZVtx.normalizedChi2());
360 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
365 GlobalVector mom = closestIn3DSpaceState.globalMomentum();
369 itrk = (
charge > 0 ? 1 : 0);
372 trackMomAfterZVtxFit[itrk].SetXYZT(mom.
x(), mom.
y(), mom.
z(),
sqrt(
pow(0.105, 2) +
pow(mom.
mag(), 2)));
377 if (totalcharge != 0)
379 <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Something went wrong! The total charge is no longer 0!" 381 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
382 std::string strMuCore = (jtrk == 0 ?
"MuMinus" :
"MuPlus");
383 setVal(strTrackType +
"_" + strMuCore +
"Pt_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].Pt());
384 setVal(strTrackType +
"_" + strMuCore +
"Pz_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].Pz());
385 setVal(strTrackType +
"_" + strMuCore +
"Phi_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].
Phi());
387 TLorentzVector ZMom_AfterZVtxFit = trackMomAfterZVtxFit[0] + trackMomAfterZVtxFit[1];
388 setVal(strTrackType +
"_ZPt_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pt());
389 setVal(strTrackType +
"_ZPz_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pz());
390 setVal(strTrackType +
"_ZPhi_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Phi());
391 setVal(strTrackType +
"_ZMass_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.M());
393 std::cerr <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Z vertex fit failed for track collection " 394 << strTrackType << std::endl;
396 setVal(strTrackType +
"_ZVtxFitOk", (ZVtxOk ? (
short)1 : (
short)0));
397 for (
unsigned int jtrk = 0; jtrk < 2; jtrk++) {
398 std::string strMuCore = (jtrk == 0 ?
"MuMinus" :
"MuPlus");
399 setVal(strTrackType +
"_" + strMuCore +
"Pt", (
float)trackMom[jtrk].Pt());
400 setVal(strTrackType +
"_" + strMuCore +
"Pz", (
float)trackMom[jtrk].Pz());
401 setVal(strTrackType +
"_" + strMuCore +
"Phi", (
float)trackMom[jtrk].
Phi());
402 setVal(strTrackType +
"_" + strMuCore +
"Vertex_x", (
float)trackVtx[jtrk].
X());
403 setVal(strTrackType +
"_" + strMuCore +
"Vertex_y", (
float)trackVtx[jtrk].
Y());
404 setVal(strTrackType +
"_" + strMuCore +
"Vertex_z", (
float)trackVtx[jtrk].
Z());
412 using namespace reco;
414 std::vector<TransientTrack> t_tks;
415 for (TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track) {
430 return stdRecoVertex;
433 return stdRecoVertex;
static const std::string kSharedResource
reco::Vertex::Point convertPos(const GlobalPoint &p)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
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)
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()