7 #include "TLorentzVector.h" 62 virtual void endJob()
override;
70 if (varposition==-1)
std::cerr <<
"HIPTwoBodyDecayAnalyzer::setVal -> Could not find the branch called " << bname <<
"!" << std::endl;
71 else if (varbranchtype==
BranchType_short_t) *(shortBranches.at(varposition).second)=value;
72 else if (varbranchtype==
BranchType_int_t) *(intBranches.at(varposition).second)=value;
73 else if (varbranchtype==
BranchType_float_t) *(floatBranches.at(varposition).second)=value;
74 else std::cerr <<
"HIPTwoBodyDecayAnalyzer::setVal -> Could not find the type " << varbranchtype <<
" for branch called " << bname <<
"!" << std::endl;
102 tree = fs->
make<TTree>(
"TestTree",
"");
114 for (
unsigned int el=0; el<
intBranches.size(); el++){
134 for (
unsigned int el=0; el<
intBranches.size(); el++){
149 for (
unsigned int el=0; el<
intBranches.size(); el++){
158 const int nTrackTypes = 4;
159 std::vector<std::string> strTrackTypes; 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++){
185 std::cerr <<
"HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " << btype <<
" for the branch " << bname <<
" is available." << std::endl;
192 std::cout <<
"Begin HIPTwoBodyDecayAnalyzer::actuateBranches" << std::endl;
201 else std::cout <<
"Failed!" << std::endl;
203 for (
unsigned int el=0; el<
intBranches.size(); el++){
207 else std::cout <<
"Failed!" << std::endl;
213 else std::cout <<
"Failed!" << std::endl;
217 if (!success)
std::cerr <<
"HIPTwoBodyDecayAnalyzer::actuateBranch: Failed to actuate the branches!" << std::endl;
226 using namespace reco;
261 if (verbose)
std::cout <<
"Starting to process the track collection for " << strTrackType << std::endl;
264 using namespace reco;
268 if (verbose)
std::cout <<
"Track collection is invalid." << std::endl;
271 if (hTrackColl->size()<2){
272 if (verbose)
std::cout <<
"Track collection size<2." << std::endl;
279 bool isValidPair=
true;
281 TLorentzVector trackMom[2];
282 TLorentzVector trackMomAfterZVtxFit[2];
283 TVector3 trackVtx[2];
285 for (
unsigned int jtrk=0; jtrk<2; jtrk++){
286 trackMom[jtrk].SetXYZT(0, 0, 0, 0);
287 trackVtx[jtrk].SetXYZ(0, 0, 0);
289 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track){
293 itrk = (charge>0 ? 1 : 0);
296 trackMom[itrk].SetPtEtaPhiM(
track->pt(),
track->eta(),
track->phi(), 0.105);
302 isValidPair = (totalcharge==0 && trackMom[0].P()!=0. && trackMom[1].P()!=0.);
303 if (verbose && !isValidPair)
std::cout <<
"Track collection does not contain a valid std::pair." << std::endl;
304 setVal(strTrackType +
"_present", (isValidPair ? (
short)1 : (
short)0));
306 TLorentzVector ZMom = trackMom[0] + trackMom[1];
307 setVal(strTrackType +
"_ZPt", (
float)ZMom.Pt());
308 setVal(strTrackType +
"_ZPz", (
float)ZMom.Pz());
309 setVal(strTrackType +
"_ZPhi", (
float)ZMom.Phi());
310 setVal(strTrackType +
"_ZMass", (
float)ZMom.M());
314 setVal(strTrackType +
"_ZVertex_x", (
float)ZVtx.x());
315 setVal(strTrackType +
"_ZVertex_y", (
float)ZVtx.y());
316 setVal(strTrackType +
"_ZVertex_z", (
float)ZVtx.z());
317 setVal(strTrackType +
"_ZVertex_NormChi2", (
float)ZVtx.normalizedChi2());
321 for (reco::TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track){
325 GlobalVector mom = closestIn3DSpaceState.globalMomentum();
329 itrk = (charge>0 ? 1 : 0);
332 trackMomAfterZVtxFit[itrk].SetXYZT(mom.
x(), mom.
y(), mom.
z(),
sqrt(
pow(0.105, 2) +
pow(mom.
mag(), 2)));
336 if (totalcharge!=0)
std::cerr <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Something went wrong! The total charge is no longer 0!" << std::endl;
337 for (
unsigned int jtrk=0; jtrk<2; jtrk++){
338 std::string strMuCore = (jtrk==0 ?
"MuMinus" :
"MuPlus");
339 setVal(strTrackType +
"_" + strMuCore +
"Pt_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].
Pt());
340 setVal(strTrackType +
"_" + strMuCore +
"Pz_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].Pz());
341 setVal(strTrackType +
"_" + strMuCore +
"Phi_AfterZVtxFit", (
float)trackMomAfterZVtxFit[jtrk].
Phi());
343 TLorentzVector ZMom_AfterZVtxFit = trackMomAfterZVtxFit[0] + trackMomAfterZVtxFit[1];
344 setVal(strTrackType +
"_ZPt_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pt());
345 setVal(strTrackType +
"_ZPz_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Pz());
346 setVal(strTrackType +
"_ZPhi_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.Phi());
347 setVal(strTrackType +
"_ZMass_AfterZVtxFit", (
float)ZMom_AfterZVtxFit.M());
349 else std::cerr <<
"HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Z vertex fit failed for track collection " << strTrackType << std::endl;
351 setVal(strTrackType +
"_ZVtxFitOk", (ZVtxOk ? (
short)1 : (
short)0));
352 for (
unsigned int jtrk=0; jtrk<2; jtrk++){
353 std::string strMuCore = (jtrk==0 ?
"MuMinus" :
"MuPlus");
354 setVal(strTrackType +
"_" + strMuCore +
"Pt", (
float)trackMom[jtrk].
Pt());
355 setVal(strTrackType +
"_" + strMuCore +
"Pz", (
float)trackMom[jtrk].Pz());
356 setVal(strTrackType +
"_" + strMuCore +
"Phi", (
float)trackMom[jtrk].
Phi());
357 setVal(strTrackType +
"_" + strMuCore +
"Vertex_x", (
float)trackVtx[jtrk].
X());
358 setVal(strTrackType +
"_" + strMuCore +
"Vertex_y", (
float)trackVtx[jtrk].
Y());
359 setVal(strTrackType +
"_" + strMuCore +
"Vertex_z", (
float)trackVtx[jtrk].
Z());
365 using namespace reco;
367 std::vector<TransientTrack> t_tks;
368 for (TrackCollection::const_iterator
track = hTrackColl->begin();
track != hTrackColl->end(); ++
track){
382 return stdRecoVertex;
386 return stdRecoVertex;
GlobalError positionError() const
reco::Vertex::Point convertPos(const GlobalPoint &p)
T getParameter(std::string const &) const
reco::Vertex fitDimuonVertex(edm::ESHandle< TransientTrackBuilder > &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool &fitOk)
edm::EDGetTokenT< reco::TrackCollection > refit1_trackCollToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
const AlgebraicSymMatrix33 matrix() const
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
float totalChiSquared() const
void analyzeTrackCollection(std::string strTrackType, edm::ESHandle< TransientTrackBuilder > &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool verbose=false)
std::vector< Track > TrackCollection
collection of Tracks
reco::TransientTrack build(const reco::Track *p) const
bool bookBranch(std::string bname, BranchType btype)
T * make(const Args &...args) const
make new ROOT object
const MagneticField * field() const
virtual void endJob() override
std::vector< std::pair< std::string, short * > > shortBranches
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
void setVal(std::string bname, varType value)
~HIPTwoBodyDecayAnalyzer()
virtual void beginJob() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::TrackCollection > alcareco_trackCollToken_
float degreesOfFreedom() const
GlobalPoint position() const
math::XYZPoint Point
point in the space
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]
TrajectoryStateOnSurface impactPointState() const
edm::EDGetTokenT< reco::TrackCollection > ctf_trackCollToken_
Power< A, B >::type pow(const A &a, const B &b)
edm::EDGetTokenT< reco::TrackCollection > final_trackCollToken_
void initializeBranches()