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::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

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
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () 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::DataProxyProvider
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::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &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 TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
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::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
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.

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 }

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

◆ ~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.

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 }

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, submitPVValidationJobs::isMC, phase1PixelTopology::layer, pixelgpudetails::MAX_SIZE, CSCDetId::ring(), relativeConstraints::ring, relativeConstraints::station, CSCDetId::station(), and submitPVValidationJobs::t.

Referenced by produceDBChipSpeedCorrection().

◆ produceDBChipSpeedCorrection()

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

Definition at line 30 of file CSCChipSpeedCorrectionDBConditions.cc.

31  {
32  // need a new object so to not be deleted at exit
35 }

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

Referenced by CSCChipSpeedCorrectionDBConditions().

◆ setIntervalFor()

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

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
CSCDBChipSpeedCorrection
Definition: CSCDBChipSpeedCorrection.h:9
mps_fire.i
i
Definition: mps_fire.py:428
CSCChipSpeedCorrectionDBConditions::dataCorrFileName
std::string dataCorrFileName
Definition: CSCChipSpeedCorrectionDBConditions.h:45
CSCChipSpeedCorrectionDBConditions::prefillDBChipSpeedCorrection
static CSCDBChipSpeedCorrection * prefillDBChipSpeedCorrection(bool isForMC, std::string dataCorrFileName, float dataOffse)
Definition: CSCChipSpeedCorrectionDBConditions.h:58
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
cms::cuda::assert
assert(be >=bs)
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
CSCChipSpeedCorrectionDBConditions::ReturnType
std::unique_ptr< CSCDBChipSpeedCorrection > ReturnType
Definition: CSCChipSpeedCorrectionDBConditions.h:30
CSCDBChipSpeedCorrection::chipSpeedCorr
ChipSpeedContainer chipSpeedCorr
Definition: CSCDBChipSpeedCorrection.h:24
dt
float dt
Definition: AMPTWrapper.h:136
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
submitPVValidationJobs.isMC
list isMC
Definition: submitPVValidationJobs.py:658
CSCDBChipSpeedCorrection::ChipSpeedContainer
std::vector< Item > ChipSpeedContainer
Definition: CSCDBChipSpeedCorrection.h:23
groupFilesInBlocks.fin
fin
Definition: groupFilesInBlocks.py:94
pixelgpudetails::MAX_SIZE
constexpr unsigned int MAX_SIZE
Definition: SiPixelROCsStatusAndMapping.h:10
CSCIndexer
Definition: CSCIndexer.h:44
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
CSCIndexer::detIdFromChamberIndex
CSCDetId detIdFromChamberIndex(IndexType ici) const
Definition: CSCIndexer.cc:61
CSCChipSpeedCorrectionDBConditions::cndbChipCorr
CSCDBChipSpeedCorrection * cndbChipCorr
Definition: CSCChipSpeedCorrectionDBConditions.h:39
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
CSCDetId
Definition: CSCDetId.h:26
createfilelist.int
int
Definition: createfilelist.py:10
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
CSCChipSpeedCorrectionDBConditions::isForMC
bool isForMC
Definition: CSCChipSpeedCorrectionDBConditions.h:42
CSCChipSpeedCorrectionDBConditions::produceDBChipSpeedCorrection
ReturnType produceDBChipSpeedCorrection(const CSCDBChipSpeedCorrectionRcd &)
Definition: CSCChipSpeedCorrectionDBConditions.cc:30
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
CSCIndexer::chipIndex
IndexType chipIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType ichip) const
Definition: CSCIndexer.h:234
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
CSCDBChipSpeedCorrection::factor_speedCorr
int factor_speedCorr
Definition: CSCDBChipSpeedCorrection.h:19
CSCChipSpeedCorrectionDBConditions::dataOffset
float dataOffset
Definition: CSCChipSpeedCorrectionDBConditions.h:46