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>
21 class CSCLayerInfo {
22 public:
24  CSCLayerInfo();
25 
27  ~CSCLayerInfo();
28 
30  void clear();
31 
33  void setId(const CSCDetId id) { theLayerId = id; }
34 
36  void addComponent(const TYPE digi) { RecDigis.push_back(digi); }
37 
39  void addComponent(const PSimHit simHit) { SimHits.push_back(simHit); }
40 
42  CSCDetId getId() const { return theLayerId; }
43 
45  std::vector<TYPE> getRecDigis() const { return RecDigis; }
46 
48  std::vector<PSimHit> getSimHits() const { return SimHits; }
49 
50 private:
52  std::vector<TYPE> RecDigis;
53  std::vector<PSimHit> SimHits;
54 };
55 
56 template <class TYPE>
58  CSCDetId tmp; // nullify theLayerId.
59  theLayerId = tmp;
60  RecDigis.reserve(3); // we may have up to three RecDigis per layer.
61  SimHits.reserve(3);
62 }
63 
64 template <class TYPE>
66  clear();
67 }
68 
69 template <class TYPE>
71  CSCDetId tmp; // nullify theLayerId.
72  theLayerId = tmp;
73  // Use the trick from ORCA-days "CommonDet/DetUtilities/interface/reset.h"
74  // to delete the capacity of the vectors.
75  std::vector<TYPE> temp_digis;
76  std::vector<PSimHit> temp_hits;
77  RecDigis.swap(temp_digis);
78  SimHits.swap(temp_hits);
79 }
80 
81 // overloaded << operator
82 template <class TYPE>
83 std::ostream& operator<<(std::ostream& output, 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.empty()) {
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:52
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< PSimHit > SimHits
Definition: CSCLayerInfo.h:53
void addComponent(const TYPE digi)
Definition: CSCLayerInfo.h:36
CSCDetId theLayerId
Definition: CSCLayerInfo.h:51
void addComponent(const PSimHit simHit)
Definition: CSCLayerInfo.h:39
void clear()
Definition: CSCLayerInfo.h:70
std::vector< TYPE > getRecDigis() const
Definition: CSCLayerInfo.h:45
std::vector< PSimHit > getSimHits() const
Definition: CSCLayerInfo.h:48
void setId(const CSCDetId id)
Definition: CSCLayerInfo.h:33
Definition: output.py:1
CSCDetId getId() const
Definition: CSCLayerInfo.h:42
void clear(EGIsoObj &c)
Definition: egamma.h:82
tmp
align.sh
Definition: createJobs.py:716