CMS 3D CMS Logo

CSCLayerInfo.h
Go to the documentation of this file.
1 
12 #ifndef CSCTriggerPrimitives_CSCLayerInfo_H
13 #define CSCTriggerPrimitives_CSCLayerInfo_H
14 
15 #include <iomanip>
16 #include <vector>
19 
20 template <class TYPE>
22 {
23  public:
25  CSCLayerInfo();
26 
28  ~CSCLayerInfo();
29 
31  void clear();
32 
34  void setId(const CSCDetId id) {theLayerId = id;}
35 
37  void addComponent(const TYPE digi) {RecDigis.push_back(digi);}
38 
40  void addComponent(const PSimHit simHit) {SimHits.push_back(simHit);}
41 
43  CSCDetId getId() const {return theLayerId;}
44 
46  std::vector<TYPE> getRecDigis() const {return RecDigis;}
47 
49  std::vector<PSimHit> getSimHits() const {return SimHits;}
50 
51  private:
53  std::vector<TYPE> RecDigis;
54  std::vector<PSimHit> SimHits;
55 };
56 
57 
58 template<class TYPE> CSCLayerInfo<TYPE>::CSCLayerInfo() {
59  CSCDetId tmp; // nullify theLayerId.
60  theLayerId = tmp;
61  RecDigis.reserve(3); // we may have up to three RecDigis per layer.
62  SimHits.reserve(3);
63 }
64 
65 template<class TYPE> CSCLayerInfo<TYPE>::~CSCLayerInfo() {
66  clear();
67 }
68 
69 template<class TYPE> void CSCLayerInfo<TYPE>::clear() {
70  CSCDetId tmp; // nullify theLayerId.
71  theLayerId = tmp;
72  // Use the trick from ORCA-days "CommonDet/DetUtilities/interface/reset.h"
73  // to delete the capacity of the vectors.
74  std::vector<TYPE> temp_digis;
75  std::vector<PSimHit> temp_hits;
76  RecDigis.swap(temp_digis);
77  SimHits.swap(temp_hits);
78 }
79 
80 // overloaded << operator
81 template<class TYPE>
82 std::ostream& operator<< (std::ostream& output,
83  const CSCLayerInfo<TYPE>& info) {
84  std::vector<TYPE> thisLayerDigis = info.getRecDigis();
85  // vector<TYPE>::iterator prd; /* upsets pedantic compillation on LINUX */
86  if (thisLayerDigis.size() > 0) {
87  output << "Layer: " << std::setw(1) << info.getId().layer();
88  for (unsigned int i = 0; i < thisLayerDigis.size(); i++) {
89  output << " RecDigi # " << i+1 << ": " << thisLayerDigis[i] << '\t';
90  }
91  }
92  std::vector<PSimHit> thisLayerHits = info.getSimHits();
93  if (thisLayerHits.size() > 0) {
94  output << "Layer: " << std::setw(1) << info.getId().layer();
95  for (unsigned int i = 0; i < thisLayerHits.size(); i++) {
96  output << " SimHit # " << i+1 << ": " << thisLayerHits[i] << '\t';
97  }
98  output << std::endl;
99  }
100  return output;
101 }
102 #endif // CSCTriggerPrimitives_CSCLayerInfo_H
std::vector< TYPE > RecDigis
Definition: CSCLayerInfo.h:53
std::vector< TYPE > getRecDigis() const
Definition: CSCLayerInfo.h:46
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< PSimHit > getSimHits() const
Definition: CSCLayerInfo.h:49
std::vector< PSimHit > SimHits
Definition: CSCLayerInfo.h:54
void addComponent(const TYPE digi)
Definition: CSCLayerInfo.h:37
CSCDetId theLayerId
Definition: CSCLayerInfo.h:52
int layer() const
Definition: CSCDetId.h:61
void addComponent(const PSimHit simHit)
Definition: CSCLayerInfo.h:40
std::ostream & operator<<(std::ostream &output, const CSCLayerInfo< TYPE > &info)
Definition: CSCLayerInfo.h:82
void clear()
Definition: CSCLayerInfo.h:69
void setId(const CSCDetId id)
Definition: CSCLayerInfo.h:34
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
CSCDetId getId() const
Definition: CSCLayerInfo.h:43