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
popcon::EcalPulseCovariancesHandler Class Reference

#include <EcalPulseCovariancesHandler.h>

Inheritance diagram for popcon::EcalPulseCovariancesHandler:
popcon::PopConSourceHandler< EcalPulseCovariances >

Public Member Functions

bool checkPulseCovariance (EcalPulseCovariances::Item *item)
 
 EcalPulseCovariancesHandler (edm::ParameterSet const &)
 
void fillSimPulseCovariance (EcalPulseCovariances::Item *item, bool isbarrel)
 
void getNewObjects ()
 
std::string id () const
 
 ~EcalPulseCovariancesHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalPulseCovariances >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Private Attributes

std::vector< double > m_EBPulseShapeCovariance
 
std::vector< double > m_EEPulseShapeCovariance
 
std::string m_filename
 
unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_lastRun
 
std::string m_name
 
const EcalPulseCovariancesmypulseshapes
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalPulseCovariances >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalPulseCovariances
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalPulseCovariances
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalPulseCovariances value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalPulseCovariances >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalPulseCovariances >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 42 of file EcalPulseCovariancesHandler.h.

Constructor & Destructor Documentation

popcon::EcalPulseCovariancesHandler::EcalPulseCovariancesHandler ( edm::ParameterSet const &  ps)

Definition at line 6 of file EcalPulseCovariancesHandler.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), m_EBPulseShapeCovariance, m_EEPulseShapeCovariance, m_filename, m_firstRun, and AlCaHLTBitMon_QueryRunRegistry::string.

7  : m_name(ps.getUntrackedParameter<std::string>("name","EcalPulseCovariancesHandler")) {
8 
9  std::cout << "EcalPulseCovariance Source handler constructor\n" << std::endl;
10  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
11  m_filename=ps.getParameter<std::string>("inputFileName");
12  m_EBPulseShapeCovariance = ps.getParameter<std::vector<double> >("EBPulseShapeCovariance");
13  m_EEPulseShapeCovariance = ps.getParameter<std::vector<double> >("EEPulseShapeCovariance");
14 }
tuple cout
Definition: gather_cfg.py:121
popcon::EcalPulseCovariancesHandler::~EcalPulseCovariancesHandler ( )

Definition at line 16 of file EcalPulseCovariancesHandler.cc.

17 {
18 }

Member Function Documentation

bool popcon::EcalPulseCovariancesHandler::checkPulseCovariance ( EcalPulseCovariances::Item item)

Definition at line 21 of file EcalPulseCovariancesHandler.cc.

References EcalPulseCovariance::covval, i, j, relval_steps::k, funct::pow(), query::result, and EcalPulseShape::TEMPLATESAMPLES.

21  {
22  // true means all is standard and OK
23  bool result=true;
24  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
27  if(fabs(item->covval[i][j]) > 1) result=false;
28  }
29  return result;
30 }
int i
Definition: DBlmapReader.cc:9
static const int TEMPLATESAMPLES
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
float covval[EcalPulseShape::TEMPLATESAMPLES][EcalPulseShape::TEMPLATESAMPLES]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void popcon::EcalPulseCovariancesHandler::fillSimPulseCovariance ( EcalPulseCovariances::Item item,
bool  isbarrel 
)

Definition at line 32 of file EcalPulseCovariancesHandler.cc.

References EcalPulseCovariance::covval, i, j, relval_steps::k, funct::pow(), and EcalPulseShape::TEMPLATESAMPLES.

32  {
33  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
37  }
38 }
int i
Definition: DBlmapReader.cc:9
static const int TEMPLATESAMPLES
int j
Definition: DBlmapReader.cc:9
float covval[EcalPulseShape::TEMPLATESAMPLES][EcalPulseShape::TEMPLATESAMPLES]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void popcon::EcalPulseCovariancesHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalPulseCovariances >.

Definition at line 40 of file EcalPulseCovariancesHandler.cc.

References gather_cfg::cout, EcalPulseCovariance::covval, EBDetId::ETAPHIMODE, spr::find(), i, EcalCondObjectContainer< T >::insert(), EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, j, relval_steps::k, geometryCSVtoXML::line, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, funct::pow(), DetId::rawId(), AlCaHLTBitMon_QueryRunRegistry::string, EcalPulseShape::TEMPLATESAMPLES, EBDetId::validDetId(), and EEDetId::validDetId().

41 {
42 
43  std::cout << "------- Ecal - > getNewObjects\n";
44 
45  // create the object pukse shapes
46  EcalPulseCovariances* pulsecovs = new EcalPulseCovariances();
47 
48  // read the templates from a text file
49  std::ifstream inputfile;
50  inputfile.open(m_filename.c_str());
52  unsigned int rawId;
53  int isbarrel;
55 
56  // keep track of bad crystals
57  int nEBbad(0), nEEbad(0);
58  int nEBgood(0), nEEgood(0);
59  std::vector<EBDetId> ebgood;
60  std::vector<EEDetId> eegood;
61 
62  // fill with the measured shapes only for data
63  if(m_firstRun > 1) {
64  while (std::getline(inputfile, line)) {
65  std::istringstream linereader(line);
66  linereader >> isbarrel >> rawId;
67  // std::cout << "Inserting template for crystal with rawId = " << rawId << " (isbarrel = " << isbarrel << ") " << std::endl;
68  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
71  linereader >> covvals[i][j];
72  }
73 
74  if (!linereader) {
75  std::cout << "Wrong format of the text file. Exit." << std::endl;
76  return;
77  }
79  for(int i=0; i<EcalPulseShape::TEMPLATESAMPLES; ++i) for(int j=0; j<EcalPulseShape::TEMPLATESAMPLES; ++j) item.covval[i][j] = covvals[i][j];
80 
81  if(isbarrel) {
82  EBDetId ebdetid(rawId);
83  if(!checkPulseCovariance(&item) ) nEBbad++;
84  else {
85  nEBgood++;
86  ebgood.push_back(ebdetid);
87  pulsecovs->insert(std::make_pair(ebdetid.rawId(),item));
88  }
89  } else {
90  EEDetId eedetid(rawId);
91  if(!checkPulseCovariance(&item) ) nEEbad++;
92  else {
93  nEEgood++;
94  eegood.push_back(eedetid);
95  pulsecovs->insert(std::make_pair(eedetid.rawId(),item));
96  }
97  }
98  }
99  }
100 
101  // now fill the bad crystals and simulation with the simulation values (from TB)
102  std::cout << "Filled the DB with the good measured ECAL templates. Now filling the others with the TB values" << std::endl;
103  for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
104  if(iEta==0) continue;
105  for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
106  if (EBDetId::validDetId(iEta,iPhi)) {
107  EBDetId ebdetid(iEta,iPhi,EBDetId::ETAPHIMODE);
108 
109  std::vector<EBDetId>::iterator it = find(ebgood.begin(),ebgood.end(),ebdetid);
110  if(it == ebgood.end()) {
112  fillSimPulseCovariance(&item,true);
113  pulsecovs->insert(std::make_pair(ebdetid.rawId(),item));
114  }
115  }
116  }
117  }
118 
119  for(int iZ=-1; iZ<2; iZ+=2) {
120  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
121  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
122  if (EEDetId::validDetId(iX,iY,iZ)) {
123  EEDetId eedetid(iX,iY,iZ);
124 
125  std::vector<EEDetId>::iterator it = find(eegood.begin(),eegood.end(),eedetid);
126  if(it == eegood.end()) {
128  fillSimPulseCovariance(&item,false);
129  pulsecovs->insert(std::make_pair(eedetid.rawId(),item));
130  }
131  }
132  }
133  }
134  }
135 
136  std::cout << "Inserted the pulse covariances into the new item object" << std::endl;
137 
138  unsigned int irun=m_firstRun;
139  Time_t snc= (Time_t) irun ;
140 
141  m_to_transfer.push_back(std::make_pair((EcalPulseCovariances*)pulsecovs,snc));
142 
143  std::cout << "Ecal - > end of getNewObjects -----------" << std::endl;
144  std::cout << "N. bad shapes for EB = " << nEBbad << std::endl;
145  std::cout << "N. bad shapes for EE = " << nEEbad << std::endl;
146  std::cout << "Written the object" << std::endl;
147 
148 }
int i
Definition: DBlmapReader.cc:9
static const int MIN_IPHI
Definition: EBDetId.h:142
void fillSimPulseCovariance(EcalPulseCovariances::Item *item, bool isbarrel)
static const int TEMPLATESAMPLES
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static const int IX_MIN
Definition: EEDetId.h:294
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
int j
Definition: DBlmapReader.cc:9
EcalPulseCovariancesMap EcalPulseCovariances
static const int ETAPHIMODE
Definition: EBDetId.h:166
float covval[EcalPulseShape::TEMPLATESAMPLES][EcalPulseShape::TEMPLATESAMPLES]
void insert(std::pair< uint32_t, Item > const &a)
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
tuple cout
Definition: gather_cfg.py:121
static const int IY_MAX
Definition: EEDetId.h:306
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool checkPulseCovariance(EcalPulseCovariances::Item *item)
std::string popcon::EcalPulseCovariancesHandler::id ( void  ) const
inlinevirtual

Member Data Documentation

std::vector<double> popcon::EcalPulseCovariancesHandler::m_EBPulseShapeCovariance
private

Definition at line 62 of file EcalPulseCovariancesHandler.h.

Referenced by EcalPulseCovariancesHandler().

std::vector<double> popcon::EcalPulseCovariancesHandler::m_EEPulseShapeCovariance
private

Definition at line 62 of file EcalPulseCovariancesHandler.h.

Referenced by EcalPulseCovariancesHandler().

std::string popcon::EcalPulseCovariancesHandler::m_filename
private

Definition at line 60 of file EcalPulseCovariancesHandler.h.

Referenced by EcalPulseCovariancesHandler().

unsigned int popcon::EcalPulseCovariancesHandler::m_firstRun
private

Definition at line 56 of file EcalPulseCovariancesHandler.h.

Referenced by EcalPulseCovariancesHandler().

std::string popcon::EcalPulseCovariancesHandler::m_gentag
private

Definition at line 59 of file EcalPulseCovariancesHandler.h.

unsigned int popcon::EcalPulseCovariancesHandler::m_lastRun
private

Definition at line 57 of file EcalPulseCovariancesHandler.h.

std::string popcon::EcalPulseCovariancesHandler::m_name
private

Definition at line 61 of file EcalPulseCovariancesHandler.h.

Referenced by id().

const EcalPulseCovariances* popcon::EcalPulseCovariancesHandler::mypulseshapes
private

Definition at line 54 of file EcalPulseCovariancesHandler.h.