InDetTrackSummaryHelperTool.cxx 24.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/

#include "InDetTrackSummaryHelperTool/InDetTrackSummaryHelperTool.h"
// forward declares
#include "InDetIdentifier/PixelID.h"
#include "InDetIdentifier/SCT_ID.h"
#include "InDetIdentifier/TRT_ID.h"
#include "TrkToolInterfaces/ITrackHoleSearchTool.h"
#include "TrkToolInterfaces/IPRD_AssociationTool.h"
#include "TrkToolInterfaces/IPixelToTPIDTool.h"
#include "TrkRIO_OnTrack/RIO_OnTrack.h"
#include "TrkTrack/Track.h"
#include "TrkTrack/TrackStateOnSurface.h"
// normal includes
#include "Identifier/Identifier.h"
#include "InDetRIO_OnTrack/TRT_DriftCircleOnTrack.h"
#include "InDetRIO_OnTrack/PixelClusterOnTrack.h"
#include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h"
#include "InDetPrepRawData/PixelCluster.h"
#include "TrkCompetingRIOsOnTrack/CompetingRIOsOnTrack.h"
#include "TrkTrackSummary/InDetTrackSummary.h"
#include "TrkParameters/TrackParameters.h"
#include "InDetRecToolInterfaces/IInDetTestBLayerTool.h"

//==========================================================================
InDet::InDetTrackSummaryHelperTool::InDetTrackSummaryHelperTool(
   const std::string& t,
   const std::string& n,
   const IInterface*  p )
   :
   AthAlgTool(t,n,p),
   m_pixelId(0),
   m_sctId(0),
   m_trtId(0),
37
   m_assoTool("InDet::InDetPRD_AssociationToolGangedPixels"), 
38
39
40
41
42
   m_pixeldedxtool(""),
   m_holeSearchTool("InDet::InDetTrackHoleSearchTool"),
   m_testBLayerTool(""),
   m_TRTStrawSummarySvc("InDetTRTStrawStatusSummarySvc",n),
   m_doSharedHits(false),
43
44
   m_doSplitPixelHits(true),
   m_runningTIDE_Ambi(false)
45
46
47
48
49
50
51
52
53
{
   declareInterface<ITrackSummaryHelperTool>(this);
   declareProperty("AssoTool",            m_assoTool);
   declareProperty("PixelToTPIDTool",     m_pixeldedxtool);
   declareProperty("HoleSearch",          m_holeSearchTool);
   declareProperty("TestBLayerTool",      m_testBLayerTool);
   declareProperty("TRTStrawSummarySvc",  m_TRTStrawSummarySvc);
   declareProperty("DoSharedHits",        m_doSharedHits);
   declareProperty("DoSplitHits",         m_doSplitPixelHits);
54
   declareProperty("RunningTIDE_Ambi",    m_runningTIDE_Ambi);
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
   declareProperty("usePixel",            m_usePixel = true);
   declareProperty("useSCT",              m_useSCT   = true);
   declareProperty("useTRT",              m_useTRT   = true);
   declareProperty("OverwriteIDSummary",  m_overwriteidsummary = false);
}

//==========================================================================

InDet::InDetTrackSummaryHelperTool::~InDetTrackSummaryHelperTool()
{ }

//==========================================================================

StatusCode InDet::InDetTrackSummaryHelperTool::initialize()
{
   if (m_usePixel) {
      if (detStore()->retrieve(m_pixelId, "PixelID").isFailure()) {
         msg(MSG::ERROR) << "Could not get PixelID helper !" << endreq;
         return StatusCode::FAILURE;
      }
   }

   if (m_useSCT) {
      if (detStore()->retrieve(m_sctId, "SCT_ID").isFailure()) {
         msg(MSG::ERROR) << "Could not get SCT_ID helper !" << endreq;
         return StatusCode::FAILURE;
      }
   }

   if (m_useTRT) {
      if (detStore()->retrieve(m_trtId, "TRT_ID").isFailure()) {
         msg(MSG::ERROR) << "Could not get TRT_ID helper !" << endreq;
         return StatusCode::FAILURE;
      }
   }

   if (m_doSharedHits) {
      if ( m_assoTool.retrieve().isFailure() ) {
         msg(MSG::FATAL) << "Failed to retrieve tool " << m_assoTool << endreq;
         return StatusCode::FAILURE;
      } else {
         msg(MSG::INFO) << "Retrieved tool " << m_assoTool << endreq;
      }
   }

   if ( !m_pixeldedxtool.empty() && m_pixeldedxtool.retrieve().isFailure() ) {
      ATH_MSG_ERROR ("Failed to retrieve pixel dEdx tool " << m_pixeldedxtool);
      ATH_MSG_ERROR ("configure as 'None' to avoid its loading.");
      return StatusCode::FAILURE;
   } else {
      if ( !m_pixeldedxtool.empty()) msg(MSG::INFO) << "Retrieved tool " << m_pixeldedxtool << endreq;
   }

   if ( m_holeSearchTool.retrieve().isFailure() ) {
      msg(MSG::FATAL) << "Failed to retrieve tool " << m_holeSearchTool << endreq;
      return StatusCode::FAILURE;
   } else {
      msg(MSG::INFO) << "Retrieved tool " << m_holeSearchTool << endreq;
   }

   if ( !m_testBLayerTool.empty() && m_testBLayerTool.retrieve().isFailure() ) {
      ATH_MSG_ERROR ("Failed to retrieve Test B Layer tool " << m_pixeldedxtool);
      ATH_MSG_ERROR ("configure as 'None' to avoid its loading.");
      return StatusCode::FAILURE;
   } else {
      if ( !m_testBLayerTool.empty()) msg(MSG::INFO) << "Retrieved tool " << m_pixeldedxtool << endreq;
   }


   if (m_useTRT && !m_TRTStrawSummarySvc.empty() && m_TRTStrawSummarySvc.retrieve().isFailure() ) {
      ATH_MSG_ERROR ("Failed to retrieve StrawStatus Summary " << m_TRTStrawSummarySvc);
      ATH_MSG_ERROR ("configure as 'None' to avoid its loading.");
      return StatusCode::FAILURE;
   } else {
      if ( !m_TRTStrawSummarySvc.empty()) msg(MSG::INFO) << "Retrieved tool " << m_TRTStrawSummarySvc << endreq;
   }



   msg(MSG::INFO) << "initialize() successful in " << name() << endreq;
135

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
   return StatusCode::SUCCESS;
}


//==========================================================================
void InDet::InDetTrackSummaryHelperTool::analyse(const Trk::Track& track, 
                                                 const Trk::RIO_OnTrack* rot, 
                                                 const Trk::TrackStateOnSurface* tsos,
                                                 std::vector<int>& information, 
                                                 std::bitset<Trk::numberOfDetectorTypes>& hitPattern ) const
{
   const Identifier& id = rot->identify();
   bool  isOutlier      = (tsos->type(Trk::TrackStateOnSurface::Outlier));
   bool  ispatterntrack =  (track.info().trackFitter()==Trk::TrackInfo::Unknown);


   //pointer to det El (possibly 0), from pointer to PRD (which can also be zero - at the moment at least)
   //const TrkDetElementBase* detEl = rot->detectorElement(); 

   if ( m_usePixel && m_pixelId->is_pixel(id) ) {

      if (isOutlier && !ispatterntrack ) { // ME: outliers on pattern tracks may be reintegrated by fitter, so count them as hits
         information[Trk::numberOfPixelOutliers]++;
         if (m_pixelId->is_blayer(id)){
            information[Trk::numberOfBLayerOutliers]++;
         }
162
163
164
165
166
167
	 if (m_pixelId->layer_disk(id)==0 && m_pixelId->is_barrel(id)){
	   information[Trk::numberOfInnermostPixelLayerOutliers]++;
	 }
	 if (m_pixelId->layer_disk(id)==1 && m_pixelId->is_barrel(id)){
	   information[Trk::numberOfNextToInnermostPixelLayerOutliers]++;
	 }
168
      } else {
169
170
         
         bool hitIsSplit(false);
171
172
173

         information[Trk::numberOfPixelHits]++;
         if ( (m_pixelId->is_blayer(id) ) ) information[Trk::numberOfBLayerHits]++; // found b layer hit
174
175
	 if (m_pixelId->layer_disk(id)==0 && m_pixelId->is_barrel(id)) information[Trk::numberOfInnermostPixelLayerHits]++;
	 if (m_pixelId->layer_disk(id)==1 && m_pixelId->is_barrel(id)) information[Trk::numberOfNextToInnermostPixelLayerHits]++;  
176
177
178
179
180
181
         // check to see if there's an ambiguity with the ganged cluster.
         const PixelClusterOnTrack* pix = dynamic_cast<const PixelClusterOnTrack*>(rot);
         if ( !pix ) {
            if (msgLvl(MSG::ERROR)) msg(MSG::ERROR)<<"Could not cast pixel RoT to PixelClusterOnTrack!"<<endreq;
         } else {
            const InDet::PixelCluster* pixPrd = pix->prepRawData();
182
            if ( pixPrd && pixPrd->isSplit() ){ information[Trk::numberOfPixelSplitHits]++; hitIsSplit=true; }
183
            if ( pixPrd && m_pixelId->is_blayer(id) && pixPrd->isSplit() ) information[Trk::numberOfBLayerSplitHits]++;
184
185
	    if ( pixPrd && m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==0 && pixPrd->isSplit() ) information[Trk::numberOfInnermostLayerSplitHits]++;
	    if ( pixPrd && m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==1 && pixPrd->isSplit() ) information[Trk::numberOfNextToInnermostLayerSplitHits]++;
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
            if ( pix->isBroadCluster() ) information[Trk::numberOfPixelSpoiltHits]++;
            if ( pix->hasClusterAmbiguity() ) {
               information[Trk::numberOfGangedPixels]++;
               if (pix->isFake() ) 
                  information[Trk::numberOfGangedFlaggedFakes]++;
            }
         }

         if ( ( m_pixelId->is_barrel(id) ) ) {
            int offset = m_pixelId->layer_disk(id); 
            if (!hitPattern.test(offset)) information[Trk::numberOfContribPixelLayers]++;
            hitPattern.set(offset); // assumes numbered consecutively
         } else {
            int offset = static_cast<int> (Trk::pixelEndCap0); //get int value of first pixel endcap disc
            offset    += m_pixelId->layer_disk(id);
            if (!hitPattern.test(offset)) information[Trk::numberOfContribPixelLayers]++;
            hitPattern.set(offset); // assumes numbered consecutively
         }

         if (m_doSharedHits) {
206
207
208
209
           // If we are running the TIDE ambi don't count split hits as shared 
           if( !(m_runningTIDE_Ambi && hitIsSplit) ){
             // used in more than one track ?
             if ( m_assoTool->isShared(*(rot->prepRawData())) ) {
210
211
212
               if (msgLvl(MSG::DEBUG)) msg() << "shared Pixel hit found" << endreq;
               information[Trk::numberOfPixelSharedHits]++;
               if ( (m_pixelId->is_blayer(id) ) ) {
213
214
                 if (msgLvl(MSG::DEBUG)) msg() << "--> shared Pixel hit is in b-layer" << endreq;
                 information[Trk::numberOfBLayerSharedHits]++;        
215
               }
216
217
218
219
220
221
222
223
224
225
	       if ( (m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==0) ) {
                 if (msgLvl(MSG::DEBUG)) msg() << "--> shared Pixel hit is in innermost layer" << endreq;
                 information[Trk::numberOfInnermostPixelLayerSharedHits]++;        
               } 
	       if ( (m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==1) ) {
                 if (msgLvl(MSG::DEBUG)) msg() << "--> shared Pixel hit is in next to innermost layer" << endreq;
                 information[Trk::numberOfNextToInnermostPixelLayerSharedHits]++;        
               }
             }
           }
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
         }
      }

   } else if (m_useSCT && m_sctId->is_sct(id) ) {

      if (isOutlier && !ispatterntrack ) { // ME: outliers on pattern tracks may be reintegrated by fitter, so count them as hits    
         information[Trk::numberOfSCTOutliers]++;

      } else {


         information[Trk::numberOfSCTHits]++;
         const InDet::SCT_ClusterOnTrack *sctclus=dynamic_cast<const InDet::SCT_ClusterOnTrack *>(rot);
         if ( !sctclus ) {
            if (msgLvl(MSG::ERROR)) msg(MSG::ERROR)<<"Could not cast SCT RoT to SCT_ClusterOnTrack!"<<endreq;
         } else {
            if (sctclus->isBroadCluster()) information[Trk::numberOfSCTSpoiltHits]++;
         }

         if ( (m_sctId->is_barrel(id) ) ) {
            int offset = static_cast<int>(Trk::sctBarrel0);
            hitPattern.set( offset + m_sctId->layer_disk(id) ); // assumes numbered consecutively
         } else {
            int offset = static_cast<int>(Trk::sctEndCap0); //get int value of first sct endcap disc
            hitPattern.set( offset + m_sctId->layer_disk(id) ); // assumes numbered consecutively
         }

         if (m_doSharedHits) {
            // used in more than one track ?
            if ( m_assoTool->isShared(*(rot->prepRawData())) ) {
               if (msgLvl(MSG::DEBUG)) msg() << "shared SCT hit found" << endreq;
               information[Trk::numberOfSCTSharedHits]++;
            }
         }
      }
        
   } else if (m_useTRT && m_trtId->is_trt(id) ) {

      bool isArgonStraw = false;
      if (!m_TRTStrawSummarySvc.empty()) {
         if (m_TRTStrawSummarySvc->getStatusHT(id) != TRTCond::StrawStatus::Good) {
            isArgonStraw = true;
         }
      }
      if (!isArgonStraw) information[Trk::numberOfTRTXenonHits ]++;

     
      if (isOutlier && !ispatterntrack ) { // ME: outliers on pattern tracks may be reintegrated by fitter, so count them as hits    
         information[Trk::numberOfTRTOutliers]++;

         const InDet::TRT_DriftCircleOnTrack* trtDriftCircle 
            = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(  rot  );
         if ( !trtDriftCircle ) {
            if (msgLvl(MSG::ERROR)) msg(MSG::ERROR)<<"Could not cast TRT RoT to TRT_DriftCircleOnTrack!"<<endreq;
         } else {
            if ( trtDriftCircle->highLevel()==true && !isArgonStraw) information[Trk::numberOfTRTHighThresholdOutliers]++;
         }

      } else {

         information[Trk::numberOfTRTHits]++;
         double error2=rot->localCovariance()(0,0);
         if (error2>1) information[Trk::numberOfTRTTubeHits]++;

         const InDet::TRT_DriftCircleOnTrack* trtDriftCircle 
            = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(  rot  );
         if ( !trtDriftCircle ) {
            if (msgLvl(MSG::ERROR)) msg(MSG::ERROR)<<"Could not cast TRT RoT to TRT_DriftCircleOnTrack!"<<endreq;
         } else {
            if ( trtDriftCircle->highLevel()==true && !isArgonStraw) information[Trk::numberOfTRTHighThresholdHits]++;
         }
      }
   }
   return;
}

void InDet::InDetTrackSummaryHelperTool::analyse(const Trk::Track& track,
                                                 const Trk::CompetingRIOsOnTrack* crot, 
                                                 const Trk::TrackStateOnSurface* tsos,
                                                 std::vector<int>& information, 
                                                 std::bitset<Trk::numberOfDetectorTypes>& hitPattern ) const
{
   // re-produce prior behaviour (i.e. just take most probable ROT)
   analyse(track, &crot->rioOnTrack(crot->indexOfMaxAssignProb() ), tsos, information, hitPattern);
}

void InDet::InDetTrackSummaryHelperTool::searchForHoles(const Trk::Track& track, 
                                                        std::vector<int>& information,
                                                        const Trk::ParticleHypothesis partHyp         ) const 
{

   // ME: this is a temporary change for getting the blayer info into the summary 
   //if (msgLvl(MSG::WARNING))
   //{
   //  msg(MSG::WARNING) << "You are accessing the hole search through the InDetTrackSummaryHelperTool." << endreq;
   //  msg(MSG::WARNING) << "This will soon be disabled. Please access the HoleSearchTool directly!" << endreq;
   // }
323
 
324
325
   ATH_MSG_DEBUG("Do hole search within HELPER, PLEASE FIX THIS AFTER 16.0.X");
   m_holeSearchTool->countHoles(track,information,partHyp);
326
  
327
328
329
330
331
332
333
334

   // this is a hack, we need to run the TestBLayer Tool somewhere

   if (m_usePixel && !m_testBLayerTool.empty() ) {

      if ( information[Trk::numberOfContribPixelLayers] == 0 ) {
         ATH_MSG_DEBUG("No pxiels on track, so wo do not expect a B-Layer hit !");
         information[Trk::expectBLayerHit] = 0;
335
336
337
338
339
340
341
342
343
344
345
346
	 information[Trk::expectInnermostPixelLayerHit] = 0;
	 information[Trk::expectNextToInnermostPixelLayerHit] = 0;
      } else{


	///blayer block
	if ( information[Trk::numberOfBLayerHits] > 0) {
	  ATH_MSG_DEBUG("B-Layer hit on track, so we expect a B-Layer hit !");
	  information[Trk::expectBLayerHit] = 1;
	} else {
	  ATH_MSG_DEBUG("Testing B-Layer using tool..");
	  if (m_testBLayerTool->expectHitInBLayer(&track) ) {
347
348
            ATH_MSG_DEBUG("expect B-Layer hit !");
            information[Trk::expectBLayerHit] = 1;
349
	  } else {
350
351
            ATH_MSG_DEBUG("do not expect B-Layer hit !");
            information[Trk::expectBLayerHit] = 0;
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
	  }
	}

	//innermost layer block
	if (information[Trk::numberOfInnermostPixelLayerHits] > 0){
	  information[Trk::expectInnermostPixelLayerHit] = 1;
	} else {

	if (m_testBLayerTool->expectHitInInnermostPixelLayer(&track) ) {
            ATH_MSG_DEBUG("expect Pixel Layer 0 hit !");
            information[Trk::expectInnermostPixelLayerHit] = 1;
	  } else {
            ATH_MSG_DEBUG("do not expect Pixel Layer 0 hit !");
            information[Trk::expectInnermostPixelLayerHit] = 0; 
	}  
	
	}
	
	//next to innermost block
	if(information[Trk::numberOfNextToInnermostPixelLayerHits] > 0){
	  information[Trk::expectNextToInnermostPixelLayerHit] = 1; 
	} else {
	  
	  if (m_testBLayerTool->expectHitInNextToInnermostPixelLayer(&track) ) {
	    ATH_MSG_DEBUG("expect Pixel Layer 1 hit !");
            information[Trk::expectNextToInnermostPixelLayerHit] = 1;
	  } else {
	    ATH_MSG_DEBUG("do not expect Pixel Layer 1 hit !");
            information[Trk::expectNextToInnermostPixelLayerHit] = 0;
	  }
	  
	}
	
385
386
387
388
389
390
391
392
393
394
395
      }
   }

   return;
}


void InDet::InDetTrackSummaryHelperTool::updateSharedHitCount(const Trk::Track &track, Trk::TrackSummary& summary) const {
    
    // loop over track states on surface and take pixel / sct to update the shared hit count
    summary.m_information[Trk::numberOfPixelSharedHits]  = 0;
396
397
398
    summary.m_information[Trk::numberOfBLayerSharedHits] = 0;
    summary.m_information[Trk::numberOfInnermostPixelLayerSharedHits] = 0;
     summary.m_information[Trk::numberOfNextToInnermostPixelLayerSharedHits] = 0;
399
    summary.m_information[Trk::numberOfSCTSharedHits]    = 0;
400
401
402
403
404
405
406
    if( m_runningTIDE_Ambi ) {
      summary.m_information[Trk::numberOfPixelSplitHits]   = 0;
      summary.m_information[Trk::numberOfBLayerSplitHits]   = 0;
      summary.m_information[Trk::numberOfInnermostLayerSplitHits]   = 0;
      summary.m_information[Trk::numberOfNextToInnermostLayerSplitHits]   = 0;
    }

407
408
409
410
411
412
413
414
415
    const DataVector<const Trk::MeasurementBase>* measurements = track.measurementsOnTrack();               
    if (measurements){
        for (auto& ms : *measurements){
            const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(ms);
            // check if it's a rot
            if (rot){
                const Identifier& id = rot->identify();
                if ( m_doSharedHits && m_usePixel && m_pixelId->is_pixel(id) ) {
                    // check if shared 
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
                   bool hitIsSplit(false);
                   if(m_runningTIDE_Ambi){
                      const PixelClusterOnTrack* pix = dynamic_cast<const PixelClusterOnTrack*>(rot);
                      if(pix){
                         const InDet::PixelCluster* pixPrd = pix->prepRawData();
                         if ( pixPrd && pixPrd->isSplit() ){ 
                            summary.m_information[Trk::numberOfPixelSplitHits]++; 
                            hitIsSplit=true;
			     if ( m_pixelId->is_blayer(id)) summary.m_information[Trk::numberOfBLayerSplitHits]++;
			    if ( m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==0) summary.m_information[Trk::numberOfInnermostLayerSplitHits]++;
			    if ( m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==1) summary.m_information[Trk::numberOfNextToInnermostLayerSplitHits]++;  
                         }
                      }
                   }

                   // If we are running the TIDE ambi don't count split hits as shared 
                  if( !(m_runningTIDE_Ambi && hitIsSplit) ){
                      if ( m_assoTool->isShared(*(rot->prepRawData())) ) {
                          ATH_MSG_DEBUG("shared Pixel hit found");
                          summary.m_information[Trk::numberOfPixelSharedHits]++;
			  if ( (m_pixelId->is_blayer(id) ) ) {
			    ATH_MSG_DEBUG("--> shared Pixel hit is in b-layer");
			    summary.m_information[Trk::numberOfBLayerSharedHits]++;       
			  }
                          if ( (m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==0) ) {
                             ATH_MSG_DEBUG("--> shared Pixel hit is in Innermost Pixel layer");
                             summary.m_information[Trk::numberOfInnermostPixelLayerSharedHits]++;       
                          }
			  else if ( (m_pixelId->is_barrel(id) && m_pixelId->layer_disk(id)==1) ) {
                             ATH_MSG_DEBUG("--> shared Pixel hit is in Next To Innermost Pixel layer");
                             summary.m_information[Trk::numberOfNextToInnermostPixelLayerSharedHits]++;       
                          }

		      }
450
451
452
453
454
455
456
457
458
459
460
461
462
463
                    }
                } else if ( m_doSharedHits && m_useSCT && m_sctId->is_sct(id) ){
                    // used in more than one track ?
                    if ( m_assoTool->isShared(*(rot->prepRawData())) ) {
                       if (msgLvl(MSG::DEBUG)) msg() << "shared SCT hit found" << endreq;
                       summary.m_information[Trk::numberOfSCTSharedHits]++;
                    }
                }
            } 
        }
    }
    return;
}

464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
void  InDet::InDetTrackSummaryHelperTool::updateExpectedHitInfo(const Trk::Track &track, Trk::TrackSummary& summary) const{

  if (m_usePixel && !m_testBLayerTool.empty() ) {
    
    if ( summary.m_information[Trk::numberOfContribPixelLayers] == 0 ) {
      ATH_MSG_DEBUG("No pxiels on track, so wo do not expect a B-Layer hit !");
      summary.m_information[Trk::expectBLayerHit] = 0;
      summary.m_information[Trk::expectInnermostPixelLayerHit] = 0;
      summary.m_information[Trk::expectNextToInnermostPixelLayerHit] = 0;
    } else{
      
      
      ///blayer block
      if ( summary.m_information[Trk::numberOfBLayerHits] > 0) {
	ATH_MSG_DEBUG("B-Layer hit on track, so we expect a B-Layer hit !");
	summary.m_information[Trk::expectBLayerHit] = 1;
      } else {
	ATH_MSG_DEBUG("Testing B-Layer using tool..");
	if (m_testBLayerTool->expectHitInBLayer(&track) ) {
	  ATH_MSG_DEBUG("expect B-Layer hit !");
	  summary.m_information[Trk::expectBLayerHit] = 1;
	} else {
	  ATH_MSG_DEBUG("do not expect B-Layer hit !");
	  summary.m_information[Trk::expectBLayerHit] = 0;
	}
      }
      
      //innermost layer block
      if (summary.m_information[Trk::numberOfInnermostPixelLayerHits] > 0){
	summary.m_information[Trk::expectInnermostPixelLayerHit] = 1;
      } else {
	
	if (m_testBLayerTool->expectHitInInnermostPixelLayer(&track) ) {
	  ATH_MSG_DEBUG("expect Pixel Layer 0 hit !");
	  summary.m_information[Trk::expectInnermostPixelLayerHit] = 1;
	} else {
	  ATH_MSG_DEBUG("do not expect Pixel Layer 0 hit !");
	  summary.m_information[Trk::expectInnermostPixelLayerHit] = 0;
	}  
	
      }
      
      //next to innermost block
      if(summary.m_information[Trk::numberOfNextToInnermostPixelLayerHits] > 0){
	summary.m_information[Trk::expectNextToInnermostPixelLayerHit] = 1;
      } else {
	
	if (m_testBLayerTool->expectHitInNextToInnermostPixelLayer(&track) ) {
	  ATH_MSG_DEBUG("expect Pixel Layer 1 hit !");
	  summary.m_information[Trk::expectNextToInnermostPixelLayerHit] = 1;
	} else {
	  ATH_MSG_DEBUG("do not expect Pixel Layer 1 hit !");
	  summary.m_information[Trk::expectNextToInnermostPixelLayerHit] = 0;
	}
	
      }
      
    }
  

}
  
  return;
}


void InDet::InDetTrackSummaryHelperTool::updateAdditionalInfo(Trk::TrackSummary& summary,std::vector<float>& eprob,float& dedx,int& nclus,int& noverflowclus) const {
  
  summary.m_eProbability = eprob;
  summary.m_dedx = dedx;
  summary.m_nhitsdedx =  nclus;
  summary.m_nhitsoverflowdedx = noverflowclus;

 return;
}

540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
void  InDet::InDetTrackSummaryHelperTool::addDetailedTrackSummary(const Trk::Track &track, Trk::TrackSummary &summary) const {
   if ( summary.m_indetTrackSummary && !m_overwriteidsummary){
      ATH_MSG_DEBUG("TrackSummary already has detailed indet track summary, not adding a new one");
      return;
   }
   if ( !m_usePixel ) {
      ATH_MSG_DEBUG("Pixels are off, so no need for an detailed indet track summary");
      return;
   }
   ATH_MSG_DEBUG("Adding detailed indet track summary");
   delete summary.m_indetTrackSummary;
   Trk::InDetTrackSummary* indetTrackSummary = new Trk::InDetTrackSummary();
   Trk::InDetTrackSummary& trackSummary      = *indetTrackSummary;
   if (m_usePixel && !m_pixeldedxtool.empty() && (track.perigeeParameters() || !track.trackParameters()->empty())){
      const Trk::TrackParameters *par = track.perigeeParameters();
      if (!par) par = *track.trackParameters()->begin();
      double p      = (par->parameters()[Trk::qOverP]!=0) ? 1./par->parameters()[Trk::qOverP] : 1.e15;
      double dedx   = summary.getPixeldEdx();
      int ngoodhits = summary.numberOfUsedHitsdEdx();
      if (ngoodhits>0 && dedx>0 && track.info().trackFitter()!=Trk::TrackInfo::Unknown && p<1.e15){
         trackSummary.m_likelihoodspixeldedx = m_pixeldedxtool->getLikelihoods(dedx,p,ngoodhits);
         trackSummary.m_massdedx             = m_pixeldedxtool->getMass(dedx,p,ngoodhits);
      }
   }
   summary.m_indetTrackSummary = indetTrackSummary;
}

// ====================================================================================================================

StatusCode InDet::InDetTrackSummaryHelperTool::finalize() {
   return StatusCode::SUCCESS;
}