CMS 3D CMS Logo

EcalTBReadout.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 
8 
9 EcalTBReadout::EcalTBReadout(const std::string theEcalTBInfoLabel) : ecalTBInfoLabel_(theEcalTBInfoLabel) {
10  theTargetCrystal_ = -1;
11  theTTlist_.reserve(1);
12 }
13 
14 void EcalTBReadout::findTTlist(const int &crysId, const EcalTrigTowerConstituentsMap &etmap) {
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 }
98 
101  const EcalTrigTowerConstituentsMap &etmap) {
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 }
131 
134  const EcalTrigTowerConstituentsMap &etmap) {
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 }
149 
151  const EcalTrigTowerConstituentsMap &theTTmap,
152  const EBDigiCollection &input,
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 }
170 
172  const EcalTrigTowerConstituentsMap &theTTmap,
173  const EEDigiCollection &input,
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 }
size
Write out results.
constexpr iterator end()
Definition: DataFrame.h:35
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
key_type id() const
Definition: EBDataFrame.h:28
key_type id() const
Definition: EEDataFrame.h:24
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
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
EcalTBReadout(const std::string theEcalTBInfoLabel)
Definition: EcalTBReadout.cc:9
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
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
void performReadout(edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, const EBDigiCollection &input, EBDigiCollection &output)
master function to be called once per event
Log< level::Info, false > LogInfo
constexpr iterator begin()
Definition: DataFrame.h:33
edm::DataFrame const & frame() const
Definition: EcalDataFrame.h:50
const std::vector< DetId > * theDetIds
Definition: EcalTBReadout.h:55
void findTTlist(const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
search for the TT to be read
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:57
Definition: event.py:1
#define LogDebug(id)