CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
EcalTestDevDB Class Reference

#include <EcalTestDevDB.h>

Inheritance diagram for EcalTestDevDB:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup)
 
 EcalTestDevDB (const edm::ParameterSet &iConfig)
 
EcalADCToGeVConstantgenerateEcalADCToGeVConstant ()
 
EcalGainRatiosgenerateEcalGainRatios ()
 
EcalIntercalibConstantsgenerateEcalIntercalibConstants ()
 
EcalLaserAlphasgenerateEcalLaserAlphas ()
 
EcalLaserAPDPNRatiosgenerateEcalLaserAPDPNRatios (uint32_t i_run)
 
EcalLaserAPDPNRatiosRefgenerateEcalLaserAPDPNRatiosRef ()
 
EcalLinearCorrectionsgenerateEcalLinearCorrections ()
 
EcalPedestalsgenerateEcalPedestals ()
 
EcalTBWeightsgenerateEcalTBWeights ()
 
EcalWeightXtalGroupsgenerateEcalWeightXtalGroups ()
 
 ~EcalTestDevDB ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::map< std::string,
unsigned long long > 
m_cacheIDs
 
unsigned long m_firstRun
 
unsigned int m_interval
 
unsigned long m_lastRun
 
std::map< std::string,
std::string > 
m_records
 
std::string m_timetype
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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

Definition at line 40 of file EcalTestDevDB.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file EcalTestDevDB.cc.

References edm::ParameterSet::getParameter(), i, m_cacheIDs, m_firstRun, m_interval, m_lastRun, m_records, record, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and copyFileAlignEB_cfg::toCopy.

25  :
26  m_timetype(iConfig.getParameter<std::string>("timetype")),
27  m_cacheIDs(),
28  m_records()
29 {
30 
31  std::string container;
34 
35  m_firstRun=static_cast<unsigned long>(atoi( iConfig.getParameter<std::string>("firstRun").c_str()));
36  m_lastRun=static_cast<unsigned long>(atoi( iConfig.getParameter<std::string>("lastRun").c_str()));
37  m_interval=static_cast<unsigned long>(atoi( iConfig.getParameter<std::string>("interval").c_str()));
38 
39  typedef std::vector< edm::ParameterSet > Parameters;
40  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
41  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
42  container = i->getParameter<std::string>("container");
43  record = i->getParameter<std::string>("record");
44  m_cacheIDs.insert( std::make_pair(container, 0) );
45  m_records.insert( std::make_pair(container, record) );
46  }
47 
48 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
JetCorrectorParameters::Record record
Definition: classes.h:7
std::map< std::string, std::string > m_records
Definition: EcalTestDevDB.h:64
unsigned long m_lastRun
Definition: EcalTestDevDB.h:66
vector< ParameterSet > Parameters
std::string m_timetype
Definition: EcalTestDevDB.h:62
unsigned int m_interval
Definition: EcalTestDevDB.h:67
unsigned long m_firstRun
Definition: EcalTestDevDB.h:65
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalTestDevDB.h:63
EcalTestDevDB::~EcalTestDevDB ( )

Definition at line 51 of file EcalTestDevDB.cc.

52 {
53 
54 }

Member Function Documentation

void EcalTestDevDB::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 56 of file EcalTestDevDB.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), edm::IOVSyncValue::endOfTime(), cond::service::PoolDBOutputService::endOfTime(), edm::IOVSyncValue::eventID(), edm::hlt::Exception, generateEcalADCToGeVConstant(), generateEcalGainRatios(), generateEcalIntercalibConstants(), generateEcalLaserAlphas(), generateEcalLaserAPDPNRatios(), generateEcalLaserAPDPNRatiosRef(), generateEcalLinearCorrections(), generateEcalPedestals(), generateEcalTBWeights(), generateEcalWeightXtalGroups(), i, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), m_firstRun, m_interval, m_lastRun, m_records, record, ecalTPGAnalyzer_cfg::recordName, edm::EventID::run(), and AlCaHLTBitMon_QueryRunRegistry::string.

57 {
58 
60  if ( !dbOutput.isAvailable() ) {
61  throw cms::Exception("PoolDBOutputService is not available");
62  }
63 
64 
65 
66  std::string container;
68  typedef std::map<std::string, std::string>::const_iterator recordIter;
69  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
70  container = (*i).first;
71  record = (*i).second;
72 
73  std::string recordName = m_records[container];
74 
75 
76  // Loop through each of the runs
77 
78  unsigned long nrec=(m_lastRun-m_firstRun)/m_interval+1;
79  unsigned long nstart=0;
80  if (m_firstRun == 0 && m_lastRun == 0) {
81  // it should do at least once the loop
82  nstart=0;
83  nrec=1;
84  }
85 
86  for(unsigned long i=nstart; i<nrec; i++) {
87  unsigned long irun=m_firstRun+i*m_interval;
88 
89 
90  // Arguments 0 0 mean infinite IOV
91  if (m_firstRun == 0 && m_lastRun == 0) {
92  std::cout << "Infinite IOV mode" << std::endl;
94  }
95 
96  std::cout << "Starting Transaction for run " << irun << "..." << std::flush;
97 
98  if (container == "EcalPedestals") {
99  EcalPedestals* condObject= generateEcalPedestals();
100 
101  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
102  // create new
103  std::cout<<"First One "<<std::endl;
104  dbOutput->createNewIOV<const EcalPedestals>( condObject, dbOutput->beginOfTime(),dbOutput->endOfTime() ,recordName);
105  } else {
106  // append
107  std::cout<<"Old One "<<std::endl;
108  dbOutput->appendSinceTime<const EcalPedestals>( condObject, irun , recordName);
109  }
110 
111  } else if (container == "EcalADCToGeVConstant") {
112 
114  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
115  // create new
116  std::cout<<"First One "<<std::endl;
117  dbOutput->createNewIOV<const EcalADCToGeVConstant>( condObject, dbOutput->beginOfTime(),dbOutput->endOfTime() ,recordName);
118  } else {
119  // append
120  std::cout<<"Old One "<<std::endl;
121  dbOutput->appendSinceTime<const EcalADCToGeVConstant>( condObject, irun , recordName);
122  }
123 
124 
125  } else if (container == "EcalIntercalibConstants") {
127  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
128  // create new
129  std::cout<<"First One "<<std::endl;
130  dbOutput->createNewIOV<const EcalIntercalibConstants>( condObject, dbOutput->beginOfTime(),dbOutput->endOfTime() ,recordName);
131  } else {
132  // append
133  std::cout<<"Old One "<<std::endl;
134  dbOutput->appendSinceTime<const EcalIntercalibConstants>( condObject, irun , recordName);
135  }
136  } else if (container == "EcalLinearCorrections") {
138  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
139  // create new
140  std::cout<<"First One "<<std::endl;
141  dbOutput->createNewIOV<const EcalLinearCorrections>( condObject, dbOutput->beginOfTime(),dbOutput->endOfTime() ,recordName);
142  } else {
143  // append
144  std::cout<<"Old One "<<std::endl;
145  dbOutput->appendSinceTime<const EcalLinearCorrections>( condObject, irun , recordName);
146  }
147 
148  } else if (container == "EcalGainRatios") {
149  EcalGainRatios* condObject= generateEcalGainRatios();
150  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
151  // create new
152  std::cout<<"First One "<<std::endl;
153  dbOutput->createNewIOV<const EcalGainRatios>( condObject,dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
154  } else {
155  // append
156  std::cout<<"Old One "<<std::endl;
157  dbOutput->appendSinceTime<const EcalGainRatios>( condObject, irun , recordName);
158  }
159 
160  } else if (container == "EcalWeightXtalGroups") {
162  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
163  // create new
164  std::cout<<"First One "<<std::endl;
165  dbOutput->createNewIOV<const EcalWeightXtalGroups>( condObject, dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
166  } else {
167  // append
168  std::cout<<"Old One "<<std::endl;
169  dbOutput->appendSinceTime<const EcalWeightXtalGroups>( condObject, irun , recordName);
170  }
171 
172  } else if (container == "EcalTBWeights") {
173  EcalTBWeights* condObject= generateEcalTBWeights();
174  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
175  // create new
176  std::cout<<"First One "<<std::endl;
177  dbOutput->createNewIOV<const EcalTBWeights>( condObject, dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
178  } else {
179  // append
180  std::cout<<"Old One "<<std::endl;
181  dbOutput->appendSinceTime<const EcalTBWeights>( condObject, irun , recordName);
182  }
183 
184  } else if (container == "EcalLaserAPDPNRatios") {
186  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
187  // create new
188  std::cout<<"First One "<<std::endl;
189  dbOutput->createNewIOV<const EcalLaserAPDPNRatios>( condObject,dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
190  } else {
191  // append
192  std::cout<<"Old One "<<std::endl;
193  dbOutput->appendSinceTime<const EcalLaserAPDPNRatios>( condObject, irun , recordName);
194  }
195  } else if (container == "EcalLaserAPDPNRatiosRef") {
197  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
198  // create new
199  std::cout<<"First One "<<std::endl;
200  dbOutput->createNewIOV<const EcalLaserAPDPNRatiosRef>( condObject, dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
201  } else {
202  // append
203  std::cout<<"Old One "<<std::endl;
204  dbOutput->appendSinceTime<const EcalLaserAPDPNRatiosRef>( condObject, irun , recordName);
205  }
206  } else if (container == "EcalLaserAlphas") {
208  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
209  // create new
210  std::cout<<"First One "<<std::endl;
211  dbOutput->createNewIOV<const EcalLaserAlphas>( condObject,dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
212  } else {
213  // append
214  std::cout<<"Old One "<<std::endl;
215  dbOutput->appendSinceTime<const EcalLaserAlphas>( condObject, irun , recordName);
216  }
217  } else {
218  std::cout << "it does not work yet for " << container << "..." << std::flush;
219 
220  }
221 
222 
223  }
224 
225 
226  }
227 
228 
229 }
RunNumber_t run() const
Definition: EventID.h:39
int i
Definition: DBlmapReader.cc:9
const EventID & eventID() const
Definition: IOVSyncValue.h:42
JetCorrectorParameters::Record record
Definition: classes.h:7
EcalLaserAlphas * generateEcalLaserAlphas()
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::map< std::string, std::string > m_records
Definition: EcalTestDevDB.h:64
EcalLaserAPDPNRatiosRef * generateEcalLaserAPDPNRatiosRef()
unsigned long m_lastRun
Definition: EcalTestDevDB.h:66
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:46
EcalWeightXtalGroups * generateEcalWeightXtalGroups()
EcalLinearCorrections * generateEcalLinearCorrections()
EcalLaserAPDPNRatios * generateEcalLaserAPDPNRatios(uint32_t i_run)
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
unsigned int m_interval
Definition: EcalTestDevDB.h:67
unsigned long m_firstRun
Definition: EcalTestDevDB.h:65
EcalTBWeights * generateEcalTBWeights()
EcalGainRatios * generateEcalGainRatios()
EcalPedestals * generateEcalPedestals()
EcalADCToGeVConstant * generateEcalADCToGeVConstant()
tuple cout
Definition: gather_cfg.py:121
EcalIntercalibConstants * generateEcalIntercalibConstants()
EcalADCToGeVConstant * EcalTestDevDB::generateEcalADCToGeVConstant ( )

Definition at line 258 of file EcalTestDevDB.cc.

References alignCSCRings::r, and rand().

Referenced by analyze().

258  {
259 //-------------------------------------------------------------
260 
261  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
262  EcalADCToGeVConstant* agc = new EcalADCToGeVConstant(36.+r*4., 60.+r*4);
263  return agc;
264 }
Signal rand(Signal arg)
Definition: vlib.cc:442
EcalGainRatios * EcalTestDevDB::generateEcalGainRatios ( )

Definition at line 358 of file EcalTestDevDB.cc.

References EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, alignCSCRings::r, rand(), DetId::rawId(), EcalMGPAGainRatio::setGain12Over6(), EcalMGPAGainRatio::setGain6Over1(), and EcalCondObjectContainer< T >::setValue().

Referenced by analyze().

358  {
359 //-------------------------------------------------------------
360 
361  // create gain ratios
362  EcalGainRatios* gratio = new EcalGainRatios;
363 
364  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
365  if(ieta==0) continue;
366  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId:: MAX_IPHI; ++iphi) {
367 
368  EBDetId ebid(ieta,iphi);
369 
370  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
371 
373  gr.setGain12Over6( 1.9 + r*0.2 );
374  gr.setGain6Over1( 5.9 + r*0.2 );
375 
376  gratio->setValue( ebid.rawId(), gr );
377 
378  } // loop over phi
379  } // loop over eta
380  return gratio;
381 }
static const int MIN_IPHI
Definition: EBDetId.h:142
void setGain12Over6(const float &g)
void setValue(const uint32_t id, const Item &item)
EcalGainRatioMap EcalGainRatios
static const int MAX_IPHI
Definition: EBDetId.h:144
static const int MAX_IETA
Definition: EBDetId.h:143
Signal rand(Signal arg)
Definition: vlib.cc:442
void setGain6Over1(const float &g)
EcalIntercalibConstants * EcalTestDevDB::generateEcalIntercalibConstants ( )

Definition at line 268 of file EcalTestDevDB.cc.

References EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, alignCSCRings::r, rand(), DetId::rawId(), and EcalCondObjectContainer< T >::setValue().

Referenced by analyze().

268  {
269 //-------------------------------------------------------------
270 
272 
273  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
274  if(ieta==0) continue;
275  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId:: MAX_IPHI; ++iphi) {
276 
277  EBDetId ebid(ieta,iphi);
278 
279  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
280  ical->setValue( ebid.rawId(), 0.85 + r*0.3 );
281  } // loop over phi
282  } // loop over eta
283  return ical;
284 }
static const int MIN_IPHI
Definition: EBDetId.h:142
void setValue(const uint32_t id, const Item &item)
static const int MAX_IPHI
Definition: EBDetId.h:144
static const int MAX_IETA
Definition: EBDetId.h:143
EcalIntercalibConstantMap EcalIntercalibConstants
Signal rand(Signal arg)
Definition: vlib.cc:442
EcalLaserAlphas * EcalTestDevDB::generateEcalLaserAlphas ( )

Definition at line 666 of file EcalTestDevDB.cc.

References EcalCondObjectContainer< T >::getMap(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, EcalCondDBWriter_cfi::laser, EBDetId::MAX_HASH, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalCondObjectContainer< T >::setValue(), EcalCondObjectContainer< T >::size(), and EEDetId::validDetId().

Referenced by analyze().

666  {
667 //--------------------------------------------------------------
668 
670 
671  EcalLaserAlpha Alpha;
672 
673  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
674  if(iEta==0) continue;
675  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
676  Alpha = double(1.55);
677  EBDetId ebid(iEta,iPhi);
678 
679  int hi = ebid.hashedIndex();
680  if (hi< static_cast<int>(laser->getMap().size())) {
681  laser->setValue(hi, Alpha);
682  } else {
683  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!" << std::endl;
684  }
685  }
686  }
687 
688  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
689  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
690 
691  if (!EEDetId::validDetId(iX,iY,1))
692  continue;
693 
694  EEDetId eedetidpos(iX,iY,1);
695  Alpha = double(1.55);
696 
697  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
698  if (hi< static_cast<int>(laser->getMap().size())) {
699  laser->setValue(hi, Alpha);
700  } else {
701  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!" << std::endl;
702  }
703 
704  if (!EEDetId::validDetId(iX,iY,-1))
705  continue;
706  EEDetId eedetidneg(iX,iY,-1);
707  Alpha = double(1.55);
708 
709  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
710  if (hi< static_cast<int>(laser->getMap().size())) {
711  laser->setValue(hi, Alpha);
712  } else {
713  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!" << std::endl;
714  }
715  }
716  }
717 
718  return laser;
719 }
float EcalLaserAlpha
static const int MIN_IPHI
Definition: EBDetId.h:142
const self & getMap() const
static const int MAX_HASH
Definition: EBDetId.h:157
static const int IX_MIN
Definition: EEDetId.h:294
static const int IY_MIN
Definition: EEDetId.h:298
void setValue(const uint32_t id, const Item &item)
EcalLaserAlphaMap EcalLaserAlphas
static const int IX_MAX
Definition: EEDetId.h:302
static const int MAX_IPHI
Definition: EBDetId.h:144
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:143
static const int IY_MAX
Definition: EEDetId.h:306
EcalLaserAPDPNRatios * EcalTestDevDB::generateEcalLaserAPDPNRatios ( uint32_t  i_run)

Definition at line 451 of file EcalTestDevDB.cc.

References gather_cfg::cout, create_public_lumi_plots::exp, EcalLaserAPDPNRatios::getLaserMap(), EcalLaserAPDPNRatios::getTimeMap(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), i, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, EcalCondDBWriter_cfi::laser, create_public_lumi_plots::log, m_firstRun, m_lastRun, EBDetId::MAX_HASH, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, EcalLaserAPDPNRatios::setTime(), EcalLaserAPDPNRatios::setValue(), EcalCondObjectContainer< T >::size(), EcalLaserAPDPNRatios::EcalLaserTimeStamp::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t2, and EEDetId::validDetId().

Referenced by analyze().

451  {
452 //--------------------------------------------------------------
453 
455 
458 
459  // if((m_firstRun == 0 && i_run == 0) || (m_firstRun == 1 && i_run == 1)){
460 
461  std::cout << "First & last run: " << i_run << " " << m_firstRun << " " << m_lastRun << " " << std::endl;
462  if (m_firstRun == i_run && (i_run == 0 || i_run == 1) ) {
463 
464  APDPNpair.p1= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10))))/double(2);
465  APDPNpair.p2= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10)+double(10))))/double(2);
466  APDPNpair.p3= double(0);
467  std::cout << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2 << std::endl;
468 
469  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
470  if(iEta==0) continue;
471  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
472  //APDPNpair.p1= double(1);
473  //APDPNpair.p2= double(1);
474 
475  EBDetId ebid(iEta,iPhi);
476  int hi = ebid.hashedIndex();
477 
478  if (hi< static_cast<int>(laser->getLaserMap().size())) {
479  laser->setValue(hi, APDPNpair);
480  } else {
481  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
482  continue;
483  }
484  }
485  }
486 
487  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
488  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
489  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
490 
491  if (!EEDetId::validDetId(iX,iY,1))
492  continue;
493 
494  EEDetId eedetidpos(iX,iY,1);
495  //APDPNpair.p1 = double(1);
496  //APDPNpair.p2 = double(1);
497 
498  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
499  if (hi< static_cast<int>(laser->getLaserMap().size())) {
500  laser->setValue(hi, APDPNpair);
501  } else {
502  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
503  continue;
504  }
505 
506  if (!EEDetId::validDetId(iX,iY,-1))
507  continue;
508 
509  EEDetId eedetidneg(iX,iY,-1);
510  //APDPNpair.p1 = double(1);
511  //APDPNpair.p2 = double(1);
512  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
513  if (hi< static_cast<int>(laser->getLaserMap().size())) {
514  laser->setValue(hi, APDPNpair);
515  } else {
516  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
517  continue;
518  }
519  }
520  }
521 
522  std::cout << std::endl;
523  for(int i=0; i<92; i++){
524  if (i< static_cast<int>(laser->getTimeMap().size())) {
525  TimeStamp.t1 = edm::Timestamp(1380*(i_run-m_firstRun) + 15*i);
526  TimeStamp.t2 = edm::Timestamp(1380*(i_run-m_firstRun + 1) + 15*i);
527  laser->setTime(i, TimeStamp);
528  //std::cout << " Timestamp for " << i << " : " << TimeStamp.t1.value() << " , " << TimeStamp.t2.value() << std::endl;
529  } else {
530  edm::LogError("EcalTestDevDB") << "error with laser Map (time)!" << std::endl;
531  continue;
532  }
533  }
534 
535  }else{
536 
537  APDPNpair.p1= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10))))/double(2);
538  APDPNpair.p2= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10)+double(10))))/double(2);
539  APDPNpair.p3= double(0);
540  std::cout << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2 << std::endl;
541 
542  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
543  if(iEta==0) continue;
544  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
545  EBDetId ebid(iEta,iPhi);
546  int hi = ebid.hashedIndex();
547 
548  if (hi< static_cast<int>(laser->getLaserMap().size())) {
549  laser->setValue(hi, APDPNpair);
550  } else {
551  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
552  }
553  }
554  }
555  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
556  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
557  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
558 
559  if (!EEDetId::validDetId(iX,iY,1))
560  continue;
561 
562  EEDetId eedetidpos(iX,iY,1);
563  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
564  if (hi< static_cast<int>(laser->getLaserMap().size())) {
565  laser->setValue(hi, APDPNpair);
566  } else {
567  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
568  continue;
569  }
570 
571  if (!EEDetId::validDetId(iX,iY,-1))
572  continue;
573 
574  EEDetId eedetidneg(iX,iY,-1);
575  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
576  if (hi< static_cast<int>(laser->getLaserMap().size())) {
577  laser->setValue(hi, APDPNpair);
578  } else {
579  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
580  continue;
581  }
582  }
583  }
584 
585  std::cout << std::endl;
586  for(int i=0; i<92; i++){
587  if (i< static_cast<int>(laser->getTimeMap().size())) {
588  TimeStamp.t1 = edm::Timestamp(1380*(i_run-m_firstRun) + 15*i);
589  TimeStamp.t2 = edm::Timestamp(1380*(i_run-m_firstRun + 1) + 15*i);
590  laser->setTime(i, TimeStamp);
591  //std::cout << " Timestamp for " << i << " : " << TimeStamp.t1.value() << " , " << TimeStamp.t2.value() << std::endl;
592  } else {
593  edm::LogError("EcalTestDevDB") << "error with laser Map (time)!" << std::endl;
594  continue;
595  }
596  }
597 
598  }
599 
600  return laser;
601 }
int i
Definition: DBlmapReader.cc:9
static const int MIN_IPHI
Definition: EBDetId.h:142
static const int MAX_HASH
Definition: EBDetId.h:157
static const int IX_MIN
Definition: EEDetId.h:294
unsigned long m_lastRun
Definition: EcalTestDevDB.h:66
static const int IY_MIN
Definition: EEDetId.h:298
const EcalLaserAPDPNRatiosMap & getLaserMap() const
void setTime(int hashedIndex, const EcalLaserTimeStamp &value)
static const int IX_MAX
Definition: EEDetId.h:302
unsigned long m_firstRun
Definition: EcalTestDevDB.h:65
static const int MAX_IPHI
Definition: EBDetId.h:144
const EcalLaserTimeStampMap & getTimeMap() const
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:143
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
tuple cout
Definition: gather_cfg.py:121
static const int IY_MAX
Definition: EEDetId.h:306
EcalLaserAPDPNRatiosRef * EcalTestDevDB::generateEcalLaserAPDPNRatiosRef ( )

Definition at line 606 of file EcalTestDevDB.cc.

References EcalCondObjectContainer< T >::getMap(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, EcalCondDBWriter_cfi::laser, EBDetId::MAX_HASH, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalCondObjectContainer< T >::setValue(), EcalCondObjectContainer< T >::size(), and EEDetId::validDetId().

Referenced by analyze().

606  {
607 //--------------------------------------------------------------
608 
610 
611  EcalLaserAPDPNref APDPNref;
612 
613 
614  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
615  if(iEta==0) continue;
616  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
617  APDPNref=double(1.5);
618  EBDetId ebid(iEta,iPhi);
619 
620  int hi = ebid.hashedIndex();
621  if (hi< static_cast<int>(laser->getMap().size())) {
622  laser->setValue(hi, APDPNref);
623  } else {
624  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!" << std::endl;
625  }
626 
627  }
628  }
629 
630  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
631  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
632 
633  if (!EEDetId::validDetId(iX,iY,1))
634  continue;
635 
636  EEDetId eedetidpos(iX,iY,1);
637  APDPNref=double(1.5);
638 
639  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
640  if (hi< static_cast<int>(laser->getMap().size())) {
641  laser->setValue(hi, APDPNref);
642  } else {
643  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!" << std::endl;
644  }
645 
646  if (!EEDetId::validDetId(iX,iY,-1))
647  continue;
648 
649  EEDetId eedetidneg(iX,iY,-1);
650  APDPNref=double(1.5);
651 
652  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
653  if (hi< static_cast<int>(laser->getMap().size())) {
654  laser->setValue(hi, APDPNref);
655  } else {
656  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!" << std::endl;
657  }
658  }
659  }
660 
661  return laser;
662 }
static const int MIN_IPHI
Definition: EBDetId.h:142
const self & getMap() const
static const int MAX_HASH
Definition: EBDetId.h:157
EcalLaserAPDPNRatiosRefMap EcalLaserAPDPNRatiosRef
static const int IX_MIN
Definition: EEDetId.h:294
float EcalLaserAPDPNref
static const int IY_MIN
Definition: EEDetId.h:298
void setValue(const uint32_t id, const Item &item)
static const int IX_MAX
Definition: EEDetId.h:302
static const int MAX_IPHI
Definition: EBDetId.h:144
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:143
static const int IY_MAX
Definition: EEDetId.h:306
EcalLinearCorrections * EcalTestDevDB::generateEcalLinearCorrections ( )

Definition at line 288 of file EcalTestDevDB.cc.

References edm::Timestamp::endOfTime(), i, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalTimeDependentCorrections::Values::p1, EcalTimeDependentCorrections::Values::p2, EcalTimeDependentCorrections::Values::p3, EcalTimeDependentCorrections::setTime(), EcalTimeDependentCorrections::setValue(), EcalTimeDependentCorrections::Times::t1, EcalTimeDependentCorrections::Times::t2, EcalTimeDependentCorrections::Times::t3, EBDetId::validDetId(), EEDetId::validDetId(), and relativeConstraints::value.

Referenced by analyze().

288  {
289 //-------------------------------------------------------------
290 
292 
293  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
294  if(ieta==0) continue;
295  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
296  if (EBDetId::validDetId(ieta,iphi)) {
297  EBDetId ebid(ieta,iphi);
298 
299 
301  pairAPDPN.p1 = 1.0;
302  pairAPDPN.p2 = 1.0;
303  pairAPDPN.p3 = 1.0;
304  ical->setValue( ebid, pairAPDPN );
305  }
306  }
307  }
308 
309  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
310  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
311  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
312  if (EEDetId::validDetId(iX,iY,1)) {
313 
314  EEDetId eedetidpos(iX,iY,1);
315 
317  pairAPDPN.p1 = 1.0;
318  pairAPDPN.p2 = 1.0;
319  pairAPDPN.p3 = 1.0;
320 
321  ical->setValue( eedetidpos, pairAPDPN );
322  }
323 
324  if (EEDetId::validDetId(iX,iY,-1)) {
325 
326  EEDetId eedetidneg(iX,iY,-1);
327 
329  pairAPDPN.p1 = 1.0;
330  pairAPDPN.p2 = 1.0;
331  pairAPDPN.p3 = 1.0;
332 
333  ical->setValue( eedetidneg, pairAPDPN );
334  }
335  }
336  }
337 
339  for(int i=0; i<92; i++){
340 
341  TimeStamp.t1 = edm::Timestamp(0);
344 
345  ical->setTime(i, TimeStamp);
346 
347 
348  }
349 
350 
351 
352 
353  return ical;
354 }
int i
Definition: DBlmapReader.cc:9
static const int MIN_IPHI
Definition: EBDetId.h:142
static Timestamp endOfTime()
Definition: Timestamp.h:102
void setValue(uint32_t rawId, const Values &value)
EcalTimeDependentCorrections EcalLinearCorrections
static const int IX_MIN
Definition: EEDetId.h:294
void setTime(int hashedIndex, const Times &value)
static const int IY_MIN
Definition: EEDetId.h:298
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:124
static const int IX_MAX
Definition: EEDetId.h:302
static const int MAX_IPHI
Definition: EBDetId.h:144
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:143
static const int IY_MAX
Definition: EEDetId.h:306
EcalPedestals * EcalTestDevDB::generateEcalPedestals ( )

Definition at line 234 of file EcalTestDevDB.cc.

References EcalCondObjectContainer< T >::insert(), EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EcalPedestal::mean_x1, EcalPedestal::mean_x12, EcalPedestal::mean_x6, EBDetId::MIN_IPHI, rand(), DetId::rawId(), EcalPedestal::rms_x1, EcalPedestal::rms_x12, and EcalPedestal::rms_x6.

Referenced by analyze().

234  {
235 //-------------------------------------------------------------
236 
237  EcalPedestals* peds = new EcalPedestals();
238  EcalPedestals::Item item;
239  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
240  if(iEta==0) continue;
241  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
242  item.mean_x1 = 200.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
243  item.rms_x1 = (double)std::rand()/(double(RAND_MAX)+double(1));
244  item.mean_x6 = 1200.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
245  item.rms_x6 = 6.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
246  item.mean_x12 = 2400.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
247  item.rms_x12 = 12.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
248 
249  EBDetId ebdetid(iEta,iPhi);
250  peds->insert(std::make_pair(ebdetid.rawId(),item));
251  }
252  }
253  return peds;
254 }
static const int MIN_IPHI
Definition: EBDetId.h:142
void insert(std::pair< uint32_t, Item > const &a)
EcalPedestalsMap EcalPedestals
Definition: EcalPedestals.h:53
static const int MAX_IPHI
Definition: EBDetId.h:144
static const int MAX_IETA
Definition: EBDetId.h:143
Signal rand(Signal arg)
Definition: vlib.cc:442
EcalTBWeights * EcalTestDevDB::generateEcalTBWeights ( )

Definition at line 401 of file EcalTestDevDB.cc.

References EcalWeightSet::getChi2WeightsAfterGainSwitch(), EcalWeightSet::getChi2WeightsBeforeGainSwitch(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), i, j, EBDetId::MAX_IETA, alignCSCRings::r, rand(), and EcalTBWeights::setValue().

Referenced by analyze().

401  {
402 //-------------------------------------------------------------
403 
404  EcalTBWeights* tbwgt = new EcalTBWeights();
405 
406  // create weights for each distinct group ID
407  int nMaxTDC = 10;
408  for(int igrp=-EBDetId::MAX_IETA; igrp<=EBDetId::MAX_IETA; ++igrp) {
409  if(igrp==0) continue;
410  for(int itdc=1; itdc<=nMaxTDC; ++itdc) {
411  // generate random number
412  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
413 
414  // make a new set of weights
415  EcalWeightSet wgt;
418 
419  for(size_t i=0; i<3; ++i) {
420  for(size_t j=0; j<10; ++j) {
421  double ww = igrp*itdc*r + i*10. + j;
422  //std::cout << "row: " << i << " col: " << j << " - val: " << ww << std::endl;
423  mat1(i,j)=ww;
424  mat2(i,j)=100+ww;
425  }
426  }
427 
428  // fill the chi2 matrcies
429  r = (double)std::rand()/( double(RAND_MAX)+double(1) );
432  for(size_t i=0; i<10; ++i) {
433  for(size_t j=0; j<10; ++j) {
434  double ww = igrp*itdc*r + i*10. + j;
435  mat3(i,j)=1000+ww;
436  mat4(i,j)=1000+100+ww;
437  }
438  }
439 
440  // put the weight in the container
441  tbwgt->setValue(std::make_pair(igrp,itdc), wgt);
442  }
443  }
444  return tbwgt;
445 }
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:31
int i
Definition: DBlmapReader.cc:9
void setValue(const EcalXtalGroupId &groupId, const EcalTDCId &tdcId, const EcalWeightSet &weight)
int j
Definition: DBlmapReader.cc:9
EcalChi2WeightMatrix & getChi2WeightsAfterGainSwitch()
Definition: EcalWeightSet.h:32
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:30
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:23
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:29
static const int MAX_IETA
Definition: EBDetId.h:143
Signal rand(Signal arg)
Definition: vlib.cc:442
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:22
EcalWeightXtalGroups * EcalTestDevDB::generateEcalWeightXtalGroups ( )

Definition at line 385 of file EcalTestDevDB.cc.

References EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, DetId::rawId(), and EcalCondObjectContainer< T >::setValue().

Referenced by analyze().

385  {
386 //-------------------------------------------------------------
387 
388  EcalWeightXtalGroups* xtalGroups = new EcalWeightXtalGroups();
389  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
390  if(ieta==0) continue;
391  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId:: MAX_IPHI; ++iphi) {
392  EBDetId ebid(ieta,iphi);
393  xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId(ieta) ); // define rings in eta
394  }
395  }
396  return xtalGroups;
397 }
static const int MIN_IPHI
Definition: EBDetId.h:142
EcalCondObjectContainer< EcalXtalGroupId > EcalWeightXtalGroups
void setValue(const uint32_t id, const Item &item)
static const int MAX_IPHI
Definition: EBDetId.h:144
static const int MAX_IETA
Definition: EBDetId.h:143

Member Data Documentation

std::map<std::string, unsigned long long> EcalTestDevDB::m_cacheIDs
private

Definition at line 63 of file EcalTestDevDB.h.

Referenced by EcalTestDevDB().

unsigned long EcalTestDevDB::m_firstRun
private

Definition at line 65 of file EcalTestDevDB.h.

Referenced by analyze(), EcalTestDevDB(), and generateEcalLaserAPDPNRatios().

unsigned int EcalTestDevDB::m_interval
private

Definition at line 67 of file EcalTestDevDB.h.

Referenced by analyze(), and EcalTestDevDB().

unsigned long EcalTestDevDB::m_lastRun
private

Definition at line 66 of file EcalTestDevDB.h.

Referenced by analyze(), EcalTestDevDB(), and generateEcalLaserAPDPNRatios().

std::map<std::string, std::string> EcalTestDevDB::m_records
private

Definition at line 64 of file EcalTestDevDB.h.

Referenced by analyze(), and EcalTestDevDB().

std::string EcalTestDevDB::m_timetype
private

Definition at line 62 of file EcalTestDevDB.h.