5 #include "GaudiKernel/ServiceHandle.h"
24 (
const std::string&
name,ISvcLocator* pSvcLocator)
56 m_pdg = std::abs(m_pdg) ;
58 m_trackCollectionStat.resize(m_tracklocation.size());
62 ATH_CHECK(m_truth_locationStrip.initialize(m_useStrip));
63 ATH_CHECK(m_clustersStripname.initialize(m_useStrip));
64 ATH_CHECK(m_spacepointsStripname.initialize(m_useStrip));
66 ATH_CHECK( m_clustersPixelname.initialize(m_usePix));
67 ATH_CHECK( m_spacepointsPixelname.initialize(m_usePix));
68 ATH_CHECK( m_truth_locationPixel.initialize(m_usePix));
70 ATH_CHECK( m_spacepointsOverlapname.initialize(m_useStrip));
75 ATH_CHECK(m_pixelDetEleCollKey.initialize());
76 ATH_CHECK(m_StripDetEleCollKey.initialize());
93 if(!m_usePix && !m_useStrip)
return StatusCode::SUCCESS;
96 std::vector<SG::ReadHandle<PRD_MultiTruthCollection> > read_handle;
97 read_handle.reserve(3);
99 read_handle.emplace_back(m_truth_locationPixel,ctx);
100 if (not read_handle.back().isValid()) {
102 return StatusCode::FAILURE;
104 event_data.
m_truthPix = &(*read_handle.back());
108 read_handle.emplace_back(m_truth_locationStrip,ctx);
109 if (not read_handle.back().isValid()) {
111 return StatusCode::FAILURE;
116 newClustersEvent (ctx,event_data);
117 newSpacePointsEvent (ctx,event_data);
118 event_data.
m_nqtracks = qualityTracksSelection(event_data);
119 tracksComparison (ctx,event_data);
122 efficiencyReconstruction(event_data);
123 if(msgLvl(
MSG::DEBUG)) noReconstructedParticles(event_data);
128 std::lock_guard<std::mutex> lock(m_statMutex);
130 for (
unsigned int i=0;
i< m_trackCollectionStat.size(); ++
i ) {
137 dumpevent(
msg(),event_data);
140 return StatusCode::SUCCESS;
148 if(m_eventStat.m_events<=0)
return StatusCode::SUCCESS;
149 const auto & w13 = std::setw(13);
150 const auto & p5 = std::setprecision(5);
151 const auto topNtail=[](
const std::string &
str){
return "|" +
str +
"|";};
152 const std::string lineSeparator(83,
'-');
153 const std::string spaceSeparator(83,
' ');
154 std::stringstream
out;
156 out<<topNtail(lineSeparator)<<
"\n";
157 out<<
"| TrackClusterAssValidation statistic for charge truth particles with |\n";
158 out<<topNtail(spaceSeparator)<<
"\n";
160 out<<
"| eta bins for eta dependent variables = [0.0, ";
161 for (
unsigned int etabin = 1; etabin<(m_etabins.size()-1); etabin++)
162 out << std::setw(2) << std::setprecision(1) << m_etabins.value().at(etabin) <<
", ";
163 out << std::setw(2) << m_etabins.value().back() <<
"] |\n";
164 out<<
"| eta dependent pT [MeV] >= [";
165 for (
unsigned int ptbin = 0; ptbin<(m_ptcuts.size()-1); ptbin++)
166 out<<std::setw(6)<<std::setprecision(2)<<m_ptcuts.value().at(ptbin)<<
", ";
167 out<<std::setw(6)<<std::setprecision(2)<<m_ptcuts.value().back()<<
"] |\n";
168 if(m_ptcutmax < 1000000.) {
169 out<<
"| pT <="<<w13<<p5<<m_ptcutmax<<
" MeV"<<
" |\n";
171 out<<
"| |rapidity| <="<<w13<<p5<<m_rapcut<<
" |\n";
172 out<<
"| max vertex radius <="<<w13<<p5<<m_rmax<<
" mm"<<
" |\n";
173 out<<
"| min vertex radius >="<<w13<<p5<<m_rmin<<
" mm"<<
" |\n";
174 out<<
"| particles pdg ="<<std::setw(8)<<m_pdg<<
" |\n";
176 auto yesNo=[](
const bool predicate){
return predicate ?
"yes" :
"no ";};
177 out<<
"| use Pixels information "<<yesNo(m_usePix)<<
" |\n";
178 out<<
"| use Strip information "<<yesNo(m_useStrip)<<
" |\n";
179 out<<
"| take into account outliers "<<yesNo(m_useOutliers)<<
" |\n";
180 out<<topNtail(spaceSeparator)<<
"\n";
181 if(!m_usePix && !m_useStrip)
return StatusCode::SUCCESS;
182 enum Regions{Barrel, Transition, Endcap, Forward, NRegions};
183 auto incrementArray=[](
auto &
array,
const int idx){
for (
int j{};j!=NRegions;++j)
array[
idx][j] +=
array[
idx+1][j];};
184 for(
int i=48;
i>=0; --
i) {
185 m_eventStat.m_particleClusters [
i] +=m_eventStat.m_particleClusters [
i+1];
186 incrementArray(m_eventStat.m_particleClustersBTE,
i);
187 m_eventStat.m_particleSpacePoints [
i] +=m_eventStat.m_particleSpacePoints [
i+1];
188 incrementArray(m_eventStat.m_particleSpacePointsBTE,
i);
190 auto coerceToOne=[](
const double & initialVal)->
double {
return (initialVal<1.) ? 1. : initialVal; };
197 double pa = coerceToOne(m_eventStat.m_particleClusters[0]);
198 std::array<double, 10> pc2ff{};
199 size_t clusterIdx = 2;
200 for (
auto & thisCluster: pc2ff){
201 thisCluster =
double(m_eventStat.m_particleClusters[ clusterIdx++ ])/ pa;
204 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Barrel]);
205 std::array<double, 10> pcBarrel2ff{};
206 size_t clusterBarrelIdx = 2;
207 for (
auto & thisClusterB: pcBarrel2ff){
208 thisClusterB =
double(m_eventStat.m_particleClustersBTE[ clusterBarrelIdx++ ][Barrel])/ pa;
211 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Transition]);
212 std::array<double, 10> pcTransition2ff{};
213 size_t clusterTransitionIdx = 2;
214 for (
auto & thisClusterT: pcTransition2ff){
215 thisClusterT =
double(m_eventStat.m_particleClustersBTE[ clusterTransitionIdx++ ][Transition])/ pa;
218 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Endcap]);
219 std::array<double, 10> pcEndcap2ff{};
220 size_t clusterEndcapIdx = 2;
221 for (
auto & thisClusterE: pcEndcap2ff){
222 thisClusterE =
double(m_eventStat.m_particleClustersBTE[ clusterEndcapIdx++ ][Endcap])/ pa;
225 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][3]);
226 std::array<double, 10> pcFwd2ff{};
227 size_t clusterFwdIdx = 2;
228 for (
auto & thisClusterD: pcFwd2ff){
229 thisClusterD =
double(m_eventStat.m_particleClustersBTE[ clusterFwdIdx++ ][Forward])/ pa;
235 pa = coerceToOne(m_eventStat.m_particleSpacePoints[0]);
236 std::array<double, 10> sp2ff{};
237 size_t spacepointIdx = 2;
238 for (
auto & thisSpacepoint: sp2ff){
239 thisSpacepoint =
double(m_eventStat.m_particleSpacePoints[ spacepointIdx++ ])/ pa;
242 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][Barrel]);
243 std::array<double, 10> spBarrel2ff{};
244 size_t spacepointBarrelIdx = 2;
245 for (
auto & thisSpacepoint: spBarrel2ff){
246 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointBarrelIdx++ ][Barrel])/ pa;
249 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][Transition]);
250 std::array<double, 10> spTransition2ff{};
251 size_t spacepointTransitionIdx = 2;
252 for (
auto & thisSpacepoint: spTransition2ff){
253 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointTransitionIdx++ ][Transition])/ pa;
256 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][Endcap]);
257 std::array<double, 10> spEndcap2ff{};
258 size_t spacepointEndcapIdx = 2;
259 for (
auto & thisSpacepoint: spEndcap2ff){
260 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointEndcapIdx++ ][Endcap])/ pa;
263 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][Forward]);
264 std::array<double, 10> spFwd2ff{};
265 size_t spacepointFwdIdx = 2;
266 for (
auto & thisSpacepoint: spFwd2ff){
267 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointFwdIdx++ ][Forward])/ pa;
269 auto w8=std::setw(8);
270 out<<
"| Probability for such charge particles to have some number silicon |\n";
271 out<<
"| clusters | space points |\n";
272 out<<
"| Total Barrel Transi Endcap Forward | Total Barrel Transi Endcap Forward |\n";
275 out<<
"| >= "<<
idx+2<< std::string((
idx<8)?
" ":
" ")
277 <<w8<<p5<<pcBarrel2ff[
idx]
278 <<w8<<p5<<pcTransition2ff[
idx]
279 <<w8<<p5<<pcEndcap2ff[
idx]
280 <<w8<<p5<<pcFwd2ff[
idx]<<
" | "
283 <<w8<<p5<<spBarrel2ff[
idx]
284 <<w8<<p5<<spTransition2ff[
idx]
285 <<w8<<p5<<spEndcap2ff[
idx]
286 <<w8<<p5<<spFwd2ff[
idx]
290 out<<topNtail(spaceSeparator)<<
"\n";
291 out<<
"| Additional cuts for truth particles are |\n";
292 out<<
"| eta dependent number of silicon clusters >= [";
293 for (
unsigned int clbin = 0; clbin<(m_clcuts.size()-1); clbin++)
294 out<<std::setw(2)<<m_clcuts.value().at(clbin)<<
", ";
295 out<<std::setw(2)<<m_clcuts.value().back()<<
"] |\n";
296 out<<
"| number space points >="<<w13<<m_spcut.value()<<
" |\n";
298 pa = coerceToOne(m_eventStat.m_particleClusters[0]);
299 out<<
"| Probability find truth particles with this cuts is "<<w8<<p5<<
double(m_eventStat.m_events)/pa<<
" |\n";
300 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Barrel]);
301 out<<
"| For barrel region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[Barrel])/pa<<
" |\n";
302 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Transition]);
303 out<<
"| For transition region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[Transition])/pa<<
" |\n";
304 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Endcap]);
305 out<<
"| For endcap region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[Endcap])/pa<<
" |\n";
306 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Forward]);
307 out<<
"| For forward region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[Forward])/pa<<
" |\n";
309 pa = coerceToOne(m_eventStat.m_nclustersNegBP);
310 double ratio =
double(m_eventStat.m_nclustersPosBP)/pa;
312 out<<
"| Ratio barrel pixels clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
313 pa = coerceToOne(m_eventStat.m_nclustersNegEP);
316 out<<
"| Ratio endcap pixels clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
317 pa = coerceToOne(m_eventStat.m_nclustersNegBS);
320 out<<
"| Ratio barrel Strip clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
321 pa = coerceToOne(m_eventStat.m_nclustersNegES);
324 out<<
"| Ratio endcap Strip clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
325 pa =
double(m_eventStat.m_eventsNEG);
if(pa < 1.) pa = 1.;
328 out<<
"| Number truth particles and +/- ratio ="<<std::setw(10)<<m_eventStat.m_events<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
330 if(m_eventStat.m_nclustersPTOT!=0)
ratio =
double(m_eventStat.m_nclustersPTOTt)/
double(m_eventStat.m_nclustersPTOT);
332 out<<
"| Number pix clusters, truth clusters and ratio = "
333 <<std::setw(10)<<m_eventStat.m_nclustersPTOT
334 <<std::setw(10)<<m_eventStat.m_nclustersPTOTt
335 <<std::setw(12)<<std::setprecision(5)<<
ratio<<
" |\n";
337 if(m_eventStat.m_nclustersSTOT!=0)
ratio =
double(m_eventStat.m_nclustersSTOTt)/
double(m_eventStat.m_nclustersSTOT);
338 out<<
"| Number strip clusters, truth clusters and ratio = "
339 <<std::setw(10)<<m_eventStat.m_nclustersSTOT
340 <<std::setw(10)<<m_eventStat.m_nclustersSTOTt
341 <<std::setw(12)<<std::setprecision(5)<<
ratio<<
" |\n";
343 out<<
"|-----------------------------------------------------------------------------------|\n\n";
348 int n = 47-(
t->key().size());
349 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
352 out<<
"|-----------------------------------------------------------------------------------|\n";
353 out<<
"| Statistic for "<<(
t->key())<<s1<<
"\n";
355 double ne =
double(m_eventStat.m_events);
if(ne < 1.) ne = 1.;
356 double ef [6];
for(
int i=0;
i!=6; ++
i)
ef [
i] =
double(m_trackCollectionStat[
nc].m_efficiency [
i]) /ne;
357 double ef0[6];
for(
int i=0;
i!=6; ++
i) ef0[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyN [
i][0])/ne;
358 double ef1[6];
for(
int i=0;
i!=6; ++
i) ef1[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyN [
i][1])/ne;
359 double ef2[6];
for(
int i=0;
i!=6; ++
i) ef2[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyN [
i][2])/ne;
362 using EffArray_t = std::array<double, 6>;
364 auto makeEffArray = [](
const auto & threeDimArray,
const size_t secondIdx,
const size_t thirdIdx,
const double denom){
367 auto invDenom = 1./
denom;
369 entry = threeDimArray[
idx++][secondIdx][thirdIdx]*invDenom;
374 const auto & efficiencyArrayInput = m_trackCollectionStat[
nc].m_efficiencyBTE;
376 double neBTE = coerceToOne(m_eventStat.m_eventsBTE[Barrel]);
377 const EffArray_t efB0 = makeEffArray(efficiencyArrayInput,0,Barrel,neBTE);
378 const EffArray_t efB1 = makeEffArray(efficiencyArrayInput,1,Barrel,neBTE);
379 const EffArray_t efB2 = makeEffArray(efficiencyArrayInput,2,Barrel,neBTE);
380 const EffArray_t efB3 = makeEffArray(efficiencyArrayInput,3,Barrel,neBTE);
381 const EffArray_t efB4 = makeEffArray(efficiencyArrayInput,4,Barrel,neBTE);
383 neBTE = coerceToOne(m_eventStat.m_eventsBTE[Transition]);
384 const EffArray_t efT0 = makeEffArray(efficiencyArrayInput,0,Transition,neBTE);
385 const EffArray_t efT1 = makeEffArray(efficiencyArrayInput,1,Transition,neBTE);
386 const EffArray_t efT2 = makeEffArray(efficiencyArrayInput,2,Transition,neBTE);
387 const EffArray_t efT3 = makeEffArray(efficiencyArrayInput,3,Transition,neBTE);
388 const EffArray_t efT4 = makeEffArray(efficiencyArrayInput,4,Transition,neBTE);
390 neBTE = coerceToOne(m_eventStat.m_eventsBTE[Endcap]);
391 const EffArray_t efE0 = makeEffArray(efficiencyArrayInput,0,Endcap,neBTE);
392 const EffArray_t efE1 = makeEffArray(efficiencyArrayInput,1,Endcap,neBTE);
393 const EffArray_t efE2 = makeEffArray(efficiencyArrayInput,2,Endcap,neBTE);
394 const EffArray_t efE3 = makeEffArray(efficiencyArrayInput,3,Endcap,neBTE);
395 const EffArray_t efE4 = makeEffArray(efficiencyArrayInput,4,Endcap,neBTE);
397 neBTE = coerceToOne(m_eventStat.m_eventsBTE[Forward]);
398 const EffArray_t efD0 = makeEffArray(efficiencyArrayInput,0,Forward,neBTE);
399 const EffArray_t efD1 = makeEffArray(efficiencyArrayInput,1,Forward,neBTE);
400 const EffArray_t efD2 = makeEffArray(efficiencyArrayInput,2,Forward,neBTE);
401 const EffArray_t efD3 = makeEffArray(efficiencyArrayInput,3,Forward,neBTE);
402 const EffArray_t efD4 = makeEffArray(efficiencyArrayInput,4,Forward,neBTE);
405 double efrec = ef0[0]+ef0[1]+ef0[2]+ef1[0]+ef1[1]+ef2[0];
406 double efrecB = efB0[0]+efB0[1]+efB0[2]+efB1[0]+efB1[1]+efB2[0];
407 double efrecT = efT0[0]+efT0[1]+efT0[2]+efT1[0]+efT1[1]+efT2[0];
408 double efrecE = efE0[0]+efE0[1]+efE0[2]+efE1[0]+efE1[1]+efE2[0];
409 double efrecD = efD0[0]+efD0[1]+efD0[2]+efD1[0]+efD1[1]+efD2[0];
411 ne = coerceToOne(m_eventStat.m_eventsPOS);
412 double efP[6];
for(
int i=0;
i!=6; ++
i) efP[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyPOS[
i])/ne;
413 ne = coerceToOne(m_eventStat.m_eventsNEG);
414 double efN[6];
for(
int i=0;
i!=6; ++
i) efN[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyNEG[
i])/ne;
416 out<<
"|-----------------------------------------------------------------------------------|\n";
417 out<<
"| Probability to lose 0 1 2 3 4 >=5 clusters |\n";
418 out<<
"|-----------------------------------------------------------------------------------|\n";
420 auto formattedOutput=[&
out](
auto & effArray){
421 for (
size_t i{};
i!=6;++
i){
422 out<<std::setw(9)<<std::setprecision(4)<<effArray[
i];
427 out<<
"| For all particles ";
429 out<<
"| For + particles ";
430 formattedOutput(efP);
431 out<<
"| For - particles ";
432 formattedOutput(efN);
433 out<<
"|-----------------------------------------------------------------------------------|\n";
434 out<<
"| Barrel region |\n";
435 out<<
"| 0 wrong clusters ";
436 formattedOutput(efB0);
437 out<<
"| 1 wrong clusters ";
438 formattedOutput(efB1);
439 out<<
"| 2 wrong clusters ";
440 formattedOutput(efB2);
441 out<<
"| 3 wrong clusters ";
442 formattedOutput(efB3);
443 out<<
"| >=4 wrong clusters ";
444 formattedOutput(efB4);
445 out<<
"|-----------------------------------------------------------------------------------|\n";
446 out<<
"| Transition region |\n";
447 out<<
"| 0 wrong clusters ";
448 formattedOutput(efT0);
449 out<<
"| 1 wrong clusters ";
450 formattedOutput(efT1);
451 out<<
"| 2 wrong clusters ";
452 formattedOutput(efT2);
453 out<<
"| 3 wrong clusters ";
454 formattedOutput(efT3);
455 out<<
"| >=4 wrong clusters ";
456 formattedOutput(efT4);
457 out<<
"|-----------------------------------------------------------------------------------|\n";
458 out<<
"| Endcap region |\n";
459 out<<
"| 0 wrong clusters ";
460 formattedOutput(efE0);
461 out<<
"| 1 wrong clusters ";
462 formattedOutput(efE1);
463 out<<
"| 2 wrong clusters ";
464 formattedOutput(efE2);
465 out<<
"| 3 wrong clusters ";
466 formattedOutput(efE3);
467 out<<
"| >=4 wrong clusters ";
468 formattedOutput(efE4);
469 out<<
"|-----------------------------------------------------------------------------------|\n";
470 out<<
"| Forward region |\n";
471 out<<
"| 0 wrong clusters ";
472 formattedOutput(efD0);
473 out<<
"| 1 wrong clusters ";
474 formattedOutput(efD1);
475 out<<
"| 2 wrong clusters ";
476 formattedOutput(efD2);
477 out<<
"| 3 wrong clusters ";
478 formattedOutput(efD3);
479 out<<
"| >=4 wrong clusters ";
480 formattedOutput(efD4);
482 out<<
"|-----------------------------------------------------------------------------------|\n";
483 pa = coerceToOne(m_eventStat.m_particleClusters[0]);
484 out<<
"| Efficiency reconstruction (number lose+wrong < 3) = "
485 <<std::setw(9)<<std::setprecision(5)<<efrec
487 <<std::setw(9)<<std::setprecision(5)<<efrec*
double(m_eventStat.m_events)/pa
490 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Barrel]);
491 out<<
"| For barrel region = "
492 <<std::setw(9)<<std::setprecision(5)<<efrecB
494 <<std::setw(9)<<std::setprecision(5)<<efrecB*
double(m_eventStat.m_eventsBTE[Barrel])/pa
497 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Transition]);
498 out<<
"| For transition region = "
499 <<std::setw(9)<<std::setprecision(5)<<efrecT
501 <<std::setw(9)<<std::setprecision(5)<<efrecT*
double(m_eventStat.m_eventsBTE[Transition])/pa
504 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Endcap]);
505 out<<
"| For endcap region = "
506 <<std::setw(9)<<std::setprecision(5)<<efrecE
508 <<std::setw(9)<<std::setprecision(5)<<efrecE*
double(m_eventStat.m_eventsBTE[Endcap])/pa
511 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Forward]);
512 out<<
"| For forward region = "
513 <<std::setw(9)<<std::setprecision(5)<<efrecD
515 <<std::setw(9)<<std::setprecision(5)<<efrecD*
double(m_eventStat.m_eventsBTE[Forward])/pa
519 out<<
"|-----------------------------------------------------------------------------------|\n";
520 out<<
"| Reconstructed tracks + - +/-ratio error |\n";
521 out<<
"|-----------------------------------------------------------------------------------|\n";
523 pa = coerceToOne(m_trackCollectionStat[
nc].m_ntracksNEGB);
528 <<std::setw(10)<<m_trackCollectionStat[
nc].m_ntracksPOSB
529 <<std::setw(11)<<m_trackCollectionStat[
nc].m_ntracksNEGB
530 <<std::setw(11)<<std::setprecision(5)<<
ratio
531 <<std::setw(11)<<std::setprecision(5)<<
eratio<<
" |\n";
532 pa = coerceToOne(m_trackCollectionStat[
nc].m_ntracksNEGE);
537 <<std::setw(10)<<m_trackCollectionStat[
nc].m_ntracksPOSE
538 <<std::setw(11)<<m_trackCollectionStat[
nc].m_ntracksNEGE
539 <<std::setw(11)<<std::setprecision(5)<<
ratio
540 <<std::setw(11)<<std::setprecision(5)<<
eratio<<
" |\n";
541 pa = coerceToOne(m_trackCollectionStat[
nc].m_ntracksNEGFWD);
542 ratio =
double(m_trackCollectionStat[
nc].m_ntracksPOSFWD)/pa;
546 <<std::setw(10)<<m_trackCollectionStat[
nc].m_ntracksPOSFWD
547 <<std::setw(11)<<m_trackCollectionStat[
nc].m_ntracksNEGFWD
548 <<std::setw(11)<<std::setprecision(5)<<
ratio
549 <<std::setw(11)<<std::setprecision(5)<<
eratio<<
" |\n";
556 for(
int k = 0;
k!=50; ++
k) {
557 nt+=m_trackCollectionStat[
nc].m_total[
k];
558 ft+=m_trackCollectionStat[
nc].m_fake [
k];
559 if(!kf &&
nt) kf =
k;
564 out<<
"|-----------------------------------------------------------------------------------|\n";
565 out<<
"| Fake tracks rate for different number of clusters on track |\n";
566 out<<
"|-----------------------------------------------------------------------------------|\n";
568 for(
int k = kf;
k!=kf+6; ++
k) {
569 out<<
"| >= "<<std::setw(2)<<
k<<
" ";
573 for(
int k = kf;
k!=kf+6; ++
k) {
575 out<<
"|"<<std::setw(12)<<std::setprecision(5)<<
eff<<
" ";
576 nt-=m_trackCollectionStat[
nc].m_total[
k];
577 ft-=m_trackCollectionStat[
nc].m_fake [
k];
580 out<<
"|-----------------------------------------------------------------------------------|\n";
585 return StatusCode::SUCCESS;
598 out<<
"|--------------------------------------------------------------------------------------------------------------------|\n";
600 n = 65-
t->key().size();
601 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
602 out<<
"| Location of input tracks | "<<
t->key()<<s1<<
"\n";
604 auto padString = [](
const std::string &
s){
605 const int n = 65 -
s.size();
606 return s + std::string(
n,
' ');
608 std::string
s2 = padString(m_spacepointsPixelname.key());
609 std::string
s3 = padString(m_spacepointsStripname.key());
610 std::string
s4 = padString(m_spacepointsOverlapname.key());
611 std::string s5 = padString(m_clustersPixelname.key());
612 std::string s6 = padString(m_clustersStripname.key());
614 std::string s7 = padString(m_truth_locationPixel.key());
615 std::string s8 = padString(m_truth_locationStrip.key());
617 out<<
"| Pixel space points | "<<
s2<<
"|\n";
618 out<<
"| Strip space points | "<<
s3<<
"|\n";
619 out<<
"| Overlap space points | "<<
s4<<
"|\n";
620 out<<
"| Pixel clusters | "<<s5<<
"|\n";
621 out<<
"| Strip clusters | "<<s6<<
"|\n";
622 out<<
"| Truth location for pixels | "<<s7<<
"|\n";
623 out<<
"| Truth location for strips | "<<s8<<
"|\n";
624 out<<
"| max pT cut | "
625 <<std::setw(14)<<std::setprecision(5)<<m_ptcutmax
627 out<<
"| rapidity cut | "
628 <<std::setw(14)<<std::setprecision(5)<<m_rapcut
630 out<<
"| min Radius | "
631 <<std::setw(14)<<std::setprecision(5)<<m_rmin
633 out<<
"| max Radius | "
634 <<std::setw(14)<<std::setprecision(5)<<m_rmax
636 out<<
"| Min. number sp.points for generated track | "
637 <<std::setw(14)<<std::setprecision(5)<<m_spcut
639 out<<
"|--------------------------------------------------------------------------------------------------------------------|\n";
650 auto formatOutput = [&
out](
const auto val){
654 out<<
"|---------------------------------------------------------------------|\n";
655 out<<
"| m_nspacepoints | ";
657 out<<
"| m_nclusters | ";
659 out<<
"| Kine-Clusters size | ";
661 out<<
"| Kine-SpacePoints size | ";
663 out<<
"| Number good kine tracks | ";
665 out<<
"|---------------------------------------------------------------------|\n";
676 std::lock_guard<std::mutex> lock(m_statMutex);
680 std::unique_ptr<SG::ReadHandle<InDet::SiClusterContainer> > pixelcontainer;
681 std::unique_ptr<SG::ReadHandle<InDet::SiClusterContainer> > stripcontainer;
684 pixelcontainer = std::make_unique<SG::ReadHandle<InDet::SiClusterContainer> >(m_clustersPixelname,ctx);
685 if (!pixelcontainer->isValid())
ATH_MSG_DEBUG(
"Failed to create Pixel clusters container read handle with key " << m_clustersPixelname.key());
691 stripcontainer = std::make_unique<SG::ReadHandle<InDet::SiClusterContainer> >(m_clustersStripname,ctx);
692 if (!stripcontainer->isValid())
ATH_MSG_DEBUG(
"Failed to create Strip clusters container read handle with key " << m_clustersStripname.key());
700 if(pixelcontainer && pixelcontainer->isValid()) {
701 InDet::SiClusterContainer::const_iterator
w = (*pixelcontainer)->begin();
702 InDet::SiClusterContainer::const_iterator we = (*pixelcontainer)->end ();
706 InDet::SiClusterCollection::const_iterator
c = (*w)->begin();
707 InDet::SiClusterCollection::const_iterator ce = (*w)->end ();
712 ++m_eventStat.m_nclustersPTOT;
713 if(isTruth(event_data,(*
c))) ++m_eventStat.m_nclustersPTOTt;
716 int nk = kine(event_data,(*
c),Kine,999);
717 for(
int i=0;
i!=nk; ++
i) {
718 if(!isTheSameDetElement(event_data,Kine[
i],(*
c))) {
730 if(stripcontainer && stripcontainer->isValid()) {
731 InDet::SiClusterContainer::const_iterator
w = (*stripcontainer)->begin();
732 InDet::SiClusterContainer::const_iterator we = (*stripcontainer)->end ();
736 InDet::SiClusterCollection::const_iterator
c = (*w)->begin();
737 InDet::SiClusterCollection::const_iterator ce = (*w)->end ();
742 ++m_eventStat.m_nclustersSTOT;
743 if(isTruth(event_data,(*
c))) ++m_eventStat.m_nclustersSTOTt;
745 int nk = kine(event_data,(*
c),Kine,999);
746 for(
int i=0;
i!=nk; ++
i) {
747 if(!isTheSameDetElement(event_data,Kine[
i],(*
c))) event_data.
m_kinecluster.insert(std::make_pair(Kine[
i],(*
c)));
765 if(m_usePix && !m_spacepointsPixelname.key().empty()) {
768 ATH_MSG_DEBUG(
"Invalid Pixels space points container read handle for key " << m_spacepointsPixelname.key() );
773 for(; spc != spce; ++spc) {
777 for(; sp != spe; ++sp) {
780 int nk = kine(event_data,(*sp)->clusterList().first,Kine,999);
781 for(
int i=0;
i!=nk; ++
i) {
783 if(!isTheSameDetElement(event_data,Kine[
i],(*sp))) {
794 if(m_useStrip && !m_spacepointsStripname.key().empty()) {
797 ATH_MSG_DEBUG(
"Invalid Strip space points container read handle for key " << m_spacepointsStripname.key() );
803 for(; spc != spce; ++spc) {
808 for(; sp != spe; ++sp) {
812 int nk = kine(event_data,(*sp)->clusterList().first,(*sp)->clusterList().second,Kine,999);
813 for(
int i=0;
i!=nk; ++
i) {
814 if(!isTheSameDetElement(event_data,Kine[
i],(*sp))) {
825 if(m_useStrip && !m_spacepointsOverlapname.key().empty()) {
826 event_data.
m_spacepointsOverlap=std::make_unique< SG::ReadHandle<SpacePointOverlapCollection> >(m_spacepointsOverlapname,ctx);
828 ATH_MSG_DEBUG(
"Invalid overlap space points container read handle for key " << m_spacepointsOverlapname.key() );
834 for (; sp!=spe; ++sp) {
837 int nk = kine(event_data,(*sp)->clusterList().first,(*sp)->clusterList().second,Kine,999);
838 for(
int i=0;
i!=nk; ++
i) {
839 if(!isTheSameDetElement(event_data,Kine[
i],(*sp))) {
864 std::list<int> worskine;
871 unsigned int nc = 1 ;
873 auto coerceTo49 = [] (
const size_t idx){
874 return (
idx<50) ?
idx : 49;
879 if((*c).first==
k0) {++
nc;
continue;}
882 const size_t clusterIdx =coerceTo49(
nc);
887 const size_t spacepointIdx =coerceTo49(
ns);
891 if (
nc < minclusters(eta) ) worskine.push_back(
k0);
908 if (
nc < minclusters(eta) ) worskine.push_back(
k0);
913 for(
auto & pThisCluster: worskine) {
923 if (not de)
continue;
965 if(++
nc >= 100)
return;
977 int KINE[200],NKINE[200];
982 se = (*t)->trackStateOnSurfaces()->end();
991 const AmgVector(5)& Vpf = tpf ->parameters ();
992 double pTf = std::abs(
std::sin(Vpf[3])/Vpf[4]);
993 double etaf = std::abs(
log(
tan(.5*Vpf[3])));
994 bool qTf = pTf > minpT(etaf);
1006 double minpt = minpT(rap);
1007 if (
pT > minpt &&
pT < m_ptcutmax) {
1012 else if(pT < -minpt && pT > -m_ptcutmax) {
1038 int Kine[1000], nk=kine0(event_data,rd,Kine,999); ++
NC;
if(!nk) ++N0;
1040 for(
int k = 0;
k!=nk; ++
k) {
1043 for(;
n!=NK; ++
n) {
if(Kine[
k]==KINE[
n]) {++NKINE[
n];
break;}}
1044 if(
n==NK) {KINE[NK] = Kine[
k]; NKINE[NK] = 1;
if (NK < 200) ++NK;}
1046 for(
int n=0;
n!=NK; ++
n) {
if(NKINE[
n]>nkm) nkm = NKINE[
n];}
1049 for(
int n=0;
n!=NK; ++
n) {
1051 int NQ = 1000*NKINE[
n]+(
NC-NKINE[
n]);
1053 event_data.
m_tracks[
nc].insert(std::make_pair(KINE[
n],NQ));
1077 std::multimap<int,int>::const_iterator
t, te = event_data.
m_tracks[
nc].end();
1088 int ts = (*t).second/1000;
1089 int ws = (*t).second%1000;
1090 if (
ts >
m ) {
m =
ts;
w = ws;}
1091 else if(
ts==
m &&
w > ws) {
w = ws;}
1093 int d =
n-
m;
if(
d<0)
d = 0;
else if(
d > 5)
d=5;
if(
w>4)
w = 4;
1098 int ch = (*p).charge();
1121 int Kine1[1000],Kine2[1000];
1122 int n1 = kine(event_data,
d1,Kine1,
nmax);
if(!
n1)
return nkine;
1123 int n2 = kine(event_data,
d2,Kine2,
nmax);
if(!n2)
return nkine;
1125 for(
int i = 0;
i!=
n1; ++
i) {
1126 for(
int j = 0; j!=n2; ++j) {
1127 if(Kine1[
i]==Kine2[j]) {Kine[nkine++] = Kine1[
i];
break;}
1141 PRD_MultiTruthCollection::const_iterator mce;
1142 PRD_MultiTruthCollection::const_iterator
mc = findTruth(event_data,
d,mce);
1147 for(;
mc!=mce; ++
mc) {
1149 if( (*mc).first !=
ID )
return nkine;
1154 if(!pa or !pa->production_vertex())
continue;
1156 int pdg = std::abs(pa->pdg_id());
if(m_pdg && m_pdg != pdg )
continue;
1158 if ( std::abs(
MC::charge(pdg)) < .5 )
continue;
1162 double px = pa->momentum().px();
1163 double py = pa->momentum().py();
1164 double pz = pa->momentum().pz();
1166 if( pt < m_ptcut || pt > m_ptcutmax)
continue;
1170 double t = std::abs(
pz)/
pt;
1171 if(
t > m_tcut )
continue;
1175 double vx = pa->production_vertex()->position().x();
1176 double vy = pa->production_vertex()->position().y();
1177 double r = std::sqrt(vx*vx+vy*vy);
1178 if( r < m_rmin || r > m_rmax)
continue;
1193 PRD_MultiTruthCollection::const_iterator mce;
1194 PRD_MultiTruthCollection::const_iterator
mc = findTruth(event_data,
d,mce);
1199 for(;
mc!=mce; ++
mc) {
1201 if( (*mc).first !=
ID )
return nkine;
1216 PRD_MultiTruthCollection::const_iterator mce;
1217 PRD_MultiTruthCollection::const_iterator
mc = findTruth(event_data,
d,mce);
1228 std::multimap<int,const Trk::PrepRawData*>::const_iterator
k = event_data.
m_kinecluster.find(K);
1231 if((*k).first!= K)
return false;
1232 if(
d->detectorElement()==(*k).second->detectorElement())
return true;
1247 std::multimap<int,const Trk::SpacePoint*>::const_iterator
k = event_data.
m_kinespacepoint.find(K);
1252 if((*k).first!= K)
return false;
1257 if(
p1->detectorElement() ==
n1->detectorElement())
return true;
1265 if((*k).first!= K)
return false;
1270 if(
p1->detectorElement() ==
n1->detectorElement())
return true;
1271 if(
p2->detectorElement() ==
n1->detectorElement())
return true;
1291 std::list<int>::const_iterator dif = event_data.
m_difference[
nc].begin();
1293 std::multimap<int,const Trk::PrepRawData*>::const_iterator
c,ce = event_data.
m_kinecluster.end();
1295 int n = 69-m_tracklocation[
nc].key().size();
1296 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
1297 std::stringstream
out;
1298 out<<
"|----------------------------------------------------------------------------------------|\n";
1299 out<<
"| "<<m_tracklocation[
nc]<<s1<<
"\n";
1300 out<<
"|----------------------------------------------------------------------------------------|\n";
1301 out<<
"| # pdg kine Ncl Ntr Nsp Lose pT(MeV) rapidity radius z |\n";
1302 out<<
"|----------------------------------------------------------------------------------------|\n";
1312 PRD_MultiTruthCollection::const_iterator mce;
1313 PRD_MultiTruthCollection::const_iterator
mc = findTruth(event_data,
d,mce);
1317 for(;
mc!=mce; ++
mc) {
1318 if((*mc).first !=
ID)
break;
1326 double px = pa->momentum().px();
1327 double py = pa->momentum().py();
1328 double pz = pa->momentum().pz();
1329 double vx = pa->production_vertex()->position().x();
1330 double vy = pa->production_vertex()->position().y();
1331 double vz = pa->production_vertex()->position().z();
1333 double t = std::atan2(
pt,
pz);
1335 double r = std::sqrt(vx*vx+vy*vy);
1339 <<std::setw(6)<<pa->pdg_id()
1343 <<std::setw(4)<<(*dif)
1344 <<std::setw(12)<<std::setprecision(5)<<
pt
1345 <<std::setw(12)<<std::setprecision(5)<<ra
1346 <<std::setw(12)<<std::setprecision(5)<<
r
1347 <<std::setw(12)<<std::setprecision(5)<<vz
1352 out<<
"|----------------------------------------------------------------------------------------|\n";
1362 PRD_MultiTruthCollection::const_iterator
1366 PRD_MultiTruthCollection::const_iterator& mce)
1371 PRD_MultiTruthCollection::const_iterator
mc;
1377 for (
int i=0;
i<3;
i++) {
1379 mce=truth[
i]->end();
1380 return truth[
i]->end();
1383 throw std::runtime_error(
"Neither Pixel nor Strip truth.");
1396 PRD_MultiTruthCollection::const_iterator mce;
1397 PRD_MultiTruthCollection::const_iterator
mc = findTruth(event_data,
d,mce);
1399 for(;
mc!=mce; ++
mc) {
1405 double px =
pat->momentum().px();
1406 double py =
pat->momentum().py();
1407 double pz =
pat->momentum().pz();
1409 double t = std::atan2(
pt,
pz) ;
1416 eta > 1.6 ? rap = 2 : eta > .8 ? rap = 1 : rap = 0;
1418 int pdg =
pat->pdg_id();
1421 if(
ch > .5)
return 1;
1422 if(
ch < -.5)
return -1;