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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 42 of file AlignPCLThresholdsWriter.cc.

Constructor & Destructor Documentation

◆ AlignPCLThresholdsWriter()

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

Definition at line 66 of file AlignPCLThresholdsWriter.cc.

67  : m_record(iConfig.getParameter<std::string>("record")),
68  m_minNrecords(iConfig.getParameter<unsigned int>("minNRecords")),
69  m_parameters(iConfig.getParameter<std::vector<edm::ParameterSet> >("thresholds")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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 77 of file AlignPCLThresholdsWriter.cc.

References Exception.

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

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

262  {
264  desc.setComment("Plugin to write payloads of type AlignPCLThresholds");
265  desc.add<unsigned int>("minNRecords", 25000);
266  edm::ParameterSetDescription desc_thresholds;
267 
268  desc_thresholds.add<std::string>("alignableId");
269  desc_thresholds.add<std::string>("DOF");
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>) {
275  desc.add<std::string>("record", "AlignPCLThresholdsHGRcd");
276  //optional thresholds from new payload version (not for all the alignables)
277  desc_thresholds.addOptional<double>("fractionCut");
278  } else {
279  desc.add<std::string>("record", "AlignPCLThresholdsRcd");
280  }
281 
282  std::vector<edm::ParameterSet> default_thresholds(1);
283  desc.addVPSet("thresholds", desc_thresholds, default_thresholds);
284  descriptions.addWithDefaultLabel(desc);
285 }
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 104 of file AlignPCLThresholdsWriter.cc.

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

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

◆ storeHGthresholds()

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

Definition at line 237 of file AlignPCLThresholdsWriter.cc.

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

238  {
239  edm::LogInfo("AlignPCLThresholdsWriter")
240  << "Found type AlignPCLThresholdsHG, additional thresholds are written" << std::endl;
241 
242  for (auto& alignable : alignables) {
243  for (auto& thePSet : m_parameters) {
244  const std::string alignableId(thePSet.getParameter<std::string>("alignableId"));
245  const std::string DOF(thePSet.getParameter<std::string>("DOF"));
246 
247  // Get coordType from DOF
249 
250  if (alignableId == alignable) {
251  if (thePSet.exists("fractionCut")) {
252  const double fractionCut(thePSet.getParameter<double>("fractionCut"));
253  myThresholds.setFractionCut(alignableId, type, fractionCut);
254  }
255  }
256  }
257  }
258 }
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 124 of file AlignPCLThresholdsWriter.cc.

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

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

◆ m_parameters

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

Definition at line 59 of file AlignPCLThresholdsWriter.cc.

◆ m_record

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

Definition at line 57 of file AlignPCLThresholdsWriter.cc.