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::EcalPulseSymmCovariancesHandler Class Reference

#include <EcalPulseSymmCovariancesHandler.h>

Inheritance diagram for popcon::EcalPulseSymmCovariancesHandler:
popcon::PopConSourceHandler< EcalPulseSymmCovariances >

Public Member Functions

bool checkPulseSymmCovariance (EcalPulseSymmCovariances::Item *item)
 
 EcalPulseSymmCovariancesHandler (edm::ParameterSet const &)
 
void fillSimPulseSymmCovariance (EcalPulseSymmCovariances::Item *item, bool isbarrel)
 
void getNewObjects ()
 
std::string id () const
 
 ~EcalPulseSymmCovariancesHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalPulseSymmCovariances >
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 EcalPulseSymmCovariancesmypulseshapes
 

Additional Inherited Members

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

Detailed Description

Definition at line 42 of file EcalPulseSymmCovariancesHandler.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file EcalPulseSymmCovariancesHandler.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","EcalPulseSymmCovariancesHandler")) {
8 
9  std::cout << "EcalPulseSymmCovariance 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::EcalPulseSymmCovariancesHandler::~EcalPulseSymmCovariancesHandler ( )

Definition at line 16 of file EcalPulseSymmCovariancesHandler.cc.

17 {
18 }

Member Function Documentation

bool popcon::EcalPulseSymmCovariancesHandler::checkPulseSymmCovariance ( EcalPulseSymmCovariances::Item item)

Definition at line 21 of file EcalPulseSymmCovariancesHandler.cc.

References EcalPulseSymmCovariance::covval, relval_steps::k, N, query::result, and EcalPulseShape::TEMPLATESAMPLES.

21  {
22  // true means all is standard and OK
23  bool result=true;
25  for(int k=0; k<N; ++k) {
26  if(fabs(item->covval[k]) > 1) result=false;
27  }
28  return result;
29 }
static const int TEMPLATESAMPLES
tuple result
Definition: query.py:137
#define N
Definition: blowfish.cc:9
float covval[EcalPulseShape::TEMPLATESAMPLES *(EcalPulseShape::TEMPLATESAMPLES+1)/2]
void popcon::EcalPulseSymmCovariancesHandler::fillSimPulseSymmCovariance ( EcalPulseSymmCovariances::Item item,
bool  isbarrel 
)

Definition at line 31 of file EcalPulseSymmCovariancesHandler.cc.

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

31  {
32  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
35  if(j>=i) {
36  int linK = j + (EcalPulseShape::TEMPLATESAMPLES-1)*i;
37  item->covval[linK] = isbarrel ? m_EBPulseShapeCovariance[k] : m_EEPulseShapeCovariance[k];
38  }
39  }
40 }
int i
Definition: DBlmapReader.cc:9
static const int TEMPLATESAMPLES
int j
Definition: DBlmapReader.cc:9
float covval[EcalPulseShape::TEMPLATESAMPLES *(EcalPulseShape::TEMPLATESAMPLES+1)/2]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void popcon::EcalPulseSymmCovariancesHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalPulseSymmCovariances >.

Definition at line 42 of file EcalPulseSymmCovariancesHandler.cc.

References gather_cfg::cout, EcalPulseSymmCovariance::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().

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

Member Data Documentation

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

Definition at line 62 of file EcalPulseSymmCovariancesHandler.h.

Referenced by EcalPulseSymmCovariancesHandler().

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

Definition at line 62 of file EcalPulseSymmCovariancesHandler.h.

Referenced by EcalPulseSymmCovariancesHandler().

std::string popcon::EcalPulseSymmCovariancesHandler::m_filename
private

Definition at line 60 of file EcalPulseSymmCovariancesHandler.h.

Referenced by EcalPulseSymmCovariancesHandler().

unsigned int popcon::EcalPulseSymmCovariancesHandler::m_firstRun
private

Definition at line 56 of file EcalPulseSymmCovariancesHandler.h.

Referenced by EcalPulseSymmCovariancesHandler().

std::string popcon::EcalPulseSymmCovariancesHandler::m_gentag
private

Definition at line 59 of file EcalPulseSymmCovariancesHandler.h.

unsigned int popcon::EcalPulseSymmCovariancesHandler::m_lastRun
private

Definition at line 57 of file EcalPulseSymmCovariancesHandler.h.

std::string popcon::EcalPulseSymmCovariancesHandler::m_name
private

Definition at line 61 of file EcalPulseSymmCovariancesHandler.h.

Referenced by id().

const EcalPulseSymmCovariances* popcon::EcalPulseSymmCovariancesHandler::mypulseshapes
private

Definition at line 54 of file EcalPulseSymmCovariancesHandler.h.