ATLAS Offline Software
Loading...
Searching...
No Matches
PixelClusterAnalysis.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
17PixelClusterAnalysis::PixelClusterAnalysis(const std::string& name, ISvcLocator *pSvcLocator)
18: AthAlgorithm(name, pSvcLocator) {}
19
21 ATH_MSG_DEBUG( "Initializing PixelClusterAnalysis" );
22
23 ATH_CHECK( m_inputKey.initialize() );
24
25 ATH_CHECK(detStore()->retrieve(m_pixelID, "PixelID"));
26
27 ATH_CHECK(m_thistSvc.retrieve());
28
29 m_tree = new TTree(TString(m_ntupleTreeName.value()), "PixelClusterAna");
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("isInnermost", &m_isInnermost);
39 m_tree->Branch("isNextToInnermost", &m_isNextToInnermost);
40 m_tree->Branch("eta", &m_eta);
41 m_tree->Branch("globalX", &m_globalX);
42 m_tree->Branch("globalY", &m_globalY);
43 m_tree->Branch("globalZ", &m_globalZ);
44 m_tree->Branch("localX", &m_localX);
45 m_tree->Branch("localY", &m_localY);
46 m_tree->Branch("localCovXX", &m_localCovXX);
47 m_tree->Branch("localCovYY", &m_localCovYY);
48 m_tree->Branch("sizeX", &m_sizeX);
49 m_tree->Branch("sizeY", &m_sizeY);
50 } else {
51 ATH_MSG_ERROR("No tree found!");
52 }
53
54 m_h_globalZR = new TH2F("h_globalZR","h_globalZR; z [mm]; r [mm]",1500,-3000.,3000,400,0.,400);
55 ATH_CHECK(m_thistSvc->regHist(m_path.value() + m_h_globalZR->GetName(), m_h_globalZR));
56
57 m_h_etaCluster = new TH1F("m_h_etaCluster","m_h_etaCluster; cluster #eta",100, -5, 5);
58 ATH_CHECK(m_thistSvc->regHist(m_path.value() + m_h_etaCluster->GetName(), m_h_etaCluster));
59
60 return StatusCode::SUCCESS;
61}
62
63StatusCode PixelClusterAnalysis::execute(const EventContext& ctx) {
64 ATH_MSG_DEBUG(" In PixelClusterAnalysis::execute()" );
65
66 m_barrelEndcap->clear();
67 m_layerDisk->clear();
68 m_phiModule->clear();
69 m_etaModule->clear();
70 m_isInnermost->clear();
71 m_isNextToInnermost->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_sizeX->clear();
81 m_sizeY->clear();
82
83
85 if(pixelContainer.isValid()) {
86 for( const InDet::PixelClusterCollection* pixelCollection : *pixelContainer) {
87 if (!pixelCollection) continue;
88 for( const InDet::PixelCluster* pCluster : *pixelCollection) {
89 const Identifier idColl(pixelCollection->identify());
90 const int pixBrlEc(m_pixelID->barrel_ec(idColl));
91 const int pixLayerDisk(m_pixelID->layer_disk(idColl));
92 const int pixPhiMod(m_pixelID->phi_module(idColl));
93 const int pixEtaMod(m_pixelID->eta_module(idColl));
94
95 bool isInnermost = (pixLayerDisk==0);
96 bool isNextToInnermost = (pixLayerDisk==1) or (pixBrlEc!=0 and pixLayerDisk==2);
97
98 m_barrelEndcap->push_back(pixBrlEc);
99 m_layerDisk->push_back(pixLayerDisk);
100 m_phiModule->push_back(pixPhiMod);
101 m_etaModule->push_back(pixEtaMod);
102 m_isInnermost->push_back(int(isInnermost));
103 m_isNextToInnermost->push_back(int(isNextToInnermost));
104
105 auto localPos = pCluster->localPosition();
106 auto localCov = pCluster->localCovariance();
107 auto globalPos = pCluster->globalPosition();
108 auto width = pCluster->width();
109
110 m_eta->push_back(globalPos.eta());
111 m_globalX->push_back(globalPos.x());
112 m_globalY->push_back(globalPos.y());
113 m_globalZ->push_back(globalPos.z());
114
115 m_localX->push_back(localPos[0]);
116 m_localY->push_back(localPos[1]);
117
118 m_localCovXX->push_back(localCov(0, 0));
119 m_localCovYY->push_back(localCov(1, 1));
120
121 m_sizeX->push_back(width.colRow()[0]);
122 m_sizeY->push_back(width.colRow()[1]);
123
124 m_h_globalZR->Fill(globalPos.z(), globalPos.perp());
125 m_h_etaCluster->Fill(globalPos.eta());
126
127 }
128 }
129 }
130
131 if (m_tree) {
132 m_tree->Fill();
133 }
134
135 return StatusCode::SUCCESS;
136}
#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.
const ServiceHandle< StoreGateSvc > & detStore() const
std::vector< double > * m_globalX
std::vector< double > * m_localCovXX
ServiceHandle< ITHistSvc > m_thistSvc
std::vector< double > * m_eta
std::vector< double > * m_localX
std::vector< int > * m_isNextToInnermost
SG::ReadHandleKey< InDet::PixelClusterContainer > m_inputKey
std::vector< int > * m_layerDisk
std::vector< int > * m_isInnermost
std::vector< int > * m_etaModule
PixelClusterAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< int > * m_barrelEndcap
std::vector< double > * m_globalY
std::vector< int > * m_sizeY
StringProperty m_ntupleFileName
std::vector< int > * m_phiModule
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) override final
Execute method.
StringProperty m_ntupleTreeName
std::vector< double > * m_globalZ
std::vector< double > * m_localCovYY
std::vector< double > * m_localY
std::vector< int > * m_sizeX