CMS 3D CMS Logo

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

#include <CSCChipSpeedCorrectionDBConditions.h>

Inheritance diagram for CSCChipSpeedCorrectionDBConditions:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Public Types

typedef std::unique_ptr< CSCDBChipSpeedCorrectionReturnType
 

Public Member Functions

 CSCChipSpeedCorrectionDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBChipSpeedCorrection (const CSCDBChipSpeedCorrectionRcd &)
 
 ~CSCChipSpeedCorrectionDBConditions () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Member Functions

static CSCDBChipSpeedCorrectionprefillDBChipSpeedCorrection (bool isForMC, std::string dataCorrFileName, float dataOffse)
 
- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
 

Private Attributes

CSCDBChipSpeedCorrectioncndbChipCorr
 
std::string dataCorrFileName
 
float dataOffset
 
bool isForMC
 

Additional Inherited Members

- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProductResolverFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Definition at line 21 of file CSCChipSpeedCorrectionDBConditions.h.

Member Typedef Documentation

◆ ReturnType

Definition at line 30 of file CSCChipSpeedCorrectionDBConditions.h.

Constructor & Destructor Documentation

◆ CSCChipSpeedCorrectionDBConditions()

CSCChipSpeedCorrectionDBConditions::CSCChipSpeedCorrectionDBConditions ( const edm::ParameterSet iConfig)

Definition at line 8 of file CSCChipSpeedCorrectionDBConditions.cc.

References dataCorrFileName, dataOffset, edm::ParameterSet::getUntrackedParameter(), isForMC, produceDBChipSpeedCorrection(), edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

8  {
9  // the following line is needed to tell the framework what
10  // data is being produced
11  isForMC = iConfig.getUntrackedParameter<bool>("isForMC", true);
12  dataCorrFileName = iConfig.getUntrackedParameter<std::string>("dataCorrFileName", "empty.txt");
13  dataOffset = 170.;
14  // added by Zhen (changed since 1_2_0)
16  findingRecord<CSCDBChipSpeedCorrectionRcd>();
17  // now do what ever other initialization is needed
18 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
ReturnType produceDBChipSpeedCorrection(const CSCDBChipSpeedCorrectionRcd &)
T getUntrackedParameter(std::string const &, T const &) const

◆ ~CSCChipSpeedCorrectionDBConditions()

CSCChipSpeedCorrectionDBConditions::~CSCChipSpeedCorrectionDBConditions ( )
override

Definition at line 20 of file CSCChipSpeedCorrectionDBConditions.cc.

20  {
21  // do anything here that needs to be done at desctruction time
22  // (e.g. close files, deallocate resources etc.)
23 }

Member Function Documentation

◆ prefillDBChipSpeedCorrection()

CSCDBChipSpeedCorrection * CSCChipSpeedCorrectionDBConditions::prefillDBChipSpeedCorrection ( bool  isForMC,
std::string  dataCorrFileName,
float  dataOffse 
)
inlinestatic

Definition at line 58 of file CSCChipSpeedCorrectionDBConditions.h.

References cms::cuda::assert(), relativeConstraints::chamber, CSCDetId::chamber(), RPCNoise_example::check, CSCIndexer::chipIndex(), CSCDBChipSpeedCorrection::chipSpeedCorr, cndbChipCorr, dataOffset, CSCIndexer::detIdFromChamberIndex(), dt, CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, CSCDBChipSpeedCorrection::factor_speedCorr, corrVsCorr::filename, groupFilesInBlocks::fin, mps_fire::i, createfilelist::int, PV_cfg::isMC, nano_mu_digi_cff::layer, pixelgpudetails::MAX_SIZE, CSCDetId::ring(), relativeConstraints::ring, relativeConstraints::station, CSCDetId::station(), and submitPVValidationJobs::t.

Referenced by produceDBChipSpeedCorrection().

60  {
61  if (isMC)
62  printf("\n Generating fake DB constants for MC\n");
63  else {
64  printf("\n Reading chip corrections from file %s \n", filename.data());
65  printf("my data offset value is %f \n", dataOffset);
66  }
67 
68  CSCIndexer indexer;
69 
70  const int CHIP_FACTOR = 100;
71  const int MAX_SIZE = 15768;
72  const int MAX_SHORT = 32767;
74 
76  itemvector.resize(MAX_SIZE);
77  cndbChipCorr->factor_speedCorr = int(CHIP_FACTOR);
78 
79  // Fill chip corrections for MC is very simple
80  if (isMC) {
81  for (int i = 0; i < MAX_SIZE; i++) {
82  itemvector[i].speedCorr = 0;
83  }
84  return cndbChipCorr;
85  }
86 
87  // Filling for data takes a little more time
88  FILE *fin = fopen(filename.data(), "r");
89 
90  int serialChamber, endcap, station, ring, chamber, chip;
91  float t, dt;
92  int nPulses;
93 
94  std::vector<int> new_index_id;
95  std::vector<float> new_chipPulse;
96  double runningTotal = 0;
97  int numNonZero = 0;
98  while (!feof(fin)) {
99  // note space at end of format string to convert last \n
100  // int check = fscanf(fin,"%d %d %f %f \n",&serialChamber,&chip,&t,&dt);
101  int check = fscanf(fin,
102  "%d %d %d %d %d %d %f %f %d \n",
103  &serialChamber,
104  &endcap,
105  &station,
106  &ring,
107  &chamber,
108  &chip,
109  &t,
110  &dt,
111  &nPulses);
112  if (check != 9) {
113  printf("The input file format is not as expected\n");
114  assert(0);
115  }
116 
117  int serialChamber_safecopy = serialChamber;
118  // Now to map from S. Durkin's serialChamber index convention
119  // ME+1/1-ME+41 = 1 -234
120  // ME+4/2 = 235-270*
121  // ME-1/1-ME-41 = 271-504*
122  // ME-4/2 = 505-540
123  // To the convention used in /DataFormats/MuonDetId/interface/CSCIndexer.h
124  // ME+1/1-ME+41 = 1 -234
125  // ME+4/2 = 469-504*
126  // ME-1/1-ME-41 = 235-468*
127  // ME-4/2 = 505-540
128  // Only the chambers marked * need to be remapped
129 
130  if (serialChamber >= 235 && serialChamber <= 270)
131  serialChamber += 234;
132  else { // not in ME+4\2
133  if (serialChamber >= 271 && serialChamber <= 504)
134  serialChamber -= 36;
135  }
136 
137  CSCDetId chamberId = indexer.detIdFromChamberIndex(serialChamber);
138  // Now to map from S. Durkin's chip index convention 0-29 (with
139  // 4,9,14,19,24,29 unused in ME1/3) To the convention used in
140  // /DataFormats/MuonDetId/interface/CSCIndexer.h Layer 1-6 and chip 1-5 for
141  // all chambers except ME1/3 which is chip 1-4
142  int layer = (chip) / 5 + 1;
143  CSCDetId cscId(chamberId.endcap(), chamberId.station(), chamberId.ring(), chamberId.chamber(), layer);
144  // This should yield the same CSCDetId as decoding the chamber serial does
145  // If not, some debugging is needed
146  CSCDetId cscId_doubleCheck(endcap, station, ring, chamber, layer);
147  if (cscId != cscId_doubleCheck) {
148  printf("Why doesn't chamberSerial %d map to e: %d s: %d r: %d c: %d ? \n",
149  serialChamber_safecopy,
150  endcap,
151  station,
152  ring,
153  chamber);
154  assert(0);
155  }
156 
157  chip = (chip % 5) + 1;
158  // The file produced by Stan starts from the geometrical strip number stored
159  // in the CSCStripDigi When the strip digis are built, the conversion from
160  // electronics channel to geometrical strip (reversing ME+1/1a and, more
161  // importantly, ME-1/1b) is done before the digi is filled
162  // (EventFilter/CSCRawToDigi/src/CSCCFEBData.cc). Since we're filling an
163  // electronics channel database, I'll flip again ME-1/1b
164  if (endcap == 2 && station == 1 && ring == 1 && chip < 5) {
165  chip = 5 - chip; // change 1-4 to 4-1
166  }
167 
168  new_index_id.push_back(indexer.chipIndex(cscId, chip));
169  new_chipPulse.push_back(t);
170  if (t != 0) {
171  runningTotal += t;
172  numNonZero++;
173  }
174  }
175  fclose(fin);
176 
177  // Fill the chip corrections with zeros to start
178  for (int i = 0; i < MAX_SIZE; i++) {
179  itemvector[i].speedCorr = 0;
180  }
181 
182  for (unsigned int i = 0; i < new_index_id.size(); i++) {
183  if ((short int)(fabs((dataOffset - new_chipPulse[i]) * CHIP_FACTOR + 0.5)) < MAX_SHORT)
184  itemvector[new_index_id[i] - 1].speedCorr =
185  (short int)((dataOffset - new_chipPulse[i]) * CHIP_FACTOR + 0.5 * (dataOffset >= new_chipPulse[i]) -
186  0.5 * (dataOffset < new_chipPulse[i]));
187  // printf("i= %d \t new index id = %d \t corr = %f \n",i,new_index_id[i],
188  // new_chipPulse[i]);
189  }
190 
191  // For now, calculate the mean chip correction and use it for all chambers
192  // that don't have calibration pulse data (speedCorr ==0) or had values of
193  // zero (speedCorr == dataOffset) This should be a temporary fix until all
194  // chips that will read out in data have calibration information Since there
195  // is only a handful out of 15K chips with values more than 3 ns away from the
196  // average, this is probably very safe to first order
197  float ave = runningTotal / numNonZero;
198  for (int i = 0; i < MAX_SIZE; i++) {
199  if (itemvector[i].speedCorr == 0 || itemvector[i].speedCorr == (short int)(dataOffset * CHIP_FACTOR + 0.5))
200  itemvector[i].speedCorr =
201  (short int)((dataOffset - ave) * CHIP_FACTOR + 0.5 * (dataOffset >= ave) - 0.5 * (dataOffset < ave));
202  }
203 
204  return cndbChipCorr;
205 }
float dt
Definition: AMPTWrapper.h:136
CSCDetId detIdFromChamberIndex(IndexType ici) const
Definition: CSCIndexer.cc:69
assert(be >=bs)
dictionary isMC
Definition: PV_cfg.py:29
IndexType chipIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType ichip) const
Definition: CSCIndexer.h:234
int chamber() const
Definition: CSCDetId.h:62
int station() const
Definition: CSCDetId.h:79
int endcap() const
Definition: CSCDetId.h:85
constexpr unsigned int MAX_SIZE
std::vector< Item > ChipSpeedContainer
int ring() const
Definition: CSCDetId.h:68

◆ produceDBChipSpeedCorrection()

CSCChipSpeedCorrectionDBConditions::ReturnType CSCChipSpeedCorrectionDBConditions::produceDBChipSpeedCorrection ( const CSCDBChipSpeedCorrectionRcd iRecord)

Definition at line 30 of file CSCChipSpeedCorrectionDBConditions.cc.

References dataCorrFileName, dataOffset, isForMC, and prefillDBChipSpeedCorrection().

Referenced by CSCChipSpeedCorrectionDBConditions().

31  {
32  // need a new object so to not be deleted at exit
35 }
static CSCDBChipSpeedCorrection * prefillDBChipSpeedCorrection(bool isForMC, std::string dataCorrFileName, float dataOffse)
std::unique_ptr< CSCDBChipSpeedCorrection > ReturnType

◆ setIntervalFor()

void CSCChipSpeedCorrectionDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 37 of file CSCChipSpeedCorrectionDBConditions.cc.

References edm::IOVSyncValue::beginOfTime(), and edm::IOVSyncValue::endOfTime().

39  {
41 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88

Member Data Documentation

◆ cndbChipCorr

CSCDBChipSpeedCorrection* CSCChipSpeedCorrectionDBConditions::cndbChipCorr
private

Definition at line 39 of file CSCChipSpeedCorrectionDBConditions.h.

Referenced by prefillDBChipSpeedCorrection().

◆ dataCorrFileName

std::string CSCChipSpeedCorrectionDBConditions::dataCorrFileName
private

◆ dataOffset

float CSCChipSpeedCorrectionDBConditions::dataOffset
private

◆ isForMC

bool CSCChipSpeedCorrectionDBConditions::isForMC
private