1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
#ifndef HcalLutManager_h
#define HcalLutManager_h
/**
\class HcalLutManager
\brief Various manipulations with trigger Lookup Tables
\author Gena Kukartsev, Brown University, March 14, 2008
*/
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include "CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h"
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
#include "CondFormats/HcalObjects/interface/AllObjects.h"
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
#include "CaloOnlineTools/HcalOnlineDb/interface/HCALConfigDB.h"
#include "CaloOnlineTools/HcalOnlineDb/interface/LMap.h"
#include "CalibFormats/HcalObjects/interface/HcalTPGCoder.h"
#include "CalibCalorimetry/CaloTPG/interface/CaloTPGTranscoderULUT.h"
#include "CaloOnlineTools/HcalOnlineDb/interface/HcalAssistant.h"
#include "CaloOnlineTools/HcalOnlineDb/interface/HcalChannelIterator.h"
#include "SimCalorimetry/HcalTrigPrimAlgos/interface/HcalFinegrainBit.h"
class XMLDOMBlock;
class HcalLutSet {
public:
std::string label;
std::vector<std::string> subdet;
std::vector<int> eta_min, eta_max, phi_min, phi_max, depth_min, depth_max;
std::vector<std::vector<unsigned int> > lut;
};
class HcalLutManager {
public:
HcalLutManager();
HcalLutManager(std::vector<HcalGenericDetId>& map);
HcalLutManager(const HcalElectronicsMap* _emap,
const HcalChannelQuality* _cq = nullptr,
uint32_t _status_word_to_mask = 0x0000);
HcalLutManager(const HcalDbService* conditions,
const HcalChannelQuality* _cq = nullptr,
uint32_t _status_word_to_mask = 0x0000);
~HcalLutManager();
void init(void);
std::string& getLutXml(std::vector<unsigned int>& _lut);
// crate=-1 stands for all crates
// legacy - use old LMAP. Use the xxxEmap method instead
std::map<int, std::shared_ptr<LutXml> > getLutXmlFromAsciiMaster(std::string _filename,
std::string _tag,
int _crate = -1,
bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename,
std::string _tag,
int _crate,
bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getLinearizationLutXmlFromAsciiMasterEmap_new(std::string _filename,
std::string _tag,
int _crate,
bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getCompressionLutXmlFromAsciiMaster(std::string _filename,
std::string _tag,
int _crate = -1,
bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getLinearizationLutXmlFromCoder(const HcalTPGCoder& _coder,
std::string _tag,
bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getMasks(int var, std::string _tag, bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder& _coder,
std::string _tag,
bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getCompressionLutXmlFromCoder(const CaloTPGTranscoderULUT& _coder,
std::string _tag,
bool split_by_crate = true);
std::map<int, std::shared_ptr<LutXml> > getZdcLutXml(const HcalTPGCoder& _coder,
std::string _tag,
bool split_by_crate = true,
bool ootpu_lut = false);
std::map<int, std::shared_ptr<LutXml> > getHEFineGrainLUTs(std::string _tag, bool split_by_crate = true);
// add two std::map<s with LUTs. Designed mainly for joining compression LUTs to linearization ones.
void addLutMap(std::map<int, std::shared_ptr<LutXml> >& result, const std::map<int, std::shared_ptr<LutXml> >& other);
// read LUTs from ASCII master file.
HcalLutSet getLutSetFromFile(std::string _filename, int _type = 1); // _type = 1 - linearization, 2 - compression
int writeLutXmlFiles(std::map<int, std::shared_ptr<LutXml> >& _xml,
std::string _tag = "default_tag",
bool split_by_crate = true);
int createLinLutXmlFiles(std::string _tag, std::string _lin_file, bool split_by_crate = true);
int createCompLutXmlFilesFromCoder(std::string _tag, bool split_by_crate = true);
int createAllLutXmlFiles(std::string _tag, std::string _lin_file, std::string _comp_file, bool split_by_crate = true);
int createAllLutXmlFilesFromCoder(const HcalTPGCoder& _coder, std::string _tag, bool split_by_crate = true);
int createLutXmlFiles_HBEFFromCoder_HOFromAscii(std::string _tag,
const HcalTPGCoder& _coder,
std::string _lin_file,
bool split_by_crate = true);
int createLutXmlFiles_HBEFFromCoder_HOFromAscii(std::string _tag,
const HcalTPGCoder& _coder,
const CaloTPGTranscoderULUT& _transcoder,
std::string _lin_file,
bool split_by_crate = true);
int createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC(std::string _tag,
const HcalTPGCoder& _coder,
const CaloTPGTranscoderULUT& _transcoder,
std::string _lin_file,
bool split_by_crate = true);
int createAllLutXmlFilesLinAsciiCompCoder(std::string _tag, std::string _lin_file, bool split_by_crate = true);
// tests
// reading LUTs from a local XML
int test_xml_access(std::string _tag, std::string _filename);
int test_direct_xml_parsing(std::string _filename);
void test_emap(void);
// connect to local XML file with LUTs and local ASCII file with LMAP
// connection interface through protected members db and lmap
int read_lmap(std::string lmap_hbef_file, std::string lmap_ho_file);
int read_luts(std::string lut_xml_file);
int local_connect(std::string lut_xml_file, std::string lmap_hbef_file, std::string lmap_ho_file);
// hcal::ConfigurationDatabase::LinearizerLUT
// hcal::ConfigurationDatabase::CompressionLUT
std::vector<unsigned int> getLutFromXml_old(std::string tag,
uint32_t _rawid,
hcal::ConfigurationDatabase::LUTType _lt);
std::vector<unsigned int> getLutFromXml(std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt);
std::map<int, std::shared_ptr<LutXml> > get_brickSet_from_oracle(
std::string tag,
const std::string _accessor =
"occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22");
int get_xml_files_from_db(
std::string tag,
const std::string db_accessor =
"occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22",
bool split_by_crate = true);
int create_lut_loader(std::string file_list,
std::string _prefix,
std::string tag_name,
std::string comment = "default comment",
std::string version = "V00-01-01",
int subversion = 1);
// get md5 checksums for LUTs
std::string get_checksum(std::vector<unsigned int>& lut);
static int getInt(std::string number);
static HcalSubdetector get_subdetector(std::string _subdet);
static std::string get_time_stamp(time_t _time);
// gives the iterator a list of channels
int initChannelIterator(std::vector<HcalGenericDetId>& map);
protected:
LutXml* lut_xml;
XMLDOMBlock* lut_checksums_xml;
HCALConfigDB* db;
LMap* lmap;
HcalChannelIterator _iter;
HcalAssistant _ass;
const HcalElectronicsMap* emap;
const HcalChannelQuality* cq;
const HcalDbService* conditions;
uint32_t status_word_to_mask;
};
class HcalLutManager_test {
public:
static int getLutXml_test(std::vector<unsigned int>& _lut) { return 0; }
static int getLutSetFromFile_test(std::string _filename);
static int getInt_test(std::string number);
protected:
LutXml* lut_xml;
};
#endif
|