CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripGainPayloadCopyAndExclude Class Reference
Inheritance diagram for SiStripGainPayloadCopyAndExclude:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 SiStripGainPayloadCopyAndExclude (const edm::ParameterSet &)
 
 ~SiStripGainPayloadCopyAndExclude () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 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
 
std::unique_ptr< SiStripApvGaingetNewObject (const std::map< std::pair< uint32_t, int >, float > &theMap)
 

Private Attributes

std::vector< unsigned int > m_excludedMods
 
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcdm_gain3Token
 
const edm::ESGetToken< SiStripGain, SiStripGainRcdm_gainToken
 
const uint32_t m_gainType
 
const std::string m_Record
 
const bool m_reverseSelect
 

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

Definition at line 49 of file SiStripGainPayloadCopyAndExclude.cc.

Constructor & Destructor Documentation

◆ SiStripGainPayloadCopyAndExclude()

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

Definition at line 72 of file SiStripGainPayloadCopyAndExclude.cc.

References edm::EDConsumerBase::esConsumes().

75  m_excludedMods{iConfig.getUntrackedParameter<std::vector<unsigned int>>("excludedModules")},
76  m_Record{iConfig.getUntrackedParameter<std::string>("record", "SiStripApvGainRcd")},
77  m_gainType{iConfig.getUntrackedParameter<uint32_t>("gainType", 1)},
78  m_reverseSelect{iConfig.getUntrackedParameter<bool>("reverseSelection", false)} {
80 
81  //now do what ever initialization is needed
82  sort(m_excludedMods.begin(), m_excludedMods.end());
83 
84  edm::LogInfo("ExcludedModules") << "Selected module list";
85  for (std::vector<unsigned int>::const_iterator mod = m_excludedMods.begin(); mod != m_excludedMods.end(); mod++) {
86  edm::LogVerbatim("ExcludedModules") << *mod;
87  }
88 }
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< SiStripGain, SiStripGainRcd > m_gainToken
Log< level::Info, false > LogInfo
static const std::string kSharedResource
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > m_gain3Token

◆ ~SiStripGainPayloadCopyAndExclude()

SiStripGainPayloadCopyAndExclude::~SiStripGainPayloadCopyAndExclude ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiStripGainPayloadCopyAndExclude::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 95 of file SiStripGainPayloadCopyAndExclude.cc.

References cond::service::PoolDBOutputService::currentTime(), ztail::d, newFWLiteAna::found, IntegrityClient_cfi::Gain, SiStripGain::getApvGain(), SiStripApvGain::getApvGain(), SiStripApvGain::getDetIds(), edm::EventSetup::getHandle(), getNewObject(), SiStripApvGain::getRange(), SiStripGain::getRange(), edm::Service< T >::isAvailable(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_excludedMods, m_gain3Token, m_gainToken, m_gainType, m_Record, m_reverseSelect, mod(), and cond::service::PoolDBOutputService::writeOneIOV().

95  {
96  using namespace edm;
97 
98  // gain to be validated
101 
102  std::map<std::pair<uint32_t, int>, float> theMap, oldPayloadMap;
103 
104  std::vector<uint32_t> detid;
105  gNew->getDetIds(detid);
106  for (const auto& d : detid) {
107  SiStripApvGain::Range range_new = gNew->getRange(d);
108  SiStripApvGain::Range range_old = gOld->getRange(d, m_gainType);
109  float nAPV = 0;
110 
111  for (int it = 0; it < range_new.second - range_new.first; it++) {
112  nAPV += 1;
113  float Gain = gNew->getApvGain(it, range_new);
114  float patchGain = gOld->getApvGain(it, range_old);
115  std::pair<uint32_t, int> index = std::make_pair(d, nAPV);
116 
117  oldPayloadMap[index] = Gain;
118 
119  bool found(false);
120  for (const auto& mod : m_excludedMods) {
121  if (d == mod) {
122  edm::LogInfo("ModuleFound") << " module " << mod << " found! Excluded... " << std::endl;
123  found = true;
124  break;
125  }
126  }
127 
128  if (m_reverseSelect)
129  found = (!found);
130 
131  if (!found) {
132  theMap[index] = Gain;
133  } else {
134  theMap[index] = patchGain;
135  }
136 
137  } // loop over APVs
138  } // loop over DetIds
139 
140  std::unique_ptr<SiStripApvGain> theAPVGains = this->getNewObject(theMap);
141 
142  // write out the APVGains record
144 
145  if (poolDbService.isAvailable())
146  poolDbService->writeOneIOV(theAPVGains.get(), poolDbService->currentTime(), m_Record);
147  else
148  throw std::runtime_error("PoolDBService required.");
149 }
static float getApvGain(uint16_t apv, const Range &range)
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:75
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:80
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::pair< ContainerIterator, ContainerIterator > Range
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
const edm::ESGetToken< SiStripGain, SiStripGainRcd > m_gainToken
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
d
Definition: ztail.py:151
Log< level::Info, false > LogInfo
std::unique_ptr< SiStripApvGain > getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
const Range getRange(const uint32_t detID) const
HLT enums.
bool isAvailable() const
Definition: Service.h:40
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > m_gain3Token

◆ fillDescriptions()

void SiStripGainPayloadCopyAndExclude::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 185 of file SiStripGainPayloadCopyAndExclude.cc.

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

185  {
187  desc.addUntracked<std::vector<unsigned int>>("excludedModules", {});
188  desc.addUntracked<std::string>("record", "SiStripApvGainRcd");
189  desc.addUntracked<uint32_t>("gainType", 1);
190  desc.addUntracked<bool>("reverseSelection", false);
191  descriptions.addWithDefaultLabel(desc);
192 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ getNewObject()

std::unique_ptr< SiStripApvGain > SiStripGainPayloadCopyAndExclude::getNewObject ( const std::map< std::pair< uint32_t, int >, float > &  theMap)
private

Definition at line 152 of file SiStripGainPayloadCopyAndExclude.cc.

References getGTfromDQMFile::obj, and FastTimerService_cff::range.

Referenced by analyze().

153  {
154  std::unique_ptr<SiStripApvGain> obj = std::make_unique<SiStripApvGain>();
155 
156  std::vector<float> theSiStripVector;
157  uint32_t PreviousDetId = 0;
158  for (const auto& element : theMap) {
159  uint32_t DetId = element.first.first;
160  if (DetId != PreviousDetId) {
161  if (!theSiStripVector.empty()) {
162  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
163  if (!obj->put(PreviousDetId, range))
164  printf("Bug to put detId = %i\n", PreviousDetId);
165  }
166  theSiStripVector.clear();
167  PreviousDetId = DetId;
168  }
169  theSiStripVector.push_back(element.second);
170 
171  edm::LogInfo("SiStripGainPayloadCopyAndExclude")
172  << " DetId: " << DetId << " APV: " << element.first.second << " Gain: " << element.second << std::endl;
173  }
174 
175  if (!theSiStripVector.empty()) {
176  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
177  if (!obj->put(PreviousDetId, range))
178  printf("Bug to put detId = %i\n", PreviousDetId);
179  }
180 
181  return obj;
182 }
std::pair< ContainerIterator, ContainerIterator > Range
Log< level::Info, false > LogInfo
Definition: DetId.h:17

Member Data Documentation

◆ m_excludedMods

std::vector<unsigned int> SiStripGainPayloadCopyAndExclude::m_excludedMods
private

Definition at line 63 of file SiStripGainPayloadCopyAndExclude.cc.

Referenced by analyze().

◆ m_gain3Token

const edm::ESGetToken<SiStripApvGain, SiStripApvGain3Rcd> SiStripGainPayloadCopyAndExclude::m_gain3Token
private

Definition at line 62 of file SiStripGainPayloadCopyAndExclude.cc.

Referenced by analyze().

◆ m_gainToken

const edm::ESGetToken<SiStripGain, SiStripGainRcd> SiStripGainPayloadCopyAndExclude::m_gainToken
private

Definition at line 61 of file SiStripGainPayloadCopyAndExclude.cc.

Referenced by analyze().

◆ m_gainType

const uint32_t SiStripGainPayloadCopyAndExclude::m_gainType
private

Definition at line 65 of file SiStripGainPayloadCopyAndExclude.cc.

Referenced by analyze().

◆ m_Record

const std::string SiStripGainPayloadCopyAndExclude::m_Record
private

Definition at line 64 of file SiStripGainPayloadCopyAndExclude.cc.

Referenced by analyze().

◆ m_reverseSelect

const bool SiStripGainPayloadCopyAndExclude::m_reverseSelect
private

Definition at line 66 of file SiStripGainPayloadCopyAndExclude.cc.

Referenced by analyze().