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, 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 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_.

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

Definition at line 25 of file EcalTBReadout.h.

25 {};

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().

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

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

Referenced by EcalTBDigiProducer::produce().

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

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

198 {
199 
200  // TB readout
201  // step 1: get the target crystal index
202 
203  edm::Handle<PEcalTBInfo> theEcalTBInfo;
204  event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo);
205 
206  int crysId = theEcalTBInfo->nCrystal();
207 
208  // step 2: update (if needed) the TT list to be read
209 
210  findTTlist(crysId, theTTmap);
211 
212  // step 3: perform the readout
213 
214  readOut( input, output, theTTmap) ;
215 }
void readOut(const EBDigiCollection &input, EBDigiCollection &output, const EcalTrigTowerConstituentsMap &etmap)
read only the digis from the selected TT
void findTTlist(const int &crysId, const EcalTrigTowerConstituentsMap &etmap)
search for the TT to be read
std::string ecalTBInfoLabel_
Definition: EcalTBReadout.h:66
void EcalTBReadout::readOut ( const EBDigiCollection input,
EBDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

Definition at line 108 of file EcalTBReadout.cc.

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

Referenced by performReadout().

111 {
112  /*
113  for(EBDigiCollection::const_iterator digiItr = input.begin();
114  digiItr != input.end(); ++digiItr)
115  {
116  EcalTrigTowerDetId thisTTdetId=etmap.towerOf(digiItr->id());
117  std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
118  if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {
119  output.push_back(*digiItr);
120  }
121  }
122  edm::LogInfo("EcalDigi") << "Read EB Digis: " << output.size();
123  */
124 
125  std::cout<<"%%%%%%% In readOut(), size="<< input.size() <<std::endl ;
126 
127  for( unsigned int digis=0; digis<input.size(); ++digis )
128  {
129  EBDataFrame ebdf = input[digis];
130 
131  EcalTrigTowerDetId thisTTdetId=etmap.towerOf(ebdf.id());
132  std::vector<EcalTrigTowerDetId>::iterator ttFound = find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId);
133 
134  if ((ttFound != theTTlist_.end()) || *(theTTlist_.end()) == thisTTdetId) {
135  output.push_back( ebdf.id() ) ;
136  EBDataFrame ebdf2( output.back() );
137  std::copy( ebdf.frame().begin(),
138  ebdf.frame().end(),
139  ebdf2.frame().begin() );
140  }
141  }
142 }
key_type id() const
Definition: EBDataFrame.h:32
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:60
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:51
void push_back(id_type iid, data_type const *idata)
tuple cout
Definition: gather_cfg.py:121
void EcalTBReadout::readOut ( const EEDigiCollection input,
EEDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

Definition at line 145 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().

148 {
149  for (unsigned int digis=0; digis<input.size(); ++digis)
150  {
151  EEDataFrame eedf ( input[digis] ) ;
152 
153  EcalTrigTowerDetId thisTTdetId ( etmap.towerOf( eedf.id() ) ) ;
154 
155  std::vector<EcalTrigTowerDetId>::iterator ttFound
156  ( find(theTTlist_.begin(), theTTlist_.end(), thisTTdetId ) ) ;
157 
158  if( ( ttFound != theTTlist_.end() ) ||
159  *(theTTlist_.end()) == thisTTdetId )
160  {
161  output.push_back( eedf.id() ) ;
162  EEDataFrame eedf2( output.back() ) ;
163  std::copy( eedf.frame().begin(),
164  eedf.frame().end(),
165  eedf2.frame().begin() );
166  }
167  }
168 }
std::vector< EcalTrigTowerDetId > theTTlist_
Definition: EcalTBReadout.h:60
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 28 of file EcalTBReadout.h.

References theDetIds.

Referenced by EcalTBDigiProducer::produce().

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

Member Data Documentation

std::string EcalTBReadout::ecalTBInfoLabel_
private

Definition at line 66 of file EcalTBReadout.h.

Referenced by performReadout().

const int EcalTBReadout::NCRYMATRIX = 7
staticprivate

Definition at line 62 of file EcalTBReadout.h.

Referenced by findTTlist().

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

Definition at line 64 of file EcalTBReadout.h.

Referenced by findTTlist(), and setDetIds().

int EcalTBReadout::theTargetCrystal_
private

Definition at line 58 of file EcalTBReadout.h.

Referenced by EcalTBReadout(), and findTTlist().

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

Definition at line 60 of file EcalTBReadout.h.

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