ATLAS Offline Software
TRT_TrackSegmentsMaker_ECcosmics.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Implementation file for class TRT_TrackSegmentsMaker_ECcosmics
8 // (c) ATLAS Detector software
10 
11 
12 
13 #include "TrkSurfaces/Surface.h"
22 #include "TGraphErrors.h"
23 #include "TF1.h"
24 #include "TVirtualFitter.h"
26 
27 #include "StoreGate/ReadHandle.h"
28 #include <cmath>
29 
30 
31 
33 // Constructor
35 
37 (const std::string& t,const std::string& n,const IInterface* p)
38  : AthAlgTool(t,n,p),
39  m_phaseMode(false),
40  m_riomakerD ("InDet::TRT_DriftCircleOnTrackTool/TRT_DriftCircleOnTrackTool" ),
41  m_riomakerN ("InDet::TRT_DriftCircleOnTrackNoDriftTimeTool/TRT_DriftCircleOnTrackNoDriftTimeTool"),
42  m_useDriftTime(false),
43  m_scaleTube(2.0),
44  m_scaleFactorDrift(1.0),
45  m_scaleTubeNoise(1.0),
46  m_cutToTLoose(7.),
47  m_cutToTTight(18.),
48  m_cutToTUpper(32.),
49  m_minDCSeed(7)
50 {
51  declareInterface<ITRT_TrackSegmentsMaker>(this);
52 
53  declareProperty("RIOonTrackToolYesDr" ,m_riomakerD );
54  declareProperty("RIOonTrackToolNoDr" ,m_riomakerN );
56  declareProperty("UseDriftTime", m_useDriftTime);
57  declareProperty("ScaleFactorTube", m_scaleTube);
58  declareProperty("ScaleFactorDrift", m_scaleFactorDrift);
59  declareProperty("ScaleFactorTubeNoise", m_scaleTubeNoise);
60  declareProperty("ToTCutLoose",m_cutToTLoose);
61  declareProperty("ToTCutTight",m_cutToTTight);
62  declareProperty("ToTCutUpper",m_cutToTUpper);
63  declareProperty("MinDCperSeed",m_minDCSeed);
64  declareProperty("HitLimit",m_hitLimit=2000);
65 
66 }
67 
69 // Destructor
71 
73 = default;
74 
75 
77 // Fitting functions
79 
80 Double_t fitf_ztanphi(const Double_t *x, const Double_t *par)
81 {
82  Double_t f = par[0]*(x[0]+par[1])/(x[0]+par[2]);
83  return f;
84 }
85 
86 Double_t fitf_zphi(const Double_t *x, const Double_t *par)
87 {
88  Double_t f = std::atan(par[0]*(x[0]+par[1])/(x[0]+par[2]));
89  return f;
90 }
91 
92 Double_t fitf_zphi_approx(const Double_t *x, const Double_t *par)
93 {
94  Double_t f = par[0]+par[1]*x[0]+par[2]*x[0]*x[0];
95  return f;
96 }
97 
99 // Initialisation
101 
103 {
105 
106  // Initialize ReadHandle
108 
109  // TRT
110  if (detStore()->retrieve(m_trtid, "TRT_ID").isFailure()) {
111  ATH_MSG_FATAL("Could not get TRT ID helper");
112  return StatusCode::FAILURE;
113  }
114 
115  // Get RIO_OnTrack creator with drift time information
116  //
117  if( m_riomakerD.retrieve().isFailure()) {
118  ATH_MSG_FATAL("Failed to retrieve tool "<< m_riomakerD);
119  return StatusCode::FAILURE;
120  }
121  ATH_MSG_DEBUG("Retrieved tool " << m_riomakerD);
122 
123  // Get RIO_OnTrack creator without drift time information
124  //
125 
126  if( m_riomakerN.retrieve().isFailure()) {
127  ATH_MSG_FATAL("Failed to retrieve tool "<< m_riomakerN);
128  return StatusCode::FAILURE;
129  }
130  ATH_MSG_DEBUG("Retrieved tool " << m_riomakerN);
131 
132  // optional PRD to track association map
133  //
135 
136 
137  return sc;
138 }
139 
140 
142  std::string fit_name1="ztanphi";
143  std::string fit_name2="zphi";
144  std::string fit_name3="zphi_ap";
145 
146  if(m_phaseMode){
147  fit_name1+="_phase";
148  fit_name2+="_phase";
149  fit_name3+="_phase";
150  }
151 
152  if(!m_prdToTrackMap.key().empty()){
153  fit_name1+="_asso";
154  fit_name2+="_asso";
155  fit_name3+="_asso";
156  }
157 
158  fit_name1+=name();
159  fit_name2+=name();
160  fit_name3+=name();
161 
162  event_data.m_fitf_ztanphi = new TF1(fit_name1.c_str(),fitf_ztanphi,-3000,3000,3);
163  event_data.m_fitf_zphi = new TF1(fit_name2.c_str(),fitf_zphi,-3000,3000,3);
164  event_data.m_fitf_zphi_approx = new TF1(fit_name3.c_str(),fitf_zphi_approx,-3000,3000,3);
165 }
166 
168 // Finalize
170 
172 {
174  return sc;
175 }
176 
178 // Initialize tool for new event
180 
181 std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData>
182 InDet::TRT_TrackSegmentsMaker_ECcosmics::newEvent (const EventContext& /*ctx*/) const
183 {
184 
185  std::unique_ptr<TRT_TrackSegmentsMaker_ECcosmics::EventData>
186  event_data = std::make_unique<TRT_TrackSegmentsMaker_ECcosmics::EventData>();
187 
188  setFitFunctions(*event_data);
189  //sort into good/noise hits
190  retrieveHits(*event_data);
191 
193  it=event_data->m_goodHits.begin();
194  itE=event_data->m_goodHits.end();
195 
196  //loop over good hits and sort them into sectors
197 
198  for(;it!=itE;++it){
199 
200  int straw = m_trtid->straw((*it)->identify());
201  const Amg::Vector3D& sc = (*it)->detectorElement()->strawCenter(straw);
202 
203  int phi = int((std::atan2(sc.y(),sc.x())+M_PI)*8./M_PI);
204 
205  if ( phi<0 ) phi = 15;
206  else if( phi>15 ) phi = 0 ;
207 
208  int z=0;
209  if(sc.z()<0) z=1;
210 
211  int zslice=int((std::abs(sc.z())-800.)/100.);
212 
213  event_data->m_sectors[z][zslice][phi].push_back(*it);
214 
215  }
216 
217  ATH_MSG_DEBUG("Number of good driftcircles: "<<event_data->m_goodHits.size());
218  ATH_MSG_DEBUG("Number of noise driftcircles: "<<event_data->m_noiseHits.size());
219 
220  return std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData>(event_data.release());
221 }
222 
224 // Initialize tool for new region
226 
227 std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData>
229 (const EventContext& /*ctx*/, const std::vector<IdentifierHash>& vTRT) const
230 {
231  (void) vTRT;
232  std::unique_ptr<TRT_TrackSegmentsMaker_ECcosmics::EventData>
233  event_data = std::make_unique<TRT_TrackSegmentsMaker_ECcosmics::EventData>();
234 
235  setFitFunctions(*event_data);
236 
237  // @TODO here the retrieve_hits method should be called with the list of the idhash
238 
239 
241  it=event_data->m_goodHits.begin();
242  itE=event_data->m_goodHits.end();
243 
244  //loop over good hits and sort them into sectors
245 
246  for(;it!=itE;++it){
247 
248  int straw = m_trtid->straw((*it)->identify());
249  const Amg::Vector3D& sc = (*it)->detectorElement()->strawCenter(straw);
250 
251  int phi = int((std::atan2(sc.y(),sc.x())+M_PI)*8./M_PI);
252 
253  if ( phi<0 ) phi = 15;
254  else if( phi>15 ) phi = 0 ;
255 
256  int z=0;
257  if(sc.z()<0) z=1;
258  int zslice=int((std::abs(sc.z())-800.)/100.);
259 
260  event_data->m_sectors[z][zslice][phi].push_back(*it);
261 
262  }
263 
264  ATH_MSG_DEBUG("Number of good driftcircles: "<<event_data->m_goodHits.size());
265  ATH_MSG_DEBUG("Number of noise driftcircles: "<<event_data->m_noiseHits.size());
266 
267  return std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData>(event_data.release());
268 }
269 
271 // Inform tool about end of event or region investigation
273 
275 {
276 }
277 
278 
279 
281 // Helper function to sort the DC along z
283 
284 namespace InDet{
286  {
287  const Amg::Vector3D& sc = x->detectorElement()->center();
288  double z1=sc.z();
289 
290 
291  const Amg::Vector3D& sc2 = y->detectorElement()->center();
292  double z2=sc2.z();
293 
294  return z1<z2;
295  }
296 
298  {
299  const Amg::Vector3D& sc = x->detectorElement()->center();
300  double y1=sc.y();
301 
302 
303  const Amg::Vector3D& sc2 = y->detectorElement()->center();
304  double y2=sc2.y();
305 
306  return y1>y2;
307  }
308 
310  {
311  const Amg::Vector3D& sc = x->detectorElement()->center();
312  double z1=sc.z();
313 
314 
315  const Amg::Vector3D& sc2 = y->detectorElement()->center();
316  double z2=sc2.z();
317 
318  return z1>z2;
319  }
320 }
321 
322 
323 
325 // Methods of TRT segment reconstruction in one event
327 
328 void InDet::TRT_TrackSegmentsMaker_ECcosmics::find(const EventContext & /*ctx*/,
331 {
334 
335 
336 
337  //loop over both endcaps
338  for(int endcap=0;endcap<2;endcap++){
339 
340  // 1st step: find sector with the maximal number of hits until no one is left
341  // with at least 5 hits
342 
343  int max=m_minDCSeed;
344 
345  while(max>=m_minDCSeed){
346  max=-1;
347  int sector=-1;
348  int zslice=-1;
349 
350  for(int j=0;j<20;j++){
351  for(int i=0;i<16;i++){
352  int count=event_data.m_sectors[endcap][j][i].size();
353 
354  if(count>0)
355  ATH_MSG_VERBOSE("Endcap "<<endcap<<" zslice "<<j<<" sector "<<i<<" : "<<count);
356 
357  if(count>max){
358  max=count;
359  sector=i;
360  zslice=j;
361  }
362  }
363  }
364 
365  if(sector<0) continue; // no hits in this endcap ...
366 
367  max=event_data.m_sectors[endcap][zslice][sector].size();
368 
369  //check if enough driftcircles present
370  if(max>=3){
371  ATH_MSG_VERBOSE("Number of DCs in seed sector: "<<max);
372 
373  //2nd step: find seed among those driftcircles
374 
375  bool found=find_seed(endcap,zslice,sector,event_data);
376 
377  //if no seed is found we clear the sector
378  if(!found){
379  event_data.m_sectors[endcap][zslice][sector].clear();
380  }
381  }
382 
383  }
384  }
385 
386  ATH_MSG_DEBUG("Found "<<event_data.m_seeds.size()<<" initial seeds !");
387 
388 
389  //now loop over all seeds and try to create segments out of them
390 
391  std::vector<std::vector<const InDet::TRT_DriftCircle*> *>::iterator sit,sitE;
392 
393  sit=event_data.m_seeds.begin();
394  sitE=event_data.m_seeds.end();
395 
396  for(;sit!=sitE;++sit){
397  create_segment(*sit, event_data);
398  }
399 
400 
401  ATH_MSG_DEBUG("Found "<<event_data.m_segments.size()<<" TRT Segments");
402 
403  event_data.m_segiterator = event_data.m_segments.begin();
404 }
405 
406 
408 // Find seeds
410 
411 
413  int zslice,
414  int sector,
416 {
417  double shift=0.;
418  double phimin=10.;
419  double phimax=-10.;
420 
421  std::vector<const InDet::TRT_DriftCircle*> dc;
423 
424  dc.reserve(event_data.m_sectors[endcap][zslice][sector].size());
425  itE=event_data.m_sectors[endcap][zslice][sector].end();
426  for(it=event_data.m_sectors[endcap][zslice][sector].begin();it!=itE;++it){
427  dc.push_back(*it);
428  }
429  //sort them along z
430 
431  std::sort(dc.begin(),dc.end(), CompareDCz);
432 
434  vit=dc.begin();
435  vitE=dc.end();
436 
437  ATH_MSG_VERBOSE("Sorted driftcircles: "<<dc.size());
438 
439  for(;vit!=vitE;++vit){
440  int straw = m_trtid->straw((*vit)->identify());
441  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
442 
443  ATH_MSG_VERBOSE("z="<<sc.z()<<" phi="<<sc.phi());
444 
445  }
446 
447 
448  //sanity check: if more than 40 good hits per seed -> not a pure cosmic event!
449 
450  if(dc.size()>=40) return false;
451 
452  //fill arrays for the fit
453 
454  vit=dc.begin();
455  vitE=dc.end();
456 
457 
458  for(;vit!=vitE;++vit){
459  int straw = m_trtid->straw((*vit)->identify());
460  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
461 
462  if(sc.phi()<phimin)
463  phimin=sc.phi();
464 
465  if(sc.phi()>phimax)
466  phimax=sc.phi();
467  }
468 
469  shift=(phimax+phimin)/2.-M_PI_4;
470  ATH_MSG_VERBOSE("Phimin="<<phimin<<" Phimax="<<phimax<<" -> shift = "<<shift);
471 
472  //protection for boundary at pi,-pi
473  if(phimin<-M_PI_2 && phimax>M_PI_2){
474  shift=3.*M_PI_4;
475  ATH_MSG_VERBOSE("Boundary between pi and -pi!!! use the following shift: "<<shift);
476  }
477 
478 
479  int count=0;
480  for(vit=dc.begin();vit!=vitE;++vit){
481  int straw = m_trtid->straw((*vit)->identify());
482  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
483 
484  double orig=sc.phi();
485 
486  double corr=orig-shift;
487 
488  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
489  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
490 
491  if(count>500){
492  return false; // a seed cannot contain that many hits
493  }
494 
495  event_data.m_a_z[count]=sc.z();
496  event_data.m_a_phi[count]=corr;
497  count++;
498  }
499 
500  int maxdc=0;
501  double p_best[3]={0,0,0};
502  p_best[2]=shift;
503 
504  for(int i=0;i<count;i++){
505  for(int j=i+1;j<count;j++){
506 
507  double p[3];
508 
509  p[2]=shift;
510 
511  if(event_data.m_a_z[i]==event_data.m_a_z[j]){
512  p[0]=1e10;
513  p[1]=event_data.m_a_z[i];
514  }else{
515  p[0]=(event_data.m_a_phi[i]-event_data.m_a_phi[j])/(event_data.m_a_z[i]-event_data.m_a_z[j]);
516  p[1]=event_data.m_a_phi[j]-p[0]*event_data.m_a_z[j];
517  }
518 
519 
520 
521  int match=evaluate_seed(endcap,zslice,sector,p,event_data);
522 
523  if(match>maxdc){
524  maxdc=match;
525  p_best[0]=p[0];
526  p_best[1]=p[1];
527  }
528  }
529  }
530 
531  ATH_MSG_VERBOSE("Number of matching dc from best seed: "<<maxdc);
532 
533 
534  if(maxdc>=4){
535  //ok, we've found a seed
536 
537  double zmin=1e4;
538  double zmax=-1e4;
539 
540 
541  int muster[3][3];
542  for(auto & i : muster)
543  for(int & j : i)
544  j=0;
545 
546  std::vector<const InDet::TRT_DriftCircle*> *seed=new std::vector<const InDet::TRT_DriftCircle*>;
547 
548  for(int zsl=zslice-1;zsl<=zslice+1;zsl++){
549  for(int ps=sector-1;ps<=sector+1;ps++){
550 
551  //make sure that the slices exist ...
552  if(zsl<0 || zsl>=20) continue;
553 
554  int ps2=ps;
555  if(ps2<0) ps2+=16;
556  else if(ps2>15) ps2-=16;
557 
558  for(it=event_data.m_sectors[endcap][zsl][ps2].begin();it!=event_data.m_sectors[endcap][zsl][ps2].end();++it){
559  int straw = m_trtid->straw((*it)->identify());
560  const Amg::Vector3D& sc = (*it)->detectorElement()->strawCenter(straw);
561 
562  double pred_phi=sc.z()*p_best[0]+p_best[1];
563  double corr=sc.phi()-p_best[2];
564 
565  if(p_best[0]==1e10){
566  if(sc.z()==p_best[1]) {
567  pred_phi=corr; //z=const ...
568  }else{
569  pred_phi=corr+0.5;
570  }
571  }
572  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
573  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
574 
575 
576  if(std::abs(phidiff(pred_phi,corr))<=4./650.){
577  seed->push_back(*it);
578  if(sc.z()<zmin) zmin=sc.z();
579  if(sc.z()>zmax) zmax=sc.z();
580  muster[zsl-zslice+1][ps-sector+1]=1;
581  }
582  }
583  }
584  }
585 
587 
588 
589  //do we need to extend the range ??
590 
591  ATH_MSG_VERBOSE("Pattern:");
592  ATH_MSG_VERBOSE("\t"<<muster[0][0]<<" "<<muster[1][0]<<" "<<muster[2][0]);
593  ATH_MSG_VERBOSE("\t"<<muster[0][1]<<" "<<muster[1][1]<<" "<<muster[2][1]);
594  ATH_MSG_VERBOSE("\t"<<muster[0][2]<<" "<<muster[1][2]<<" "<<muster[2][2]);
595 
596  int zsl=-1;
597  if(muster[2][0] || muster[2][1] || muster[2][2]){
598  //extend towards higher z-values
599  zsl=zslice+2;
600 
601  for(int ps=sector-2;ps<=sector+2;ps++){
602 
603  //make sure that the slices exist ...
604  if(zsl<0 || zsl>=20) continue;
605 
606  int ps2=ps;
607  if(ps2<0) ps2+=16;
608  else if(ps2>15) ps2-=16;
609 
610  for(it=event_data.m_sectors[endcap][zsl][ps2].begin();it!=event_data.m_sectors[endcap][zsl][ps2].end();++it){
611  int straw = m_trtid->straw((*it)->identify());
612  const Amg::Vector3D& sc = (*it)->detectorElement()->strawCenter(straw);
613 
614  double pred_phi=sc.z()*p_best[0]+p_best[1];
615  double corr=sc.phi()-p_best[2];
616 
617  if(p_best[0]==1e10){
618  if(sc.z()==p_best[1]) {
619  pred_phi=corr; //z=const ...
620  }else{
621  pred_phi=corr+0.5;
622  }
623  }
624  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
625  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
626 
627 
628  if(std::abs(phidiff(pred_phi,corr))<=4./650.){
629  if (msgLvl(MSG::VERBOSE)) msg()<<"extended hit at z= "<<sc.z()<<endmsg;
630  if(sc.z()<zmin) zmin=sc.z();
631  if(sc.z()>zmax) zmax=sc.z();
632  seed->push_back(*it);
633  }
634  }
635  }
636  }
637 
638  if(muster[0][0] || muster[0][1] || muster[0][2]){
639  //extend towards lower z-values
640  zsl=zslice-2;
641 
642  for(int ps=sector-2;ps<=sector+2;ps++){
643 
644  //make sure that the slices exist ...
645  if(zsl<0 || zsl>=20) continue;
646 
647  int ps2=ps;
648  if(ps2<0) ps2+=16;
649  else if(ps2>15) ps2-=16;
650 
651  for(it=event_data.m_sectors[endcap][zsl][ps2].begin();it!=event_data.m_sectors[endcap][zsl][ps2].end();++it){
652  int straw = m_trtid->straw((*it)->identify());
653  const Amg::Vector3D& sc = (*it)->detectorElement()->strawCenter(straw);
654 
655  double pred_phi=sc.z()*p_best[0]+p_best[1];
656  double corr=sc.phi()-p_best[2];
657 
658  if(p_best[0]==1e10){
659  if(sc.z()==p_best[1]) {
660  pred_phi=corr; //z=const ...
661  }else{
662  pred_phi=corr+0.5;
663  }
664  }
665  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
666  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
667 
668 
669  if(std::abs(phidiff(pred_phi,corr))<=4./650.){
670  ATH_MSG_VERBOSE("extended hit at z= "<<sc.z());
671  if(sc.z()<zmin) zmin=sc.z();
672  if(sc.z()>zmax) zmax=sc.z();
673  seed->push_back(*it);
674  }
675  }
676  }
677  }
678 
679 
680  if(seed->size()<(size_t)m_minDCSeed){
681  ATH_MSG_VERBOSE("Seed has too few hits: "<<seed->size());
682  seed->clear();
683  delete seed;
684  return false;
685  }
686 
687 
688  vit=seed->begin();
689  vitE=seed->end();
690 
691  for(;vit!=vitE;++vit){
692  int straw = m_trtid->straw((*vit)->identify());
693  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
694 
695  int phi = int((std::atan2(sc.y(),sc.x())+M_PI)*8./M_PI);
696 
697  if ( phi<0 ) phi = 15;
698  else if( phi>15 ) phi = 0 ;
699 
700  int z=0;
701  if(sc.z()<0) z=1;
702  int zslic=int((std::abs(sc.z())-800.)/100.);
703 
704  event_data.m_sectors[z][zslic][phi].remove(*vit);
705 
706  }
707 
708  //just to be sure: check also the noise hits in these 9 slices
709 
711  lit=event_data.m_noiseHits.begin();
712  litE=event_data.m_noiseHits.end();
713 
714  for(;lit!=litE;++lit){
715 
716  //don't add hits that really look like noise
717  if((*lit)->timeOverThreshold()<m_cutToTLoose) continue;
718 
719  int straw = m_trtid->straw((*lit)->identify());
720  const Amg::Vector3D& sc = (*lit)->detectorElement()->strawCenter(straw);
721 
722  int phi = int((std::atan2(sc.y(),sc.x())+M_PI)*8./M_PI);
723 
724  if ( phi<0 ) phi = 15;
725  else if( phi>15 ) phi = 0 ;
726 
727 
728  int zsl=int((std::abs(sc.z())-800.)/100.);
729 
730  if(std::abs(zsl-zslice)<2){
731  double pred_phi=sc.z()*p_best[0]+p_best[1];
732  double corr=sc.phi()-p_best[2];
733 
734  if(p_best[0]==1e10){
735  if(sc.z()==p_best[1]) {
736  pred_phi=corr; //z=const ...
737  }else{
738  pred_phi=corr+0.5;
739  }
740  }
741  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
742  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
743 
744 
745  if(std::abs(phidiff(pred_phi,corr))<=4./650.){
746  if(sc.z()>zmin && sc.z()<zmax){
747  seed->push_back(*lit);
748  ATH_MSG_VERBOSE("\t\t noise hit matched seed! z="<< sc.z());
749  }
750  }
751 
752  }
753 
754 
755  }
756 
757 
758 
759 
760  event_data.m_seeds.push_back(seed);
761 
762  return true;
763  }
764 
765 
766  return false;
767 
768 }
769 
771  int zslice,
772  int sector,
773  const double *p,
775 {
776 
778 
779  int count=0;
780 
781  //look at all nearest neighbours ...
782 
783  for(int zsl=zslice-1;zsl<=zslice+1;zsl++){
784  for(int ps=sector-1;ps<=sector+1;ps++){
785 
786  //make sure that the slices exist ...
787  if(zsl<0 || zsl>=20) continue;
788 
789  int ps2=ps;
790  if(ps2<0) ps2+=16;
791  else if(ps2>15) ps2-=16;
792 
793 
794  itE=event_data.m_sectors[endcap][zsl][ps2].end();
795  for(it=event_data.m_sectors[endcap][zsl][ps2].begin();it!=itE;++it){
796  int straw = m_trtid->straw((*it)->identify());
797  const Amg::Vector3D& sc = (*it)->detectorElement()->strawCenter(straw);
798 
799  double pred_phi=sc.z()*p[0]+p[1];
800  double corr=sc.phi()-p[2];
801 
802  if(p[0]==1e10){
803  if(sc.z()==p[1]) {
804  pred_phi=corr; //z=const ...
805  }else{
806  pred_phi=corr+0.5;
807  }
808  }
809  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
810  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
811 
812 
813  if(std::abs(phidiff(pred_phi,corr))<=4./650.){
814  count=count+1;
815  }
816  }
817  }
818  }
819 
820 
821  return count;
822 }
823 
824 
825 void InDet::TRT_TrackSegmentsMaker_ECcosmics::create_segment(std::vector<const InDet::TRT_DriftCircle*> *seed,
827 {
828 
829  ATH_MSG_VERBOSE("Number of hits in initial seed: "<<seed->size());
830 
831  double shift=0.;
832  double phimin=10.;
833  double phimax=-10.;
834 
835  double zmin=1e5;
836  double zmax=-1e5;
837 
839 
840  vit=seed->begin();
841  vitE=seed->end();
842 
843  int count=0;
844  for(;vit!=vitE;++vit){
845  int straw = m_trtid->straw((*vit)->identify());
846  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
847 
848  if(sc.z()<zmin) zmin=sc.z();
849  if(sc.z()>zmax) zmax=sc.z();
850 
851  if(count>500){
852  return; // a seed cannot contain that many hits
853  }
854 
855  event_data.m_a_z[count]=sc.z();
856  event_data.m_a_phi[count]=sc.phi();
857  event_data.m_a_tan[count]=std::tan(sc.phi());
858  const auto cosPhi{std::cos(sc.phi())};
859  event_data.m_a_tan_err[count]=(1.15/700.)/(cosPhi*cosPhi);
860  event_data.m_a_z_err[count]=1.15; // 4/sqrt(12)
861  event_data.m_a_phi_err[count]=1.15/700.; //take uncertainty at a radius of 700 mm
862 
863  if(sc.phi()<phimin)
864  phimin=sc.phi();
865 
866  if(sc.phi()>phimax)
867  phimax=sc.phi();
868 
869  count++;
870  }
871 
872  shift=(phimax+phimin)/2.-M_PI_4;
873  ATH_MSG_VERBOSE("Phimin="<<phimin<<" Phimax="<<phimax<<" shift="<<shift);
874 
875  //protection for boundary at pi,-pi
876  if(phimin<-M_PI_2 && phimax>M_PI_2){
877  shift=3.*M_PI_4;
878  ATH_MSG_VERBOSE("Boundary between pi and -pi!!! use the following shift: "<<shift);
879  }
880 
881 
882  //correct the phi values
883 
884  for(int i=0;i<count;i++){
885  double orig=event_data.m_a_phi[i];
886 
887  double corr=orig-shift;
888  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
889  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
890 
891  event_data.m_a_phi[i]=corr;
892  event_data.m_a_tan[i]=std::tan(corr);
893  const auto cosCorr{std::cos(corr)};
894  event_data.m_a_tan_err[i]=(1.15/700.)/(cosCorr*cosCorr);
895  }
896 
897  TF1 *fit=perform_fit(count, event_data);
898  if(!fit) return;
899 
901 
902  //add the ones from the good list (but skip the ones that we already have)
903  lit=event_data.m_goodHits.begin();
904  litE=event_data.m_goodHits.end();
905 
906  std::vector<const InDet::TRT_DriftCircle*> tobeadded;
907 
908 
909  for(;lit!=litE;++lit){
910  int straw = m_trtid->straw((*lit)->identify());
911  const Amg::Vector3D& sc = (*lit)->detectorElement()->strawCenter(straw);
912 
913  double fitted_phi=fit->Eval(sc.z(),0.,0.);
914  fitted_phi+=shift;
915 
916  if (fitted_phi > M_PI) fitted_phi = std::fmod(fitted_phi+M_PI,2.*M_PI)-M_PI;
917  else if(fitted_phi <-M_PI) fitted_phi = std::fmod(fitted_phi-M_PI,2.*M_PI)+M_PI;
918 
919  if(std::abs(phidiff(fitted_phi,sc.phi()))<m_scaleTube*4./800.){
920  //verify that this hit is not already included
921 
922  vit=seed->begin();
923  vitE=seed->end();
924  bool new_hit=true;
925  for(;vit!=vitE && new_hit;++vit){
926  if((*vit)==(*lit)){
927  new_hit=false;
928  }
929  }
930  if(new_hit){
931  ATH_MSG_VERBOSE("\t\t good hit matched! fitted_phi="<<fitted_phi<<" z=" <<sc.z());
932 
933  if(sc.z()>zmin-200 && sc.z()<zmax+200){
934  if(sc.z()<zmin) zmin=sc.z();
935  if(sc.z()>zmax) zmax=sc.z();
936 
937  seed->push_back(*lit);
938  }else{
939  //not sure if this is really a good hit yet ...
940  tobeadded.push_back(*lit);
941  }
942  }
943  }
944  }
945 
946  std::sort(tobeadded.begin(),tobeadded.end(), CompareDCz);
947 
948  int index1=-1,index2=-1;
949 
950  double z1=-1e5;
951 
952  count=0;
953  ATH_MSG_VERBOSE("zmin="<<zmin<<" zmax="<<zmax);
954  for(vit=tobeadded.begin();vit!=tobeadded.end();++vit){
955  int straw = m_trtid->straw((*vit)->identify());
956  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
957  ATH_MSG_VERBOSE("Shall we add hit at z="<<sc.z());
958 
959  if(sc.z()<zmin && sc.z()>z1) {
960  z1=sc.z();
961  index1=count;
962  }
963  if(sc.z()>zmax && index2==-1) {
964  index2=count;
965  }
966  count++;
967  }
968 
969  ATH_MSG_VERBOSE("index1="<<index1<<" index2="<<index2);
970 
971  if(index2>=0){
972  for(int i=index2;i<count;i++){
973  int straw = m_trtid->straw(tobeadded[i]->identify());
974  const Amg::Vector3D& sc = tobeadded[i]->detectorElement()->strawCenter(straw);
975  if(sc.z()<zmax+200){
976  zmax=sc.z();
977  seed->push_back(tobeadded[i]);
978  ATH_MSG_VERBOSE(" added goot hit at z="<<sc.z());
979  }else{
980  ATH_MSG_VERBOSE(" rejected goot hit at z="<<sc.z());
981  i=count;
982  }
983  }
984  }
985  if(index1>=0){
986  for(int i=index1;i>=0;i--){
987  int straw = m_trtid->straw(tobeadded[i]->identify());
988  const Amg::Vector3D& sc = tobeadded[i]->detectorElement()->strawCenter(straw);
989  if(sc.z()>zmin-200){
990  zmin=sc.z();
991  seed->push_back(tobeadded[i]);
992  ATH_MSG_VERBOSE(" added goot hit at z="<<sc.z());
993  }else{
994  ATH_MSG_VERBOSE(" rejected goot hit at z="<<sc.z());
995  i=-1;
996  }
997  }
998  }
999  tobeadded.clear();
1000 
1001 
1002 
1003  //fit again
1004  std::sort(seed->begin(),seed->end(), CompareDCz);
1005 
1006  vit=seed->begin();
1007  vitE=seed->end();
1008 
1009  count=0;
1010  for(;vit!=vitE;++vit){
1011  int straw = m_trtid->straw((*vit)->identify());
1012  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
1013 
1014  if(count>500){
1015  return; // a seed cannot contain that many hits
1016  }
1017 
1018  event_data.m_a_z[count]=sc.z();
1019  event_data.m_a_phi[count]=sc.phi();
1020  event_data.m_a_tan[count]=std::tan(sc.phi());
1021  const auto cosPhi{std::cos(sc.phi())};
1022  event_data.m_a_tan_err[count]=(1.15/700.)/(cosPhi*cosPhi);
1023  event_data.m_a_z_err[count]=1.15; // 4/sqrt(12)
1024  event_data.m_a_phi_err[count]=1.15/700.; //take uncertainty at a radius of 700 mm
1025 
1026  if(sc.phi()<phimin)
1027  phimin=sc.phi();
1028 
1029  if(sc.phi()>phimax)
1030  phimax=sc.phi();
1031 
1032  count++;
1033  }
1034 
1035  shift=(phimax+phimin)/2.-M_PI_4;
1036  ATH_MSG_VERBOSE("Phimin="<<phimin<<" Phimax="<<phimax<<" shift="<<shift);
1037 
1038  //protection for boundary at pi,-pi
1039  if(phimin<-M_PI_2 && phimax>M_PI_2){
1040  shift=3.*M_PI_4;
1041  ATH_MSG_VERBOSE("Boundary between pi and -pi!!! use the following shift: "<<shift);
1042  }
1043 
1044  //correct the phi values
1045 
1046  for(int i=0;i<count;i++){
1047  double orig=event_data.m_a_phi[i];
1048  double corr=orig-shift;
1049 
1050  if (corr > M_PI) corr = std::fmod(corr+M_PI,2.*M_PI)-M_PI;
1051  else if(corr <-M_PI) corr = std::fmod(corr-M_PI,2.*M_PI)+M_PI;
1052 
1053  event_data.m_a_phi[i]=corr;
1054  event_data.m_a_tan[i]=std::tan(corr);
1055  const auto cosCorr{std::cos(corr)};
1056  event_data.m_a_tan_err[i]=(1.15/700.)/(cosCorr*cosCorr);
1057  }
1058 
1059 
1060  fit=perform_fit(count, event_data);
1061  if(!fit) return;
1062 
1063  //add the ones from the noise list
1064  lit=event_data.m_noiseHits.begin();
1065  litE=event_data.m_noiseHits.end();
1066 
1067  for(;lit!=litE;++lit){
1068 
1069  //don't add hits that really look like noise
1070 
1071  int straw = m_trtid->straw((*lit)->identify());
1072  const Amg::Vector3D& sc = (*lit)->detectorElement()->strawCenter(straw);
1073 
1074  double z=sc.z();
1075  double phi=sc.phi();
1076  double fitted_phi=fit->Eval(sc.z(),0.,0.);
1077  fitted_phi+=shift;
1078 
1079  if (fitted_phi > M_PI) fitted_phi = std::fmod(fitted_phi+M_PI,2.*M_PI)-M_PI;
1080  else if(fitted_phi <-M_PI) fitted_phi = std::fmod(fitted_phi-M_PI,2.*M_PI)+M_PI;
1081 
1082  //only look into the same endcap for noise hits
1083  if(z*event_data.m_a_z[0]<0) continue;
1084 
1085  if(std::abs(phidiff(fitted_phi,phi))<m_scaleTubeNoise*4./800.){
1086  vit=seed->begin();
1087  vitE=seed->end();
1088  bool new_hit=true;
1089  for(;vit!=vitE && new_hit;++vit){
1090  if((*vit)==(*lit)){
1091  new_hit=false;
1092  }
1093  }
1094  if(new_hit){
1095  if(sc.z()>zmin-50 && sc.z()<zmax+50){
1096  ATH_MSG_VERBOSE("\t\t noise hit matched! fitted_phi="<<fitted_phi<<" z=" <<sc.z());
1097  seed->push_back(*lit);
1098  }else{
1099  ATH_MSG_VERBOSE("\t\t noise hit matched but too far away! fitted_phi="<<fitted_phi<<" z=" <<sc.z());
1100  }
1101  }
1102  }
1103  }
1104 
1105  //first: sort along y
1106  std::sort(seed->begin(),seed->end(), CompareDCy);
1107 
1108  //check z-coordinate of first and last hit
1109  Amg::Vector3D firststraw=((*seed)[0]->detectorElement()->strawCenter( m_trtid->straw((*seed)[0]->identify()) ));
1110  Amg::Vector3D laststraw=((*seed)[seed->size()-1]->detectorElement()->strawCenter( m_trtid->straw((*seed)[seed->size()-1]->identify()) ));
1111  z1=firststraw.z();
1112  double z2=laststraw.z();
1113  double yfirst=firststraw.y();
1114  double ylast=laststraw.y();
1115 
1116  ATH_MSG_VERBOSE("zfirst="<<z1<<" zlast="<<z2);
1117 
1118  double Theta=0;
1119  int state=0;
1120 
1121  //sort again, but this time with the correct ordering
1122  if (std::abs(yfirst-ylast)>50){
1123  if(z1>z2) {
1124  std::sort(seed->begin(),seed->end(), CompareDCzreverse);
1125  }else{
1126  std::sort(seed->begin(),seed->end(), CompareDCz);
1127  }
1128  }
1129  else {
1130  if ((yfirst>0 && z1<0) || (yfirst<0 && z1>0)) std::sort(seed->begin(),seed->end(), CompareDCz);
1131  else std::sort(seed->begin(),seed->end(), CompareDCzreverse);
1132  }
1133  firststraw=(*seed)[0]->detectorElement()->strawCenter( m_trtid->straw((*seed)[0]->identify()) );
1134  laststraw=(*seed)[seed->size()-1]->detectorElement()->strawCenter( m_trtid->straw((*seed)[seed->size()-1]->identify()) );
1135  z1=firststraw.z();
1136  z2=laststraw.z();
1137 
1138 
1139  if(z1>z2) {
1140  Theta=M_PI-std::atan2(400.,std::abs(z1-z2));
1141  state=2;
1142  }else{
1143  Theta=std::atan2(400.,std::abs(z1-z2));
1144  state=1;
1145  }
1146 
1147  double globaly=((*seed)[0]->detectorElement()->strawCenter( m_trtid->straw((*seed)[0]->identify()) )).y();
1148  double firstphi=((*seed)[0]->detectorElement()->strawCenter( m_trtid->straw((*seed)[0]->identify()) )).phi();
1149 
1150 
1151  ATH_MSG_VERBOSE("Number of tube hits matching straight line: "<<seed->size());
1152 
1153 
1154  //estimate Segment parameters from first and last hit
1155 
1156  const Amg::Vector3D& sc_first = ((*seed)[0]->detectorElement()->strawCenter( m_trtid->straw((*seed)[0]->identify()) ));
1157  const Amg::Vector3D& sc_last = ((*seed)[seed->size()-1]->detectorElement()->strawCenter( m_trtid->straw((*seed)[seed->size()-1]->identify()) ));
1158 
1159 
1160  double tx1,tx2,ty1,ty2;
1161 
1162  tx1=1050*std::cos(sc_first.phi());
1163  ty1=1050*std::sin(sc_first.phi());
1164 
1165  tx2=650*std::cos(sc_last.phi());
1166  ty2=650*std::sin(sc_last.phi());
1167 
1168  double tphi=std::atan2(ty2-ty1,tx2-tx1);
1169 
1170 
1171  ATH_MSG_VERBOSE("First hit: "<<sc_first<<" \nLast hit: "<<sc_last);
1172 
1173 
1174  ATH_MSG_VERBOSE(" (x1,y1) = ("<<tx1<<","<<ty1<<")");
1175  ATH_MSG_VERBOSE(" (x2,y2) = ("<<tx2<<","<<ty2<<")");
1176 
1177 
1178 
1179  //correct phi to point downwards
1180  if(tphi>0)
1181  tphi-=M_PI;
1182 
1183  //make sure that Theta is positive and less than Pi!
1184 
1185  while(Theta<0)
1186  Theta+=M_PI;
1187 
1188  while(Theta>M_PI)
1189  Theta-=M_PI;
1190 
1191  ATH_MSG_VERBOSE(" tphi="<<tphi);
1192 
1193  ATH_MSG_VERBOSE("globaly = "<<globaly<<" phi="<<firstphi<<" theta="<<Theta<<" --> state = "<<state);
1194 
1195 
1196  vit=seed->begin();
1197  vitE=seed->end();
1198 
1199  count=0;
1200  for(;vit!=vitE;++vit){
1201  count++;
1202  int straw = m_trtid->straw((*vit)->identify());
1203  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
1204  ATH_MSG_VERBOSE("Hit "<<count<<" z="<<sc.z()<<" phi="<<sc.phi()<<" y="<<sc.y());
1205  }
1206 
1207 
1208  if(m_useDriftTime){
1209 
1210  ATH_MSG_VERBOSE("drifttime should be used!!!");
1211 
1212  //refit the seed but this time including the drift time information
1213 
1214  //take the left-rigfht assignment from the tube fit and then fit again
1215  count=0;
1216 
1217  vit=seed->begin();
1218  vitE=seed->end();
1219 
1220  for(;vit!=vitE;++vit){
1221  int straw = m_trtid->straw((*vit)->identify());
1222  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
1223 
1224  double fitted_phi=fit->Eval(sc.z(),0.,0.);
1225  fitted_phi+=shift;
1226 
1227  if (fitted_phi > M_PI) fitted_phi = std::fmod(fitted_phi+M_PI,2.*M_PI)-M_PI;
1228  else if(fitted_phi <-M_PI) fitted_phi = std::fmod(fitted_phi-M_PI,2.*M_PI)+M_PI;
1229 
1230  int sign=1;
1231  if(fitted_phi<sc.phi()) sign=-1;
1232 
1233 
1234  double driftr = (*vit)->localPosition()(Trk::driftRadius);
1235  double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1236 
1237  double straw_r=640+400./std::abs(z2-z1)*std::abs(sc.z()-z1);
1238 
1239  double dphi=sign*driftr/straw_r;
1240 
1241 
1242  event_data.m_a_z[count]=sc.z();
1243  event_data.m_a_phi[count]=sc.phi()+dphi;
1244  event_data.m_a_phi_err[count]=drifte/straw_r;
1245 
1246  event_data.m_a_tan[count]=std::tan(event_data.m_a_phi[count]-shift);
1247  const auto cosPhiMinShift{std::cos(event_data.m_a_phi[count]-shift)};
1248  event_data.m_a_tan_err[count]=(event_data.m_a_phi_err[count])/( cosPhiMinShift
1249  * cosPhiMinShift);
1250 
1251  event_data.m_a_z_err[count]=0.;
1252 
1253  ATH_MSG_VERBOSE(count<<" z="<<event_data.m_a_z[count]<<" phi="<<event_data.m_a_phi[count]<<" +- "<< event_data.m_a_phi_err[count]);
1254  count++;
1255  }
1256 
1257  ATH_MSG_VERBOSE("Number of hits in first fit (driftradius): "<<count);
1258 
1259  fit=perform_fit(count,event_data);
1260  if(!fit) return;
1261 
1262 
1263  //check if hits are matching
1264  vit=seed->begin();
1265  vitE=seed->end();
1266 
1267  count=0;
1268  for(;vit!=vitE;++vit){
1269  int straw = m_trtid->straw((*vit)->identify());
1270  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
1271  double fitted_phi=fit->Eval(sc.z(),0.,0.);
1272  fitted_phi+=shift;
1273 
1274  double driftr = (*vit)->localPosition()(Trk::driftRadius);
1275  double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1276  int sign=1;
1277 
1278  if(fitted_phi<sc.phi()) sign=-1;
1279 
1280  double straw_r=640+400./std::abs(z2-z1)*std::abs(sc.z()-z1);
1281  double dphi=sign*driftr/straw_r;
1282 
1283  if(count>500){
1284  return; // a seed cannot contain that many hits
1285  }
1286 
1287  if (msgLvl(MSG::VERBOSE)) msg()<<"z="<<sc.z()<<" phi="<<sc.phi()<<" fitted_phi = "<<fitted_phi<<endmsg;
1288  if(std::abs(phidiff(fitted_phi,sc.phi()-dphi)) < m_scaleFactorDrift* drifte/straw_r){
1289  if (msgLvl(MSG::VERBOSE)) msg()<<"\t\t matched!!!"<<endmsg;
1290 
1291  event_data.m_a_z[count]=sc.z();
1292  event_data.m_a_phi[count]=sc.phi()+dphi;
1293  event_data.m_a_phi_err[count]=drifte/straw_r;
1294 
1295  event_data.m_a_tan[count]=std::tan(event_data.m_a_phi[count]-shift);
1296  const auto cosPhiMinShift{ std::cos(event_data.m_a_phi[count]-shift)};
1297  event_data.m_a_tan_err[count]=(event_data.m_a_phi_err[count])/( cosPhiMinShift
1298  *cosPhiMinShift);
1299 
1300  event_data.m_a_z_err[count]=0.;
1301  count++;
1302 
1303  }
1304  }
1305 
1306  //refit
1307 
1308  ATH_MSG_VERBOSE("Number of hits in second fit (driftradius): "<<count);
1309 
1310  if(count>4){
1311  fit=perform_fit(count,event_data);
1312  if(!fit) return;
1313  }
1314 
1315  vit=seed->begin();
1316  vitE=seed->end();
1317 
1318  count=0;
1319  for(;vit!=vitE;++vit){
1320  int straw = m_trtid->straw((*vit)->identify());
1321  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
1322 
1323  double fitted_phi=fit->Eval(sc.z(),0.,0.);
1324  fitted_phi+=shift;
1325 
1326  if (fitted_phi > M_PI) fitted_phi = std::fmod(fitted_phi+M_PI,2.*M_PI)-M_PI;
1327  else if(fitted_phi <-M_PI) fitted_phi = std::fmod(fitted_phi-M_PI,2.*M_PI)+M_PI;
1328 
1329  double driftr = (*vit)->localPosition()(Trk::driftRadius);
1330  double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1331  int sign=1;
1332 
1333  if(fitted_phi<sc.phi()) sign=-1;
1334 
1335  double straw_r=640+400./std::abs(z2-z1)*std::abs(sc.z()-z1);
1336  double dphi=sign*driftr/straw_r;
1337 
1338 
1339  ATH_MSG_VERBOSE("z="<<sc.z()<<" phi="<<sc.phi()<<" fitted_phi = "<<fitted_phi);
1340  if(std::abs(phidiff(fitted_phi,sc.phi()-dphi)) < m_scaleFactorDrift* drifte/straw_r){
1341  ATH_MSG_VERBOSE("\t\t matched!!!");
1342  count++;
1343  }
1344  }
1345 
1346  ATH_MSG_VERBOSE("Number of hits matched after second fit: "<<count);
1347 
1348  }
1349 
1350 
1351  //create the segment
1352 
1353 
1354 
1355  if(count<m_minDCSeed) return; //too short segments don't make sense
1356 
1357  if(count>=400) return; //too long segments don't make sense
1358 
1359 
1360 
1361  // RIOonTrack production
1362  //
1364 
1365  vit=seed->begin();
1366  vitE=seed->end();
1367 
1368  double chi2=0.;
1369 
1370  double initial_r=-10.;
1371  double initial_locz=0.;
1372 
1373  count=0;
1374  for(;vit!=vitE;++vit){
1376  (&((*vit)->detectorElement())->surface( (*vit)->identify()));
1377 
1378 
1379  int straw = m_trtid->straw((*vit)->identify());
1380  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
1381 
1382  double z=sc.z();
1383  // double phi=sc.phi();
1384 
1385  double locz=0.;
1386 
1387  if(std::abs(z2-z1)>0.000001){
1388  if(state==1){
1389  locz=400./std::abs(z2-z1)*std::abs(z-z1)-200.;
1390  }else{
1391  locz=200.-400./std::abs(z2-z1)*std::abs(z-z1);
1392  }
1393  }
1394  double fitted_phi=fit->Eval(z,0.,0.);
1395  fitted_phi+=shift;
1396 
1397  if (fitted_phi > M_PI) fitted_phi = std::fmod(fitted_phi+M_PI,2.*M_PI)-M_PI;
1398  else if(fitted_phi <-M_PI) fitted_phi = std::fmod(fitted_phi-M_PI,2.*M_PI)+M_PI;
1399 
1400  double fitted_r=(phidiff(fitted_phi,sc.phi()))*(840+locz);
1401  double temp_phi=fitted_phi;
1402 
1403  if(initial_r==-10. && std::abs(fitted_r)<4.0){
1404  initial_r=fitted_r;
1405  initial_locz=locz;
1406  }
1407 
1408  if (temp_phi > M_PI) temp_phi = std::fmod(temp_phi+M_PI,2.*M_PI)-M_PI;
1409  else if(temp_phi <-M_PI) temp_phi = std::fmod(temp_phi-M_PI,2.*M_PI)+M_PI;
1410 
1411  ATH_MSG_VERBOSE(count<<" fitted_r = "<<fitted_r<<" locz="<<locz<<" temp_phi="<<temp_phi);
1412 
1413 
1414  fitted_r*=-1.0;
1415 
1416 
1417  temp_phi=firstphi;
1418 
1419  const Trk::AtaStraightLine Tp(fitted_r,locz,tphi,Theta,.000000001,*line);
1420 
1421  //decide if drifttime should be used
1422 
1423 
1424 
1425 
1426  bool useDrift=false;
1427 
1428  if(m_useDriftTime){
1429  double driftr = (*vit)->localPosition()(Trk::driftRadius);
1430  double drifte = 2*std::sqrt((*vit)->localCovariance()(0,0));
1431  int sign=1;
1432 
1433  if(fitted_phi<sc.phi()) sign=-1;
1434 
1435  double straw_r=640+400./std::abs(z2-z1)*std::abs(sc.z()-z1);
1436  double dphi=sign*driftr/straw_r;
1437 
1438  if(std::abs(phidiff(fitted_phi,sc.phi()-dphi)) < 3* drifte/straw_r){
1439  useDrift=true;
1440  chi2+=(std::abs(fitted_r)-std::abs(driftr))*(std::abs(fitted_r)-std::abs(driftr))/(drifte*drifte);
1441  }
1442 
1443  }
1444 
1445 
1446  if(useDrift){
1447  ATH_MSG_VERBOSE("RIO using drift time!");
1448  rio.push_back(m_riomakerD->correct(*(*vit),Tp));
1449  }else{
1450  ATH_MSG_VERBOSE("RIO without using drift time!");
1451  chi2+=(fitted_r/1.15)*(fitted_r/1.15); // no drift time used
1452  ATH_MSG_VERBOSE(count<<"\t\t chi2 contribution: "<<(fitted_r/1.15)*(fitted_r/1.15));
1453  rio.push_back(m_riomakerN->correct(*(*vit),Tp));
1454  }
1455 
1456  count++;
1457 
1458  //add a pseudomeasurement for the first and the last hit constraining loc_z
1459  if(count==1 || (size_t)count==seed->size()){
1462  Amg::MatrixX cov(1,1);
1463  cov<<1.;
1464 
1465  //create new surface
1466  Amg::Vector3D C = line->transform().translation();
1467 
1468  if(state==2 || state==3){
1469  C[2]-=1.;
1470  }else{
1471  C[2]+=1.;
1472  }
1473  Amg::Transform3D T = Amg::Transform3D(line->transform().rotation()*Amg::Translation3D(C));
1475 
1476 
1478  std::move(par),
1479  std::move(cov),
1480  *surface);
1481 
1482  delete surface;
1483 
1484  rio.push_back(pseudo);
1485 
1486  }
1487  }
1488 
1489 
1490  //Track Segment production
1491 
1492  Trk::FitQuality * fqu = new Trk::FitQuality(chi2,count-2);
1493  const Trk::Surface * sur = &((*seed)[0]->detectorElement())->surface((*seed)[0]->identify());
1494 
1495 
1496  //phi should always be negative!
1497 
1498  if(firstphi>0) firstphi=-firstphi;
1499 
1500 
1501  Trk::DefinedParameter dp0(initial_r,Trk::locR);
1502  Trk::DefinedParameter dp1(initial_locz,Trk::locZ);
1503  Trk::DefinedParameter dp2(tphi,Trk::phi);
1504  Trk::DefinedParameter dp3(Theta,Trk::theta);
1505  Trk::DefinedParameter dp4(0.00002,Trk::qOverP);
1506 
1507  std::array<Trk::DefinedParameter,5> defPar = {dp0,dp1,dp2,dp3,dp4};
1508 
1509  Trk::LocalParameters par(defPar);
1510 
1511 
1512  ATH_MSG_VERBOSE("Track parameters from segment:"<<par);
1513 
1514  double universal=1.15;
1515 
1516 
1517  Amg::MatrixX cov(5,5);
1518  cov<<
1519  universal*universal, 0., 0., 0., 0.,
1520  0. , 160000./12., 0., 0., 0.,
1521  0. , 0., 0.1, 0., 0.,
1522  0. , 0., 0., 1., 0.,
1523  0. , 0., 0., 0., 1.;
1525  std::move(par), std::move(cov), sur, std::move(rio), fqu, Trk::Segment::TRT_SegmentMaker);
1526 
1527  //add segment to list of segments
1528 
1529  ATH_MSG_VERBOSE("Add segment to list");
1530  event_data.m_segments.push_back(segment);
1531 
1532 
1533 }
1534 
1535 
1536 
1538 // Pseudo iterator
1540 
1542 {
1545 
1546  if(event_data.m_segiterator!=event_data.m_segments.end()) return (*event_data.m_segiterator++);
1547  return nullptr;
1548 }
1549 
1551 // Dumps relevant information into the MsgStream
1553 
1555 {
1556  return out;
1557 }
1558 
1559 
1561 // Dumps relevant information into the ostream
1563 
1564 std::ostream& InDet::TRT_TrackSegmentsMaker_ECcosmics::dump( std::ostream& out ) const
1565 {
1566  return out;
1567 }
1568 
1569 
1571 // retrieve Hits from StoreGate and sort into noise/good hits lists
1573 
1575 {
1576 
1577  event_data.m_noiseHits.clear();
1578  event_data.m_goodHits.clear();
1579 
1580 
1582  if (not trtcontainer.isValid()) {
1583  ATH_MSG_DEBUG("Could not get TRT_DriftCircleContainer");
1584  return;
1585  }
1586 
1587  SG::ReadHandle<Trk::PRDtoTrackMap> prd_to_track_map;
1588  const Trk::PRDtoTrackMap *prd_to_track_map_cptr=nullptr;
1589  if (!m_prdToTrackMap.key().empty()) {
1591  if (!prd_to_track_map.isValid()) {
1592  ATH_MSG_ERROR("Failed to read PRD to track association map: " << m_prdToTrackMap );
1593  }
1594  prd_to_track_map_cptr = prd_to_track_map.cptr();
1595  }
1596 
1597  const InDet::TRT_DriftCircleContainer* mjo_trtcontainer = trtcontainer.get();
1598  if (!mjo_trtcontainer) return;
1599 
1600  InDet::TRT_DriftCircleContainer::const_iterator
1601  w = trtcontainer->begin(),we = trtcontainer->end();
1602  for(; w!=we; ++w) {
1603 
1604  Identifier ID = (*w)->identify();
1605  if(std::abs(m_trtid->barrel_ec(ID))!=2) continue; // only endcaps please!!!
1606 
1607  InDet::TRT_DriftCircleCollection::const_iterator
1608  c = (*w)->begin(), ce = (*w)->end();
1609 
1610  for(; c!=ce; ++c) {
1611 
1612  if(prd_to_track_map_cptr && prd_to_track_map_cptr->isUsed(*(*c))) continue; //don't use hits that have already been used
1613 
1614  if( (*c)->isNoise() || (*c)->timeOverThreshold()<m_cutToTLoose) {
1615  event_data.m_noiseHits.push_back(*c);
1616  }else{
1617  event_data.m_goodHits.push_back(*c);
1618  }
1619 
1620  }
1621  }
1622 
1623  ATH_MSG_DEBUG("good hits in endcap: "<<event_data.m_goodHits.size());
1624  ATH_MSG_DEBUG("noise hits in endcap: "<<event_data.m_noiseHits.size());
1625 
1626 
1627  if(event_data.m_goodHits.size()>(size_t)m_hitLimit){
1628  // this event is too busy ...
1629  ATH_MSG_DEBUG("This event has more than "<<m_hitLimit<<" good hits. Aborting segment finding ...");
1630  event_data.m_goodHits.clear();
1631  event_data.m_noiseHits.clear();
1632  return;
1633  }
1634 
1635  //move isolated hits from the good hits vector to the noise hits vector
1636  //
1637  auto it=event_data.m_goodHits.begin();
1638  auto itE=event_data.m_goodHits.end();
1639  auto it_remove(it);
1640  bool remove=false;
1641  //
1642  const double dPhiLimit{0.03};
1643  const double dzLimit{31.};
1644  for(;it!=itE;++it){
1645  if(remove){
1646  event_data.m_goodHits.erase(it_remove);
1647  remove=false;
1648  }
1649  const bool accept=accepted(it, event_data.m_goodHits, dPhiLimit, dzLimit);
1650  if(!accept){
1651  event_data.m_noiseHits.push_back(*it);
1652  it_remove=it;
1653  remove=true;
1654  }
1655  }
1656  if(remove){
1657  event_data.m_goodHits.erase(it_remove);
1658  remove=false;
1659  }
1660 
1661  //2nd pass through good hits with increased ToT cut
1662 
1663  it=event_data.m_goodHits.begin();
1664  itE=event_data.m_goodHits.end();
1665 
1666  remove=false;
1667 
1668  for(;it!=itE;++it){
1669 
1670  if(remove){
1671  event_data.m_goodHits.erase(it_remove);
1672  remove=false;
1673  }
1674 
1675  if((*it)->timeOverThreshold()<m_cutToTTight || (*it)->timeOverThreshold()>m_cutToTUpper){
1676  event_data.m_noiseHits.push_back(*it);
1677  it_remove=it;
1678  remove=true;
1679  }
1680  }
1681  if(remove){
1682  event_data.m_goodHits.erase(it_remove);
1683  remove=false;
1684  }
1685 
1686 
1687  //2nd pass through good hits with loosened isolation criteria
1688 
1689  it=event_data.m_goodHits.begin();
1690  itE=event_data.m_goodHits.end();
1691 
1692  remove=false;
1693 
1694  for(;it!=itE;++it){
1695  if(remove){
1696  event_data.m_goodHits.erase(it_remove);
1697  remove=false;
1698  }
1699  const bool accept=accepted(it, event_data.m_goodHits, 0.25, 200.);
1700  if(!accept){
1701  ATH_MSG_DEBUG("Removing hit in 2nd pass isolation");
1702  event_data.m_noiseHits.push_back(*it);
1703  it_remove=it;
1704  remove=true;
1705  }
1706  }
1707 
1708  if(remove){
1709  event_data.m_goodHits.erase(it_remove);
1710  remove=false;
1711  }
1712 
1713  ATH_MSG_DEBUG("good hits in endcap: "<<event_data.m_goodHits.size());
1714  ATH_MSG_DEBUG("noise hits in endcap: "<<event_data.m_noiseHits.size());
1715 
1716 }
1717 
1718 bool
1721  std::list<const InDet::TRT_DriftCircle*> & container,
1722  double dPhiLimit, double dzLimit) const{
1723  //
1724  const auto id = (*it)->identify();
1725  const auto ns = m_trtid->straw(id);
1726  const auto endcap= m_trtid->barrel_ec(id);
1727  const auto wheel = std::abs(m_trtid->layer_or_wheel(id));
1728  const Amg::Vector3D& sc = (*it)->detectorElement()->strawCenter(ns);
1729  //
1730  bool accept{false};
1731  for(auto it2=container.begin();it2!=container.end();++it2){
1732  if(it==it2) continue;
1733  Identifier id2 = (*it2)->identify();
1734  int endcap2=m_trtid->barrel_ec(id2);
1735  int wheel2=std::abs(m_trtid->layer_or_wheel(id2));
1736  //only look inside the same wheel
1737  if(endcap!=endcap2 || wheel2!=wheel) continue;
1738  int ns2 = m_trtid->straw(id2);
1739  const Amg::Vector3D& sc2 = (*it2)->detectorElement()->strawCenter(ns2);
1740  double dz=sc.z()-sc2.z();
1741  double dphi=phidiff(sc.phi(),sc2.phi());
1742  dphi*=300.0; // scale factor for dphi to get equal weight
1743  dz=std::abs(dz);
1744  dphi=std::abs(dphi/300.0);
1745  if(dphi<dPhiLimit and dz<dzLimit){
1746  accept=true;
1747  //break was not in original code...
1748  break; //...but no need to continue once accept has been set
1749  }
1750  } //end inner loop
1751  return accept;
1752 }
1753 
1755 // Perform the actual track fit to the coordinates
1757 
1759 
1762 {
1763  // @TODO not thread-safe enough! need a globak root lock !
1764  std::lock_guard<std::mutex> lock(s_fitMutex);
1765  TVirtualFitter::SetMaxIterations(100000);
1766 
1767  RootUtils::WithRootErrorHandler hand ([] (int, bool, const char*, const char*) { return false; });
1768 
1769 
1770  event_data.m_fitf_ztanphi->SetParameter(0,0.);
1771  event_data.m_fitf_ztanphi->SetParameter(1,0.);
1772  event_data.m_fitf_ztanphi->SetParameter(2,0.);
1773 
1774  TGraphErrors *gre=new TGraphErrors(count,event_data.m_a_z,event_data.m_a_tan,event_data.m_a_z_err,event_data.m_a_tan_err);
1775  int fitresult1=gre->Fit(event_data.m_fitf_ztanphi,"Q");
1776 
1777  ATH_MSG_VERBOSE("Fit result (ztanphi): a0="<<event_data.m_fitf_ztanphi->GetParameter(0)
1778  <<" a1="<<event_data.m_fitf_ztanphi->GetParameter(1)<<" a2="
1779  <<event_data.m_fitf_ztanphi->GetParameter(2)<<" fitresult="<<fitresult1);
1780 
1781  //copy over the parameters
1782  event_data.m_fitf_zphi->SetParameter(0,event_data.m_fitf_ztanphi->GetParameter(0));
1783  event_data.m_fitf_zphi->SetParameter(1,event_data.m_fitf_ztanphi->GetParameter(1));
1784  event_data.m_fitf_zphi->SetParameter(2,event_data.m_fitf_ztanphi->GetParameter(2));
1785 
1786  delete gre;
1787 
1788  gre=new TGraphErrors(count,event_data.m_a_z,event_data.m_a_phi,event_data.m_a_z_err,event_data.m_a_phi_err);
1789  int fitresult2=gre->Fit(event_data.m_fitf_zphi_approx,"Q");
1790 
1791 
1792  ATH_MSG_VERBOSE( "Fit result (zphi): a0="<< event_data.m_fitf_zphi_approx->GetParameter(0)
1793  <<" a1="<< event_data.m_fitf_zphi_approx->GetParameter(1)<<" a2="
1794  << event_data.m_fitf_zphi_approx->GetParameter(2)<<" fitresult="<<fitresult2);
1795 
1796  double p1=event_data.m_fitf_ztanphi->GetProb();
1797  double p2=event_data.m_fitf_zphi_approx->GetProb();
1798 
1799  ATH_MSG_VERBOSE("tanphi prob: "<<p1<<" pol2 prob : "<<p2);
1800 
1801  delete gre;
1802 
1803 
1804  if(fitresult1!=0 && fitresult2!=0) return nullptr;
1805  if(fitresult1!=0 && fitresult2==0) return event_data.m_fitf_zphi_approx;
1806  if(fitresult1==0 && fitresult2!=0) return event_data.m_fitf_zphi;
1807 
1808 
1809  int match_tan=0;
1810  int match_phi=0;
1811  for(int i=0;i<count;i++){
1812  double phi1=event_data.m_fitf_zphi->Eval(event_data.m_a_z[i]);
1813  double phi2=event_data.m_fitf_zphi_approx->Eval(event_data.m_a_z[i]);
1814 
1815  if(std::abs(phi1-event_data.m_a_phi[i])<2*event_data.m_a_phi_err[i])
1816  match_tan++;
1817 
1818  if(std::abs(phi2-event_data.m_a_phi[i])<2*event_data.m_a_phi_err[i])
1819  match_phi++;
1820 
1821  }
1822 
1823 
1824  ATH_MSG_VERBOSE("Number of hits matching this fit: tan="<<match_tan<<" pol2="<<match_phi);
1825 
1826  if(match_tan>match_phi){
1827  return event_data.m_fitf_zphi;
1828  }else if(match_tan<match_phi){
1829  return event_data.m_fitf_zphi_approx;
1830  }
1831 
1832  if(p1>p2){
1833  return event_data.m_fitf_zphi;
1834  }else{
1835  return event_data.m_fitf_zphi_approx;
1836  }
1837 
1838 }
1839 
1841 // Provide the proper subtraction of two phi values
1843 
1844 
1845 // @TODO unusued
1847  std::vector<const InDet::TRT_DriftCircle*> *seed) const
1848 {
1849 
1850  double mean=0,var=0;
1851  double meanz=0,varz=0;
1852 
1854 
1855  vit=seed->begin();
1856  vitE=seed->end();
1857 
1858  double dcz[500];
1859  int count=0;
1860  int index=-1;
1861  for(;vit!=vitE;++vit){
1862  int straw = m_trtid->straw((*vit)->identify());
1863  const Amg::Vector3D& sc = (*vit)->detectorElement()->strawCenter(straw);
1864 
1865  if(dc==*vit) index=count;
1866  dcz[count++]=sc.z();
1867 
1868  meanz+=sc.z();
1869  varz+=sc.z()*sc.z();
1870  }
1871 
1872  if(count < 2) return true;
1873 
1874  varz=(count*varz-meanz*meanz);
1875  varz/=(double)(count*(count-1));
1876 
1877  meanz/=(double)count;
1878 
1879  varz=std::sqrt(varz);
1880 
1881  double zmin_sel=100000;
1882 
1883  for(int i=0;i<count;i++){
1884  double zmin=10000;
1885 
1886  if(i-1>=0)
1887  if(std::abs(dcz[i]-dcz[i-1])<zmin) zmin=std::abs(dcz[i]-dcz[i-1]);
1888  if(i+1<count)
1889  if(std::abs(dcz[i]-dcz[i+1])<zmin) zmin=std::abs(dcz[i]-dcz[i+1]);
1890 
1891  if(i==index)
1892  zmin_sel=zmin;
1893 
1894  mean+=zmin;
1895  var+=zmin*zmin;
1896  }
1897 
1898  var=(count*var-mean*mean);
1899  var/=(double)(count*(count-1));
1900 
1901  mean/=(double)count;
1902 
1903  var=std::sqrt(var);
1904 
1905  if(var<6) var=6;
1906 
1907  if(std::abs(zmin_sel-mean)>2*var){// || std::abs(dcz[index]-meanz)>2*varz){
1908  if(index>=0) {
1909  ATH_MSG_VERBOSE("Hit is suspicious, remove it! "<<std::abs(zmin_sel-mean)<<" , "<<2*var<<" -> "<<zmin_sel<< " : "<<dcz[index]<<" <-> "<<meanz<<" ("<<varz<<")");
1910  }
1911  return true;
1912  }else{
1913  if(index>=0) {
1914  ATH_MSG_VERBOSE("Hit seems to be ok: "<<std::abs(zmin_sel-mean)<<" < "<<2*var<<" && "<<std::abs(dcz[index]-meanz)<<" < "<<1.5*varz);
1915  }
1916  }
1917  return false;
1918 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
fitf_zphi_approx
Double_t fitf_zphi_approx(const Double_t *x, const Double_t *par)
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:92
Trk::LocalParameters
Definition: LocalParameters.h:98
TRT_TrackSegmentsMaker_ECcosmics.h
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
InDet::TRT_TrackSegmentsMaker_ECcosmics::setFitFunctions
void setFitFunctions(TRT_TrackSegmentsMaker_ECcosmics::EventData &event_data) const
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:141
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
checkFileSG.line
line
Definition: checkFileSG.py:75
TRT::Hit::straw
@ straw
Definition: HitInfo.h:82
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_goodHits
std::list< const InDet::TRT_DriftCircle * > m_goodHits
List containing potenitally good hits.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:137
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
InDet::TRT_TrackSegmentsMaker_ECcosmics::perform_fit
TF1 * perform_fit(int count, TRT_TrackSegmentsMaker_ECcosmics::EventData &event_data) const
Perform the fit and return a function that provides the fitted phi information.
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:1760
InDet::TRT_TrackSegmentsMaker_ECcosmics::find_seed
bool find_seed(int endcap, int zslice, int sector, TRT_TrackSegmentsMaker_ECcosmics::EventData &event_data) const
Find seed in the given sector/zslice/endcap.
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:412
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
StraightLineSurface.h
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
InDet::TRT_TrackSegmentsMaker_ECcosmics::accepted
bool accepted(const std::list< const InDet::TRT_DriftCircle * >::iterator compareIt, std::list< const InDet::TRT_DriftCircle * > &container, double phiLimit, double dzLimit) const
is the hit accepted?
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:1719
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
TRT_DetectorManager.h
Surface.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Trk::PRDtoTrackMap
Definition: PRDtoTrackMap.h:17
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:176
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
initialize
void initialize()
Definition: run_EoverP.cxx:894
IRIO_OnTrackCreator.h
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
InDet::TRT_TrackSegmentsMaker_ECcosmics::is_suspicious
bool is_suspicious(const InDet::TRT_DriftCircle *dc, std::vector< const InDet::TRT_DriftCircle * > *seed) const
checks if a hit that matches the segment looks suspicious (i.e.
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:1846
skel.it
it
Definition: skel.GENtoEVGEN.py:423
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
M_PI
#define M_PI
Definition: ActiveFraction.h:11
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_scaleTubeNoise
double m_scaleTubeNoise
Scalefactor for uncertainty of tube hits flagged as noise.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:180
InDet::TRT_TrackSegmentsMaker_ECcosmics::next
virtual Trk::TrackSegment * next(InDet::ITRT_TrackSegmentsMaker::IEventData &event_data) const override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:1541
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_scaleFactorDrift
double m_scaleFactorDrift
Scalefactor for uncertainty of drifttime hits
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:179
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_segiterator
std::list< Trk::TrackSegment * >::iterator m_segiterator
Iterator over found segments.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:144
Trk::locR
@ locR
Definition: ParamDefs.h:50
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_riomakerD
ToolHandle< Trk::IRIO_OnTrackCreator > m_riomakerD
RI0_onTrack creator with drift information.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:174
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::TrackSegment
Definition: TrackSegment.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
x
#define x
InDet::TRT_TrackSegmentsMaker_ECcosmics::find
virtual void find(const EventContext &ctx, InDet::ITRT_TrackSegmentsMaker::IEventData &event_data, InDet::TRT_DetElementLink_xk::TRT_DetElemUsedMap &used) const override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:328
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_fitf_zphi
TF1 * m_fitf_zphi
analytic function to fit phi vs.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:156
InDet::TRT_DriftCircle
Definition: TRT_DriftCircle.h:32
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_cutToTTight
double m_cutToTTight
Hard cut on ToT (preselection)
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:182
TruthTest.itE
itE
Definition: TruthTest.py:25
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_sectors
std::list< const InDet::TRT_DriftCircle * > m_sectors[2][20][16]
Divide into two endcaps and each endcap into 16 sectors in phi and 20 in z.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:140
Trk::DefinedParameter
std::pair< double, ParamDefs > DefinedParameter
Definition: DefinedParameter.h:27
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
InDet::TRT_TrackSegmentsMaker_ECcosmics::phidiff
static double phidiff(double a, double b)
provide the proper subtraction of two phi values
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:235
Trk::PseudoMeasurementOnTrack
Class to handle pseudo-measurements in fitters and on track objects.
Definition: PseudoMeasurementOnTrack.h:44
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
TRT_ID::straw
int straw(const Identifier &id) const
Definition: TRT_ID.h:902
athena.ps2
ps2
Definition: athena.py:134
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::index1
@ index1
Definition: BoundarySurfaceFace.h:48
Trk::locZ
@ locZ
local cylindrical
Definition: ParamDefs.h:48
InDet::TRT_TrackSegmentsMaker_ECcosmics::newEvent
virtual std::unique_ptr< InDet::ITRT_TrackSegmentsMaker::IEventData > newEvent(const EventContext &ctx) const override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:182
InDet::CompareDCy
bool CompareDCy(const InDet::TRT_DriftCircle *x, const InDet::TRT_DriftCircle *y)
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:297
id2
HWIdentifier id2
Definition: LArRodBlockPhysicsV0.cxx:564
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_useDriftTime
bool m_useDriftTime
Shall the drifttime be used or only tube hits?
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:177
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_minDCSeed
int m_minDCSeed
Minimum number of driftcircles to form a seed
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:184
PixelAthClusterMonAlgCfg.e4
e4
Definition: PixelAthClusterMonAlgCfg.py:317
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:72
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
Trk::driftRadius
@ driftRadius
trt, straws
Definition: ParamDefs.h:59
InDet::TRT_TrackSegmentsMaker_ECcosmics::finalize
virtual StatusCode finalize() override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:171
InDet::TRT_TrackSegmentsMaker_ECcosmics::endEvent
void endEvent(InDet::ITRT_TrackSegmentsMaker::IEventData &event_data) const override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:274
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_cutToTLoose
double m_cutToTLoose
Loose cut on ToT (preselection)
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:181
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_riomakerN
ToolHandle< Trk::IRIO_OnTrackCreator > m_riomakerN
RI0_onTrack creator without drift information.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:175
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_a_z_err
double m_a_z_err[1000]
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:151
PseudoMeasurementOnTrack.h
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:127
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_seeds
std::vector< std::vector< const InDet::TRT_DriftCircle * > * > m_seeds
Vector of seeds.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:142
InDet::TRT_TrackSegmentsMaker_ECcosmics::create_segment
void create_segment(std::vector< const InDet::TRT_DriftCircle * > *seed, TRT_TrackSegmentsMaker_ECcosmics::EventData &event_data) const
Create segment out of a seed.
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:825
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_a_phi_err
double m_a_phi_err[1000]
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:148
InDet::TRT_TrackSegmentsMaker_ECcosmics::~TRT_TrackSegmentsMaker_ECcosmics
virtual ~TRT_TrackSegmentsMaker_ECcosmics()
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TRT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: TRT_ID.h:866
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
fitf_zphi
Double_t fitf_zphi(const Double_t *x, const Double_t *par)
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:86
InDet::TRT_TrackSegmentsMaker_ECcosmics::evaluate_seed
int evaluate_seed(int endcap, int zslice, int sector, const double *p, TRT_TrackSegmentsMaker_ECcosmics::EventData &event_data) const
Evaluate how many dc match this seed.
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:770
DataVector< const Trk::MeasurementBase >
TRT_ID::layer_or_wheel
int layer_or_wheel(const Identifier &id) const
Definition: TRT_ID.h:884
Trk::PRDtoTrackMap::isUsed
bool isUsed(const PrepRawData &prd) const
does this PRD belong to at least one track?
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:118
MuonValidation_CreateResolutionProfiles.fit
def fit(h, emin, emax)
Definition: MuonValidation_CreateResolutionProfiles.py:69
InDet::TRT_TrackSegmentsMaker_ECcosmics::newRegion
virtual std::unique_ptr< InDet::ITRT_TrackSegmentsMaker::IEventData > newRegion(const EventContext &ctx, const std::vector< IdentifierHash > &) const override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:229
InDet::TRT_DriftCircleContainer
Trk::PrepRawDataContainer< TRT_DriftCircleCollection > TRT_DriftCircleContainer
Definition: TRT_DriftCircleContainer.h:27
TRT_DriftCircleContainer.h
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_noiseHits
std::list< const InDet::TRT_DriftCircle * > m_noiseHits
List containing potentially noise hits.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:136
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_hitLimit
int m_hitLimit
Maximum number of good hits (i.e.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:185
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_fitf_ztanphi
TF1 * m_fitf_ztanphi
analytic function to fit tan(phi) vs.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:155
Trk::index2
@ index2
Definition: BoundarySurfaceFace.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
RIO_OnTrack.h
RootUtils::WithRootErrorHandler
Run a MT piece of code with an alternate root error handler.
Definition: WithRootErrorHandler.h:56
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_scaleTube
double m_scaleTube
Scalefactor for uncertainty of tube hits
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:178
InDet::CompareDCz
bool CompareDCz(const InDet::TRT_DriftCircle *x, const InDet::TRT_DriftCircle *y)
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:285
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_prdToTrackMap
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:172
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_a_tan
double m_a_tan[1000]
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:149
WithRootErrorHandler.h
Run a MT piece of code with an alternate root error handler.
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_phaseMode
bool m_phaseMode
Switch to destinguish between phase calculation and full reco.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:167
fitf_ztanphi
Double_t fitf_ztanphi(const Double_t *x, const Double_t *par)
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:80
y
#define y
InDet::TRT_TrackSegmentsMaker_ECcosmics::TRT_TrackSegmentsMaker_ECcosmics
TRT_TrackSegmentsMaker_ECcosmics(const std::string &, const std::string &, const IInterface *)
Constructor with parameters.
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:37
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
InDet::TRT_TrackSegmentsMaker_ECcosmics::initialize
virtual StatusCode initialize() override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:102
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_a_tan_err
double m_a_tan_err[1000]
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:150
InDet::CompareDCzreverse
bool CompareDCzreverse(const InDet::TRT_DriftCircle *x, const InDet::TRT_DriftCircle *y)
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:309
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_trtid
const TRT_ID * m_trtid
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:168
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:73
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_a_z
double m_a_z[1000]
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:146
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_fitf_zphi_approx
TF1 * m_fitf_zphi_approx
anpprox function to fit phi vs.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:159
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_cutToTUpper
double m_cutToTUpper
Upper cut on ToT (preselection)
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:183
Trk::MeasurementBaseType::PseudoMeasurementOnTrack
@ PseudoMeasurementOnTrack
Definition: MeasurementBase.h:51
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
Trk::phi
@ phi
Definition: ParamDefs.h:81
Trk::EventDataBase< EventData, InDet::ITRT_TrackSegmentsMaker::IEventData >::getPrivateEventData
static EventData & getPrivateEventData(InDet::ITRT_TrackSegmentsMaker::IEventData &virt_event_data)
Definition: EventDataBase.h:19
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_segments
std::list< Trk::TrackSegment * > m_segments
List of found segments.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:143
FitQuality.h
InDet::TRT_TrackSegmentsMaker_ECcosmics::EventData::m_a_phi
double m_a_phi[1000]
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:147
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
InDet::ITRT_TrackSegmentsMaker::IEventData
Definition: ITRT_TrackSegmentsMaker.h:53
InDet::TRT_TrackSegmentsMaker_ECcosmics::dump
virtual MsgStream & dump(MsgStream &out) const override
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:1554
python.compressB64.c
def c
Definition: compressB64.py:93
InDet::TRT_TrackSegmentsMaker_ECcosmics::m_trtname
SG::ReadHandleKey< InDet::TRT_DriftCircleContainer > m_trtname
TRTs container.
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:170
Trk::Segment::TRT_SegmentMaker
@ TRT_SegmentMaker
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:73
python.Dumpers.FitQuality
FitQuality
Definition: Dumpers.py:63
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
InDet::TRT_TrackSegmentsMaker_ECcosmics::s_fitMutex
static std::mutex s_fitMutex
Definition: TRT_TrackSegmentsMaker_ECcosmics.h:187
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
InDet::TRT_TrackSegmentsMaker_ECcosmics::retrieveHits
void retrieveHits(TRT_TrackSegmentsMaker_ECcosmics::EventData &event_data) const
sort hits into good/noise lists
Definition: TRT_TrackSegmentsMaker_ECcosmics.cxx:1574