@@ -12,11 +12,12 @@ namespace delphes
1212/* ****************************************************************/
1313
1414void
15- TOFLayer::setup (float radius, float length, float sigmat)
15+ TOFLayer::setup (float radius, float length, float sigmat, float sigma0 )
1616{
1717 mRadius = radius;
1818 mLength = length;
1919 mSigmaT = sigmat;
20+ mSigma0 = sigma0;
2021}
2122
2223/* ****************************************************************/
@@ -43,7 +44,7 @@ TOFLayer::hasTOF(const Track &track)
4344float
4445TOFLayer::getBeta (const Track &track)
4546{
46- double tof = track.TOuter * 1 .e9 - mTime0 ; // [ns]
47+ double tof = track.TOuter * 1 .e9 ; // [ns]
4748 double L = track.L * 0.1 ; // [cm]
4849 double c = 29.9792458 ; // [cm/ns]
4950 return (L / tof / c);
@@ -57,7 +58,8 @@ TOFLayer::makePID(const Track &track, std::array<float, 5> &deltat, std::array<f
5758 double pmass[5 ] = {0.00051099891 , 0.10565800 , 0.13957000 , 0.49367700 , 0.93827200 };
5859
5960 /* * get info **/
60- double tof = track.TOuter * 1 .e9 - mTime0 ; // [ns]
61+ double tof = track.TOuter * 1 .e9 ; // [ns]
62+ double etof = track.ErrorT * 1 .e9 ; // [ns]
6163 double L = track.L * 0.1 ; // [cm]
6264 double p = track.P ;
6365 double p2 = p * p;
@@ -70,7 +72,7 @@ TOFLayer::makePID(const Track &track, std::array<float, 5> &deltat, std::array<f
7072 double mass2 = pmass[ipart] * pmass[ipart];
7173 double texp = Lc / p * TMath::Sqrt (mass2 + p2);
7274 double etexp = Lc * mass2 / p2 / TMath::Sqrt (mass2 + p2) * ep;
73- double sigma = TMath::Sqrt (etexp * etexp + mSigmaT * mSigmaT + mSigma0 * mSigma0 );
75+ double sigma = TMath::Sqrt (etexp * etexp + etof * etof );
7476 deltat[ipart] = tof - texp;
7577 nsigma[ipart] = deltat[ipart] / sigma;
7678 }
@@ -85,13 +87,14 @@ TOFLayer::eventTime(std::vector<Track *> &tracks, std::array<float, 2> &tzero)
8587
8688 double sum = 0 .;
8789 double sumw = 0 .;
88-
90+
8991 for (auto &track : tracks) {
9092
9193 int pid = track->PID ;
9294 double mass = TDatabasePDG::Instance ()->GetParticle (pid)->Mass ();
9395 double mass2 = mass * mass;
9496 double tof = track->TOuter * 1 .e9 ; // [ns]
97+ double etof = track->ErrorT * 1 .e9 ; // [ns]
9598 double L = track->L * 0.1 ; // [cm]
9699 double p = track->P ; // [GeV/c]
97100 double ep = track->ErrorP ;
@@ -100,7 +103,7 @@ TOFLayer::eventTime(std::vector<Track *> &tracks, std::array<float, 2> &tzero)
100103 double Lc = L / c;
101104 double texp = Lc / p * TMath::Sqrt (mass2 + p2);
102105 double etexp = Lc * mass2 / p2 / TMath::Sqrt (mass2 + p2) * ep;
103- double sigma = TMath::Sqrt (etexp * etexp + mSigmaT * mSigmaT );
106+ double sigma = TMath::Sqrt (etexp * etexp + etof * etof );
104107 double deltat = tof - texp;
105108
106109 double w = 1 . / (sigma * sigma);
@@ -110,14 +113,74 @@ TOFLayer::eventTime(std::vector<Track *> &tracks, std::array<float, 2> &tzero)
110113 }
111114
112115 if (sumw <= 0 .) {
113- mTime0 = 0 .;
114- mSigma0 = 1000 . ;
116+ tzero[ 0 ] = 0 .;
117+ tzero[ 1 ] = mSigma0 ;
115118 return false ;
116119 }
117120
118- mTime0 = tzero[0 ] = sum / sumw;
119- mSigma0 = tzero[1 ] = sqrt (1 . / sumw);
121+ tzero[0 ] = sum / sumw;
122+ tzero[1 ] = sqrt (1 . / sumw);
123+
124+ // if we have many tracks, we use the start-time computed with all tracks
125+
126+ if (tracks.size () > 4 ) {
127+ for (auto &track : tracks) {
128+ track->TOuter -= tzero[0 ] * 1 .e -9 ; // [s]
129+ track->ErrorT = std::hypot (track->ErrorT , tzero[1 ] * 1 .e -9 );
130+ }
131+ return true ;
132+ }
133+
134+ // if we have few tracks, we do the combinations excluding the track of interest
135+
136+ std::vector<double > time0, sigma0;
137+ time0.reserve (tracks.size ());
138+ sigma0.reserve (tracks.size ());
139+ for (int itrack = 0 ; itrack < tracks.size (); ++itrack) {
140+
141+ time0[itrack] = 0 ;
142+ sigma0[itrack] = mSigma0 ;
143+
144+ sum = 0 .;
145+ sumw = 0 .;
146+
147+ for (int jtrack = 0 ; jtrack < tracks.size (); ++jtrack) {
148+ if (itrack == jtrack) continue ; // do not use self
149+
150+ auto &track = tracks[jtrack];
151+ int pid = track->PID ;
152+ double mass = TDatabasePDG::Instance ()->GetParticle (pid)->Mass ();
153+ double mass2 = mass * mass;
154+ double tof = track->TOuter * 1 .e9 ; // [ns]
155+ double etof = track->ErrorT * 1 .e9 ; // [ns]
156+ double L = track->L * 0.1 ; // [cm]
157+ double p = track->P ; // [GeV/c]
158+ double ep = track->ErrorP ;
159+ double p2 = p * p;
160+ double c = 29.9792458 ; // [cm/ns]
161+ double Lc = L / c;
162+ double texp = Lc / p * TMath::Sqrt (mass2 + p2);
163+ double etexp = Lc * mass2 / p2 / TMath::Sqrt (mass2 + p2) * ep;
164+ double sigma = TMath::Sqrt (etexp * etexp + etof * etof);
165+ double deltat = tof - texp;
166+ double w = 1 . / (sigma * sigma);
167+ sum += w * deltat;
168+ sumw += w;
169+ }
170+
171+ if (sumw <= 0 .) continue ;
172+
173+ time0[itrack] = sum / sumw;
174+ sigma0[itrack] = std::sqrt (1 . / sumw);
120175
176+ }
177+
178+ for (int itrack = 0 ; itrack < tracks.size (); ++itrack) {
179+ auto &track = tracks[itrack];
180+ track->TOuter -= time0[itrack] * 1 .e -9 ; // [s]
181+ track->ErrorT = std::hypot (track->ErrorT , sigma0[itrack] * 1 .e -9 );
182+ }
183+
121184 return true ;
122185}
123186
0 commit comments