CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
AlignPCLThresholdsWriter Class Reference

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

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

Public Member Functions

 AlignPCLThresholdsWriter (const edm::ParameterSet &)
 
 ~AlignPCLThresholdsWriter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () 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
 
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::vector< ModuleDescription const * > &modules, 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 updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
 
void beginJob () override
 
void endJob () override
 
DOFs::dof mapOntoEnum (std::string coord)
 

Private Attributes

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

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)
 
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 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)
 

Detailed Description

Description: class to build the SiPixelAli PCL thresholds

Definition at line 48 of file AlignPCLThresholdsWriter.cc.

Constructor & Destructor Documentation

AlignPCLThresholdsWriter::AlignPCLThresholdsWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 73 of file AlignPCLThresholdsWriter.cc.

References myThresholds.

73  :
74  m_record(iConfig.getParameter<std::string>("record")),
75  m_minNrecords(iConfig.getParameter<unsigned int>("minNRecords")),
76  m_parameters(iConfig.getParameter<std::vector<edm::ParameterSet> >("thresholds"))
77 {
78  //now do what ever initialization is needed
80 }
T getParameter(std::string const &) const
const std::vector< edm::ParameterSet > m_parameters
AlignPCLThresholdsWriter::~AlignPCLThresholdsWriter ( )
override

Definition at line 83 of file AlignPCLThresholdsWriter.cc.

References myThresholds.

84 {
85  delete myThresholds;
86 }

Member Function Documentation

void AlignPCLThresholdsWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 94 of file AlignPCLThresholdsWriter.cc.

References a, cond::service::PoolDBOutputService::currentTime(), qjetsadder_cfi::cutoff, spr::find(), edm::Service< T >::isAvailable(), m_minNrecords, m_parameters, m_record, mapOntoEnum(), myThresholds, AlignPCLThresholds::printAll(), AlignPCLThresholds::setAlignPCLThreshold(), AlignPCLThresholds::setNRecords(), AlignPCLThreshold::coordThresholds::setThresholds(), candidateVertexArbitrator_cfi::sigCut, AlignPCLThresholds::size(), AlCaHLTBitMon_QueryRunRegistry::string, DOFs::thetaX, DOFs::thetaY, DOFs::thetaZ, cond::service::PoolDBOutputService::writeOne(), DOFs::X, DOFs::Y, and DOFs::Z.

95 {
96  using namespace edm;
97 
98  edm::LogInfo("AlignPCLThresholdsWriter")<<"Size of AlignPCLThresholds object "<< myThresholds->size() <<std::endl<<std::endl;
99 
100  // loop on the PSet and insert the conditions
101 
102  std::array<std::string,6> mandatories = {{"X","Y","Z","thetaX","thetaY","thetaZ"}};
103  std::vector<std::string> alignables;
104 
105  // fill the list of alignables
106  for(auto& thePSet : m_parameters){
107  const std::string alignableId(thePSet.getParameter<std::string>("alignableId"));
108  // only if it is not yet in the list
109  if(std::find(alignables.begin(), alignables.end(), alignableId) == alignables.end()) {
110  alignables.push_back(alignableId);
111  }
112  }
113 
114  for (auto& alignable : alignables){
115 
122 
123  std::vector<std::string> presentDOF;
124 
125  // extra degrees of freedom
126  std::vector< AlignPCLThreshold::coordThresholds > extraDOFs = std::vector< AlignPCLThreshold::coordThresholds >();
127 
128  for(auto& thePSet : m_parameters){
129 
130  const std::string alignableId(thePSet.getParameter<std::string>("alignableId"));
131  const std::string DOF(thePSet.getParameter<std::string>("DOF"));
132 
133  const double cutoff(thePSet.getParameter<double>("cut"));
134  const double sigCut(thePSet.getParameter<double>("sigCut"));
135  const double maxMoveCut(thePSet.getParameter<double>("maxMoveCut"));
136  const double maxErrorCut(thePSet.getParameter<double>("maxErrorCut"));
137 
138  if (alignableId == alignable){
139  presentDOF.push_back(DOF);
140  // create the objects
141 
142  switch( mapOntoEnum(DOF) )
143  {
144  case DOFs::X:
145  my_X.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF);
146  break;
147  case DOFs::Y:
148  my_Y.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF);
149  break;
150  case DOFs::Z:
151  my_Z.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF);
152  break;
153  case DOFs::thetaX:
154  my_tX.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF);
155  break;
156  case DOFs::thetaY:
157  my_tY.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF);
158  break;
159  case DOFs::thetaZ:
160  my_tZ.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF);
161  break;
162  default:
163  edm::LogInfo("AlignPCLThresholdsWriter")<<"Appending Extra degree of freeedom: "<< DOF <<" " << mapOntoEnum(DOF) << std::endl;
165  ExtraDOF.setThresholds(cutoff,sigCut,maxErrorCut,maxMoveCut,DOF);
166  extraDOFs.push_back(ExtraDOF);
167  }
168 
169  AlignPCLThreshold a(my_X,my_tX,my_Y,my_tY,my_Z,my_tZ,extraDOFs);
170  myThresholds->setAlignPCLThreshold(alignableId,a);
171 
172  } // if alignable is found in the PSet
173  } // loop on the PSets
174 
175  // checks if all mandatories are present
176  edm::LogInfo("AlignPCLThresholdsWriter")<<"Size of AlignPCLThresholds object "<<myThresholds->size() <<std::endl;
177  for(auto& mandatory : mandatories){
178  if(std::find(presentDOF.begin(), presentDOF.end(), mandatory) == presentDOF.end()) {
179  edm::LogWarning("AlignPCLThresholdsWriter")<<"Configuration for DOF: "<<mandatory<<" for alignable "<< alignable <<"is not present \n"
180  <<"Will build object with defaults!" <<std::endl;
181  }
182  }
183 
184  } // ends loop on the alignable units
185 
186  // set the minimum number of records to be used in pede
188  edm::LogInfo("AlignPCLThresholdsWriter")<<"Content of AlignPCLThresholds "<<std::endl;
189 
190  // use buil-in method in the CondFormat
192 
193  // Form the data here
195  if( poolDbService.isAvailable() ){
196  cond::Time_t valid_time = poolDbService->currentTime();
197  // this writes the payload to begin in current run defined in cfg
198  poolDbService->writeOne(myThresholds,valid_time, m_record);
199  }
200 }
void setAlignPCLThreshold(const std::string &AlignableId, const AlignPCLThreshold &Threshold)
double size() const
const std::vector< edm::ParameterSet > m_parameters
DOFs::dof mapOntoEnum(std::string coord)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
unsigned long long Time_t
Definition: Time.h:16
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
void setNRecords(const int &Nrecords)
HLT enums.
double a
Definition: hdecay.h:121
void setThresholds(float theCut, float theSigCut, float theErrorCut, float theMaxMoveCut, const std::string &theLabel)
void AlignPCLThresholdsWriter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 204 of file AlignPCLThresholdsWriter.cc.

205 {
206 }
void AlignPCLThresholdsWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 210 of file AlignPCLThresholdsWriter.cc.

211 {
212 }
void AlignPCLThresholdsWriter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static
DOFs::dof AlignPCLThresholdsWriter::mapOntoEnum ( std::string  coord)
private

Definition at line 214 of file AlignPCLThresholdsWriter.cc.

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

Referenced by analyze().

214  {
215  if( coord=="X" ){
216  return DOFs::X;
217  }
218  else if ( coord=="Y" ){
219  return DOFs::Y;
220  }
221  else if ( coord=="Z" ){
222  return DOFs::Z;
223  }
224  else if ( coord=="thetaX" ){
225  return DOFs::thetaX;
226  }
227  else if ( coord=="thetaY" ){
228  return DOFs::thetaY;
229  }
230  else if ( coord=="thetaZ" ){
231  return DOFs::thetaZ;
232  }
233  else {
234  return DOFs::extraDOF;
235  }
236 
237 }

Member Data Documentation

const unsigned int AlignPCLThresholdsWriter::m_minNrecords
private

Definition at line 64 of file AlignPCLThresholdsWriter.cc.

Referenced by analyze().

const std::vector<edm::ParameterSet> AlignPCLThresholdsWriter::m_parameters
private

Definition at line 65 of file AlignPCLThresholdsWriter.cc.

Referenced by analyze().

const std::string AlignPCLThresholdsWriter::m_record
private

Definition at line 63 of file AlignPCLThresholdsWriter.cc.

Referenced by analyze().

AlignPCLThresholds* AlignPCLThresholdsWriter::myThresholds
private