68 : m_record(iConfig.getParameter<
std::
string>(
"record")),
69 m_minNrecords(iConfig.getParameter<unsigned
int>(
"minNRecords")),
80 bool newClass =
false;
81 for (
auto& thePSet : m_parameters) {
82 if (thePSet.exists(
"fractionCut")) {
89 if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
91 this->writePayload(myThresholds);
93 throw cms::Exception(
"AlignPCLThresholdsWriter") <<
"mismatched configuration";
97 this->writePayload(myThresholds);
99 throw cms::Exception(
"AlignPCLThresholdsWriter") <<
"mismatched configuration";
104 template <
typename T>
108 }
else if (coord ==
"Y") {
110 }
else if (coord ==
"Z") {
112 }
else if (coord ==
"thetaX") {
114 }
else if (coord ==
"thetaY") {
116 }
else if (coord ==
"thetaZ") {
124 template <
typename T>
128 edm::LogInfo(
"AlignPCLThresholdsWriter") <<
"Size of AlignPCLThresholds object " << myThresholds.size() << std::endl;
131 std::array<std::string, 6> mandatories = {{
"X",
"Y",
"Z",
"thetaX",
"thetaY",
"thetaZ"}};
132 std::vector<std::string> alignables;
135 for (
auto& thePSet : m_parameters) {
138 if (
std::find(alignables.begin(), alignables.end(), alignableId) == alignables.end()) {
139 alignables.push_back(alignableId);
143 for (
auto& alignable : alignables) {
151 std::vector<std::string> presentDOF;
154 std::vector<AlignPCLThreshold::coordThresholds> extraDOFs = std::vector<AlignPCLThreshold::coordThresholds>();
156 for (
auto& thePSet : m_parameters) {
160 const double cutoff(thePSet.getParameter<
double>(
"cut"));
161 const double sigCut(thePSet.getParameter<
double>(
"sigCut"));
162 const double maxMoveCut(thePSet.getParameter<
double>(
"maxMoveCut"));
163 const double maxErrorCut(thePSet.getParameter<
double>(
"maxErrorCut"));
165 if (alignableId == alignable) {
166 presentDOF.push_back(DOF);
169 switch (mapOntoEnum(DOF)) {
190 <<
"Appending Extra degree of freeedom: " << DOF <<
" " << mapOntoEnum(DOF) << std::endl;
193 extraDOFs.push_back(ExtraDOF);
197 myThresholds.setAlignPCLThreshold(alignableId,
a);
204 <<
"Size of AlignPCLThresholds object " << myThresholds.size() << std::endl;
205 for (
auto& mandatory : mandatories) {
206 if (
std::find(presentDOF.begin(), presentDOF.end(), mandatory) == presentDOF.end()) {
208 <<
"Configuration for DOF: " << mandatory <<
" for alignable " << alignable <<
"is not present \n" 209 <<
"Will build object with defaults!" << std::endl;
216 myThresholds.setNRecords(m_minNrecords);
217 edm::LogInfo(
"AlignPCLThresholdsWriter") <<
"Content of AlignPCLThresholds " << std::endl;
220 if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
221 storeHGthresholds(myThresholds, alignables);
225 myThresholds.printAll();
232 poolDbService->
writeOneIOV(myThresholds, valid_time, m_record);
237 template <
typename T>
239 const std::vector<std::string>& alignables) {
241 <<
"Found type AlignPCLThresholdsHG, additional thresholds are written" << std::endl;
243 for (
auto& alignable : alignables) {
244 for (
auto& thePSet : m_parameters) {
251 if (alignableId == alignable) {
252 if (thePSet.exists(
"fractionCut")) {
253 const double fractionCut(thePSet.getParameter<
double>(
"fractionCut"));
262 template <
typename T>
265 desc.setComment(
"Plugin to write payloads of type AlignPCLThresholds");
266 desc.add<
unsigned int>(
"minNRecords", 25000);
271 desc_thresholds.add<
double>(
"cut");
272 desc_thresholds.add<
double>(
"sigCut");
273 desc_thresholds.add<
double>(
"maxMoveCut");
274 desc_thresholds.add<
double>(
"maxErrorCut");
275 if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
278 desc_thresholds.addOptional<
double>(
"fractionCut");
283 std::vector<edm::ParameterSet> default_thresholds(1);
284 desc.addVPSet(
"thresholds", desc_thresholds, default_thresholds);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
~AlignPCLThresholdsWriter() override=default
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
#define DEFINE_FWK_MODULE(type)
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