test
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 19 of file EcalTBReadout.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file EcalTBReadout.cc.

References theTargetCrystal_, and theTTlist_.

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

Definition at line 24 of file EcalTBReadout.h.

24 {};

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

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

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

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

Referenced by EcalTBDigiProducer::finalizeEvent().

176 {
177  // TB readout
178  // step 1: get the target crystal index
179 
180  edm::Handle<PEcalTBInfo> theEcalTBInfo;
181  event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo);
182 
183  int crysId = theEcalTBInfo->nCrystal();
184 
185  // step 2: update (if needed) the TT list to be read
186 
187  findTTlist(crysId, theTTmap);
188 
189  // step 3: perform the readout
190 
191  readOut( input, output, theTTmap ) ;
192 }
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:65
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 195 of file EcalTBReadout.cc.

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

199 {
200 
201  // TB readout
202  // step 1: get the target crystal index
203 
204  edm::Handle<PEcalTBInfo> theEcalTBInfo;
205  event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo);
206 
207  int crysId = theEcalTBInfo->nCrystal();
208 
209  // step 2: update (if needed) the TT list to be read
210 
211  findTTlist(crysId, theTTmap);
212 
213  // step 3: perform the readout
214 
215  readOut( input, output, theTTmap) ;
216 }
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:65
void EcalTBReadout::readOut ( const EBDigiCollection input,
EBDigiCollection output,
const EcalTrigTowerConstituentsMap etmap 
)

read only the digis from the selected TT

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

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

read only the digis from the selected TT

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

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

References theDetIds.

Referenced by EcalTBDigiProducer::initializeEvent().

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

Member Data Documentation

std::string EcalTBReadout::ecalTBInfoLabel_
private

Definition at line 65 of file EcalTBReadout.h.

Referenced by performReadout().

const int EcalTBReadout::NCRYMATRIX = 7
staticprivate

Definition at line 61 of file EcalTBReadout.h.

Referenced by findTTlist().

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

Definition at line 63 of file EcalTBReadout.h.

Referenced by findTTlist(), and setDetIds().

int EcalTBReadout::theTargetCrystal_
private

Definition at line 57 of file EcalTBReadout.h.

Referenced by EcalTBReadout(), and findTTlist().

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

Definition at line 59 of file EcalTBReadout.h.

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