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

#include <EcalPulseShapesHandler.h>

Inheritance diagram for popcon::EcalPulseShapesHandler:
popcon::PopConSourceHandler< EcalPulseShapes >

Public Member Functions

bool checkPulseShape (EcalPulseShapes::Item *item)
 
 EcalPulseShapesHandler (edm::ParameterSet const &)
 
void fillSimPulseShape (EcalPulseShapes::Item *item, bool isbarrel)
 
void getNewObjects ()
 
std::string id () const
 
 ~EcalPulseShapesHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalPulseShapes >
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_EBPulseShapeTemplate
 
std::vector< double > m_EEPulseShapeTemplate
 
std::string m_filename
 
unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_lastRun
 
std::string m_name
 
const EcalPulseShapesmypulseshapes
 

Additional Inherited Members

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

Detailed Description

Definition at line 42 of file EcalPulseShapesHandler.h.

Constructor & Destructor Documentation

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

Definition at line 7 of file EcalPulseShapesHandler.cc.

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

8  : m_name(ps.getUntrackedParameter<std::string>("name","EcalPulseShapesHandler")) {
9 
10  std::cout << "EcalPulseShape Source handler constructor\n" << std::endl;
11  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
12  m_filename=ps.getParameter<std::string>("inputFileName");
13  m_EBPulseShapeTemplate=ps.getParameter<std::vector<double> >("EBPulseShapeTemplate");
14  m_EEPulseShapeTemplate=ps.getParameter<std::vector<double> >("EEPulseShapeTemplate");
15 
16 }
std::vector< double > m_EBPulseShapeTemplate
std::vector< double > m_EEPulseShapeTemplate
tuple cout
Definition: gather_cfg.py:121
popcon::EcalPulseShapesHandler::~EcalPulseShapesHandler ( )

Definition at line 18 of file EcalPulseShapesHandler.cc.

19 {
20 }

Member Function Documentation

bool popcon::EcalPulseShapesHandler::checkPulseShape ( EcalPulseShapes::Item item)

Definition at line 23 of file EcalPulseShapesHandler.cc.

References EcalPulseShape::pdfval, query::result, alignCSCRings::s, and EcalPulseShape::TEMPLATESAMPLES.

23  {
24  // true means all is standard and OK
25  bool result=true;
26  for(int s=0; s<EcalPulseShape::TEMPLATESAMPLES; ++s) {
27  if(item->pdfval[s] > 1 || item->pdfval[s] < 0) result=false;
28  }
29  return result;
30 }
static const int TEMPLATESAMPLES
tuple result
Definition: query.py:137
float pdfval[TEMPLATESAMPLES]
void popcon::EcalPulseShapesHandler::fillSimPulseShape ( EcalPulseShapes::Item item,
bool  isbarrel 
)

Definition at line 32 of file EcalPulseShapesHandler.cc.

References EcalPulseShape::pdfval, alignCSCRings::s, and EcalPulseShape::TEMPLATESAMPLES.

32  {
33  for(int s=0; s<EcalPulseShape::TEMPLATESAMPLES; ++s) {
34  item->pdfval[s] = isbarrel ? m_EBPulseShapeTemplate[s] : m_EEPulseShapeTemplate[s];
35  }
36 }
std::vector< double > m_EBPulseShapeTemplate
static const int TEMPLATESAMPLES
std::vector< double > m_EEPulseShapeTemplate
float pdfval[TEMPLATESAMPLES]
void popcon::EcalPulseShapesHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalPulseShapes >.

Definition at line 38 of file EcalPulseShapesHandler.cc.

References gather_cfg::cout, EBDetId::ETAPHIMODE, spr::find(), EcalCondObjectContainer< T >::insert(), EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, geometryCSVtoXML::line, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EcalPulseShape::pdfval, DetId::rawId(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, EcalPulseShape::TEMPLATESAMPLES, EBDetId::validDetId(), and EEDetId::validDetId().

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

Implements popcon::PopConSourceHandler< EcalPulseShapes >.

Definition at line 51 of file EcalPulseShapesHandler.h.

References m_name.

51 { return m_name;}

Member Data Documentation

std::vector<double> popcon::EcalPulseShapesHandler::m_EBPulseShapeTemplate
private

Definition at line 62 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

std::vector<double> popcon::EcalPulseShapesHandler::m_EEPulseShapeTemplate
private

Definition at line 62 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

std::string popcon::EcalPulseShapesHandler::m_filename
private

Definition at line 60 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

unsigned int popcon::EcalPulseShapesHandler::m_firstRun
private

Definition at line 56 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

std::string popcon::EcalPulseShapesHandler::m_gentag
private

Definition at line 59 of file EcalPulseShapesHandler.h.

unsigned int popcon::EcalPulseShapesHandler::m_lastRun
private

Definition at line 57 of file EcalPulseShapesHandler.h.

std::string popcon::EcalPulseShapesHandler::m_name
private

Definition at line 61 of file EcalPulseShapesHandler.h.

Referenced by id().

const EcalPulseShapes* popcon::EcalPulseShapesHandler::mypulseshapes
private

Definition at line 54 of file EcalPulseShapesHandler.h.