ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
17SCT_ClusterAnalysis::SCT_ClusterAnalysis(const std::string& name, ISvcLocator *pSvcLocator)
18: AthAlgorithm(name, pSvcLocator) {}
19
21 ATH_MSG_DEBUG( "Initializing SCT_ClusterAnalysis" );
22
23 ATH_CHECK( m_inputKey.initialize() );
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
const double width
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
std::vector< double > * m_globalY
StringProperty m_ntupleDirName
std::vector< double > * m_localCovXY
std::vector< int > * m_phiModule
virtual StatusCode execute() override final
std::vector< double > * m_globalZ
std::vector< int > * m_sideModule
ServiceHandle< ITHistSvc > m_thistSvc
StringProperty m_ntupleTreeName
std::vector< double > * m_localCovYX
std::vector< int > * m_etaModule
std::vector< double > * m_globalX
std::vector< int > * m_sizeX
virtual StatusCode initialize() override final
std::vector< double > * m_localY
std::vector< double > * m_localCovYY
std::vector< double > * m_localX
std::vector< double > * m_eta
std::vector< double > * m_localCovXX
std::vector< int > * m_barrelEndcap
StringProperty m_ntupleFileName
SG::ReadHandleKey< InDet::SCT_ClusterContainer > m_inputKey
std::vector< int > * m_sizeY
SCT_ClusterAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< int > * m_layerDisk