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
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 const EventContext& ctx = Algorithm::getContext();
84
86 if(pixelContainer.isValid()) {
87 for( const InDet::PixelClusterCollection* pixelCollection : *pixelContainer) {
88 if (!pixelCollection) continue;
89 for( const InDet::PixelCluster* pCluster : *pixelCollection) {
90 const Identifier idColl(pixelCollection->identify());
91 const int pixBrlEc(m_pixelID->barrel_ec(idColl));
92 const int pixLayerDisk(m_pixelID->layer_disk(idColl));
93 const int pixPhiMod(m_pixelID->phi_module(idColl));
94 const int pixEtaMod(m_pixelID->eta_module(idColl));
95
96 bool isInnermost = (pixLayerDisk==0);
97 bool isNextToInnermost = (pixLayerDisk==1) or (pixBrlEc!=0 and pixLayerDisk==2);
98
99 m_barrelEndcap->push_back(pixBrlEc);
100 m_layerDisk->push_back(pixLayerDisk);
101 m_phiModule->push_back(pixPhiMod);
102 m_etaModule->push_back(pixEtaMod);
103 m_isInnermost->push_back(int(isInnermost));
104 m_isNextToInnermost->push_back(int(isNextToInnermost));
105
106 auto localPos = pCluster->localPosition();
107 auto localCov = pCluster->localCovariance();
108 auto globalPos = pCluster->globalPosition();
109 auto width = pCluster->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_localCovYY->push_back(localCov(1, 1));
121
122 m_sizeX->push_back(width.colRow()[0]);
123 m_sizeY->push_back(width.colRow()[1]);
124
125 m_h_globalZR->Fill(globalPos.z(), globalPos.perp());
126 m_h_etaCluster->Fill(globalPos.eta());
127
128 }
129 }
130 }
131
132 if (m_tree) {
133 m_tree->Fill();
134 }
135
136 return StatusCode::SUCCESS;
137}
#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_globalX
std::vector< double > * m_localCovXX
ServiceHandle< ITHistSvc > m_thistSvc
virtual StatusCode execute() override final
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
StringProperty m_ntupleTreeName
std::vector< double > * m_globalZ
std::vector< double > * m_localCovYY
std::vector< double > * m_localY
std::vector< int > * m_sizeX