67 : m_record(iConfig.getParameter<
std::
string>(
"record")),
68 m_minNrecords(iConfig.getParameter<unsigned
int>(
"minNRecords")),
79 bool newClass =
false;
80 for (
auto& thePSet : m_parameters) {
81 if (thePSet.exists(
"fractionCut")) {
88 if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
90 this->writePayload(myThresholds);
92 throw cms::Exception(
"AlignPCLThresholdsWriter") <<
"mismatched configuration";
96 this->writePayload(myThresholds);
98 throw cms::Exception(
"AlignPCLThresholdsWriter") <<
"mismatched configuration";
103 template <
typename T>
107 }
else if (coord ==
"Y") {
109 }
else if (coord ==
"Z") {
111 }
else if (coord ==
"thetaX") {
113 }
else if (coord ==
"thetaY") {
115 }
else if (coord ==
"thetaZ") {
123 template <
typename T>
127 edm::LogInfo(
"AlignPCLThresholdsWriter") <<
"Size of AlignPCLThresholds object " << myThresholds.size() << std::endl;
130 std::array<std::string, 6> mandatories = {{
"X",
"Y",
"Z",
"thetaX",
"thetaY",
"thetaZ"}};
131 std::vector<std::string> alignables;
134 for (
auto& thePSet : m_parameters) {
137 if (
std::find(alignables.begin(), alignables.end(), alignableId) == alignables.end()) {
138 alignables.push_back(alignableId);
142 for (
auto& alignable : alignables) {
150 std::vector<std::string> presentDOF;
153 std::vector<AlignPCLThreshold::coordThresholds> extraDOFs = std::vector<AlignPCLThreshold::coordThresholds>();
155 for (
auto& thePSet : m_parameters) {
159 const double cutoff(thePSet.getParameter<
double>(
"cut"));
160 const double sigCut(thePSet.getParameter<
double>(
"sigCut"));
161 const double maxMoveCut(thePSet.getParameter<
double>(
"maxMoveCut"));
162 const double maxErrorCut(thePSet.getParameter<
double>(
"maxErrorCut"));
164 if (alignableId == alignable) {
165 presentDOF.push_back(DOF);
168 switch (mapOntoEnum(DOF)) {
189 <<
"Appending Extra degree of freeedom: " << DOF <<
" " << mapOntoEnum(DOF) << std::endl;
192 extraDOFs.push_back(ExtraDOF);
196 myThresholds.setAlignPCLThreshold(alignableId,
a);
203 <<
"Size of AlignPCLThresholds object " << myThresholds.size() << std::endl;
204 for (
auto& mandatory : mandatories) {
205 if (
std::find(presentDOF.begin(), presentDOF.end(), mandatory) == presentDOF.end()) {
207 <<
"Configuration for DOF: " << mandatory <<
" for alignable " << alignable <<
"is not present \n" 208 <<
"Will build object with defaults!" << std::endl;
215 myThresholds.setNRecords(m_minNrecords);
216 edm::LogInfo(
"AlignPCLThresholdsWriter") <<
"Content of AlignPCLThresholds " << std::endl;
219 if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
220 storeHGthresholds(myThresholds, alignables);
224 myThresholds.printAll();
231 poolDbService->
writeOneIOV(myThresholds, valid_time, m_record);
236 template <
typename T>
238 const std::vector<std::string>& alignables) {
240 <<
"Found type AlignPCLThresholdsHG, additional thresholds are written" << std::endl;
242 for (
auto& alignable : alignables) {
243 for (
auto& thePSet : m_parameters) {
250 if (alignableId == alignable) {
251 if (thePSet.exists(
"fractionCut")) {
252 const double fractionCut(thePSet.getParameter<
double>(
"fractionCut"));
261 template <
typename T>
264 desc.setComment(
"Plugin to write payloads of type AlignPCLThresholds");
265 desc.add<
unsigned int>(
"minNRecords", 25000);
270 desc_thresholds.add<
double>(
"cut");
271 desc_thresholds.add<
double>(
"sigCut");
272 desc_thresholds.add<
double>(
"maxMoveCut");
273 desc_thresholds.add<
double>(
"maxErrorCut");
274 if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
277 desc_thresholds.addOptional<
double>(
"fractionCut");
282 std::vector<edm::ParameterSet> default_thresholds(1);
283 desc.addVPSet(
"thresholds", desc_thresholds, default_thresholds);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
~AlignPCLThresholdsWriter() override=default
#define DEFINE_FWK_MODULE(type)
void analyze(const edm::Event &, const edm::EventSetup &) override
const std::string m_record
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void storeHGthresholds(AlignPCLThresholdsHG &myThresholds, const std::vector< std::string > &alignables)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
AlignPCLThresholdsWriter< AlignPCLThresholds > AlignPCLThresholdsLGWriter
unsigned long long Time_t
cond::Time_t currentTime() const
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
AlignPCLThresholdsWriter(const edm::ParameterSet &)
AlignPCLThresholdsWriter< AlignPCLThresholdsHG > AlignPCLThresholdsHGWriter
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Info, false > LogInfo
const unsigned int m_minNrecords
DOFs::dof mapOntoEnum(std::string coord)
void writePayload(T &myThresholds)
Log< level::Warning, false > LogWarning
void setFractionCut(const std::string &AlignableId, const coordType &type, const float &cut)
void setThresholds(float theCut, float theSigCut, float theErrorCut, float theMaxMoveCut, const std::string &theLabel)
const std::vector< edm::ParameterSet > m_parameters