ATLAS Offline Software
TRT_TrackSegmentsMaker_BarrelCosmics.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TRT_TrackSegmentsMaker_BarrelCosmics.h, (c) ATLAS Detector software
8 
10 
14 #include "StoreGate/ReadHandle.h"
15 #include "InDetIdentifier/TRT_ID.h"
17 #include <cmath>
18 
20 // standard methods: constructor, initialize, finalize
22 
24 (const std::string& t,const std::string& n,const IInterface* p)
25  : AthAlgTool(t,n,p),
26  m_TRTManagerName("TRT"),
27  m_trtid(nullptr),
28  m_maxTotalHits(21000), // corresponds to 20% occupancy
29  m_minHitsForSeed(-1),
30  m_minHitsForSegment(20),
31  m_minHitsAboveTOT(-1),
32  m_nBinsInX(100),
33  m_nBinsInPhi(10),
34  m_minSeedTOT(10.),
35  m_magneticField(true),
36  m_mergeSegments(false)
37  //Endcap Trigger Hack
38 {
39 
40  declareInterface<ITRT_TrackSegmentsMaker>(this);
41 
42  declareProperty("MaxTotalNumberOfBarrelHits", m_maxTotalHits); // if set to 0, this requirement is not used. total number of TRT barrel straws is 105088
43 
44  declareProperty("MinimalNumberOfTRTHits", m_minHitsForSegment);
45  declareProperty("MinNumberOfHitsForSeed", m_minHitsForSeed);
46  declareProperty("MinNumberOfHitsAboveTOT", m_minHitsAboveTOT);
47 
48  declareProperty("NbinsInX", m_nBinsInX);
49  declareProperty("NbinsInPhi", m_nBinsInPhi);
50 
51  declareProperty("MinimalTOTForSeedSearch", m_minSeedTOT);
52  declareProperty("IsMagneticFieldOn", m_magneticField);
53  declareProperty("TrtManagerLocation", m_TRTManagerName);
54  declareProperty("MergeSegments", m_mergeSegments);
55 
56 }
57 
59 
60  ATH_MSG_DEBUG("InDet::TRT_TrackSegmentsMaker_BarrelCosmics::initialize(), March 2012"
61  << ", magnetic field: " << (m_magneticField?"ON":"OFF")
62  << " search bins: " << m_nBinsInX << ", " << m_nBinsInPhi);
63 
64  StatusCode sc = StatusCode::SUCCESS;
65 
66  // Initialize ReadHandle
68  // TRT
69  if (detStore()->retrieve(m_trtid, "TRT_ID").isFailure()) {
70  ATH_MSG_FATAL("Could not get TRT ID helper");
71  return StatusCode::FAILURE;
72  }
73 
76 
77  ATH_MSG_DEBUG("m_minHitsForSegment = " << m_minHitsForSegment);
78  ATH_MSG_DEBUG("m_minHitsForSeed = " << m_minHitsForSeed);
79  ATH_MSG_DEBUG("m_minHitsAboveTOT = " << m_minHitsAboveTOT);
80 
81  if (m_minSeedTOT<0. || m_minSeedTOT>20.)
82  ATH_MSG_WARNING("initialize(): are you sure about the MinimalTOTForSeedSearch setting? (set at " << m_minSeedTOT << ")");
83 
84  ATH_MSG_DEBUG("InDet::TRT_TrackSegmentsMaker_BarrelCosmics::initialize(), jobProperties: "
85  << "MinimalNumberOfTRTHits " << m_minHitsForSegment << ", MinimalTOTForSeedSearch: " << m_minSeedTOT
86  << ", m_minHitsForSeed: " << m_minHitsForSeed << ", m_minHitsAboveTOT: " << m_minHitsAboveTOT );
87 
88  return sc;
89 }
90 
92  return StatusCode::SUCCESS;
93 }
94 
96 // other methods inherited from ITRT_TrackSegmentsMaker: newEvent, newRegion, endEvent
98 
99 std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData> InDet::TRT_TrackSegmentsMaker_BarrelCosmics::newEvent(const EventContext& ctx) const {
100 
101  ATH_MSG_DEBUG( "InDet::TRT_TrackSegmentsMaker_BarrelCosmics::newEvent()");
102 
103 
104  SG::ReadHandle<InDet::TRT_DriftCircleContainer> trtcontainer(m_driftCirclesName, ctx); // get TRT_DriftCircle list from StoreGate containers
105 
106  if (not trtcontainer.isValid()) {
107  msg(MSG::ERROR) << "Could not find TRT_DriftCircles collection!" << endmsg;
108  std::stringstream msg;
109  msg << name() <<" no TRT drift circles : " << m_driftCirclesName.key();
110  throw std::runtime_error(msg.str());
111  }
112 
113  std::unique_ptr<TRT_TrackSegmentsMaker_BarrelCosmics::EventData>
114  event_data = std::make_unique<TRT_TrackSegmentsMaker_BarrelCosmics::EventData>(trtcontainer.cptr());
115 
116  for(const auto *it : *trtcontainer) {
117 
118  const InDet::TRT_DriftCircleCollection *colNext=&(*it);
119  if (!colNext) { msg(MSG::WARNING) << "newEvent(): !colNext " << endmsg; continue; }
120 
121  for (const auto *circleit : *colNext){
122 
123  if ( m_trtid->is_barrel((*circleit).identify()) ) { // TRT barrel
124 
125  event_data->m_listHits.push_back( circleit );
126 
127  double onMyTime = circleit->timeOverThreshold();
128  if ( circleit->firstBinHigh() && (circleit->trailingEdge() != 24) && (circleit->trailingEdge() != 0) ) onMyTime = ( (double) circleit->trailingEdge() + 1 ) * 3.125;
129  if (onMyTime < m_minSeedTOT) continue;
130 
131  const Amg::Vector3D &center = circleit->detectorElement()->surface(circleit->identify()).center();
132  event_data->m_listHitCenter.push_back( center );
133  }
134  }
135  } // end trtcontainer loop
136 
137  if ( m_maxTotalHits && ((int)event_data->m_listHits.size()) > m_maxTotalHits ) {
138  ATH_MSG_DEBUG( "skipping high occupancy event of " << event_data->m_listHits.size() << " barrel hits, limit at "
139  << m_maxTotalHits );
140  event_data->clear();
141  }
142 
143  ATH_MSG_DEBUG( "newEvent(): Number of TRT barrel hits: " << event_data->m_listHits.size()
144  << " Number of hits with TOT > " << m_minSeedTOT << ": " << event_data->m_listHitCenter.size() );
145 
146  return std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData>(event_data.release());
147 }
148 
149 std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData>
150 InDet::TRT_TrackSegmentsMaker_BarrelCosmics::newRegion(const EventContext& ctx, const std::vector<IdentifierHash> &vTRT) const {
151 
152  ATH_MSG_DEBUG("InDet::TRT_TrackSegmentsMaker_BarrelCosmics::newRegion()" );
153 
155  if (not trtcontainer.isValid()) {
156  msg(MSG::ERROR) << "m_trtcontainer is empty!!!" << endmsg;
157  std::stringstream msg;
158  msg << name() <<" no TRT drift circles : " << m_driftCirclesName.key();
159  throw std::runtime_error(msg.str());
160  }
161 
162  std::unique_ptr<TRT_TrackSegmentsMaker_BarrelCosmics::EventData>
163  event_data = std::make_unique<TRT_TrackSegmentsMaker_BarrelCosmics::EventData>(trtcontainer.cptr());
164 
165 
166  for(auto d : vTRT) {
167  for ( InDet::TRT_DriftCircleContainer::const_iterator w = trtcontainer->indexFind(d); w!=trtcontainer->end(); ++w ) {
168  for(const auto *circleit : **w) {
169 
170  if(std::abs(m_trtid->barrel_ec( circleit->identify() ))!=1) continue;
171 
172  event_data->m_listHits.push_back(circleit);
173 
174  double onMyTime = circleit->timeOverThreshold();
175  if ( circleit->firstBinHigh() && (circleit->trailingEdge() != 24) && (circleit->trailingEdge() != 0) ) onMyTime = ( (double) circleit->trailingEdge() + 1 ) * 3.125;
176  if (onMyTime < m_minSeedTOT) continue;
177  const Amg::Vector3D &center = circleit->detectorElement()->surface(circleit->identify()).center();
178  event_data->m_listHitCenter.push_back( center );
179  }
180  }
181  }
182 
183  if ( m_maxTotalHits && ((int)event_data->m_listHits.size()) > m_maxTotalHits ) {
184  ATH_MSG_DEBUG("skipping high occupancy event of " << event_data->m_listHits.size() << " barrel hits, limit at "
185  << m_maxTotalHits);
186  event_data->clear();
187  }
188 
189  ATH_MSG_DEBUG( "newRegion(): Number of TRT barrel hits: " << event_data->m_listHits.size()
190  << " Number of hits with TOT > " << m_minSeedTOT << ": " << event_data->m_listHitCenter.size() );
191 
192  return std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData>(event_data.release());
193 }
194 
198 
199  ATH_MSG_DEBUG("InDet::TRT_TrackSegmentsMaker_BarrelCosmics::endEvent()" );
200 
201  // elements of m_segments created by new have not been passed on
202  if ( event_data.m_segmentDriftCirclesCount < event_data.m_segments.size() ) {
203  msg(MSG::WARNING) << "endEvent() you called the function t create the segments but not retrived them later??" << endmsg;
204  msg(MSG::WARNING) << "endEvent() deleting remaining elements of m_segments" << endmsg;
205  for (unsigned int i=event_data.m_segmentDriftCirclesCount; i<event_data.m_segments.size(); i++) delete event_data.m_segments[i];
206  }
207 
208  }
209 
211 // segment finding algorithm function: find, calls findSeed
213 
214 void InDet::TRT_TrackSegmentsMaker_BarrelCosmics::find(const EventContext &/*ctx*/,
219 
220  if (!m_magneticField) { findOld(event_data); return; }
221 
222  ATH_MSG_DEBUG("InDet::TRT_TrackSegmentsMaker_BarrelCosmics::find()" );
223 
224 
225  if ((int)event_data.m_listHitCenter.size()<m_minHitsAboveTOT) return;
226 
227  if (!event_data.m_segmentDriftCircles.empty()) { // debug only
228  msg(MSG::WARNING) << "TRT_TrackSegmentsMaker_BarrelCosmics::find() probably called twice per event? or newEvent / newRegion have not been called. check your program" << endmsg;
229  event_data.clear(); return;
230  }
231 
232  std::vector<double> x0, phi, pivotX, pivotY, Xparabola, cotanParabola, InverseR;
233  std::vector<int> nHitsPosY, nHitsNegY;
234 
235  // first find seeds
236  int nIterations(15), countCalls(0);
237  while (countCalls<150) {
238 
239  double xRange(1000.), phiRange(M_PI_4);
240  double par[] = {0., M_PI_2, 0., 0., 0., 0., 0., 0.};
241  int foundSeed(0);
242 
243  for (int i=0; i<nIterations; i++) {
244 
245  countCalls++;
246  foundSeed = findSeed( par[0]-xRange, par[0]+xRange, par[1]-phiRange, par[1]+phiRange, par, event_data);
247  if ( !foundSeed ) break;
248 
249  xRange /= 3.;
250  phiRange /= 2.;
251  if ( xRange < 0.01 || phiRange < 0.00001) break;
252  }
253  if (!foundSeed) break;
254 
255  if (m_magneticField) findSeedInverseR(par, event_data);
256 
257 // remove the hits associated with this region, save this region, search again
258  int countAssociatedHits[] = {0, 0};
259  double cosphi = std::cos( par[1] );
260  double sinphi = std::sqrt( 1. - cosphi*cosphi );
261  double range = (m_magneticField) ? 10. : 2.; // BE CAREFULL ABOUT THIS RANGE, IT USED TO BE 2 BUT PERHAPS IT SHOULD BE INCREASED TO 10 in the case of magnetic field!
262 
263 
264  double measx[200], measy[200];
265  int countMeas(0);
266 
267  for (std::vector< Amg::Vector3D>::iterator it = event_data.m_listHitCenter.begin(); it!=event_data.m_listHitCenter.end(); ) {
268 
269  double a = (par[3]-it->x())*sinphi+(it->y()-par[4])*cosphi;
270  double b = (m_magneticField) ? 0.5 * (std::pow(it->x()-par[3], 2.) + std::pow(it->y()-par[4], 2.) - std::pow(a, 2)) : 0.;
271  if ( std::abs(a+par[2]*b) > range ) { ++it; continue; }
272 
273  if (m_magneticField && countMeas<200) { measx[countMeas] = it->x(); measy[countMeas] = it->y(); countMeas++; }
274 
275  countAssociatedHits[(it->y()>0)?0:1]++;
276  it = event_data.m_listHitCenter.erase( it );
277  }
278 
279  if ( countAssociatedHits[0]+countAssociatedHits[1] < m_minHitsAboveTOT ) continue;
280 
281  if (m_magneticField) segFit(measx, measy, countMeas, nullptr, par+3);
282 
283  ATH_MSG_DEBUG("countAssociatedHits " << countAssociatedHits[0] << " "
284  << countAssociatedHits[1] << " m_minHitsAboveTOT " << m_minHitsAboveTOT );
285  x0.push_back( par[0] ); phi.push_back( par[1] ); nHitsPosY.push_back( countAssociatedHits[0] ); nHitsNegY.push_back( countAssociatedHits[1] );
286 
287  pivotX.push_back( par[3] ); pivotY.push_back( par[4] ); Xparabola.push_back( par[5] ); cotanParabola.push_back( par[6] ); InverseR.push_back( par[7] );
288  } // end for (int i=0; i<nIterations; i++) loop
289 // end finding seeds
290 
291 // save all TRT hits for found segments
292 
293  int nFoundSegments = x0.size(); if (nFoundSegments>10) nFoundSegments = 10; // number of found segments
294  {
295  for (int i=0; i<nFoundSegments; i++) {
296  event_data.m_segmentDriftCircles.emplace_back();
297  }
298  }
299 
300  double window = (m_magneticField) ? 4. : 2.; // change for magnetic field
301  double residual;
302 
303  for (unsigned int i=0; i<event_data.m_listHits.size(); i++) {
304 
305  const Amg::Vector3D &center = event_data.m_listHits[i]->detectorElement()->surface(event_data.m_listHits[i]->identify()).center();
306  for (int j=0; j<nFoundSegments; j++) {
307 
308  if (nHitsPosY[j]<5 && center.y()>0.) continue;
309  if (nHitsNegY[j]<5 && center.y()<0.) continue;
310 
311  if (m_magneticField) {
312  double sinphi = std::sqrt(1./(1+cotanParabola[j]*cotanParabola[j]));
313  double cosphi = std::sqrt(1.-sinphi*sinphi); if (cotanParabola[j]<0.) cosphi *= -1.;
314  double a = (pivotX[j]+Xparabola[j]-center.x())*sinphi+(center.y()-pivotY[j])*cosphi;
315  double b = 0.5 * (std::pow(center.x()-pivotX[j], 2.) + std::pow(center.y()-pivotY[j], 2.) - std::pow(a, 2)) ;
316  residual = a + InverseR[j] * b;
317 
318  } else {
319  double cosphi = std::cos(phi[j]);
320  double sinphi = std::sqrt(1.-cosphi*cosphi);
321  residual = (x0[j]-center.x())*sinphi+center.y()*cosphi;
322  }
323 
324  if (std::abs(residual)<window) {
325  event_data.m_segmentDriftCircles[j].push_back(event_data.m_listHits[i]);
326  break;
327  }
328  }
329  }
330  // end saving TRT hits
331 
332 
333 
334  // merge segments: can be simple: if 2 of them similar values of impact par -> copy hits from the second vector into the first one and clear the second one
335  // XXXXXXXX to do: determine the optimal merging parameters
336 
337  if (m_mergeSegments) { // merge segments, not yet tested properly
338 
339  if (x0.size()>1) {
340  int mergeI = 0;
341  int mergeJ = 0;
342  double mergeX0(100.), mergePhi(0.1);
343  for (int i=0; i<nFoundSegments; i++) {
344  for (int j=i+1; j<nFoundSegments; j++) {
345  if ( std::abs(x0[i]-x0[j])<mergeX0 && std::abs(phi[i]-phi[j])<mergePhi ) {
346  mergeI = i;
347  mergeJ = j;
348  mergeX0 = std::abs(x0[i]-x0[j]);
349  mergePhi = std::abs(phi[i]-phi[j]);
350  }
351  }
352  }
353  if (mergeI != mergeJ) {
354  ATH_MSG_DEBUG("Merge segments " << mergeI << " and " << mergeJ << " of size "
355  << event_data.m_segmentDriftCircles[mergeI].size() << ", " << event_data.m_segmentDriftCircles[mergeJ].size()
356  << "; difference in the impact par x: " << mergeX0 << " phi: " << mergePhi );
357  for (unsigned int i=0; i<event_data.m_segmentDriftCircles[mergeJ].size(); i++) {
358  event_data.m_segmentDriftCircles[mergeI].push_back(event_data.m_segmentDriftCircles[mergeJ][i]);
359  }
360  event_data.m_segmentDriftCircles[mergeJ].clear();
361  }
362  }
363  } // end merge segments
364 
365 
366  if (msgLvl(MSG::DEBUG)) { // debug: check how many hits per found segments
367  msg(MSG::DEBUG) << "find() debug (" << nFoundSegments << ")" ;
368  for (unsigned int i=0; i<event_data.m_segmentDriftCircles.size(); i++) {
369  msg(MSG::DEBUG) << " " << i << " " << event_data.m_segmentDriftCircles[i].size();
370  }
371  msg(MSG::DEBUG) << endmsg;
372  }
373 
374  for (unsigned int i=0; i<event_data.m_segmentDriftCircles.size(); i++) { // convert to segments
375  if ((int)event_data.m_segmentDriftCircles[i].size()<m_minHitsForSegment) continue;
376  double trackpar[] = {x0[i], phi[i]};
377  convert(event_data.m_segmentDriftCircles[i], trackpar, event_data);
378  }
379  ATH_MSG_DEBUG( "find(), number of converted segments: " << event_data.m_segments.size() );
380 }
381 
383 // the last method inherited from ITRT_TrackSegmentsMaker: next()
384 // returns ptr to i-th found TrackSegment, until it returns 0 (no more segments)
385 // assumes any provided segments will be deleted by those who request them!!!
387 
389 {
392 
393  // next 6 lines: for debugging purposes only
394  ATH_MSG_DEBUG( "InDet::TRT_TrackSegmentsMaker_BarrelCosmics::next(): return "
395  << event_data.m_segmentDriftCirclesCount << " out of " << event_data.m_segments.size() );
396 
397  if (event_data.m_segmentDriftCirclesCount > event_data.m_segments.size())
398  msg(MSG::ERROR) << "m_segmentDriftCirclesCount = " << event_data.m_segmentDriftCirclesCount << ", m_segments.size() = "
399  << event_data.m_segments.size() << endmsg;
400 
401  return (event_data.m_segmentDriftCirclesCount<event_data.m_segments.size())
402  ?(event_data.m_segments[event_data.m_segmentDriftCirclesCount++])
403  :nullptr;
404 }
405 
406 
407 
409  double xmax,
410  double phimin,
411  double phimax,
412  double *bestParameters,
414 {
415  if ((int)event_data.m_listHitCenter.size()<m_minHitsAboveTOT) return 0;
416 
417  double xbin = (xmax-xmin) / (1.*m_nBinsInX);
418  double searchWindow = (xbin>2.) ? xbin : 2.; //searchWindow *= searchWindow;
419  double phibin = (phimax-phimin) / (1.*m_nBinsInPhi);
420  int maxHits(0), index, indexmin, indexmax;
421 
422  int binInX[100]; for (int & i : binInX) i = 0;
423 
424  for (int j=0; j<m_nBinsInPhi; j++) {
425 
426  double phi = phimin+(0.5+j)*phibin;
427  double cosphi( std::cos(phi) ), sinphi( std::sin(phi) );
428  for (int i=0; i<m_nBinsInX; i++) binInX[i] = 0;
429  double transformXMin(xmin*sinphi); xbin = (xmax-xmin)*sinphi / (1.*m_nBinsInX);
430 
431  for (auto & k : event_data.m_listHitCenter) {
432  double transformX = k.x() * sinphi - k.y() * cosphi;
433  indexmin = (int) ((transformX-transformXMin-searchWindow)/xbin);
434  indexmax = (int) ((transformX-transformXMin+searchWindow)/xbin);
435 
436  if (indexmin<0) indexmin=0;
437  if (indexmax>99) indexmax=99;
438  for (index = indexmin; index<=indexmax; index++) binInX[index]++;
439  }
440  index = -1;
441  for (int i=0; i<m_nBinsInX; i++) if (binInX[i]>maxHits) { index = i; maxHits = binInX[i]; }
442  if (index>=0) {
443  bestParameters[0] = ( xbin * index + transformXMin) / sinphi;
444  bestParameters[1] = phi;
445  }
446  }
447 
448  return (maxHits>=m_minHitsForSeed) ? 1 : 0;
449 }
450 
453 
454  double cosphi = std::cos( par[1] );
455  double sinphi = std::sqrt( 1. - cosphi*cosphi );
456 
457  double parTransformX = par[0] * sinphi;
458 
459  double meanTransformY(0.);
460  int countMeanTransformY(0);
461  for (auto & k : event_data.m_listHitCenter) { // first determine the mean
462 
463  double transformX = k.x() * sinphi - k.y() * cosphi;
464  if ( std::abs(transformX-parTransformX) > 2. ) continue;
465  meanTransformY += k.x() * cosphi + k.y() * sinphi;
466  countMeanTransformY++;
467  }
468  if (!countMeanTransformY) {
469  ATH_MSG_WARNING("InDet::TRT_TrackSegmentsMaker_BarrelCosmics::findSeedInverseR(), no hits in the seed region???" );
470  return;
471  }
472  meanTransformY /= (double) countMeanTransformY;
473 
474 
475 // hard-coded parameters in the second part of this function:
476 // search range: [-0.00202, 0.00202] divided into 101 bins of width 0.00004 (such that range [-0.00002, 0.00002] is bin 50)
477 // 1/R = 0.002/mm corresponds to R = 0.5 m
478 // circle search window: 200 mm (for R=1m, circle-to-line distance 0.5 m away from a common point is 130mm)
479 
480 // -> pivot at: x_pivot = meanTransformY * cosphi + parTransformX * sinphi; y_pivot = meanTransformY * sinphi - parTransformX * cosphi;
481  double mean[] = { meanTransformY * cosphi + parTransformX * sinphi, meanTransformY * sinphi - parTransformX * cosphi };
482  int scanInverseR[101]; for (int & i : scanInverseR) i = 0;
483 
484  double window = 10.; // parabola search window BE CAREFULL OF THIS RANGE!
485 
486  for (auto & it : event_data.m_listHitCenter) {
487 
488  double transformX = it.x() * sinphi - it.y() * cosphi;
489  if ( std::abs(transformX-parTransformX) > 200. ) continue; // search circles in a broad band
490 
491  double a = (mean[0]-it.x())*sinphi+(it.y()-mean[1])*cosphi; // TEST THAT THIS CONDITION ( if ( fabs(a) > 200. ) continue; ) IS THE SAME AS ABOVE!
492  double b = 0.5 * (std::pow(it.x()-mean[0], 2.) + std::pow(it.y()-mean[1], 2.) - std::pow(a, 2));
493 
494  // estimated allowed range in radius: x_1,2 = ( +- window - a ) / b -> get integer as ((int) (ceil(x/bin-0.5))) + 50
495  b *= 0.00004; // multiply by the bin width
496 
497  int i1(0), i2(0);
498  if (std::abs(b)>0.0000001) {
499  double i1_tmp = ( window - a ) / b + 0.5;
500  double i2_tmp = ( -window - a ) / b + 0.5;
501  if (std::abs(i1_tmp)<1000.) { i1 = (int) (std::ceil( i1_tmp )); i1 += 50; }
502  if (std::abs(i2_tmp)<1000.) { i2 = (int) (std::ceil( i2_tmp )); i2 += 50; }
503  }
504  if (i1>100) { i1 = 100; } else { if (i1<0) i1 = 0; }
505  if (i2>100) { i2 = 100; } else { if (i2<0) i2 = 0; }
506  if (i1+i2==0 || i1+i2==200) continue; // out of search range
507  if (i1<=i2) { for (int i=i1; i<=i2; i++) scanInverseR[i]++; }
508  else { for (int i=i2; i<=i1; i++) scanInverseR[i]++; }
509  }
510 
511  int iMax(-1), hitsMax(0);
512  for (int i=0; i<101; i++) if (scanInverseR[i]>hitsMax) { iMax = i; hitsMax = scanInverseR[i]; } // find max bin
513 
514  par[2] = 0.00004 * (iMax-50); // save estimated inverse radius
515  for (int i=0; i<2; i++) par[3+i] = mean[i]; }
516 
518 // convert list of TRT hits to "TrackSegment": convert()
519 //
520 // the only TrackSegment constructor one can use for the purpose:
521 //
522 // TrackSegment( const LocalParameters* locpars, // LocalParameters(radius, z0, phi0, theta, QoverP) at Surface point "sf"
523 // const ErrorMatrix* locerr, // error matrix for above params
524 // const Surface* sf, //
525 // DataVector<const MeasurementBase>* crots, // TRT_DriftCircleOnTrack : RIO_OnTrack : MeasurementBase
526 // FitQuality* fqual, // FitQuality(float chi2, short ndf)
527 // Segment::Author author = Segment::AuthorUnknown
528 // );
530 
531 void InDet::TRT_TrackSegmentsMaker_BarrelCosmics::linearRegressionParabolaFit(double *mean, double *a) { // input: elsewhere calculated mean, output: result a
532 
533  double A[6], discriminant;
534 
535  A[0] = mean[8]*mean[8]-mean[4]*mean[9]; // parabola fit
536  A[1] = mean[1]*mean[9]-mean[4]*mean[8];
537  A[2] = mean[4]*mean[4]-mean[1]*mean[8];
538  A[3] = mean[4]*mean[4]-mean[9];
539  A[4] = mean[8]-mean[1]*mean[4];
540  A[5] = mean[1]*mean[1]-mean[4];
541  discriminant = std::abs( std::pow(mean[4], 3) + mean[8]*mean[8] + mean[1]*mean[1]*mean[9] - mean[4]*(2.*mean[1]*mean[8]+mean[9]) );
542 
543  a[0] = A[0] * mean[0] + A[1] * mean[2] + A[2] * mean[6];
544  a[1] = A[1] * mean[0] + A[3] * mean[2] + A[4] * mean[6];
545  a[2] = A[2] * mean[0] + A[4] * mean[2] + A[5] * mean[6];
546  discriminant *= -1.;
547  for (int i=0; i<3; i++) { a[i] /= discriminant; }
548 
549  double inverseSin3phi = 1. + a[1]*a[1]; inverseSin3phi *= std::sqrt(inverseSin3phi); // 1/sin^3phi
550  a[2] *= 2. / inverseSin3phi; }
551 
553 
554  double y1 = (dc1->detectorElement())->surface(dc1->identify()).center().y();
555  double y2 = (dc2->detectorElement())->surface(dc2->identify()).center().y();
556  return ( y1 > y2 );
557 }
558 
559 void InDet::TRT_TrackSegmentsMaker_BarrelCosmics::convert(std::vector<const InDet::TRT_DriftCircle *> &hits,
560  double *trackpar,
562 //Track Segment production - based on TRT_TrackSegmentsMaker_ECcosmics Tool
563 
564  ATH_MSG_DEBUG("InDet::TRT_TrackSegmentsMaker_BarrelCosmics::convert() segment " << event_data.m_segments.size()
565  << ", N hits = " << hits.size());
566 
567  if (hits.size()<5) { msg(MSG::ERROR) << "convert(): empty list of hits! size: " << hits.size() << endmsg; return; }
568 
569  // sort the vector of hits
571 
572  // remove hits from the opposite side
573  int countOppositeSide(0);
575  int side = m_trtid->barrel_ec( (*it)->identify() );
576  int previous = ( it == hits.begin() ) ? m_trtid->barrel_ec( (*(it+2))->identify() ) : m_trtid->barrel_ec( (*(it-1))->identify() );
577  int next = ( it == hits.end()-1 ) ? m_trtid->barrel_ec( (*(it-2))->identify() ) : m_trtid->barrel_ec( (*(it+1))->identify() );
578  if ( previous==next && side*next==-1 ) { it = hits.erase( it ); countOppositeSide++; }
579  else { ++it; }
580  }
581  if (countOppositeSide>5) {
582  ATH_MSG_DEBUG( "convert(): removed " << countOppositeSide << " hits from the other side, N remaining hits: " << hits.size() );
583  }
584  if (hits.size()<5) {
585  ATH_MSG_WARNING( "convert(): not enough hits after opposite side removal: " << hits.size() << ", removed: "
586  << countOppositeSide );
587  return;
588  }
589 
590  // make the linear regression fit
591  double mean[10]; for (double & i : mean) i = 0.;
592  for (auto & hit : hits) {
593 
594  mean[0] += (hit->detectorElement())->surface(hit->identify()).center().x();
595  mean[1] += (hit->detectorElement())->surface(hit->identify()).center().y();
596  }
597  for (int i=0; i<2; i++) mean[i] /= (double) hits.size();
598  int iPivot(-1); double yPivot(10000000.); // choose pivot closest to the mean
599  for (unsigned int i=0; i<hits.size(); i++) {
600  double x = (hits[i]->detectorElement())->surface(hits[i]->identify()).center().x() - mean[0];
601  double y = (hits[i]->detectorElement())->surface(hits[i]->identify()).center().y() - mean[1];
602  double x2 = x * x;
603  double y2 = y * y;
604  mean[2] += x * y;
605  mean[3] += x2;
606  mean[4] += y2;
607  mean[5] += x2 * y;
608  mean[6] += y2 * x;
609  mean[7] += x2 * x;
610  mean[8] += y2 * y;
611  mean[9] += y2 * y2;
612  if (x2+y2<yPivot) { yPivot = x2+y2; iPivot = i; }
613  }
614 
615  if (iPivot==-1) {
616  msg(MSG::ERROR) << "SF pivot index not found!!! " << yPivot << " " << iPivot << endmsg;
617  iPivot = 0;
618  }
619 
620  double cotanPhi = mean[2] / mean[4];
621  double phi = std::atan(1./cotanPhi); if (phi<0.) phi += M_PI;
622  ATH_MSG_DEBUG("compare parameters X : " << trackpar[0] << " vs. " << mean[0]-mean[1]*cotanPhi );
623  ATH_MSG_DEBUG("compare parameters phi: " << trackpar[1] << " vs. " << phi );
624 
625  double qOverp = 0.; // units q / MeV, set only if there is magnetic field
626 
627  if (m_magneticField) { // fit parabola instead of line, add circle if neccessary
628 
629  double A[6], discriminant, a[3];
630 
631  A[0] = mean[8]*mean[8]-mean[4]*mean[9]; // parabola fit
632  A[1] = mean[1]*mean[9]-mean[4]*mean[8];
633  A[2] = mean[4]*mean[4]-mean[1]*mean[8];
634  A[3] = mean[4]*mean[4]-mean[9];
635  A[4] = mean[8]-mean[1]*mean[4];
636  A[5] = mean[1]*mean[1]-mean[4];
637  discriminant = std::abs( std::pow(mean[4], 3) + mean[8]*mean[8] + mean[1]*mean[1]*mean[9] - mean[4]*(2.*mean[1]*mean[8]+mean[9]) );
638 
639  a[0] = A[0] * mean[0] + A[1] * mean[2] + A[2] * mean[6];
640  a[1] = A[1] * mean[0] + A[3] * mean[2] + A[4] * mean[6];
641  a[2] = A[2] * mean[0] + A[4] * mean[2] + A[5] * mean[6];
642  discriminant *= -1.;
643  for (double & i : a) { i /= discriminant; }
644 
645  double Xparabola = a[0];
646  double cotanParabola = a[1];
647  double inverseSin3phi = 1. + a[1]*a[1]; inverseSin3phi *= std::sqrt(inverseSin3phi); // 1/sin^3phi
648  double inverseR = 2. * a[2] / inverseSin3phi;
649 
650  if (msgLvl(MSG::DEBUG)) {
651  msg(MSG::DEBUG) << "TRT_TrackSegmentsMaker_BarrelCosmics: parabola fit, X: " << Xparabola << endmsg;
652  msg(MSG::DEBUG) << " parabola fit, cotan: " << cotanParabola << " compare to " << cotanPhi << endmsg;
653  msg(MSG::DEBUG) << " parabola fit, 1/R: " << inverseR << "/ mm " << endmsg;
654  }
655 
656  qOverp = inverseR / 0.6; // [1/MeV]; 1 / (eBRC) = 1 / (e 2T 3 100 M m/s mm) / R[mm] = (1/R[mm]) / 0.6
657  }
658 
659 // errors from the fit:
660 // - for d: sigma_r / sqrt(N hits) -> sigma_d^2 =
661 // - for cotanPhi: sigma_r / (sqrt(N hits * <y^2>) * sinPhi)
662 // - for phi: 1 / (1 + cotanPhi^2) * DcotanPhi // note that this mthod gives a biased estimate for phi!
663 
664  Amg::MatrixX cov(5,5);
665 
666  double f33 = 4. / ( 3. * (1.+cotanPhi*cotanPhi) * mean[4] ); // see above, mean[4] = N hits * <y^2>
667  cov<<
668  4. , 0., 0., 0., 0.,
669  0. ,45633., 0., 0., 0.,
670  0. , 0., f33, 0., 0.,
671  0. , 0., 0., 0.2, 0.,
672  0. , 0., 0., 0., 1.;
673 
674  Amg::Vector3D hepVec( mean[0], mean[1],
675  (hits[iPivot]->detectorElement())->surface(hits[iPivot]->identify()).center().z() );
676 
677 
678  Amg::Transform3D htrans = Amg::Transform3D(Amg::Translation3D(hepVec)*Amg::RotationMatrix3D::Identity());
679 
680 
681 
683 
684  if (phi>0.) phi -= M_PI;
685  if (phi<-M_PI || phi>0.) msg(MSG::ERROR) << "phi value problem: " << phi << endmsg;
686 
687  Trk::LocalParameters par(0., 0., phi, M_PI_2, qOverp);
688 
689  ATH_MSG_DEBUG("pivot: " << sur->center() << ", cross-check: " << mean[0] << " " << mean[1] );
690 
691  // calculate TrackParameters so that one can calculate input for TRT_DriftCircleOnTrack
692  // Global direction of the track parameters
694 
696 
697  for (const auto *DC : hits) { // rewrite: InDet::TRT_DriftCircle -> InDet::TRT_DriftCircleOnTrack
698  // based on http://atlas-sw.cern.ch/cgi-bin/viewcvs-atlas.cgi/offline/InnerDetector/InDetRecTools/TRT_DriftCircleOnTrackTool/src/TRT_DriftCircleOnTrackNoDriftTimeTool.cxx?revision=1.11&view=markup
699 
700  // Straw identification
701  const InDetDD::TRT_BaseElement* pE = DC->detectorElement();
702  if (!pE) {
703  ATH_MSG_ERROR("convert(): no detectorElement info!");
704  continue;
705  }
706  Identifier iD = DC->identify();
708 
709  // TRT_DriftCircleOnTrack production
712  Amg::MatrixX cov(1,1); cov<<1.33333;
713  const InDet::TRT_DriftCircleOnTrack *element = new InDet::TRT_DriftCircleOnTrack(DC, std::move(lp), std::move(cov),
714  iH, 1., dir, Trk::NODRIFTTIME);
715  rio.push_back( dynamic_cast<const Trk::MeasurementBase *>(element) );
716  } // end fill rio
717 
718  // add pseudo measurement - follow up https://savannah.cern.ch/bugs/?41079
719 if (1) { // limit the scope of all these variables
720 
721  Trk::DefinedParameter pseudoz( 0., Trk::locZ);
722  Trk::DefinedParameter pseudotheta( M_PI/2., Trk::theta);
723  Trk::LocalParameters pseudoPar( pseudoz, pseudotheta );
724 
725  Amg::MatrixX pseudocov(2,2);
726  pseudocov <<
727  1. , 0.,
728  0. , .001;
729 
730  const Trk::Surface &surf = (hits[hits.size()-1]->detectorElement())->surface(hits[hits.size()-1]->identify());
731 
732  Amg::RotationMatrix3D linerot=surf.transform().rotation();
733  Amg::Vector3D firstcenter=surf.center();
734  Amg::Vector3D faketransl(firstcenter.x(),firstcenter.y()-5.,firstcenter.z());
735  Amg::Transform3D faketransf = Amg::Transform3D(linerot* Amg::Translation3D(faketransl));
736  Trk::StraightLineSurface *pseudoSurface = new Trk::StraightLineSurface( faketransf, 99999., 99999. );
737 
739  std::move(pseudoPar),
740  std::move(pseudocov),
741  *pseudoSurface );
742  rio.push_back( pseudo );
743  delete pseudoSurface;
744 }
745 
746  double chi2 = mean[3] - 2.*cotanPhi*mean[2] + mean[4]*cotanPhi*cotanPhi;
747  chi2 /= ( 1. + cotanPhi*cotanPhi );
748  int ndf = (int) hits.size() - 2;
749  ATH_MSG_DEBUG( "Chi2 = " << chi2 << ", ndf = " << ndf << ", chi2/ndf = " << chi2/ndf );
750  Trk::FitQuality * fqu = new Trk::FitQuality(chi2, ndf);
751 
753  std::move(par), std::move(cov), sur, std::move(rio), fqu, Trk::Segment::TRT_SegmentMaker);
754 
755  //add segment to list of segments
756  ATH_MSG_DEBUG( "Add " << event_data.m_segments.size() << "th segment to list" );
757  event_data.m_segments.push_back(segment);
758 }
759 
761 //
762 // DEBUG FUNCTIONS
763 //
765 
766 void InDet::TRT_TrackSegmentsMaker_BarrelCosmics::segFit(double *measx, double *measy, int nhits, double *residuals, double *result ) {
767 
768  if (nhits<10) return;
769 
770  double shift[] = {0., 0.}; // shift the points so that mean x = 0 and mean y = 0
771  for (int i=0; i<nhits; i++) { shift[0] += measx[i]; shift[1] += measy[i]; }
772  for (double & i : shift) i /= (double) nhits;
773  for (int i=0; i<nhits; i++) { measx[i] -= shift[0]; measy[i] -= shift[1]; }
774 
775  double mean[10]; for (double & i : mean) i = 0.; // calculate momenta needed for the line, circle and parabola fit
776  for (int i=0; i<nhits; i++) {
777  double x2 = measx[i]*measx[i];
778  double y2 = measy[i]*measy[i];
779  mean[0] += measx[i];
780  mean[1] += measy[i];
781  mean[2] += measx[i]*measy[i];
782  mean[3] += x2;
783  mean[4] += y2;
784  mean[5] += x2 * measy[i];
785  mean[6] += y2 * measx[i];
786  mean[7] += x2 * measx[i];
787  mean[8] += y2 * measy[i];
788  mean[9] += y2 * y2;
789  }
790  for (double & i : mean) i /= (double) nhits;
791 
792  double A[6], discriminant, a[3];
793 
794  A[0] = mean[8]*mean[8]-mean[4]*mean[9]; // parabola fit, no need for mean[3], [5], [7], se mi zdi
795  A[1] = mean[1]*mean[9]-mean[4]*mean[8];
796  A[2] = mean[4]*mean[4]-mean[1]*mean[8];
797  A[3] = mean[4]*mean[4]-mean[9];
798  A[4] = mean[8]-mean[1]*mean[4];
799  A[5] = mean[1]*mean[1]-mean[4];
800  discriminant = std::abs( std::pow(mean[4], 3) + mean[8]*mean[8] + mean[1]*mean[1]*mean[9] - mean[4]*(2.*mean[1]*mean[8]+mean[9]) );
801 
802  a[0] = A[0] * mean[0] + A[1] * mean[2] + A[2] * mean[6];
803  a[1] = A[1] * mean[0] + A[3] * mean[2] + A[4] * mean[6];
804  a[2] = A[2] * mean[0] + A[4] * mean[2] + A[5] * mean[6];
805  discriminant *= -1.;
806  for (double & i : a) i /= discriminant;
807  double Xparabola = a[0];
808  double cotanParabola = a[1];
809  double inverseSin3phi = 1. + a[1]*a[1]; inverseSin3phi *= std::sqrt(inverseSin3phi); // 1/sin^3phi
810  double inverseR = 2. * a[2] / inverseSin3phi;
811  double sinphi = std::sqrt(1./(1+a[1]*a[1]));
812  double cosphi = std::sqrt(1.-sinphi*sinphi); if (cotanParabola<0.) cosphi *= -1.;
813 
814  if (result) {
815  for (int i=0; i<2; i++) result[i] = shift[i]; // pivot
816  result[2] = Xparabola;
817  result[3] = cotanParabola;
818  result[4] = inverseR;
819  }
820 
821  if (residuals) {
822  for (int i=0; i<nhits; i++) {
823  double tmp = (Xparabola-measx[i])*sinphi+measy[i]*cosphi;
824  double res = (tmp+0.5*inverseR*(std::pow(measx[i]-Xparabola, 2.) + std::pow(measy[i], 2.) - std::pow(tmp, 2)));
825  residuals[i] = res;
826  }
827  }
828 
829  for (int i=0; i<nhits; i++) { measx[i] += shift[0]; measy[i] += shift[1]; }
830 
831  }
832 
833 
835 //
836 // DEBUG cpu consumption: old find method
837 //
839 
840 
842 
843  ATH_MSG_DEBUG( "InDet::TRT_TrackSegmentsMaker_BarrelCosmics::find()");
844 
845  if ((int)event_data.m_listHitCenter.size()<m_minHitsAboveTOT) return;
846 
847  if (!event_data.m_segmentDriftCircles.empty()) { // debug only
848  ATH_MSG_WARNING("find probably called twice per event? or newEvent / newRegion have not been called. check your program" );
849  event_data.clear(); return;
850  }
851 
852  std::vector<double> x0, phi;
853  std::vector<int> nHitsPosY, nHitsNegY;
854 
855  // first find seeds
856  int nIterations(15), countCalls(0);
857  while (countCalls<150) {
858 
859  double xRange(1000.), phiRange(M_PI_4);
860  double par[] = {0., M_PI_2};
861  int foundSeed(0);
862 
863  for (int i=0; i<nIterations; i++) {
864 
865  countCalls++;
866  foundSeed = findSeed( par[0]-xRange, par[0]+xRange, par[1]-phiRange, par[1]+phiRange, par, event_data);
867  if ( !foundSeed ) break;
868 
869  xRange /= 3.;
870  phiRange /= 2.;
871  if ( xRange < 0.01 || phiRange < 0.00001) break;
872 
873  }
874  if (!foundSeed) break;
875 
876 // remove the hits associated with this region, save this region, search again
877  int countAssociatedHits[] = {0, 0};
878  double cosphi = std::cos(par[1]);
879  double sinphi = std::sqrt(1.-cosphi*cosphi);
880 
881  for (std::vector< Amg::Vector3D >::iterator it = event_data.m_listHitCenter.begin(); it!=event_data.m_listHitCenter.end(); ) {
882 
883  if ( std::abs( (par[0]-it->x())*sinphi + it->y()*cosphi ) > 2. ) { ++it; continue; }
884  countAssociatedHits[(it->y()>0)?0:1]++;
885  it = event_data.m_listHitCenter.erase( it );
886  }
887 
888  if ( countAssociatedHits[0]+countAssociatedHits[1] < m_minHitsAboveTOT ) continue;
889 
890  x0.push_back( par[0] ); phi.push_back( par[1] ); nHitsPosY.push_back( countAssociatedHits[0] ); nHitsNegY.push_back( countAssociatedHits[1] );
891 
892  } // end for (int i=0; i<nIterations; i++) loop
893 // end finding seeds
894 
895 // save all TRT hits for found segments
896  int nFoundSegments = x0.size();
897  if (nFoundSegments>10) nFoundSegments = 10; // number of found segments
898  for (int i=0; i<nFoundSegments; i++) {
899  event_data.m_segmentDriftCircles.emplace_back();
900  }
901 
902  for (unsigned int i=0; i<event_data.m_listHits.size(); i++) {
903  const Amg::Vector3D &
904  center = event_data.m_listHits[i]->detectorElement()->surface(event_data.m_listHits[i]->identify()).center();
905 
906  for (int j=0; j<nFoundSegments; j++) {
907  if (nHitsPosY[j]<5 && center.y()>0.) continue;
908  if (nHitsNegY[j]<5 && center.y()<0.) continue;
909  double cosphi = std::cos(phi[j]);
910  double sinphi = std::sqrt(1.-cosphi*cosphi);
911  if ( std::abs((x0[j]-center.x())*sinphi+center.y()*cosphi) < 2.) {
912  event_data.m_segmentDriftCircles[j].push_back(event_data.m_listHits[i]);
913  break;
914  }
915  }
916  }
917  // end saving TRT hits
918 
919  if (msgLvl(MSG::DEBUG)) {
920  // debug: check how many hits per found segments
921  msg(MSG::DEBUG) << "find() debug (" << nFoundSegments << ")" ;
922  for (unsigned int i=0; i<event_data.m_segmentDriftCircles.size(); i++) {
923  msg(MSG::DEBUG) << " " << i << " " \
924  << event_data.m_segmentDriftCircles[i].size() ;
925  }
926  msg(MSG::DEBUG) << endmsg;
927  }
928 
929  for (unsigned int i=0; i<event_data.m_segmentDriftCircles.size(); i++) { // convert to segments
930  if ((int)event_data.m_segmentDriftCircles[i].size()<m_minHitsForSegment) continue;
931  double trackpar[] = {x0[i], phi[i]};
932  convert(event_data.m_segmentDriftCircles[i], trackpar, event_data);
933  }
934  ATH_MSG_DEBUG( "find(), number of converted segments: " << event_data.m_segments.size() );
935 }
936 
937 
938 
939 
940 
941 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
covarianceTool.ndf
ndf
Definition: covarianceTool.py:678
Trk::LocalParameters
Definition: LocalParameters.h:98
TRT_ID::layer_id
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition: TRT_ID.h:500
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::EventData::m_listHitCenter
std::vector< Amg::Vector3D > m_listHitCenter
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:97
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
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
get_generator_info.result
result
Definition: get_generator_info.py:21
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
StraightLineSurface.h
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
Trk::locX
@ locX
Definition: ParamDefs.h:43
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::EventData
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:79
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::EventData::m_listHits
std::vector< const InDet::TRT_DriftCircle * > m_listHits
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:96
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::convert
void convert(std::vector< const InDet::TRT_DriftCircle * > &hits, double *trackpar, TRT_TrackSegmentsMaker_BarrelCosmics::EventData &event_data) const
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:559
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
hist_file_dump.d
d
Definition: hist_file_dump.py:137
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
InDet::TRT_DriftCircle::detectorElement
virtual const InDetDD::TRT_BaseElement * detectorElement() const override final
return the detector element corresponding to this PRD
skel.it
it
Definition: skel.GENtoEVGEN.py:423
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::sortHits
static bool sortHits(const InDet::TRT_DriftCircle *, const InDet::TRT_DriftCircle *)
sort hits on segment such that they are ordered from larger y to smaller (from top down)
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:552
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_driftCirclesName
SG::ReadHandleKey< InDet::TRT_DriftCircleContainer > m_driftCirclesName
Container with TRT clusters.
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:109
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
M_PI
#define M_PI
Definition: ActiveFraction.h:11
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::newRegion
virtual std::unique_ptr< InDet::ITRT_TrackSegmentsMaker::IEventData > newRegion(const EventContext &ctx, const std::vector< IdentifierHash > &) const override
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:150
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_minHitsForSegment
int m_minHitsForSegment
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:146
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::TrackSegment
Definition: TrackSegment.h:56
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::linearRegressionParabolaFit
static void linearRegressionParabolaFit(double *mean, double *a)
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:531
InDet::TRT_DriftCircleOnTrack
Definition: TRT_DriftCircleOnTrack.h:53
x
#define x
InDet::TRT_DriftCircle
Definition: TRT_DriftCircle.h:32
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
TRT::Hit::side
@ side
Definition: HitInfo.h:83
Trk::PseudoMeasurementOnTrack
Class to handle pseudo-measurements in fitters and on track objects.
Definition: PseudoMeasurementOnTrack.h:44
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_minHitsForSeed
int m_minHitsForSeed
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:145
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::locZ
@ locZ
local cylindrical
Definition: ParamDefs.h:48
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::segFit
static void segFit(double *measx, double *measy, int nhits, double *residuals=0, double *result=0)
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:766
lumiFormat.i
int i
Definition: lumiFormat.py:92
xmin
double xmin
Definition: listroot.cxx:60
z
#define z
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::findSeed
int findSeed(double xmin, double xmax, double phimin, double phimax, double *bestParameters, TRT_TrackSegmentsMaker_BarrelCosmics::EventData &event_data) const
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:408
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
PseudoMeasurementOnTrack.h
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::EventData::m_segments
std::vector< Trk::TrackSegment * > m_segments
List of found segments.
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:100
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_trtid
const TRT_ID * m_trtid
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:112
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::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_BarrelCosmics.cxx:214
Trk::NODRIFTTIME
@ NODRIFTTIME
drift time was not used - drift radius is 0.
Definition: DriftCircleStatus.h:24
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::EventData::m_segmentDriftCirclesCount
unsigned int m_segmentDriftCirclesCount
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:95
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
TRT_DriftCircleOnTrack.h
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
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_minSeedTOT
double m_minSeedTOT
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:151
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::EventData::clear
void clear()
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:85
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::initialize
virtual StatusCode initialize() override
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:58
DataVector< const Trk::MeasurementBase >
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::TRT_TrackSegmentsMaker_BarrelCosmics
TRT_TrackSegmentsMaker_BarrelCosmics(const std::string &, const std::string &, const IInterface *)
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:24
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::findSeedInverseR
void findSeedInverseR(double *par, TRT_TrackSegmentsMaker_BarrelCosmics::EventData &event_data) const
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:451
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_nBinsInPhi
int m_nBinsInPhi
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:149
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::finalize
virtual StatusCode finalize() override
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:91
TauJetParameters::discriminant
@ discriminant
Definition: TauJetParameters.h:166
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::newEvent
virtual std::unique_ptr< InDet::ITRT_TrackSegmentsMaker::IEventData > newEvent(const EventContext &ctx) const override
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:99
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_TRTManagerName
std::string m_TRTManagerName
Name of TRT det.
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:110
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
InDet::TRT_DriftCircleCollection
Trk::PrepRawDataCollection< TRT_DriftCircle > TRT_DriftCircleCollection
Definition: TRT_DriftCircleCollection.h:26
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_magneticField
bool m_magneticField
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:152
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::findOld
void findOld(TRT_TrackSegmentsMaker_BarrelCosmics::EventData &event_data) const
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:841
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_minHitsAboveTOT
int m_minHitsAboveTOT
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:147
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_nBinsInX
int m_nBinsInX
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:148
TRT_TrackSegmentsMaker_BarrelCosmics.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
ReadCellNoiseFromCool.indexmin
indexmin
Definition: ReadCellNoiseFromCool.py:226
DeMoScan.index
string index
Definition: DeMoScan.py:362
TRT_ID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel.
Definition: TRT_ID.h:857
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
DEBUG
#define DEBUG
Definition: page_access.h:11
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
xmax
double xmax
Definition: listroot.cxx:61
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::endEvent
void endEvent(InDet::ITRT_TrackSegmentsMaker::IEventData &event_data) const override
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:195
Trk::MeasurementBaseType::PseudoMeasurementOnTrack
@ PseudoMeasurementOnTrack
Definition: MeasurementBase.h:51
ReadCellNoiseFromCool.indexmax
indexmax
Definition: ReadCellNoiseFromCool.py:227
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::next
virtual Trk::TrackSegment * next(InDet::ITRT_TrackSegmentsMaker::IEventData &event_data) const override
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.cxx:388
Trk::EventDataBase< EventData, InDet::ITRT_TrackSegmentsMaker::IEventData >::getPrivateEventData
static EventData & getPrivateEventData(InDet::ITRT_TrackSegmentsMaker::IEventData &virt_event_data)
Definition: EventDataBase.h:19
LArCellBinning.phiRange
phiRange
Filling Phi ranges.
Definition: LArCellBinning.py:107
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
Definition: IdentifierHash.h:38
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
FitQuality.h
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::EventData::m_segmentDriftCircles
std::vector< std::vector< const InDet::TRT_DriftCircle * > > m_segmentDriftCircles
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:99
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
InDet::ITRT_TrackSegmentsMaker::IEventData
Definition: ITRT_TrackSegmentsMaker.h:53
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_mergeSegments
bool m_mergeSegments
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:153
Trk::Segment::TRT_SegmentMaker
@ TRT_SegmentMaker
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:73
python.Dumpers.FitQuality
FitQuality
Definition: Dumpers.py:63
InDet::TRT_TrackSegmentsMaker_BarrelCosmics::m_maxTotalHits
int m_maxTotalHits
Definition: TRT_TrackSegmentsMaker_BarrelCosmics.h:143
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
TRT_ID::straw_layer_hash
IdentifierHash straw_layer_hash(Identifier straw_layer_id) const
straw_layer hash from id - optimized
Definition: TRT_ID.h:750
fitman.k
k
Definition: fitman.py:528
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
Trk::previous
@ previous
Definition: BinningData.h:32