CMS 3D CMS Logo

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 () override
 
std::string id () const override
 
 ~EcalPulseShapesHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalPulseShapes >
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const *, std::string const > operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
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::map< Time_t, std::shared_ptr< EcalPulseShapes > > Container
 
typedef std::unique_ptr< EcalPulseShapesRef
 
typedef PopConSourceHandler< EcalPulseShapesself
 
typedef cond::Time_t Time_t
 
typedef EcalPulseShapes value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalPulseShapes >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalPulseShapes >
Container m_iovs
 
std::vector< std::pair< EcalPulseShapes *, Time_t > > m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 40 of file EcalPulseShapesHandler.h.

Constructor & Destructor Documentation

◆ EcalPulseShapesHandler()

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  std::cout << "EcalPulseShape 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_EBPulseShapeTemplate = ps.getParameter<std::vector<double> >("EBPulseShapeTemplate");
13  m_EEPulseShapeTemplate = ps.getParameter<std::vector<double> >("EEPulseShapeTemplate");
14 }
std::vector< double > m_EBPulseShapeTemplate
std::vector< double > m_EEPulseShapeTemplate

◆ ~EcalPulseShapesHandler()

popcon::EcalPulseShapesHandler::~EcalPulseShapesHandler ( )
override

Definition at line 16 of file EcalPulseShapesHandler.cc.

16 {}

Member Function Documentation

◆ checkPulseShape()

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

Definition at line 18 of file EcalPulseShapesHandler.cc.

References B2GTnPMonitor_cfi::item, mps_fire::result, alignCSCRings::s, and EcalPulseShape::TEMPLATESAMPLES.

18  {
19  // true means all is standard and OK
20  bool result = true;
21  for (int s = 0; s < EcalPulseShape::TEMPLATESAMPLES; ++s) {
22  if (item->pdfval[s] > 1 || item->pdfval[s] < 0)
23  result = false;
24  }
25  return result;
26 }
static const int TEMPLATESAMPLES

◆ fillSimPulseShape()

void popcon::EcalPulseShapesHandler::fillSimPulseShape ( EcalPulseShapes::Item item,
bool  isbarrel 
)

Definition at line 28 of file EcalPulseShapesHandler.cc.

References B2GTnPMonitor_cfi::item, alignCSCRings::s, and EcalPulseShape::TEMPLATESAMPLES.

28  {
29  for (int s = 0; s < EcalPulseShape::TEMPLATESAMPLES; ++s) {
30  item->pdfval[s] = isbarrel ? m_EBPulseShapeTemplate[s] : m_EEPulseShapeTemplate[s];
31  }
32 }
std::vector< double > m_EBPulseShapeTemplate
static const int TEMPLATESAMPLES
std::vector< double > m_EEPulseShapeTemplate

◆ getNewObjects()

void popcon::EcalPulseShapesHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalPulseShapes >.

Definition at line 34 of file EcalPulseShapesHandler.cc.

References gather_cfg::cout, EBDetId::ETAPHIMODE, spr::find(), l1tPhase2CaloJetEmulator_cfi::iEta, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::if(), EcalCondObjectContainer< T >::insert(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, B2GTnPMonitor_cfi::item, EEDetId::IX_MAX, EEDetId::IX_MIN, EEDetId::IY_MAX, EEDetId::IY_MIN, mps_splice::line, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, DetId::rawId(), nano_mu_digi_cff::rawId, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, EcalPulseShape::TEMPLATESAMPLES, EBDetId::validDetId(), and EEDetId::validDetId().

34  {
35  std::cout << "------- Ecal - > getNewObjects\n";
36 
37  // create the object pukse shapes
38  EcalPulseShapes* pulseshapes = new EcalPulseShapes();
39 
40  // read the templates from a text file
41  std::ifstream inputfile;
42  inputfile.open(m_filename.c_str());
43  float templatevals[EcalPulseShape::TEMPLATESAMPLES];
44  unsigned int rawId;
45  int isbarrel;
47 
48  // keep track of bad crystals
49  int nEBbad(0), nEEbad(0);
50  std::vector<EBDetId> ebgood;
51  std::vector<EEDetId> eegood;
52 
53  // fill with the measured shapes only for data
54  if (m_firstRun > 1) {
55  while (std::getline(inputfile, line)) {
56  std::istringstream linereader(line);
57  linereader >> isbarrel >> rawId;
58  // std::cout << "Inserting template for crystal with rawId = " << rawId << " (isbarrel = " << isbarrel << ") " << std::endl;
59  for (int s = 0; s < EcalPulseShape::TEMPLATESAMPLES; ++s) {
60  linereader >> templatevals[s];
61  // std::cout << templatevals[s] << "\t";
62  }
63  // std::cout << std::endl;
64 
65  if (!linereader) {
66  std::cout << "Wrong format of the text file. Exit." << std::endl;
67  return;
68  }
70  for (int s = 0; s < EcalPulseShape::TEMPLATESAMPLES; ++s)
71  item.pdfval[s] = templatevals[s];
72 
73  if (isbarrel) {
74  EBDetId ebdetid(rawId);
75  if (!checkPulseShape(&item))
76  nEBbad++;
77  else {
78  ebgood.push_back(ebdetid);
79  pulseshapes->insert(std::make_pair(ebdetid.rawId(), item));
80  }
81  } else {
82  EEDetId eedetid(rawId);
83  if (!checkPulseShape(&item))
84  nEEbad++;
85  else {
86  eegood.push_back(eedetid);
87  pulseshapes->insert(std::make_pair(eedetid.rawId(), item));
88  }
89  }
90  }
91  }
92 
93  // now fill the bad crystals and simulation with the simulation values (from TB)
94  std::cout << "Filled the DB with the good measured ECAL templates. Now filling the others with the TB values"
95  << std::endl;
96  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
97  if (iEta == 0)
98  continue;
99  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
100  if (EBDetId::validDetId(iEta, iPhi)) {
101  EBDetId ebdetid(iEta, iPhi, EBDetId::ETAPHIMODE);
102 
103  std::vector<EBDetId>::iterator it = find(ebgood.begin(), ebgood.end(), ebdetid);
104  if (it == ebgood.end()) {
106  fillSimPulseShape(&item, true);
107  pulseshapes->insert(std::make_pair(ebdetid.rawId(), item));
108  }
109  }
110  }
111  }
112 
113  for (int iZ = -1; iZ < 2; iZ += 2) {
114  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
115  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
116  if (EEDetId::validDetId(iX, iY, iZ)) {
117  EEDetId eedetid(iX, iY, iZ);
118 
119  std::vector<EEDetId>::iterator it = find(eegood.begin(), eegood.end(), eedetid);
120  if (it == eegood.end()) {
122  fillSimPulseShape(&item, false);
123  pulseshapes->insert(std::make_pair(eedetid.rawId(), item));
124  }
125  }
126  }
127  }
128  }
129 
130  std::cout << "Inserted the pulse shapes into the new item object" << std::endl;
131 
132  unsigned int irun = m_firstRun;
133  Time_t snc = (Time_t)irun;
134 
135  m_to_transfer.push_back(std::make_pair((EcalPulseShapes*)pulseshapes, snc));
136 
137  std::cout << "Ecal - > end of getNewObjects -----------" << std::endl;
138  std::cout << "N. bad shapes for EB = " << nEBbad << std::endl;
139  std::cout << "N. bad shapes for EE = " << nEEbad << std::endl;
140  std::cout << "Written the object" << std::endl;
141 }
EcalPulseShapesMap EcalPulseShapes
static const int MIN_IPHI
Definition: EBDetId.h:135
static const int TEMPLATESAMPLES
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
bool checkPulseShape(EcalPulseShapes::Item *item)
void fillSimPulseShape(EcalPulseShapes::Item *item, bool isbarrel)
std::vector< std::pair< EcalPulseShapes *, Time_t > > m_to_transfer
static const int ETAPHIMODE
Definition: EBDetId.h:158
void insert(std::pair< uint32_t, Item > const &a)
static const int IX_MAX
Definition: EEDetId.h:298
static const int MAX_IPHI
Definition: EBDetId.h:137
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:136
static const int IY_MAX
Definition: EEDetId.h:302
if(threadIdxLocalY==0 &&threadIdxLocalX==0)

◆ id()

std::string popcon::EcalPulseShapesHandler::id ( ) const
inlineoverridevirtual

Implements popcon::PopConSourceHandler< EcalPulseShapes >.

Definition at line 47 of file EcalPulseShapesHandler.h.

References m_name.

47 { return m_name; }

Member Data Documentation

◆ m_EBPulseShapeTemplate

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

Definition at line 58 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

◆ m_EEPulseShapeTemplate

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

Definition at line 58 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

◆ m_filename

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

Definition at line 56 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

◆ m_firstRun

unsigned int popcon::EcalPulseShapesHandler::m_firstRun
private

Definition at line 52 of file EcalPulseShapesHandler.h.

Referenced by EcalPulseShapesHandler().

◆ m_gentag

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

Definition at line 55 of file EcalPulseShapesHandler.h.

◆ m_lastRun

unsigned int popcon::EcalPulseShapesHandler::m_lastRun
private

Definition at line 53 of file EcalPulseShapesHandler.h.

◆ m_name

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

Definition at line 57 of file EcalPulseShapesHandler.h.

Referenced by id().

◆ mypulseshapes

const EcalPulseShapes* popcon::EcalPulseShapesHandler::mypulseshapes
private

Definition at line 50 of file EcalPulseShapesHandler.h.