CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
AlignPCLThresholdsWriter< T > Class Template Reference

#include <CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc>

Inheritance diagram for AlignPCLThresholdsWriter< T >:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 AlignPCLThresholdsWriter (const edm::ParameterSet &)
 
 ~AlignPCLThresholdsWriter () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
DOFs::dof mapOntoEnum (std::string coord)
 
void storeHGthresholds (AlignPCLThresholdsHG &myThresholds, const std::vector< std::string > &alignables)
 
void writePayload (T &myThresholds)
 

Private Attributes

const unsigned int m_minNrecords
 
const std::vector< edm::ParameterSetm_parameters
 
const std::string m_record
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

template<typename T>
class AlignPCLThresholdsWriter< T >

Description: class to build the SiPixelAli PCL thresholds

Definition at line 43 of file AlignPCLThresholdsWriter.cc.

Constructor & Destructor Documentation

◆ AlignPCLThresholdsWriter()

template<typename T >
AlignPCLThresholdsWriter< T >::AlignPCLThresholdsWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 67 of file AlignPCLThresholdsWriter.cc.

68  : m_record(iConfig.getParameter<std::string>("record")),
69  m_minNrecords(iConfig.getParameter<unsigned int>("minNRecords")),
70  m_parameters(iConfig.getParameter<std::vector<edm::ParameterSet> >("thresholds")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const std::vector< edm::ParameterSet > m_parameters

◆ ~AlignPCLThresholdsWriter()

template<typename T >
AlignPCLThresholdsWriter< T >::~AlignPCLThresholdsWriter ( )
overridedefault

Member Function Documentation

◆ analyze()

template<typename T >
void AlignPCLThresholdsWriter< T >::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 78 of file AlignPCLThresholdsWriter.cc.

References Exception.

78  {
79  // detect if new payload is used
80  bool newClass = false;
81  for (auto& thePSet : m_parameters) {
82  if (thePSet.exists("fractionCut")) {
83  newClass = true;
84  break;
85  }
86  }
87 
88  T myThresholds{};
89  if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
90  if (newClass) {
91  this->writePayload(myThresholds);
92  } else {
93  throw cms::Exception("AlignPCLThresholdsWriter") << "mismatched configuration";
94  }
95  } else {
96  if (!newClass) {
97  this->writePayload(myThresholds);
98  } else {
99  throw cms::Exception("AlignPCLThresholdsWriter") << "mismatched configuration";
100  }
101  }
102 }
void writePayload(T &myThresholds)
long double T
const std::vector< edm::ParameterSet > m_parameters

◆ fillDescriptions()

template<typename T >
void AlignPCLThresholdsWriter< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 263 of file AlignPCLThresholdsWriter.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

263  {
265  desc.setComment("Plugin to write payloads of type AlignPCLThresholds");
266  desc.add<unsigned int>("minNRecords", 25000);
267  edm::ParameterSetDescription desc_thresholds;
268 
269  desc_thresholds.add<std::string>("alignableId");
270  desc_thresholds.add<std::string>("DOF");
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>) {
276  desc.add<std::string>("record", "AlignPCLThresholdsHGRcd");
277  //optional thresholds from new payload version (not for all the alignables)
278  desc_thresholds.addOptional<double>("fractionCut");
279  } else {
280  desc.add<std::string>("record", "AlignPCLThresholdsRcd");
281  }
282 
283  std::vector<edm::ParameterSet> default_thresholds(1);
284  desc.addVPSet("thresholds", desc_thresholds, default_thresholds);
285  descriptions.addWithDefaultLabel(desc);
286 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ mapOntoEnum()

template<typename T >
DOFs::dof AlignPCLThresholdsWriter< T >::mapOntoEnum ( std::string  coord)
private

Definition at line 105 of file AlignPCLThresholdsWriter.cc.

References DOFs::extraDOF, DOFs::thetaX, DOFs::thetaY, DOFs::thetaZ, DOFs::X, DOFs::Y, and DOFs::Z.

105  {
106  if (coord == "X") {
107  return DOFs::X;
108  } else if (coord == "Y") {
109  return DOFs::Y;
110  } else if (coord == "Z") {
111  return DOFs::Z;
112  } else if (coord == "thetaX") {
113  return DOFs::thetaX;
114  } else if (coord == "thetaY") {
115  return DOFs::thetaY;
116  } else if (coord == "thetaZ") {
117  return DOFs::thetaZ;
118  } else {
119  return DOFs::extraDOF;
120  }
121 }

◆ storeHGthresholds()

template<typename T >
void AlignPCLThresholdsWriter< T >::storeHGthresholds ( AlignPCLThresholdsHG myThresholds,
const std::vector< std::string > &  alignables 
)
private

Definition at line 238 of file AlignPCLThresholdsWriter.cc.

References AlignPCLThresholdsHG::setFractionCut(), and AlCaHLTBitMon_QueryRunRegistry::string.

239  {
240  edm::LogInfo("AlignPCLThresholdsWriter")
241  << "Found type AlignPCLThresholdsHG, additional thresholds are written" << std::endl;
242 
243  for (auto& alignable : alignables) {
244  for (auto& thePSet : m_parameters) {
245  const std::string alignableId(thePSet.getParameter<std::string>("alignableId"));
246  const std::string DOF(thePSet.getParameter<std::string>("DOF"));
247 
248  // Get coordType from DOF
250 
251  if (alignableId == alignable) {
252  if (thePSet.exists("fractionCut")) {
253  const double fractionCut(thePSet.getParameter<double>("fractionCut"));
254  myThresholds.setFractionCut(alignableId, type, fractionCut);
255  }
256  }
257  }
258  }
259 }
Log< level::Info, false > LogInfo
DOFs::dof mapOntoEnum(std::string coord)
void setFractionCut(const std::string &AlignableId, const coordType &type, const float &cut)
const std::vector< edm::ParameterSet > m_parameters

◆ writePayload()

template<typename T >
void AlignPCLThresholdsWriter< T >::writePayload ( T myThresholds)
private

Definition at line 125 of file AlignPCLThresholdsWriter.cc.

References a, cond::service::PoolDBOutputService::currentTime(), EcalSCDynamicDPhiParametersESProducer_cfi::cutoff, spr::find(), edm::Service< T >::isAvailable(), AlignPCLThreshold::coordThresholds::setThresholds(), HLT_2023v12_cff::sigCut, AlCaHLTBitMon_QueryRunRegistry::string, DOFs::thetaX, DOFs::thetaY, DOFs::thetaZ, cond::service::PoolDBOutputService::writeOneIOV(), DOFs::X, DOFs::Y, and DOFs::Z.

125  {
126  using namespace edm;
127 
128  edm::LogInfo("AlignPCLThresholdsWriter") << "Size of AlignPCLThresholds object " << myThresholds.size() << std::endl;
129 
130  // loop on the PSet and insert the conditions
131  std::array<std::string, 6> mandatories = {{"X", "Y", "Z", "thetaX", "thetaY", "thetaZ"}};
132  std::vector<std::string> alignables;
133 
134  // fill the list of alignables
135  for (auto& thePSet : m_parameters) {
136  const std::string alignableId(thePSet.getParameter<std::string>("alignableId"));
137  // only if it is not yet in the list
138  if (std::find(alignables.begin(), alignables.end(), alignableId) == alignables.end()) {
139  alignables.push_back(alignableId);
140  }
141  }
142 
143  for (auto& alignable : alignables) {
150 
151  std::vector<std::string> presentDOF;
152 
153  // extra degrees of freedom
154  std::vector<AlignPCLThreshold::coordThresholds> extraDOFs = std::vector<AlignPCLThreshold::coordThresholds>();
155 
156  for (auto& thePSet : m_parameters) {
157  const std::string alignableId(thePSet.getParameter<std::string>("alignableId"));
158  const std::string DOF(thePSet.getParameter<std::string>("DOF"));
159 
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"));
164 
165  if (alignableId == alignable) {
166  presentDOF.push_back(DOF);
167  // create the objects
168 
169  switch (mapOntoEnum(DOF)) {
170  case DOFs::X:
171  my_X.setThresholds(cutoff, sigCut, maxErrorCut, maxMoveCut, DOF);
172  break;
173  case DOFs::Y:
174  my_Y.setThresholds(cutoff, sigCut, maxErrorCut, maxMoveCut, DOF);
175  break;
176  case DOFs::Z:
177  my_Z.setThresholds(cutoff, sigCut, maxErrorCut, maxMoveCut, DOF);
178  break;
179  case DOFs::thetaX:
180  my_tX.setThresholds(cutoff, sigCut, maxErrorCut, maxMoveCut, DOF);
181  break;
182  case DOFs::thetaY:
183  my_tY.setThresholds(cutoff, sigCut, maxErrorCut, maxMoveCut, DOF);
184  break;
185  case DOFs::thetaZ:
186  my_tZ.setThresholds(cutoff, sigCut, maxErrorCut, maxMoveCut, DOF);
187  break;
188  default:
189  edm::LogInfo("AlignPCLThresholdsWriter")
190  << "Appending Extra degree of freeedom: " << DOF << " " << mapOntoEnum(DOF) << std::endl;
192  ExtraDOF.setThresholds(cutoff, sigCut, maxErrorCut, maxMoveCut, DOF);
193  extraDOFs.push_back(ExtraDOF);
194  }
195 
196  AlignPCLThreshold a(my_X, my_tX, my_Y, my_tY, my_Z, my_tZ, extraDOFs);
197  myThresholds.setAlignPCLThreshold(alignableId, a);
198 
199  } // if alignable is found in the PSet
200  } // loop on the PSets
201 
202  // checks if all mandatories are present
203  edm::LogInfo("AlignPCLThresholdsWriter")
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()) {
207  edm::LogWarning("AlignPCLThresholdsWriter")
208  << "Configuration for DOF: " << mandatory << " for alignable " << alignable << "is not present \n"
209  << "Will build object with defaults!" << std::endl;
210  }
211  }
212 
213  } // ends loop on the alignable units
214 
215  // set the minimum number of records to be used in pede
216  myThresholds.setNRecords(m_minNrecords);
217  edm::LogInfo("AlignPCLThresholdsWriter") << "Content of AlignPCLThresholds " << std::endl;
218 
219  // additional thresholds for AlignPCLThresholdsHG
220  if constexpr (std::is_same_v<T, AlignPCLThresholdsHG>) {
221  storeHGthresholds(myThresholds, alignables);
222  }
223 
224  // use built-in method in the CondFormat
225  myThresholds.printAll();
226 
227  // Form the data here
229  if (poolDbService.isAvailable()) {
230  cond::Time_t valid_time = poolDbService->currentTime();
231  // this writes the payload to begin in current run defined in cfg
232  poolDbService->writeOneIOV(myThresholds, valid_time, m_record);
233  }
234 }
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)
Definition: FindCaloHit.cc:19
unsigned long long Time_t
Definition: Time.h:14
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Info, false > LogInfo
DOFs::dof mapOntoEnum(std::string coord)
HLT enums.
double a
Definition: hdecay.h:121
bool isAvailable() const
Definition: Service.h:40
Log< level::Warning, false > LogWarning
void setThresholds(float theCut, float theSigCut, float theErrorCut, float theMaxMoveCut, const std::string &theLabel)
const std::vector< edm::ParameterSet > m_parameters

Member Data Documentation

◆ m_minNrecords

template<typename T >
const unsigned int AlignPCLThresholdsWriter< T >::m_minNrecords
private

Definition at line 59 of file AlignPCLThresholdsWriter.cc.

◆ m_parameters

template<typename T >
const std::vector<edm::ParameterSet> AlignPCLThresholdsWriter< T >::m_parameters
private

Definition at line 60 of file AlignPCLThresholdsWriter.cc.

◆ m_record

template<typename T >
const std::string AlignPCLThresholdsWriter< T >::m_record
private

Definition at line 58 of file AlignPCLThresholdsWriter.cc.