TileHitVecToCntTool.h 6.95 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
43
44
45
46
47
48
49
50
51
52
53
54
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
/*
  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/

//**************************************************************************
// Filename : TileHitVecToCntTool.h
// Author   : Vishnu Zutshi
// Created  : Dec. 2009
//
// DESCRIPTION
// 
//    TileHitVecToCnt copies all TileHits from TileHitVector (AthenaHitsVector)
//    to TileHitContainer (identifiable container) without any corrections.
//    If pileup option is set, all hits are merged. The pileup is done bunchXing
//    by bunchXing (main difference from TileHitVecToCnt). If several hits have
//    the same ID, energy and time from all of them is stored in vectors
//    inside single TileHit. 
//
// Properties (JobOption Parameters):
//
//    TileHitVectors            string   Name of TileHitVector to read
//    TileHitContainer          string   Name of TileHitContainer to write
//    TileInfoName              string   Name of object in TDS with all parameters
//    PileUp                    bool     Do or not pileup
//    HitTimeFlag               int      Working with hit times
//**************************************************************************

#ifndef TILESIMALGS_TILEHITVECTOCNTTOOL_H
#define TILESIMALGS_TILEHITVECTOCNTTOOL_H

// Gaudi includes
#include "GaudiKernel/ServiceHandle.h"

// Athena includes
#include "PileUpTools/PileUpToolBase.h"

// Tile includes
#include "TileIdentifier/TileFragHash.h"
#include "TileSimEvent/TileHitVector.h"


// Avoid pushing dependencies into clients- just fwd declare the following:

class TileID;
class TileTBID;
class TileHit;
class TileInfo;
class TileHitContainer;
class TileDetDescrManager;
class PileUpMergeSvc;
class ITriggerTime;
class IAtRndmGenSvc;
class Identifier;
class TileCablingSvc;
class TileCablingService;
class TileHitCollection;


namespace CLHEP {
  class HepRandomEngine;
}

// C++ STL includes
#include <string>
#include <vector>

/** 
 @class TileHitVecToCntTool
 @brief This AlgTool merges TileHits from different AthenaHitVectors and stores the result in a TileHitContainer

 TileHitVecToCntTool copies all TileHits from TileHitVector (AthenaHitsVector)
 to TileHitContainer (identifiable container) without any corrections
 If pileup option is set, all hits are merged, if several hits have
 the same ID, energy and time from all of them is stored in vectors
 inside single TileHit
 */

class TileHitVecToCntTool: public PileUpToolBase {

  public:
    TileHitVecToCntTool(const std::string& type, const std::string& name, const IInterface* parent); //!< Constructor
    StatusCode initialize();
    virtual StatusCode prepareEvent(unsigned int /*nInputEvents*/);
    virtual StatusCode mergeEvent();
    virtual StatusCode processBunchXing(int bunchXing
                                        , PileUpEventInfo::SubEvent::const_iterator bSubEvents
                                        , PileUpEventInfo::SubEvent::const_iterator eSubEvents);
    virtual StatusCode processAllSubEvents();
    StatusCode finalize();

  private:
    StatusCode createContainers();
    void processHitVectorForOverlay(const TileHitVector* inputHits, int& nHit, double& eHitTot);
    void processHitVectorForPileUp(const TileHitVector* inputHits, double SubEvtTimOffset, int& nHit, double& eHitTot);
    void processHitVectorWithoutPileUp(const TileHitVector* inputHits, int& nHit, double& eHitTot);
    double ApplyPhotoStat(double energy, Identifier pmt_id);    //!< Method to apply photostatistics effect
    void findAndMergeE1(const TileHitCollection* const_coll, int frag_id);
    void findAndMergeMBTS(const TileHitCollection* const_coll, int frag_id);

    std::vector<std::string> m_hitVectorNames;  //!< vector with the names of TileHitVectors to use
    std::string m_hitContainer;                 //!< name of the TileHitCointainer
    std::string m_infoName;                     //!< name of TileInfo object in TES
103
    bool m_run2;                                //!< if true => RUN2 geometry with E4' and merged E1
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
    bool m_pileUp;                              //!< if true => pileup mode is activated
    double m_deltaT;                            //!< minimal time granularity for TileHit
    int m_timeFlag;                             //!< specail options to deal with times of hits for cosmics and TB
    double m_triggerTime;                       //!< fixed trigger time value (default=0)
    double m_maxHitTime;                        //!< all sub-hits with time above m_maxHitTime will be ignored
    double m_photoStatWindow;                   //!< sum up energy in [-m_photoStatWindow,+m_photoStatWindow] and use it for photostatistics
    int m_PhElStat;                             //!< photoelectron statistics type: 0 - Poisson, 1 - "new" Poisson + Gauss, 2 - Poisson->Gauss
    bool m_skipNoHit;                           //!< if true => skip events with no Tile hits 
    bool m_rndmEvtOverlay;                      //!< If true => overlay with random event (zero-luminosity pile-up)
    bool m_useTriggerTime;                      //!< if true => take trigger time from external tool or from m_triggerTime
    ToolHandle<ITriggerTime> m_triggerTimeTool; //!< tool to take the time from

    PileUpMergeSvc* m_mergeSvc;                 //!< Pointer to PileUpMergeService

    const TileID* m_tileID;                     //!< Pointer to TileID helper
    const TileTBID* m_tileTBID;                 //!< Pointer to TileID helper
    const TileInfo* m_tileInfo;                 //!< Pointer to TileInfo
    const TileDetDescrManager* m_tileMgr;       //!< Pointer to TileDetDescrManager
122
    float numPhElec[7];                         //!< number of photo electrons per GeV in samplings
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

    CLHEP::HepRandomEngine* m_pHRengine;       //!< Random number service to use
    ServiceHandle<IAtRndmGenSvc> m_rndmSvc;     //!< Random number generator engine to use

    std::vector<TileHit*> m_allHits;           //!< vector for all TileHits
    TileHitContainer* m_hits;                   //!< pointer to hits container

    bool do_checks;                             //!< initial value of do_checks flag in TileID helper
    bool do_checks_tb;                          //!< initial value of do_checks flag in TileTBID helper

    int m_mbtsOffset;                           //<! index of first MBTS hit in m_allHits vector
    static const int nSide = 2;
    static const int nPhi = 8;
    static const int nEta = 2;
    static const int nCellMBTS = nSide * nPhi * nEta;
    inline int mbts_index(int side, int phi, int eta) const {
      return (side * nPhi + phi) * nEta + eta + m_mbtsOffset;
    }
141
142
143
144
145
146
147
    static const int E4side = -1;
    static const int E4eta  = 2;
    static const int E4nPhi = 4;
    static const int nCellE4pr = E4nPhi;
    inline int e4pr_index(int phi) const {
      return  phi + nCellMBTS + m_mbtsOffset;
    }
148
149
150
151
152
153
154
155
156
157

    ServiceHandle<TileCablingSvc> m_cablingSvc;
    const TileCablingService* m_cabling; 
    TileFragHash m_fragHashFunc;
    std::vector<bool> m_E1merged;
    std::vector<bool> m_MBTSmerged;
    enum CELL_TOWER{E1_TOWER = 10};
};

#endif // TILESIMALGS_TILEHITVECTOCNTTOOL_H