Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This pull request includes fixes #43

Merged
merged 12 commits into from
Oct 19, 2018
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ SET( ROOT_DICT_INPUT_HEADERS
${PROJECT_SOURCE_DIR}/include/testproc.h
${PROJECT_SOURCE_DIR}/include/TrackNtuple.h
${PROJECT_SOURCE_DIR}/include/VertexMassRecovery.h
${PROJECT_SOURCE_DIR}/include/VertexNtuple.h
${PROJECT_SOURCE_DIR}/include/LinkDef.h
)
SET( ROOT_DICT_INCLUDE_DIRS ${Marlin_INCLUDE_DIRS} )
Expand Down
3 changes: 2 additions & 1 deletion include/JetFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class JetFinder {
/** Constructor.
@param[in] cfg specify the algorithm and the parameters
*/
JetFinder(const JetConfig& cfg);
JetFinder(const JetConfig& cfg, const Vertex* ip = 0);
/** Destructor. */
~JetFinder() {};
/** Replace JetConfig.
Expand Down Expand Up @@ -137,6 +137,7 @@ class JetFinder {
double (*_Yfunc)(Jet& jet1, Jet& jet2, double Evis2, JetConfig& cfg);
double (*_YfuncBeam)(Jet& jet1, double Evis2, JetConfig& cfg);
JetConfig _cfg;
const Vertex* _privtx;
};

/*
Expand Down
1 change: 1 addition & 0 deletions include/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#pragma link C++ class lcfiplus::ReadMVA;
#pragma link C++ class lcfiplus::TrackNtuple;
#pragma link C++ class lcfiplus::VertexMassRecovery+;
#pragma link C++ class lcfiplus::VertexNtuple;

#pragma link C++ class lcfiplus::ZHHAlgo;
#pragma link C++ class lcfiplus::TestAlgo;
Expand Down
21 changes: 11 additions & 10 deletions include/TrackSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,34 @@ class TrackSelectorConfig {

class TrackSelector {
public:
vector<const Track*> operator () (const vector<const Track*>& tracks, TrackSelectorConfig& config) {
vector<const Track*> operator () (const vector<const Track*>& tracks, TrackSelectorConfig& config, const Vertex* ip = 0) {
vector<const Track*> ret;

for (unsigned int i=0; i<tracks.size(); i++) {
if (passesCut(tracks[i], config))
if (passesCut(tracks[i], config, ip))
ret.push_back(tracks[i]);
}

return ret;
}

bool passesCut(const Track* trk, const TrackSelectorConfig& cfg) {
bool passesCut(const Track* trk, const TrackSelectorConfig& cfg, const Vertex* ip = 0) {
// AND cuts

if (fabs(trk->getD0()) < cfg.minD0) return false;
if (fabs(trk->getD0()) > cfg.maxD0) return false;
if (trk->getCovMatrix()[tpar::d0d0] < cfg.minD0Err) return false;
if (trk->getCovMatrix()[tpar::d0d0] > cfg.maxD0Err) return false;
if (sqrt(trk->getCovMatrix()[tpar::d0d0]) < cfg.minD0Err) return false;
if (sqrt(trk->getCovMatrix()[tpar::d0d0]) > cfg.maxD0Err) return false;
double d0sig = fabs(trk->getD0()) / sqrt(trk->getCovMatrix()[tpar::d0d0]);
if ( d0sig < cfg.minD0Sig) return false;
if ( d0sig > cfg.maxD0Sig) return false;

if (fabs(trk->getZ0()) < cfg.minZ0) return false;
if (fabs(trk->getZ0()) > cfg.maxZ0) return false;
if (trk->getCovMatrix()[tpar::z0z0] < cfg.minZ0Err) return false;
if (trk->getCovMatrix()[tpar::z0z0] > cfg.maxZ0Err) return false;
double z0sig = fabs(trk->getZ0()) / sqrt(trk->getCovMatrix()[tpar::z0z0]);
double z0 = (ip ? fabs(trk->getZ0() - ip->getZ()) : fabs(trk->getZ0()) );
if (z0 < cfg.minZ0) return false;
if (z0 > cfg.maxZ0) return false;
if (sqrt(trk->getCovMatrix()[tpar::z0z0]) < cfg.minZ0Err) return false;
if (sqrt(trk->getCovMatrix()[tpar::z0z0]) > cfg.maxZ0Err) return false;
double z0sig = z0 / sqrt(trk->getCovMatrix()[tpar::z0z0]);
if ( z0sig < cfg.minZ0Sig) return false;
if ( z0sig > cfg.maxZ0Sig) return false;

Expand Down
33 changes: 17 additions & 16 deletions include/VertexFitterSimple.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ class VertexFitterSimple {

GeometryHandler* gh = GeometryHandler::Instance();
if (pointConstraint) {
Point* ip = new Point(pointConstraint);
Point* ip = new Point(pointConstraint,PointBase::PRIVTX);
vector<PointBase*> tracks;
if (!pointInitialOnly)
if (!pointInitialOnly) {
tracks.push_back(ip);
}
int ntracks = 0;
for (Iterator it = tracksBegin; it != tracksEnd; it++,ntracks++) {
tracks.push_back(new Helix(*it));
tracks.push_back(new Helix(*it,PointBase::PRIVTX));
}
if (verbose)
cout << "VertexFitterSimple: number of tracks is " << ntracks << endl;

TVector3 initial = pointConstraint->getPos();
Point* result = new Point;
Point* result = new Point(PointBase::NOTUSED);
double chi2 = -gh->PointFit(tracks, initial, result);

TVector3 vresult = result->GetPos();
Expand Down Expand Up @@ -60,7 +61,7 @@ class VertexFitterSimple {

Vertex* vtx = new Vertex(chi2, TMath::Prob(chi2, ntracks*2-3), vresult.x(), vresult.y(), vresult.z(), cov, false);
for (Iterator it = tracksBegin; it != tracksEnd; it++,ntracks++) {
Helix hel(*it);
Helix hel(*it,PointBase::PRIVTX);
double ll = hel.LogLikelihood(vresult); // need to incorporate vertex error??

if (verbose)
Expand All @@ -80,12 +81,12 @@ class VertexFitterSimple {
vector<Helix*> tracks;
int ntracks = 0;
for (Iterator it = tracksBegin; it != tracksEnd; it++,ntracks++) {
tracks.push_back(new Helix(*it));
tracks.push_back(new Helix(*it,PointBase::SECVTX));
}
if (verbose)
cout << "VertexFitterSimple: number of tracks is " << ntracks << endl;

Point* result = new Point;
Point* result = new Point(PointBase::NOTUSED);
double chi2 = -gh->HelixPointFit(tracks, result);

TVector3 vresult = result->GetPos();
Expand All @@ -104,7 +105,7 @@ class VertexFitterSimple {

Vertex* vtx = new Vertex(chi2, (ntracks > 1 ? TMath::Prob(chi2, ntracks*2-3) : 1), vresult.x(), vresult.y(), vresult.z(), cov, false);
for (Iterator it = tracksBegin; it != tracksEnd; it++, ntracks++) {
Helix hel(*it);
Helix hel(*it,PointBase::SECVTX);
double ll = hel.LogLikelihood(vresult); // need to incorporate vertex error??
if (verbose)
cout << "VertexFitterSimple: track loglikelihood is " << ll << endl;
Expand All @@ -119,18 +120,18 @@ class VertexFitterSimple {
return vtx;
}

double getChi2(const Vertex* vtx, const Track* trk, int mode=1) {
double getChi2(const Vertex* vtx, const Track* trk, int mode=1, PointBase::FITFLAG flag=PointBase::NOTUSED) {
// 110510 suehara for IPassoc study
if (mode == 0) {
// mode 0: no fit at all
Helix hel(trk);
Helix hel(trk,flag);
TVector3 v = vtx->getPos();
return -hel.LogLikelihood(v);
} else if (mode == 1) {
// mode 1: vertex treated as errored point

Point ptVtx(vtx);
Helix hel(trk);
Point ptVtx(vtx,flag);
Helix hel(trk,flag);

vector<PointBase*> vpt;
vpt.push_back(&ptVtx);
Expand All @@ -142,12 +143,12 @@ class VertexFitterSimple {
// mode 2: vertex treated as track list
vector<PointBase*> vpt;
for (unsigned int n=0; n<vtx->getTracks().size(); n++) {
vpt.push_back(new Helix(vtx->getTracks()[n]));
vpt.push_back(new Helix(vtx->getTracks()[n],flag));
}
vpt.push_back(new Helix(trk));
vpt.push_back(new Helix(trk,flag));

GeometryHandler* gh = GeometryHandler::Instance();
Point ret;
Point ret(PointBase::NOTUSED);
double ll = -gh->PointFit(vpt, vtx->getPos(), &ret);

for (unsigned int n=0; n<vpt.size(); n++) {
Expand All @@ -156,7 +157,7 @@ class VertexFitterSimple {
if (mode == 2) {
return ll;
} else {
Helix hel(trk);
Helix hel(trk,flag);
return -hel.LogLikelihood(ret.GetPos());
}
}
Expand Down
41 changes: 41 additions & 0 deletions include/VertexNtuple.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// VertexNtuple.h

#ifndef VertexNtuple_h
#define VertexNtuple_h 1

class TFile;
class TNtuple;

#include "lcfiplus.h"

namespace lcfiplus {

/**
Storing the number of tracks associated to vertices..

@author R.Yonamine, Dept. of Physics, Tohok University
@version $Id$
*/

class VertexNtuple : public Algorithm {
public:
VertexNtuple() {}
virtual ~VertexNtuple() {}

void init(Parameters* param);
void process();
void end();

private:
TFile* _file;
TNtuple* _tree;

string _jetcolname;
string _primvtxcolname;

ClassDef(VertexNtuple,1)
};

}

#endif
6 changes: 4 additions & 2 deletions include/algoEtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ vector<const Track*> extractTracks(VertexVec& vtx);
double calcThrust( vector<TVector3>& list, TVector3& taxis );

bool SimpleSecMuonFinder(const Track* tr, double d0sigth, double z0sigth, double maxpos, double mudepmin,
double ecaldepmin, double ecaldepmax, double hcaldepmin, double hcaldepmax, double maxclusterpertrackenergy = 10.);
double ecaldepmin, double ecaldepmax, double hcaldepmin, double hcaldepmax, double maxclusterpertrackenergy = 10.,
const Vertex* ip = 0);
bool SimpleSecElectronFinder(const Track* tr, double d0sigth, double z0sigth, double maxpos, double emin,
double minfracecal, double minecalpertrackenergy, double maxecalpertrackenergy);
double minfracecal, double minecalpertrackenergy, double maxecalpertrackenergy,
const Vertex* ip = 0);

}
}
Expand Down
13 changes: 13 additions & 0 deletions include/flavtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ class FtJProbZ2;
class FtJProbR25Sigma;
class FtJProbZ25Sigma;

class FtD0bProb2;
class FtD0cProb2;
class FtD0qProb2;
class FtZ0bProb2;
class FtZ0cProb2;
class FtZ0qProb2;

class FtIPProbHolder {
friend class FtD0bProb;
friend class FtD0cProb;
Expand All @@ -176,6 +183,12 @@ class FtIPProbHolder {
friend class FtJProbR25Sigma;
friend class FtJProbZ25Sigma;

friend class FtD0bProb2;
friend class FtD0cProb2;
friend class FtD0qProb2;
friend class FtZ0bProb2;
friend class FtZ0cProb2;
friend class FtZ0qProb2;
public:
FtIPProbHolder(const char* d0probfile, const char* z0probfile);
~FtIPProbHolder();
Expand Down
34 changes: 21 additions & 13 deletions include/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ class PointBase { // pure virtual point-base class
virtual double LogLikelihood(const TVector3& p)const = 0;
virtual void LogLikelihoodDeriv(const TVector3& p,double* output)const = 0;
virtual ~PointBase() {}

enum FITFLAG { NOTUSED, PRIVTX, SECVTX };
protected:
PointBase() {}
//PointBase() : _fitflag(DEFAULT) {}
PointBase(FITFLAG flag) : _fitflag(flag) {}
//void SetFlag(FITFLAG flag) { _fitflag = flag; }
FITFLAG GetFlag() const { return _fitflag; }
FITFLAG _fitflag;
};

class Point : public PointBase { // real 3D-point with error
Expand All @@ -34,16 +38,20 @@ class Point : public PointBase { // real 3D-point with error
double LogLikelihood(const TVector3& p)const;
void LogLikelihoodDeriv(const TVector3& p, double* output)const;

Point() {}
Point(const SVector3& pos, const SMatrixSym3& err) {
//Point() {}
Point(FITFLAG flag) : PointBase(flag) {}
//Point(const SVector3& pos, const SMatrixSym3& err) {
Point(const SVector3& pos, const SMatrixSym3& err, FITFLAG flag) : PointBase(flag) {
_pos = pos;
_err = err;
}
Point(const Point& ref) {
//Point(const Point& ref) {
Point(const Point& ref, FITFLAG flag) : PointBase(flag) {
_pos = ref._pos;
_err = ref._err;
}
Point(const Vertex* vtx);
Point(const Vertex* vtx, FITFLAG flag) ;
//Point(const Vertex* vtx, FITFLAG flag);
~Point() {}

void SetPosErr(const SVector3& pos, const SMatrixSym3& err) {
Expand Down Expand Up @@ -133,13 +141,13 @@ class Helix : public PointBase { // parametrized point for helix

double LongitudinalDeviation(const Vertex* ip, const Vertex* sec);

Helix() {}
Helix(const SVector5& hel, const SMatrixSym5& err, int charge) {
Helix(FITFLAG flag) : PointBase(flag) {}
Helix(const SVector5& hel, const SMatrixSym5& err, int charge, FITFLAG flag) : PointBase(flag) {
_hel = hel, _err = err;
_charge = charge;
}
Helix(const Track* trk);
Helix(const Helix& ref) {
Helix(const Track* trk, FITFLAG flag) ;
Helix(const Helix& ref, FITFLAG flag) : PointBase(flag) {
_hel = ref._hel;
_err = ref._err;
_charge = ref._charge;
Expand Down Expand Up @@ -186,14 +194,14 @@ class VertexLine : public PointBase { // line with error for IP-vertex line
void LogLikelihoodDeriv(const TVector3& p, double* output)const;
double Variance(const TVector3& p, double t)const; // t-fixed version, internally used

VertexLine() {}
VertexLine(const Vertex* ip, const Vertex* secvtx) {
VertexLine(FITFLAG flag) : PointBase(flag) {}
VertexLine(const Vertex* ip, const Vertex* secvtx, FITFLAG flag) : PointBase(flag) {
_ip = ip;
_vertex = secvtx;
_origin = _vertex->getPos();
_unit = (_origin - _ip->getPos()).Unit();
}
VertexLine(const TVector3& origin, const TVector3& dir) {
VertexLine(const TVector3& origin, const TVector3& dir, FITFLAG flag) : PointBase(flag) {
_origin = origin;
_unit = dir.Unit();
_ip = 0;
Expand Down
4 changes: 2 additions & 2 deletions include/lcfiplus.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ class Parameters {
} else if (_map.find(key)->second.first == &typeid(T))ret = *(T*)(_map.find(key)->second.second);
else if (_allowstring && _map.find(key)->second.first == &typeid(string)) {
istringstream str(*(string*)_map.find(key)->second.second);
str >> ret;
str >> boolalpha >> ret;
} else if (_allowstring && _map.find(key)->second.first == &typeid(vector<string>)) {
istringstream str((*(const vector<string>*)_map.find(key)->second.second)[0]);
str >> ret;
str >> boolalpha >> ret;
} else {
cout << "Parameter type invalid: key = " << key << ", type = " << _map.find(key)->second.first->name() << " vs " << typeid(T).name() << endl;
throw (Exception("Parameter type invalid."));
Expand Down
5 changes: 3 additions & 2 deletions include/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PrimaryVertexFinder : public Algorithm {
bool _beamspotSmearing;

// track cut parameters
TrackSelectorConfig* _secVtxCfg; //!
TrackSelectorConfig* _priVtxCfg; //!
};

class BuildUpVertex : public Algorithm {
Expand Down Expand Up @@ -109,7 +109,8 @@ class JetClustering : public Algorithm {
double _vsMaxDist;
double _vsK0MassWidth;
bool _outputVertexStoresVertex;
string _vcolname;
string _vpricolname;
string _vseccolname;
int _maxYth;

double _yaddVV;
Expand Down
Loading