ATLAS Offline Software
TileWienerFilterWeights.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <iostream>
7 #include <fstream>
8 #include <string>
9 #include <cstring>
11 
12 using std::memset;
13 
15  : m_Luminosity(40)
16  , m_loaded(false)
17  , m_weights(nullptr)
18 {
19 }
20 
22 {
23  if (m_weights) delete m_weights;
24 }
25 
27 {
28  log<<MSG::DEBUG<<"TileWienerFilterWeights::loadWeights"<<endmsg;
29 
31  memset(m_weights,0,sizeof(TileWienerFilterWeightsStruct));
32 
33  // set luminosity
35  log<<MSG::DEBUG<<" Luminosity="<<m_Luminosity<<endmsg;
36 
38  // GENERAL WEIGHTS
39  std::string file_name_gn = "wiener_General_mu"+std::to_string(m_Luminosity)+".dat";
40  std::string file_path_gn = PathResolver::find_file(file_name_gn, "DATAPATH");
41  std::ifstream file_gn(file_path_gn.c_str());
42  std::string line_gn;
43 
44  if (file_gn.is_open()) {
45  log<<MSG::DEBUG<<file_name_gn<<" opened"<<endmsg;
46 
47  int partition, channel;
48 
49  while (std::getline(file_gn, line_gn)) {
50  // skip empty or comment lines
51  if (line_gn.empty() || line_gn[0] == '#') continue;
52 
53  // read values
54  std::istringstream iss(line_gn);
55  iss>>partition;
56  iss>>channel;
57  if (partition > -1 && partition < 4 && channel > -1 && channel < 48) {
58  for (int i=0; i<8; i++) {
60  }
61  }
62  }
63 
64  file_gn.close();
65  } else {
66  log<<MSG::FATAL<<file_name_gn<<" not found"<<endmsg;
67  return;
68  }
70 
72  // OPTIMAL WEIGHTS
73  std::string file_name_op = "wiener_Optimal_mu"+std::to_string(m_Luminosity)+".dat";
74  std::string file_path_op = PathResolver::find_file(file_name_op, "DATAPATH");
75  std::ifstream file_op(file_path_op.c_str());
76  std::string line_op;
77 
78  if (file_op.is_open()) {
79  log<<MSG::DEBUG<<file_name_op<<" opened"<<endmsg;
80 
81  int bcidIndex = 0;
82 
83  while (std::getline(file_op, line_op)) {
84  // skip empty or comment lines
85  if (line_op.empty() || line_op[0] == '#') continue;
86 
87  // read values
88  std::istringstream iss(line_op);
89  for (int i=0; i<8; i++) {
90  iss>>m_weights->optimalWeights[bcidIndex][i];
91  }
92  bcidIndex++;
93  }
94 
95  file_op.close();
96  } else {
97  log<<MSG::FATAL<<file_name_op<<" not found"<<endmsg;
98  return;
99  }
101 
102  m_loaded = true;
103  log<<MSG::DEBUG<<" WienerFilter Weights loaded"<<endmsg;
104 }
TileWienerFilterWeights::loadWeights
void loadWeights(MsgStream &log)
Definition: TileWienerFilterWeights.cxx:26
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
TileWienerFilterWeights.h
TileWienerFilterWeightsStruct
Definition: TileWienerFilterWeights.h:11
TileWienerFilterWeights::TileWienerFilterWeights
TileWienerFilterWeights()
Definition: TileWienerFilterWeights.cxx:14
TileWienerFilterWeights::m_loaded
bool m_loaded
Definition: TileWienerFilterWeights.h:35
TileWienerFilterWeights::m_weights
TileWienerFilterWeightsStruct * m_weights
Definition: TileWienerFilterWeights.h:36
TileWienerFilterWeights::~TileWienerFilterWeights
~TileWienerFilterWeights()
Definition: TileWienerFilterWeights.cxx:21
TileWienerFilterWeightsStruct::generalWeights
double generalWeights[4][48][8]
Definition: TileWienerFilterWeights.h:13
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TileWienerFilterWeights::m_Luminosity
int m_Luminosity
Definition: TileWienerFilterWeights.h:33
TileWienerFilterWeightsStruct::luminosity
int luminosity
Definition: TileWienerFilterWeights.h:12
PathResolver.h
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
DEBUG
#define DEBUG
Definition: page_access.h:11
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TileWienerFilterWeightsStruct::optimalWeights
double optimalWeights[7][8]
Definition: TileWienerFilterWeights.h:14