7 #include "vdt/vdtMath.h" 12 #define LOG edm::LogPrint("VertexTimeAlgorithmFromTracksPID") 14 #define LOG LogDebug("VertexTimeAlgorithmFromTracksPID") 20 trackMTDTimeToken_(iCC.consumes(iConfig.getParameter<
edm::
InputTag>(
"trackMTDTimeVMapTag"))),
21 trackMTDTimeErrorToken_(iCC.consumes(iConfig.getParameter<
edm::
InputTag>(
"trackMTDTimeErrorVMapTag"))),
22 trackMTDTimeQualityToken_(iCC.consumes(iConfig.getParameter<
edm::
InputTag>(
"trackMTDTimeQualityVMapTag"))),
23 trackMTDTofPiToken_(iCC.consumes(iConfig.getParameter<
edm::
InputTag>(
"trackMTDTofPiVMapTag"))),
24 trackMTDTofKToken_(iCC.consumes(iConfig.getParameter<
edm::
InputTag>(
"trackMTDTofKVMapTag"))),
25 trackMTDTofPToken_(iCC.consumes(iConfig.getParameter<
edm::
InputTag>(
"trackMTDTofPVMapTag"))),
26 minTrackVtxWeight_(iConfig.getParameter<double>(
"minTrackVtxWeight")),
27 minTrackTimeQuality_(iConfig.getParameter<double>(
"minTrackTimeQuality")),
28 probPion_(iConfig.getParameter<double>(
"probPion")),
29 probKaon_(iConfig.getParameter<double>(
"probKaon")),
30 probProton_(iConfig.getParameter<double>(
"probProton")),
31 Tstart_(iConfig.getParameter<double>(
"Tstart")),
32 coolingFactor_(iConfig.getParameter<double>(
"coolingFactor")) {}
38 ->setComment(
"Input ValueMap for track time at MTD");
40 ->setComment(
"Input ValueMap for track time uncertainty at MTD");
42 ->setComment(
"Input ValueMap for track MVA quality value");
44 ->setComment(
"Input ValueMap for track tof as pion");
46 ->setComment(
"Input ValueMap for track tof as kaon");
48 ->setComment(
"Input ValueMap for track tof as proton");
50 iDesc.
add<
double>(
"minTrackVtxWeight", 0.5)->
setComment(
"Minimum track weight");
51 iDesc.
add<
double>(
"minTrackTimeQuality", 0.8)->
setComment(
"Minimum MVA Quality selection on tracks");
53 iDesc.
add<
double>(
"probPion", 0.7)->
setComment(
"A priori probability pions");
54 iDesc.
add<
double>(
"probKaon", 0.2)->
setComment(
"A priori probability kaons");
55 iDesc.
add<
double>(
"probProton", 0.1)->
setComment(
"A priori probability protons");
57 iDesc.
add<
double>(
"Tstart", 256.)->
setComment(
"DA initial temperature T");
58 iDesc.
add<
double>(
"coolingFactor", 0.5)->
setComment(
"DA cooling factor");
74 if (
vtx.originalTracks().empty()) {
78 auto const vtxTime_init = vtxTime;
79 auto const vtxTimeError_init = vtxTimeError;
80 const int max_iterations = 100;
88 std::vector<TrackInfo> v_trackInfo;
89 v_trackInfo.reserve(
vtx.originalTracks().size());
92 for (
const auto& trk :
vtx.originalTracks()) {
93 auto const trkWeight =
vtx.trackWeight(trk);
101 v_trackInfo.emplace_back();
102 auto& trkInfo = v_trackInfo.back();
104 trkInfo.trkWeight = trkWeight;
105 trkInfo.trkTimeError = trkTimeError;
107 trkInfo.trkTimeHyp[0] = trkTime -
trackMTDTofPi_[trk.trackBaseRef()];
108 trkInfo.trkTimeHyp[1] = trkTime -
trackMTDTofK_[trk.trackBaseRef()];
109 trkInfo.trkTimeHyp[2] = trkTime -
trackMTDTofP_[trk.trackBaseRef()];
111 auto const wgt = trkWeight / (trkTimeError * trkTimeError);
115 tsum += wgt * trkInfo.trkTimeHyp[
j] *
a[
j];
117 LOG <<
"vertexTimeFromTracks: track" 118 <<
" pt=" << trk.track().pt() <<
" eta=" << trk.track().eta() <<
" phi=" << trk.track().phi()
119 <<
" vtxWeight=" << trkWeight <<
" time=" << trkTime <<
" timeError=" << trkTimeError
120 <<
" timeQuality=" << trkTimeQuality <<
" timeHyp[pion]=" << trkInfo.trkTimeHyp[0]
121 <<
" timeHyp[kaon]=" << trkInfo.trkTimeHyp[1] <<
" timeHyp[proton]=" << trkInfo.trkTimeHyp[2];
126 auto t0 = tsum / wsum;
129 while ((nit++) < max_iterations) {
134 for (
auto const& trkInfo : v_trackInfo) {
135 double dt = trkInfo.trkTimeError;
136 double e[3] = {0, 0, 0};
137 const double cut_off = 4.5;
138 double Z = vdt::fast_exp(
140 for (
unsigned int j = 0;
j < 3;
j++) {
141 auto const tpull = (trkInfo.trkTimeHyp[
j] -
t0) /
dt;
142 e[
j] = vdt::fast_exp(-0.5 *
beta * tpull * tpull);
148 double wt =
a[
j] *
e[
j] /
Z;
149 double w = wt * trkInfo.trkWeight / (
dt *
dt);
151 tsum +=
w * trkInfo.trkTimeHyp[
j];
155 w2sum += wsum_trk * wsum_trk * (
dt *
dt) / trkInfo.trkWeight;
159 LOG <<
"vertexTimeFromTracks: failed while iterating";
163 vtxTime = tsum / wsum;
165 LOG <<
"vertexTimeFromTracks: iteration=" << nit <<
", T= " << 1 /
beta <<
", t=" << vtxTime
166 <<
", t-t0=" << vtxTime -
t0;
171 LOG <<
"vertexTimeFromTracks: tfit = " << vtxTime <<
" +/- " << vtxTimeError <<
" trec = " <<
vtx.time()
172 <<
", iteration=" << nit;
184 LOG <<
"vertexTimeFromTracks: failed to converge";
186 LOG <<
"vertexTimeFromTracks: has no track timing info";
189 vtxTime = vtxTime_init;
190 vtxTimeError = vtxTimeError_init;
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofKToken_
edm::ValueMap< float > trackMTDTimes_
void setComment(std::string const &value)
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPToken_
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeQualityToken_
void setEvent(edm::Event &iEvent, edm::EventSetup const &iSetup) override
double const minTrackTimeQuality_
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeToken_
edm::ValueMap< float > trackMTDTofPi_
edm::ValueMap< float > trackMTDTimeErrors_
Abs< T >::type abs(const T &t)
edm::ValueMap< float > trackMTDTofP_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTofPiToken_
edm::ValueMap< float > trackMTDTimeQualities_
double const coolingFactor_
double const minTrackVtxWeight_
edm::ValueMap< float > trackMTDTofK_
VertexTimeAlgorithmFromTracksPID(const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
bool vertexTime(float &vtxTime, float &vtxTimeError, TransientVertex const &vtx) const override
edm::EDGetTokenT< edm::ValueMap< float > > const trackMTDTimeErrorToken_