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 | 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, EBDigiCollection &input, EBDigiCollection &output)
 master function to be called once per event More...
 
void performReadout (edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, EEDigiCollection &input, EEDigiCollection &output)
 master function to be called once per event More...
 
void readOut (EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
 read only the digis from the selected TT More...
 
void readOut (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 20 of file EcalTBReadout.h.

Constructor & Destructor Documentation

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

Definition at line 8 of file EcalTBReadout.cc.

References theTargetCrystal_, and theTTlist_.

9 : ecalTBInfoLabel_(theEcalTBInfoLabel) {
10 
11  theTargetCrystal_ = -1;
12  theTTlist_.reserve(1);
13 
14 }
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:52
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:58
EcalTBReadout::~EcalTBReadout ( )
inline

Definition at line 28 of file EcalTBReadout.h.

28 {};

Member Function Documentation

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 16 of file EcalTBReadout.cc.

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

Referenced by performReadout().

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

master function to be called once per event

Definition at line 165 of file EcalTBReadout.cc.

References ecalTBInfoLabel_, findTTlist(), and readOut().

Referenced by EcalTBDigiProducer::produce().

165  {
166 
167  // TB readout
168  // step 1: get the target crystal index
169 
170  edm::Handle<PEcalTBInfo> theEcalTBInfo;
171  event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo);
172 
173  int crysId = theEcalTBInfo->nCrystal();
174 
175  // step 2: update (if needed) the TT list to be read
176 
177  findTTlist(crysId, theTTmap);
178 
179  // step 3: perform the readout
180 
181  readOut(input, output, theTTmap);
182 
183 }
void findTTlist(const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
search for the TT to be read
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:58
void readOut(EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
read only the digis from the selected TT
void EcalTBReadout::performReadout ( edm::Event event,
const EcalTrigTowerConstituentsMap theTTmap,
EEDigiCollection input,
EEDigiCollection output 
)

master function to be called once per event

Definition at line 186 of file EcalTBReadout.cc.

References ecalTBInfoLabel_, findTTlist(), and readOut().

186  {
187 
188  // TB readout
189  // step 1: get the target crystal index
190 
191  edm::Handle<PEcalTBInfo> theEcalTBInfo;
192  event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo);
193 
194  int crysId = theEcalTBInfo->nCrystal();
195 
196  // step 2: update (if needed) the TT list to be read
197 
198  findTTlist(crysId, theTTmap);
199 
200  // step 3: perform the readout
201 
202  readOut(input, output, theTTmap);
203 
204 }
void findTTlist(const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
search for the TT to be read
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:58
void readOut(EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
read only the digis from the selected TT
void EcalTBReadout::readOut ( EBDigiCollection input,
EBDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

Definition at line 107 of file EcalTBReadout.cc.

References edm::DataFrameContainer::back(), edm::DataFrame::begin(), filterCSVwithJSON::copy, edm::DataFrame::end(), spr::find(), EcalDataFrame::frame(), EBDataFrame::id(), edm::DataFrameContainer::push_back(), edm::DataFrameContainer::size(), theTTlist_, and EcalTrigTowerConstituentsMap::towerOf().

Referenced by performReadout().

107  {
108 
109  /*
110  for(EBDigiCollection::const_iterator digiItr = input.begin();
111  digiItr != input.end(); ++digiItr)
112  {
113  EcalTrigTowerDetId thisTTdetId=etmap.towerOf(digiItr->id());
114  std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
115  if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {
116  output.push_back(*digiItr);
117  }
118  }
119  edm::LogInfo("EcalDigi") << "Read EB Digis: " << output.size();
120  */
121 
122  for (unsigned int digis=0; digis<input.size(); ++digis){
123 
124  EBDataFrame ebdf = input[digis];
125 
126  EcalTrigTowerDetId thisTTdetId=etmap.towerOf(ebdf.id());
127  std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
128 
129  if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {
130  output.push_back( ebdf.id() ) ;
131  EBDataFrame ebdf2( output.back() );
132  std::copy( ebdf.frame().begin(),
133  ebdf.frame().end(),
134  ebdf2.frame().begin() );
135  }
136  }
137 }
key_type id() const
Definition: EBDataFrame.h:32
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:52
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
iterator begin()
Definition: DataFrame.h:47
iterator end()
Definition: DataFrame.h:50
edm::DataFrame const & frame() const
Definition: EcalDataFrame.h:46
void push_back(id_type iid, data_type const *idata)
void EcalTBReadout::readOut ( EEDigiCollection input,
EEDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

Definition at line 140 of file EcalTBReadout.cc.

References edm::DataFrameContainer::back(), edm::DataFrame::begin(), filterCSVwithJSON::copy, edm::DataFrame::end(), spr::find(), EcalDataFrame::frame(), EEDataFrame::id(), edm::DataFrameContainer::push_back(), edm::DataFrameContainer::size(), theTTlist_, and EcalTrigTowerConstituentsMap::towerOf().

143 {
144  for (unsigned int digis=0; digis<input.size(); ++digis)
145  {
146  EEDataFrame eedf ( input[digis] ) ;
147 
148  EcalTrigTowerDetId thisTTdetId ( etmap.towerOf( eedf.id() ) ) ;
149 
150  std::vector<EcalTrigTowerDetId>::iterator ttFound
151  ( find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId ) ) ;
152 
153  if( ( ttFound != theTTlist_.end() ) ||
154  *(theTTlist_.end()) == thisTTdetId )
155  {
156  output.push_back( eedf.id() ) ;
157  EEDataFrame eedf2( output.back() ) ;
158  std::copy( eedf.frame().begin(),
159  eedf.frame().end(),
160  eedf2.frame().begin() );
161  }
162  }
163 }
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:52
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
void push_back(id_type iid, data_type const *idata)
void EcalTBReadout::setDetIds ( const std::vector< DetId > &  detIds)
inline

tell the readout which cells exist

Definition at line 31 of file EcalTBReadout.h.

References theDetIds.

Referenced by EcalTBDigiProducer::produce().

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

Member Data Documentation

std::string EcalTBReadout::ecalTBInfoLabel_
private

Definition at line 58 of file EcalTBReadout.h.

Referenced by performReadout().

const int EcalTBReadout::NCRYMATRIX = 7
staticprivate

Definition at line 54 of file EcalTBReadout.h.

Referenced by findTTlist().

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

Definition at line 56 of file EcalTBReadout.h.

Referenced by findTTlist(), and setDetIds().

int EcalTBReadout::theTargetCrystal_
private

Definition at line 50 of file EcalTBReadout.h.

Referenced by EcalTBReadout(), and findTTlist().

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

Definition at line 52 of file EcalTBReadout.h.

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