CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
EcalTBReadout Class Reference

#include <EcalTBReadout.h>

Public Member Functions

 EcalTBReadout (const std::string theEcalTBInfoLabel)
 
void findTTlist (const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
 search for the TT to be read More...
 
void performReadout (edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, const EBDigiCollection &input, EBDigiCollection &output)
 master function to be called once per event More...
 
void performReadout (edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, const EEDigiCollection &input, EEDigiCollection &output)
 master function to be called once per event More...
 
void readOut (const EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
 read only the digis from the selected TT More...
 
void readOut (const EEDigiCollection &input, EEDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
 read only the digis from the selected TT More...
 
void setDetIds (const std::vector< DetId > &detIds)
 tell the readout which cells exist More...
 
 ~EcalTBReadout ()
 

Private Attributes

std::string ecalTBInfoLabel_
 
const std::vector< DetId > * theDetIds
 
int theTargetCrystal_
 
std::vector< EcalTrigTowerDetIdtheTTlist_
 

Static Private Attributes

static const int NCRYMATRIX = 7
 

Detailed Description

Definition at line 19 of file EcalTBReadout.h.

Constructor & Destructor Documentation

◆ EcalTBReadout()

EcalTBReadout::EcalTBReadout ( const std::string  theEcalTBInfoLabel)

Definition at line 9 of file EcalTBReadout.cc.

References theTargetCrystal_, and theTTlist_.

9  : ecalTBInfoLabel_(theEcalTBInfoLabel) {
10  theTargetCrystal_ = -1;
11  theTTlist_.reserve(1);
12 }
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:51
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:57

◆ ~EcalTBReadout()

EcalTBReadout::~EcalTBReadout ( )
inline

Definition at line 22 of file EcalTBReadout.h.

22 {};

Member Function Documentation

◆ findTTlist()

void EcalTBReadout::findTTlist ( const int &  crysId,
const EcalTrigTowerConstituentsMap etmap 
)

search for the TT to be read

step 1: find the correspondence between the crystal identified in module and its DetId assuming only 1 SM present

step 2: find the crystals in the matrix and fill the TT list
loop on all the valid DetId and search for the good ones

Definition at line 14 of file EcalTBReadout.cc.

References Exception, spr::find(), newFWLiteAna::found, mps_fire::i, EBDetId::ic(), EBDetId::ieta(), EBDetId::iphi(), LogDebug, NCRYMATRIX, findQualityFiles::size, theDetIds, theTargetCrystal_, theTTlist_, and EcalTrigTowerConstituentsMap::towerOf().

Referenced by performReadout().

14  {
15  // search for the TT involved in the NCRYMATRIX x NCRYMATRIX
16  // around the target crystal if a new target, otherwise use
17  // the list already filled
18 
19  if (crysId == theTargetCrystal_) {
20  return;
21  }
22 
23  theTTlist_.clear();
24 
28 
29  EBDetId theTargetId;
30  std::vector<DetId>::const_iterator idItr = theDetIds->begin();
31  unsigned int ncount = 0;
32  bool found = false;
33 
34  while ((ncount < theDetIds->size()) && !found) {
35  EBDetId thisEBdetid(idItr->rawId());
36  if (thisEBdetid.ic() == crysId) {
37  theTargetId = thisEBdetid;
38  found = true;
39  }
40  ++idItr;
41  ++ncount;
42  }
43  if (!found) {
44  throw cms::Exception("ObjectNotFound", "Ecal TB target crystal not found in geometry");
45  return;
46  }
47  theTargetCrystal_ = theTargetId.ic();
48 
51 
52  int myEta = theTargetId.ieta();
53  int myPhi = theTargetId.iphi();
54 
55  for (int icrysEta = (myEta - (NCRYMATRIX - 1) / 2); icrysEta <= (myEta + (NCRYMATRIX - 1) / 2); ++icrysEta) {
56  for (int icrysPhi = (myPhi - (NCRYMATRIX - 1) / 2); icrysPhi <= (myPhi + (NCRYMATRIX - 1) / 2); ++icrysPhi) {
58 
59  EBDetId thisEBdetid;
60 
61  idItr = theDetIds->begin();
62  ncount = 0;
63  found = false;
64 
65  while ((ncount < theDetIds->size()) && !found) {
66  EBDetId myEBdetid(idItr->rawId());
67  if ((myEBdetid.ieta() == icrysEta) && (myEBdetid.iphi() == icrysPhi)) {
68  thisEBdetid = myEBdetid;
69  found = true;
70  }
71  ++idItr;
72  ++ncount;
73  }
74 
75  if (found) {
76  EcalTrigTowerDetId thisTTdetId = etmap.towerOf(thisEBdetid);
77 
78  LogDebug("EcalDigi") << "Crystal to be readout: sequential id = " << thisEBdetid.ic() << " eta = " << icrysEta
79  << " phi = " << icrysPhi << " from TT = " << thisTTdetId;
80 
81  if (theTTlist_.empty() || (theTTlist_.size() == 1 && theTTlist_[0] != thisTTdetId)) {
82  theTTlist_.push_back(thisTTdetId);
83  } else {
84  std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
85  if (theTTlist_.size() > 1 && ttFound == theTTlist_.end() && *(theTTlist_.end()) != thisTTdetId) {
86  theTTlist_.push_back(thisTTdetId);
87  }
88  }
89  }
90  }
91  }
92 
93  edm::LogInfo("EcalDigi") << " TT to be read: ";
94  for (unsigned int i = 0; i < theTTlist_.size(); ++i) {
95  edm::LogInfo("EcalDigi") << " TT " << i << " " << theTTlist_[i];
96  }
97 }
size
Write out results.
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:51
static const int NCRYMATRIX
Definition: EcalTBReadout.h:53
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
Log< level::Info, false > LogInfo
const std::vector< DetId > * theDetIds
Definition: EcalTBReadout.h:55
#define LogDebug(id)

◆ performReadout() [1/2]

void EcalTBReadout::performReadout ( edm::Event event,
const EcalTrigTowerConstituentsMap theTTmap,
const EBDigiCollection input,
EBDigiCollection output 
)

master function to be called once per event

Definition at line 150 of file EcalTBReadout.cc.

References ecalTBInfoLabel_, findTTlist(), input, PEcalTBInfo::nCrystal(), convertSQLitetoXML_cfg::output, and readOut().

Referenced by EcalTBDigiProducer::finalizeEvent().

153  {
154  // TB readout
155  // step 1: get the target crystal index
156 
157  edm::Handle<PEcalTBInfo> theEcalTBInfo;
158  event.getByLabel(ecalTBInfoLabel_, theEcalTBInfo);
159 
160  int crysId = theEcalTBInfo->nCrystal();
161 
162  // step 2: update (if needed) the TT list to be read
163 
164  findTTlist(crysId, theTTmap);
165 
166  // step 3: perform the readout
167 
168  readOut(input, output, theTTmap);
169 }
static std::string const input
Definition: EdmProvDump.cc:47
void readOut(const EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
read only the digis from the selected TT
int nCrystal() const
Definition: PEcalTBInfo.h:27
void findTTlist(const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
search for the TT to be read
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:57

◆ performReadout() [2/2]

void EcalTBReadout::performReadout ( edm::Event event,
const EcalTrigTowerConstituentsMap theTTmap,
const EEDigiCollection input,
EEDigiCollection output 
)

master function to be called once per event

Definition at line 171 of file EcalTBReadout.cc.

References ecalTBInfoLabel_, findTTlist(), input, PEcalTBInfo::nCrystal(), convertSQLitetoXML_cfg::output, and readOut().

174  {
175  // TB readout
176  // step 1: get the target crystal index
177 
178  edm::Handle<PEcalTBInfo> theEcalTBInfo;
179  event.getByLabel(ecalTBInfoLabel_, theEcalTBInfo);
180 
181  int crysId = theEcalTBInfo->nCrystal();
182 
183  // step 2: update (if needed) the TT list to be read
184 
185  findTTlist(crysId, theTTmap);
186 
187  // step 3: perform the readout
188 
189  readOut(input, output, theTTmap);
190 }
static std::string const input
Definition: EdmProvDump.cc:47
void readOut(const EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
read only the digis from the selected TT
int nCrystal() const
Definition: PEcalTBInfo.h:27
void findTTlist(const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
search for the TT to be read
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:57

◆ readOut() [1/2]

void EcalTBReadout::readOut ( const EBDigiCollection input,
EBDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

Definition at line 99 of file EcalTBReadout.cc.

References edm::DataFrame::begin(), filterCSVwithJSON::copy, gather_cfg::cout, edm::DataFrame::end(), spr::find(), EcalDataFrame::frame(), EBDataFrame::id(), input, convertSQLitetoXML_cfg::output, theTTlist_, and EcalTrigTowerConstituentsMap::towerOf().

Referenced by performReadout().

101  {
102  /*
103  for(EBDigiCollection::const_iterator digiItr = input.begin();
104  digiItr != input.end(); ++digiItr)
105  {
106  EcalTrigTowerDetId thisTTdetId=etmap.towerOf(digiItr->id());
107  std::vector<EcalTrigTowerDetId>::iterator ttFound =
108  find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId); if ((ttFound !=
109  theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {
110  output.push_back(*digiItr);
111  }
112  }
113  edm::LogInfo("EcalDigi") << "Read EB Digis: " << output.size();
114  */
115 
116  std::cout << "%%%%%%% In readOut(), size=" << input.size() << std::endl;
117 
118  for (unsigned int digis = 0; digis < input.size(); ++digis) {
119  EBDataFrame ebdf = input[digis];
120 
121  EcalTrigTowerDetId thisTTdetId = etmap.towerOf(ebdf.id());
122  std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
123 
124  if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {
125  output.push_back(ebdf.id());
126  EBDataFrame ebdf2(output.back());
127  std::copy(ebdf.frame().begin(), ebdf.frame().end(), ebdf2.frame().begin());
128  }
129  }
130 }
constexpr iterator end()
Definition: DataFrame.h:35
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:51
key_type id() const
Definition: EBDataFrame.h:28
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
static std::string const input
Definition: EdmProvDump.cc:47
constexpr iterator begin()
Definition: DataFrame.h:33
edm::DataFrame const & frame() const
Definition: EcalDataFrame.h:50

◆ readOut() [2/2]

void EcalTBReadout::readOut ( const EEDigiCollection input,
EEDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

Definition at line 132 of file EcalTBReadout.cc.

References edm::DataFrame::begin(), filterCSVwithJSON::copy, edm::DataFrame::end(), spr::find(), EcalDataFrame::frame(), EEDataFrame::id(), input, convertSQLitetoXML_cfg::output, theTTlist_, and EcalTrigTowerConstituentsMap::towerOf().

134  {
135  for (unsigned int digis = 0; digis < input.size(); ++digis) {
136  EEDataFrame eedf(input[digis]);
137 
138  EcalTrigTowerDetId thisTTdetId(etmap.towerOf(eedf.id()));
139 
140  std::vector<EcalTrigTowerDetId>::iterator ttFound(find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId));
141 
142  if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {
143  output.push_back(eedf.id());
144  EEDataFrame eedf2(output.back());
145  std::copy(eedf.frame().begin(), eedf.frame().end(), eedf2.frame().begin());
146  }
147  }
148 }
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:51
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
static std::string const input
Definition: EdmProvDump.cc:47

◆ setDetIds()

void EcalTBReadout::setDetIds ( const std::vector< DetId > &  detIds)
inline

tell the readout which cells exist

Definition at line 25 of file EcalTBReadout.h.

References theDetIds.

Referenced by EcalTBDigiProducer::initializeEvent().

25 { theDetIds = &detIds; }
const std::vector< DetId > * theDetIds
Definition: EcalTBReadout.h:55

Member Data Documentation

◆ ecalTBInfoLabel_

std::string EcalTBReadout::ecalTBInfoLabel_
private

Definition at line 57 of file EcalTBReadout.h.

Referenced by performReadout().

◆ NCRYMATRIX

const int EcalTBReadout::NCRYMATRIX = 7
staticprivate

Definition at line 53 of file EcalTBReadout.h.

Referenced by findTTlist().

◆ theDetIds

const std::vector<DetId>* EcalTBReadout::theDetIds
private

Definition at line 55 of file EcalTBReadout.h.

Referenced by findTTlist(), and setDetIds().

◆ theTargetCrystal_

int EcalTBReadout::theTargetCrystal_
private

Definition at line 49 of file EcalTBReadout.h.

Referenced by EcalTBReadout(), and findTTlist().

◆ theTTlist_

std::vector<EcalTrigTowerDetId> EcalTBReadout::theTTlist_
private

Definition at line 51 of file EcalTBReadout.h.

Referenced by EcalTBReadout(), findTTlist(), and readOut().