TruthSvc.h 4.67 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
37
38
39
40
41
42
/*
  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/

///////////////////////////////////////////////////////////////////
// TruthSvc.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////

#ifndef ISF_SERVICES_HEPMC_TRUTHSVC_H
#define ISF_SERVICES_HEPMC_TRUTHSVC_H 1

// STL includes
#include <string>

// FrameWork includes
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "AthenaBaseComps/AthService.h"

// ISF include
#include "ISF_Interfaces/ITruthSvc.h"

// DetectorDescription
#include "AtlasDetDescr/AtlasRegion.h"

// Barcode
#include "BarcodeEvent/Barcode.h"

// McEventCollection
#include "GeneratorObjects/McEventCollection.h"

// forward declarations
class StoreGateSvc;

namespace Barcode {
  class IBarcodeSvc;
}

namespace HepMC {
  class GenEvent;
}

43
44
45
46
namespace ISFTesting {
  class TruthSvc_test;
}

47
48
49
50
51
52
53
54
55
56
57
58
59
namespace ISF {

  class ITruthStrategy;
  typedef ToolHandleArray<ITruthStrategy>     TruthStrategyArray;

  /** @class TruthSvc

      HepMC based version of the ISF::ITruthSvc,
      currently it takes an ITruthIncident base class


      @author Andreas.Salzburger -at- cern.ch , Elmar.Ritsch -at- cern.ch
  */
60
  class TruthSvc : public extends<AthService, ITruthSvc> {
61
62
63
64

    // allow test to access private data
    friend ISFTesting::TruthSvc_test;

65
66
67
68
69
70
71
72
73
74
75
76
77
78
  public:

    //** Constructor with parameters */
    TruthSvc( const std::string& name, ISvcLocator* pSvcLocator );

    /** Destructor */
    virtual ~TruthSvc();

    /** Athena algorithm's interface method initialize() */
    StatusCode  initialize() override final;
    /** Athena algorithm's interface method finalize() */
    StatusCode  finalize() override final;

    /** Register a truth incident */
79
    void registerTruthIncident( ITruthIncident& truthincident, bool saveAllChildren=false) const override final;
80
81
82
83
84
85
86
87
88

    /** Initialize the Truth Svc at the beginning of each event */
    StatusCode initializeTruthCollection() override final;

    /** Finalize the Truth Svc at the end of each event*/
    StatusCode releaseEvent() override final;

  private:
    /** Record the given truth incident to the MC Truth */
89
    void recordIncidentToMCTruth( ITruthIncident& truthincident, bool passWholeVertex) const;
90
    /** Record and end vertex to the MC Truth for the parent particle */
91
    HepMC::GenVertex *createGenVertexFromTruthIncident( ITruthIncident& truthincident,
John Chapman's avatar
John Chapman committed
92
                                                        bool replaceExistingGenVertex=false) const;
93
94

    /** Set shared barcode for child particles */
John Chapman's avatar
John Chapman committed
95
    void setSharedChildParticleBarcode( ITruthIncident& truthincident) const;
96

97
    /** Delete child vertex */
John Chapman's avatar
John Chapman committed
98
    void deleteChildVertex(HepMC::GenVertex* vertex) const;
99

100
101
102
103
104
105
    /** Helper function to determine the largest particle barcode set by the generator */
    int maxGeneratedParticleBarcode(HepMC::GenEvent *genEvent) const;

    /** Helper function to determine the largest vertex barcode set by the generator */
    int maxGeneratedVertexBarcode(HepMC::GenEvent *genEvent) const;

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
    ServiceHandle<Barcode::IBarcodeSvc>       m_barcodeSvc;           //!< The Barcode service

    /** the truth strategie applied (as AthenaToolHandle Array) */
    TruthStrategyArray                        m_geoStrategyHandles[AtlasDetDescr::fNumAtlasRegions];
    /** for faster access: using an internal pointer to the actual ITruthStrategy instances */
    ITruthStrategy**                          m_geoStrategies[AtlasDetDescr::fNumAtlasRegions];
    unsigned short                            m_numStrategies[AtlasDetDescr::fNumAtlasRegions];

    /** MCTruth steering */
    bool                                      m_skipIfNoChildren;       //!< do not record incident if numChildren==0
    bool                                      m_skipIfNoParentBarcode;  //!< do not record if parentBarcode==fUndefinedBarcode
    bool                                      m_ignoreUndefinedBarcodes;//!< do/don't abort if retrieve an undefined barcode

    bool                                      m_passWholeVertex;

    std::vector<bool>                         m_forceEndVtxRegionsVec; //!< property containing AtlasRegions for which
                                                                              //   to write end-vtx
    bool                                      m_forceEndVtx[AtlasDetDescr::fNumAtlasRegions]; //!< attach end vertex to
                                                                                                     //   all parent particles if they die

    bool                                      m_quasiStableParticlesIncluded; //!< does this job simulate quasi-stable particles.

  };
}


#endif //> !ISF_SERVICES_HEPMC_TRUTHSVC_H