ATLAS Offline Software
SCT_ClusterAnalysis.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "SCT_ClusterAnalysis.h"
6 #include "StoreGate/ReadHandle.h"
7 #include "GaudiKernel/EventContext.h"
8 
9 #include "TTree.h"
10 #include "TString.h"
11 
12 #include <algorithm>
13 #include <cmath>
14 #include <functional>
15 #include <iostream>
16 
17 SCT_ClusterAnalysis::SCT_ClusterAnalysis(const std::string& name, ISvcLocator *pSvcLocator)
18 : AthAlgorithm(name, pSvcLocator) {}
19 
21  ATH_MSG_DEBUG( "Initializing SCT_ClusterAnalysis" );
22 
24 
25  ATH_CHECK(detStore()->retrieve(m_stripID, "SCT_ID"));
26 
27  ATH_CHECK(m_thistSvc.retrieve());
28 
29  m_tree = new TTree(TString(m_ntupleTreeName.value()), "SCT_ClusterAna");
30  std::string fullNtupleName = m_ntupleFileName.value() + m_ntupleDirName.value() + m_ntupleTreeName.value();
31  ATH_CHECK(m_thistSvc->regTree(fullNtupleName, m_tree));
32 
33  if (m_tree) {
34  m_tree->Branch("barrelEndcap", &m_barrelEndcap);
35  m_tree->Branch("layerDisk", &m_layerDisk);
36  m_tree->Branch("phiModule", &m_phiModule);
37  m_tree->Branch("etaModule", &m_etaModule);
38  m_tree->Branch("sideModule", &m_sideModule);
39  m_tree->Branch("eta", &m_eta);
40  m_tree->Branch("globalX", &m_globalX);
41  m_tree->Branch("globalY", &m_globalY);
42  m_tree->Branch("globalZ", &m_globalZ);
43  m_tree->Branch("localX", &m_localX);
44  m_tree->Branch("localY", &m_localY);
45  m_tree->Branch("localCovXX", &m_localCovXX);
46  m_tree->Branch("localCovYY", &m_localCovYY);
47  m_tree->Branch("localCovXY", &m_localCovXY);
48  m_tree->Branch("localCovYX", &m_localCovYX);
49  m_tree->Branch("sizeX", &m_sizeX);
50  m_tree->Branch("sizeY", &m_sizeY);
51  } else {
52  ATH_MSG_ERROR("No tree found!");
53  }
54 
55  m_h_globalZR = new TH2F("m_h_globalZR","m_h_globalZR; z [mm]; r [mm]",1500,-3000.,3000,400,400.,1200);
56  ATH_CHECK(m_thistSvc->regHist(m_path.value() + m_h_globalZR->GetName(), m_h_globalZR));
57 
58  m_h_etaCluster = new TH1F("m_h_etaCluster","m_h_etaCluster; cluster #eta",100, -5, 5);
59  ATH_CHECK(m_thistSvc->regHist(m_path.value() + m_h_etaCluster->GetName(), m_h_etaCluster));
60 
61  return StatusCode::SUCCESS;
62 }
63 
65  ATH_MSG_DEBUG(" In SCT_ClusterAnalysis::execute()" );
66 
67  m_barrelEndcap->clear();
68  m_layerDisk->clear();
69  m_phiModule->clear();
70  m_etaModule->clear();
71  m_sideModule->clear();
72  m_eta->clear();
73  m_globalX->clear();
74  m_globalY->clear();
75  m_globalZ->clear();
76  m_localX->clear();
77  m_localY->clear();
78  m_localCovXX->clear();
79  m_localCovYY->clear();
80  m_localCovXY->clear();
81  m_localCovYX->clear();
82  m_sizeX->clear();
83  m_sizeY->clear();
84 
85  const EventContext& ctx = Algorithm::getContext();
86 
88  if( stripContainer.isValid() ) {
89  for( const InDet::SCT_ClusterCollection* stripCollection : *stripContainer ) {
90  if( !stripCollection ) continue;
91  for( const InDet::SCT_Cluster* sCluster : *stripCollection ) {
92 
93  const Identifier idColl(stripCollection->identify());
94  const int sctBrlEc(m_stripID->barrel_ec(idColl));
95  const int sctLayerDisk(m_stripID->layer_disk(idColl));
96  const int sctPhiMod(m_stripID->phi_module(idColl));
97  const int sctEtaMod(m_stripID->eta_module(idColl));
98  const int sctSideMod(m_stripID->side(idColl));
99 
100  m_barrelEndcap->push_back(sctBrlEc);
101  m_layerDisk->push_back(sctLayerDisk);
102  m_phiModule->push_back(sctPhiMod);
103  m_etaModule->push_back(sctEtaMod);
104  m_sideModule->push_back(sctSideMod);
105 
106  auto localPos = sCluster->localPosition();
107  auto localCov = sCluster->localCovariance();
108  auto globalPos = sCluster->globalPosition();
109  auto width = sCluster->width();
110 
111  m_eta->push_back(globalPos.eta());
112  m_globalX->push_back(globalPos.x());
113  m_globalY->push_back(globalPos.y());
114  m_globalZ->push_back(globalPos.z());
115 
116  m_localX->push_back(localPos[0]);
117  m_localY->push_back(localPos[1]);
118 
119  m_localCovXX->push_back(localCov(0, 0));
120  m_localCovXY->push_back(localCov(0, 1));
121  m_localCovYY->push_back(localCov(1, 1));
122  m_localCovYX->push_back(localCov(1, 0));
123 
124  m_sizeX->push_back(width.colRow()[0]);
125  m_sizeY->push_back(width.colRow()[1]);
126 
127  m_h_globalZR->Fill(globalPos.z(), globalPos.perp());
128  m_h_etaCluster->Fill(globalPos.eta());
129 
130  }
131  }
132  }
133 
134  if (m_tree) {
135  m_tree->Fill();
136  }
137 
138  return StatusCode::SUCCESS;
139 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_ClusterAnalysis::m_sizeX
std::vector< int > * m_sizeX
Definition: SCT_ClusterAnalysis.h:54
SCT_ClusterAnalysis::m_tree
TTree * m_tree
Definition: SCT_ClusterAnalysis.h:60
SCT_ClusterAnalysis::m_ntupleFileName
StringProperty m_ntupleFileName
Definition: SCT_ClusterAnalysis.h:61
SCT_ClusterAnalysis::m_phiModule
std::vector< int > * m_phiModule
Definition: SCT_ClusterAnalysis.h:41
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SCT_ClusterAnalysis::m_sideModule
std::vector< int > * m_sideModule
Definition: SCT_ClusterAnalysis.h:43
SCT_ClusterAnalysis::execute
virtual StatusCode execute() override final
Definition: SCT_ClusterAnalysis.cxx:64
SCT_ClusterAnalysis::m_globalY
std::vector< double > * m_globalY
Definition: SCT_ClusterAnalysis.h:46
SCT_ClusterAnalysis::m_h_etaCluster
TH1 * m_h_etaCluster
Definition: SCT_ClusterAnalysis.h:58
SCT_ClusterAnalysis::m_localCovXY
std::vector< double > * m_localCovXY
Definition: SCT_ClusterAnalysis.h:51
SCT_ClusterAnalysis::m_eta
std::vector< double > * m_eta
Definition: SCT_ClusterAnalysis.h:44
SCT_ClusterAnalysis::m_ntupleDirName
StringProperty m_ntupleDirName
Definition: SCT_ClusterAnalysis.h:62
SCT_ClusterAnalysis::m_localY
std::vector< double > * m_localY
Definition: SCT_ClusterAnalysis.h:49
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
DataPrepToActsConfig.stripContainer
stripContainer
Definition: DataPrepToActsConfig.py:10
SCT_ClusterAnalysis::m_localCovYY
std::vector< double > * m_localCovYY
Definition: SCT_ClusterAnalysis.h:52
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
SCT_ClusterAnalysis::m_inputKey
SG::ReadHandleKey< InDet::SCT_ClusterContainer > m_inputKey
Definition: SCT_ClusterAnalysis.h:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
SCT_ClusterAnalysis.h
SCT_ClusterAnalysis::m_barrelEndcap
std::vector< int > * m_barrelEndcap
Definition: SCT_ClusterAnalysis.h:39
SCT_ClusterAnalysis::m_globalZ
std::vector< double > * m_globalZ
Definition: SCT_ClusterAnalysis.h:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ClusterAnalysis::m_ntupleTreeName
StringProperty m_ntupleTreeName
Definition: SCT_ClusterAnalysis.h:63
SCT_ClusterAnalysis::m_h_globalZR
TH2 * m_h_globalZR
Definition: SCT_ClusterAnalysis.h:57
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
InDet::SCT_Cluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/SCT_Cluster.h:34
SCT_ClusterAnalysis::initialize
virtual StatusCode initialize() override final
Definition: SCT_ClusterAnalysis.cxx:20
AthAlgorithm
Definition: AthAlgorithm.h:47
SCT_ClusterAnalysis::m_etaModule
std::vector< int > * m_etaModule
Definition: SCT_ClusterAnalysis.h:42
SCT_ClusterAnalysis::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition: SCT_ClusterAnalysis.h:65
SCT_ClusterAnalysis::m_sizeY
std::vector< int > * m_sizeY
Definition: SCT_ClusterAnalysis.h:55
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_ClusterAnalysis::SCT_ClusterAnalysis
SCT_ClusterAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_ClusterAnalysis.cxx:17
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
SCT_ClusterAnalysis::m_globalX
std::vector< double > * m_globalX
Definition: SCT_ClusterAnalysis.h:45
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
SCT_ClusterAnalysis::m_localCovXX
std::vector< double > * m_localCovXX
Definition: SCT_ClusterAnalysis.h:50
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
SCT_ClusterAnalysis::m_localX
std::vector< double > * m_localX
Definition: SCT_ClusterAnalysis.h:48
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
ReadHandle.h
Handle class for reading from StoreGate.
InDet::SCT_ClusterCollection
Trk::PrepRawDataCollection< SCT_Cluster > SCT_ClusterCollection
Definition: SCT_ClusterCollection.h:26
SCT_ClusterAnalysis::m_path
StringProperty m_path
Definition: SCT_ClusterAnalysis.h:64
SCT_ClusterAnalysis::m_localCovYX
std::vector< double > * m_localCovYX
Definition: SCT_ClusterAnalysis.h:53
SCT_ClusterAnalysis::m_stripID
const SCT_ID * m_stripID
Definition: SCT_ClusterAnalysis.h:37
SCT_ClusterAnalysis::m_layerDisk
std::vector< int > * m_layerDisk
Definition: SCT_ClusterAnalysis.h:40
Identifier
Definition: IdentifierFieldParser.cxx:14