ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_PixelIdentifier.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8AFP_PixelIdentifier::AFP_PixelIdentifier(const std::string& input_name, const std::string& output_name, const std::vector<std::string>& pixelTools) :
9 m_input_file (std::make_unique<TFile>(input_name.c_str(),"read")),
10 m_output_file (std::make_unique<TFile>(output_name.c_str(),"recreate")),
11 m_pixelTools_names(pixelTools)
12{
13 for(const std::string& pixel_name: m_pixelTools_names)
14 {
15 if(pixel_name=="AFP_DeadPixel")
16 {
17 m_pixelTools.push_back(std::make_unique<AFP_DeadPixelTool>());
18 }
19 else if(pixel_name=="AFP_NoisyPixel")
20 {
21 m_pixelTools.push_back(std::make_unique<AFP_NoisyPixelTool>());
22 }
23 }
24
25 AFP_CONSTANTS afp_consts;
28}
29
30
32{
33 if(m_pixelTools.empty())
34 {
35 return 0;
36 }
37
38 std::unique_ptr<TH1I> hist_lb(static_cast<TH1I*>(m_input_file->Get("LBRangeLength")));
39 int LBRangeLength=hist_lb->GetBinContent(2)/hist_lb->GetBinContent(1);
40
41 for(int st=0;st<m_nStations;++st)
42 {
43 for(int la=0;la<m_nLayers;++la)
44 {
45 int lbIdx=0;
46 while(true) // repeat until there are valid histograms
47 {
48 std::shared_ptr<const TH2F> pixelHits(dynamic_cast<TH2F*>(m_input_file->Get(
49 Form("pixel_hits_lb_%d_%d_station_%d_layer_%d", lbIdx*LBRangeLength, (lbIdx+1)*LBRangeLength-1, st,la)
50 )));
51
52 if(!pixelHits.get()) break;
53
54 for(auto &pixelTool : m_pixelTools)
55 {
56 std::vector<TH2F> output{TH2F(Form("lb_%d_%d_station_%d_layer_%d",lbIdx*LBRangeLength,(lbIdx+1)*LBRangeLength-1,st,la),
57 Form("lb %d-%d, station %d, layer %d", lbIdx*LBRangeLength,(lbIdx+1)*LBRangeLength-1,st,la),
59
60 pixelTool->Identify(pixelHits,output);
61
62 for(TH2F& out : output)
63 {
64 out.Write();
65 }
66 }
67
68 ++lbIdx;
69 }
70 }
71 }
72
73 m_output_file->Close();
74 return 0;
75}
76
77
std::unique_ptr< TFile > m_output_file
AFP_PixelIdentifier(const std::string &input_name="AFP_PixelHistoFiller.root", const std::string &output_name="AFP_PixelIdentifier.root", const std::vector< std::string > &pixelTools={"AFP_DeadPixel", "AFP_NoisyPixel"})
static const int m_nStations
std::vector< std::string > m_pixelTools_names
std::unique_ptr< TFile > m_input_file
std::vector< std::unique_ptr< IAFP_GenericPixelTool > > m_pixelTools
static const int m_nLayers
STL namespace.
static constexpr double SiT_Pixel_amount_y
static constexpr double SiT_Pixel_amount_x