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

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 ()
 
EcalPedestalsgenerateEcalPedestals ()
 
EcalTBWeightsgenerateEcalTBWeights ()
 
EcalWeightXtalGroupsgenerateEcalWeightXtalGroups ()
 
 ~EcalTestDevDB ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 38 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, 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;
32  std::string tag;
33  std::string record;
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:11
std::map< std::string, std::string > m_records
Definition: EcalTestDevDB.h:61
unsigned long m_lastRun
Definition: EcalTestDevDB.h:63
vector< ParameterSet > Parameters
std::string m_timetype
Definition: EcalTestDevDB.h:59
unsigned int m_interval
Definition: EcalTestDevDB.h:64
unsigned long m_firstRun
Definition: EcalTestDevDB.h:62
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalTestDevDB.h:60
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(), generateEcalPedestals(), generateEcalTBWeights(), generateEcalWeightXtalGroups(), i, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), m_firstRun, m_interval, m_lastRun, m_records, record, ecalTPGAnalyzer_cfg::recordName, and edm::EventID::run().

57 {
58 
60  if ( !dbOutput.isAvailable() ) {
61  throw cms::Exception("PoolDBOutputService is not available");
62  }
63 
64 
65 
66  std::string container;
67  std::string record;
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 
137  } else if (container == "EcalGainRatios") {
138  EcalGainRatios* condObject= generateEcalGainRatios();
139  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
140  // create new
141  std::cout<<"First One "<<std::endl;
142  dbOutput->createNewIOV<const EcalGainRatios>( condObject,dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
143  } else {
144  // append
145  std::cout<<"Old One "<<std::endl;
146  dbOutput->appendSinceTime<const EcalGainRatios>( condObject, irun , recordName);
147  }
148 
149  } else if (container == "EcalWeightXtalGroups") {
151  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
152  // create new
153  std::cout<<"First One "<<std::endl;
154  dbOutput->createNewIOV<const EcalWeightXtalGroups>( condObject, dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
155  } else {
156  // append
157  std::cout<<"Old One "<<std::endl;
158  dbOutput->appendSinceTime<const EcalWeightXtalGroups>( condObject, irun , recordName);
159  }
160 
161  } else if (container == "EcalTBWeights") {
162  EcalTBWeights* condObject= generateEcalTBWeights();
163  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
164  // create new
165  std::cout<<"First One "<<std::endl;
166  dbOutput->createNewIOV<const EcalTBWeights>( condObject, dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
167  } else {
168  // append
169  std::cout<<"Old One "<<std::endl;
170  dbOutput->appendSinceTime<const EcalTBWeights>( condObject, irun , recordName);
171  }
172 
173  } else if (container == "EcalLaserAPDPNRatios") {
175  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
176  // create new
177  std::cout<<"First One "<<std::endl;
178  dbOutput->createNewIOV<const EcalLaserAPDPNRatios>( condObject,dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
179  } else {
180  // append
181  std::cout<<"Old One "<<std::endl;
182  dbOutput->appendSinceTime<const EcalLaserAPDPNRatios>( condObject, irun , recordName);
183  }
184  } else if (container == "EcalLaserAPDPNRatiosRef") {
186  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
187  // create new
188  std::cout<<"First One "<<std::endl;
189  dbOutput->createNewIOV<const EcalLaserAPDPNRatiosRef>( condObject, dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
190  } else {
191  // append
192  std::cout<<"Old One "<<std::endl;
193  dbOutput->appendSinceTime<const EcalLaserAPDPNRatiosRef>( condObject, irun , recordName);
194  }
195  } else if (container == "EcalLaserAlphas") {
197  if(irun==m_firstRun && dbOutput->isNewTagRequest(recordName)) {
198  // create new
199  std::cout<<"First One "<<std::endl;
200  dbOutput->createNewIOV<const EcalLaserAlphas>( condObject,dbOutput->beginOfTime(), dbOutput->endOfTime() ,recordName);
201  } else {
202  // append
203  std::cout<<"Old One "<<std::endl;
204  dbOutput->appendSinceTime<const EcalLaserAlphas>( condObject, irun , recordName);
205  }
206  } else {
207  std::cout << "it does not work yet for " << container << "..." << std::flush;
208 
209  }
210 
211 
212  }
213 
214 
215  }
216 
217 
218 }
RunNumber_t run() const
Definition: EventID.h:42
int i
Definition: DBlmapReader.cc:9
const EventID & eventID() const
Definition: IOVSyncValue.h:42
JetCorrectorParameters::Record record
Definition: classes.h:11
EcalLaserAlphas * generateEcalLaserAlphas()
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::map< std::string, std::string > m_records
Definition: EcalTestDevDB.h:61
EcalLaserAPDPNRatiosRef * generateEcalLaserAPDPNRatiosRef()
unsigned long m_lastRun
Definition: EcalTestDevDB.h:63
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:47
EcalWeightXtalGroups * generateEcalWeightXtalGroups()
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:64
unsigned long m_firstRun
Definition: EcalTestDevDB.h:62
EcalTBWeights * generateEcalTBWeights()
EcalGainRatios * generateEcalGainRatios()
EcalPedestals * generateEcalPedestals()
EcalADCToGeVConstant * generateEcalADCToGeVConstant()
tuple cout
Definition: gather_cfg.py:121
EcalIntercalibConstants * generateEcalIntercalibConstants()
EcalADCToGeVConstant * EcalTestDevDB::generateEcalADCToGeVConstant ( )

Definition at line 247 of file EcalTestDevDB.cc.

References alignCSCRings::r, and rand().

Referenced by analyze().

247  {
248 //-------------------------------------------------------------
249 
250  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
251  EcalADCToGeVConstant* agc = new EcalADCToGeVConstant(36.+r*4., 60.+r*4);
252  return agc;
253 }
Signal rand(Signal arg)
Definition: vlib.cc:442
EcalGainRatios * EcalTestDevDB::generateEcalGainRatios ( )

Definition at line 277 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().

277  {
278 //-------------------------------------------------------------
279 
280  // create gain ratios
281  EcalGainRatios* gratio = new EcalGainRatios;
282 
283  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
284  if(ieta==0) continue;
285  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId:: MAX_IPHI; ++iphi) {
286 
287  EBDetId ebid(ieta,iphi);
288 
289  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
290 
292  gr.setGain12Over6( 1.9 + r*0.2 );
293  gr.setGain6Over1( 5.9 + r*0.2 );
294 
295  gratio->setValue( ebid.rawId(), gr );
296 
297  } // loop over phi
298  } // loop over eta
299  return gratio;
300 }
static const int MIN_IPHI
Definition: EBDetId.h:121
void setGain12Over6(const float &g)
void setValue(const uint32_t id, const Item &item)
EcalGainRatioMap EcalGainRatios
static const int MAX_IPHI
Definition: EBDetId.h:123
static const int MAX_IETA
Definition: EBDetId.h:122
Signal rand(Signal arg)
Definition: vlib.cc:442
void setGain6Over1(const float &g)
EcalIntercalibConstants * EcalTestDevDB::generateEcalIntercalibConstants ( )

Definition at line 257 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().

257  {
258 //-------------------------------------------------------------
259 
261 
262  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
263  if(ieta==0) continue;
264  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId:: MAX_IPHI; ++iphi) {
265 
266  EBDetId ebid(ieta,iphi);
267 
268  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
269  ical->setValue( ebid.rawId(), 0.85 + r*0.3 );
270  } // loop over phi
271  } // loop over eta
272  return ical;
273 }
static const int MIN_IPHI
Definition: EBDetId.h:121
void setValue(const uint32_t id, const Item &item)
static const int MAX_IPHI
Definition: EBDetId.h:123
static const int MAX_IETA
Definition: EBDetId.h:122
EcalIntercalibConstantMap EcalIntercalibConstants
Signal rand(Signal arg)
Definition: vlib.cc:442
EcalLaserAlphas * EcalTestDevDB::generateEcalLaserAlphas ( )

Definition at line 585 of file EcalTestDevDB.cc.

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

Referenced by analyze().

585  {
586 //--------------------------------------------------------------
587 
588  EcalLaserAlphas* laser = new EcalLaserAlphas();
589 
590  EcalLaserAlpha Alpha;
591 
592  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
593  if(iEta==0) continue;
594  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
595  Alpha = double(1.55);
596  EBDetId ebid(iEta,iPhi);
597 
598  int hi = ebid.hashedIndex();
599  if (hi< static_cast<int>(laser->getMap().size())) {
600  laser->setValue(hi, Alpha);
601  } else {
602  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!" << std::endl;
603  }
604  }
605  }
606 
607  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
608  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
609 
610  if (!EEDetId::validDetId(iX,iY,1))
611  continue;
612 
613  EEDetId eedetidpos(iX,iY,1);
614  Alpha = double(1.55);
615 
616  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
617  if (hi< static_cast<int>(laser->getMap().size())) {
618  laser->setValue(hi, Alpha);
619  } else {
620  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!" << std::endl;
621  }
622 
623  if (!EEDetId::validDetId(iX,iY,-1))
624  continue;
625  EEDetId eedetidneg(iX,iY,-1);
626  Alpha = double(1.55);
627 
628  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
629  if (hi< static_cast<int>(laser->getMap().size())) {
630  laser->setValue(hi, Alpha);
631  } else {
632  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!" << std::endl;
633  }
634  }
635  }
636 
637  return laser;
638 }
float EcalLaserAlpha
static const int MIN_IPHI
Definition: EBDetId.h:121
const self & getMap() const
static const int MAX_HASH
Definition: EBDetId.h:136
static const int IX_MIN
Definition: EEDetId.h:271
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
static const int IY_MIN
Definition: EEDetId.h:275
void setValue(const uint32_t id, const Item &item)
EcalLaserAlphaMap EcalLaserAlphas
static const int IX_MAX
Definition: EEDetId.h:279
static const int MAX_IPHI
Definition: EBDetId.h:123
static const int MAX_IETA
Definition: EBDetId.h:122
static const int IY_MAX
Definition: EEDetId.h:283
EcalLaserAPDPNRatios * EcalTestDevDB::generateEcalLaserAPDPNRatios ( uint32_t  i_run)

Definition at line 370 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, 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().

370  {
371 //--------------------------------------------------------------
372 
374 
377 
378  // if((m_firstRun == 0 && i_run == 0) || (m_firstRun == 1 && i_run == 1)){
379 
380  std::cout << "First & last run: " << i_run << " " << m_firstRun << " " << m_lastRun << " " << std::endl;
381  if (m_firstRun == i_run && (i_run == 0 || i_run == 1) ) {
382 
383  APDPNpair.p1= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10))))/double(2);
384  APDPNpair.p2= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10)+double(10))))/double(2);
385  APDPNpair.p3= double(0);
386  std::cout << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2 << std::endl;
387 
388  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
389  if(iEta==0) continue;
390  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
391  //APDPNpair.p1= double(1);
392  //APDPNpair.p2= double(1);
393 
394  EBDetId ebid(iEta,iPhi);
395  int hi = ebid.hashedIndex();
396 
397  if (hi< static_cast<int>(laser->getLaserMap().size())) {
398  laser->setValue(hi, APDPNpair);
399  } else {
400  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
401  continue;
402  }
403  }
404  }
405 
406  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
407  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
408  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
409 
410  if (!EEDetId::validDetId(iX,iY,1))
411  continue;
412 
413  EEDetId eedetidpos(iX,iY,1);
414  //APDPNpair.p1 = double(1);
415  //APDPNpair.p2 = double(1);
416 
417  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
418  if (hi< static_cast<int>(laser->getLaserMap().size())) {
419  laser->setValue(hi, APDPNpair);
420  } else {
421  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
422  continue;
423  }
424 
425  if (!EEDetId::validDetId(iX,iY,-1))
426  continue;
427 
428  EEDetId eedetidneg(iX,iY,-1);
429  //APDPNpair.p1 = double(1);
430  //APDPNpair.p2 = double(1);
431  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
432  if (hi< static_cast<int>(laser->getLaserMap().size())) {
433  laser->setValue(hi, APDPNpair);
434  } else {
435  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
436  continue;
437  }
438  }
439  }
440 
441  std::cout << std::endl;
442  for(int i=0; i<92; i++){
443  if (i< static_cast<int>(laser->getTimeMap().size())) {
444  TimeStamp.t1 = edm::Timestamp(1380*(i_run-m_firstRun) + 15*i);
445  TimeStamp.t2 = edm::Timestamp(1380*(i_run-m_firstRun + 1) + 15*i);
446  laser->setTime(i, TimeStamp);
447  //std::cout << " Timestamp for " << i << " : " << TimeStamp.t1.value() << " , " << TimeStamp.t2.value() << std::endl;
448  } else {
449  edm::LogError("EcalTestDevDB") << "error with laser Map (time)!" << std::endl;
450  continue;
451  }
452  }
453 
454  }else{
455 
456  APDPNpair.p1= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10))))/double(2);
457  APDPNpair.p2= (double(1)+1/double(log(exp(1)+double((i_run-m_firstRun)*10)+double(10))))/double(2);
458  APDPNpair.p3= double(0);
459  std::cout << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2 << std::endl;
460 
461  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
462  if(iEta==0) continue;
463  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
464  EBDetId ebid(iEta,iPhi);
465  int hi = ebid.hashedIndex();
466 
467  if (hi< static_cast<int>(laser->getLaserMap().size())) {
468  laser->setValue(hi, APDPNpair);
469  } else {
470  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
471  }
472  }
473  }
474  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
475  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
476  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
477 
478  if (!EEDetId::validDetId(iX,iY,1))
479  continue;
480 
481  EEDetId eedetidpos(iX,iY,1);
482  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
483  if (hi< static_cast<int>(laser->getLaserMap().size())) {
484  laser->setValue(hi, APDPNpair);
485  } else {
486  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
487  continue;
488  }
489 
490  if (!EEDetId::validDetId(iX,iY,-1))
491  continue;
492 
493  EEDetId eedetidneg(iX,iY,-1);
494  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
495  if (hi< static_cast<int>(laser->getLaserMap().size())) {
496  laser->setValue(hi, APDPNpair);
497  } else {
498  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!" << std::endl;
499  continue;
500  }
501  }
502  }
503 
504  std::cout << std::endl;
505  for(int i=0; i<92; i++){
506  if (i< static_cast<int>(laser->getTimeMap().size())) {
507  TimeStamp.t1 = edm::Timestamp(1380*(i_run-m_firstRun) + 15*i);
508  TimeStamp.t2 = edm::Timestamp(1380*(i_run-m_firstRun + 1) + 15*i);
509  laser->setTime(i, TimeStamp);
510  //std::cout << " Timestamp for " << i << " : " << TimeStamp.t1.value() << " , " << TimeStamp.t2.value() << std::endl;
511  } else {
512  edm::LogError("EcalTestDevDB") << "error with laser Map (time)!" << std::endl;
513  continue;
514  }
515  }
516 
517  }
518 
519  return laser;
520 }
int i
Definition: DBlmapReader.cc:9
static const int MIN_IPHI
Definition: EBDetId.h:121
static const int MAX_HASH
Definition: EBDetId.h:136
static const int IX_MIN
Definition: EEDetId.h:271
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
unsigned long m_lastRun
Definition: EcalTestDevDB.h:63
static const int IY_MIN
Definition: EEDetId.h:275
const EcalLaserAPDPNRatiosMap & getLaserMap() const
void setTime(int hashedIndex, const EcalLaserTimeStamp &value)
static const int IX_MAX
Definition: EEDetId.h:279
unsigned long m_firstRun
Definition: EcalTestDevDB.h:62
static const int MAX_IPHI
Definition: EBDetId.h:123
const EcalLaserTimeStampMap & getTimeMap() const
static const int MAX_IETA
Definition: EBDetId.h:122
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
tuple cout
Definition: gather_cfg.py:121
static const int IY_MAX
Definition: EEDetId.h:283
EcalLaserAPDPNRatiosRef * EcalTestDevDB::generateEcalLaserAPDPNRatiosRef ( )

Definition at line 525 of file EcalTestDevDB.cc.

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

Referenced by analyze().

525  {
526 //--------------------------------------------------------------
527 
529 
530  EcalLaserAPDPNref APDPNref;
531 
532 
533  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
534  if(iEta==0) continue;
535  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
536  APDPNref=double(1.5);
537  EBDetId ebid(iEta,iPhi);
538 
539  int hi = ebid.hashedIndex();
540  if (hi< static_cast<int>(laser->getMap().size())) {
541  laser->setValue(hi, APDPNref);
542  } else {
543  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!" << std::endl;
544  }
545 
546  }
547  }
548 
549  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
550  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
551 
552  if (!EEDetId::validDetId(iX,iY,1))
553  continue;
554 
555  EEDetId eedetidpos(iX,iY,1);
556  APDPNref=double(1.5);
557 
558  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
559  if (hi< static_cast<int>(laser->getMap().size())) {
560  laser->setValue(hi, APDPNref);
561  } else {
562  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!" << std::endl;
563  }
564 
565  if (!EEDetId::validDetId(iX,iY,-1))
566  continue;
567 
568  EEDetId eedetidneg(iX,iY,-1);
569  APDPNref=double(1.5);
570 
571  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
572  if (hi< static_cast<int>(laser->getMap().size())) {
573  laser->setValue(hi, APDPNref);
574  } else {
575  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!" << std::endl;
576  }
577  }
578  }
579 
580  return laser;
581 }
static const int MIN_IPHI
Definition: EBDetId.h:121
const self & getMap() const
static const int MAX_HASH
Definition: EBDetId.h:136
EcalLaserAPDPNRatiosRefMap EcalLaserAPDPNRatiosRef
static const int IX_MIN
Definition: EEDetId.h:271
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
float EcalLaserAPDPNref
static const int IY_MIN
Definition: EEDetId.h:275
void setValue(const uint32_t id, const Item &item)
static const int IX_MAX
Definition: EEDetId.h:279
static const int MAX_IPHI
Definition: EBDetId.h:123
static const int MAX_IETA
Definition: EBDetId.h:122
static const int IY_MAX
Definition: EEDetId.h:283
EcalPedestals * EcalTestDevDB::generateEcalPedestals ( )

Definition at line 223 of file EcalTestDevDB.cc.

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

Referenced by analyze().

223  {
224 //-------------------------------------------------------------
225 
226  EcalPedestals* peds = new EcalPedestals();
227  EcalPedestals::Item item;
228  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
229  if(iEta==0) continue;
230  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
231  item.mean_x1 = 200.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
232  item.rms_x1 = (double)std::rand()/(double(RAND_MAX)+double(1));
233  item.mean_x6 = 1200.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
234  item.rms_x6 = 6.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
235  item.mean_x12 = 2400.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
236  item.rms_x12 = 12.*( (double)std::rand()/(double(RAND_MAX)+double(1)) );
237 
238  EBDetId ebdetid(iEta,iPhi);
239  peds->insert(std::make_pair(ebdetid.rawId(),item));
240  }
241  }
242  return peds;
243 }
static const int MIN_IPHI
Definition: EBDetId.h:121
void insert(std::pair< uint32_t, Item > const &a)
EcalPedestalsMap EcalPedestals
Definition: EcalPedestals.h:38
static const int MAX_IPHI
Definition: EBDetId.h:123
static const int MAX_IETA
Definition: EBDetId.h:122
Signal rand(Signal arg)
Definition: vlib.cc:442
EcalTBWeights * EcalTestDevDB::generateEcalTBWeights ( )

Definition at line 320 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().

320  {
321 //-------------------------------------------------------------
322 
323  EcalTBWeights* tbwgt = new EcalTBWeights();
324 
325  // create weights for each distinct group ID
326  int nMaxTDC = 10;
327  for(int igrp=-EBDetId::MAX_IETA; igrp<=EBDetId::MAX_IETA; ++igrp) {
328  if(igrp==0) continue;
329  for(int itdc=1; itdc<=nMaxTDC; ++itdc) {
330  // generate random number
331  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
332 
333  // make a new set of weights
334  EcalWeightSet wgt;
337 
338  for(size_t i=0; i<3; ++i) {
339  for(size_t j=0; j<10; ++j) {
340  double ww = igrp*itdc*r + i*10. + j;
341  //std::cout << "row: " << i << " col: " << j << " - val: " << ww << std::endl;
342  mat1(i,j)=ww;
343  mat2(i,j)=100+ww;
344  }
345  }
346 
347  // fill the chi2 matrcies
348  r = (double)std::rand()/( double(RAND_MAX)+double(1) );
351  for(size_t i=0; i<10; ++i) {
352  for(size_t j=0; j<10; ++j) {
353  double ww = igrp*itdc*r + i*10. + j;
354  mat3(i,j)=1000+ww;
355  mat4(i,j)=1000+100+ww;
356  }
357  }
358 
359  // put the weight in the container
360  tbwgt->setValue(std::make_pair(igrp,itdc), wgt);
361  }
362  }
363  return tbwgt;
364 }
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:29
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:30
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:28
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:21
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:27
static const int MAX_IETA
Definition: EBDetId.h:122
Signal rand(Signal arg)
Definition: vlib.cc:442
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:20
EcalWeightXtalGroups * EcalTestDevDB::generateEcalWeightXtalGroups ( )

Definition at line 304 of file EcalTestDevDB.cc.

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

Referenced by analyze().

304  {
305 //-------------------------------------------------------------
306 
307  EcalWeightXtalGroups* xtalGroups = new EcalWeightXtalGroups();
308  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
309  if(ieta==0) continue;
310  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId:: MAX_IPHI; ++iphi) {
311  EBDetId ebid(ieta,iphi);
312  xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId(ieta) ); // define rings in eta
313  }
314  }
315  return xtalGroups;
316 }
static const int MIN_IPHI
Definition: EBDetId.h:121
EcalCondObjectContainer< EcalXtalGroupId > EcalWeightXtalGroups
void setValue(const uint32_t id, const Item &item)
static const int MAX_IPHI
Definition: EBDetId.h:123
static const int MAX_IETA
Definition: EBDetId.h:122

Member Data Documentation

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

Definition at line 60 of file EcalTestDevDB.h.

Referenced by EcalTestDevDB().

unsigned long EcalTestDevDB::m_firstRun
private

Definition at line 62 of file EcalTestDevDB.h.

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

unsigned int EcalTestDevDB::m_interval
private

Definition at line 64 of file EcalTestDevDB.h.

Referenced by analyze(), and EcalTestDevDB().

unsigned long EcalTestDevDB::m_lastRun
private

Definition at line 63 of file EcalTestDevDB.h.

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

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

Definition at line 61 of file EcalTestDevDB.h.

Referenced by analyze(), and EcalTestDevDB().

std::string EcalTestDevDB::m_timetype
private

Definition at line 59 of file EcalTestDevDB.h.