Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:49

0001 /** \class CSCLayerInfo
0002  *
0003  * Auxiliary class containing vectors of comparator or wire RecDigis and
0004  * their matched SimHits for given Layer.
0005  *
0006  * \author Jason Mumford, Slava Valuev  21 August 2001
0007  * Porting from ORCA by S. Valuev in September 2006.
0008  *
0009  *
0010  */
0011 
0012 #ifndef CSCTriggerPrimitives_CSCLayerInfo_H
0013 #define CSCTriggerPrimitives_CSCLayerInfo_H
0014 
0015 #include <iomanip>
0016 #include <vector>
0017 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0018 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0019 
0020 template <class TYPE>
0021 class CSCLayerInfo {
0022 public:
0023   /** default constructor */
0024   CSCLayerInfo();
0025 
0026   /** destructor */
0027   ~CSCLayerInfo();
0028 
0029   /** clears LayerInfo */
0030   void clear();
0031 
0032   /** sets detId of this layer */
0033   void setId(const CSCDetId id) { theLayerId = id; }
0034 
0035   /** fills RecDigi */
0036   void addComponent(const TYPE digi) { RecDigis.push_back(digi); }
0037 
0038   /** fills SimHit */
0039   void addComponent(const PSimHit simHit) { SimHits.push_back(simHit); }
0040 
0041   /** returns the layer */
0042   CSCDetId getId() const { return theLayerId; }
0043 
0044   /** returns the vector of RecDigis (comparator or wire) */
0045   std::vector<TYPE> getRecDigis() const { return RecDigis; }
0046 
0047   /** returns the vector of SimHits */
0048   std::vector<PSimHit> getSimHits() const { return SimHits; }
0049 
0050 private:
0051   CSCDetId theLayerId;
0052   std::vector<TYPE> RecDigis;
0053   std::vector<PSimHit> SimHits;
0054 };
0055 
0056 template <class TYPE>
0057 CSCLayerInfo<TYPE>::CSCLayerInfo() {
0058   CSCDetId tmp;  // nullify theLayerId.
0059   theLayerId = tmp;
0060   RecDigis.reserve(3);  // we may have up to three RecDigis per layer.
0061   SimHits.reserve(3);
0062 }
0063 
0064 template <class TYPE>
0065 CSCLayerInfo<TYPE>::~CSCLayerInfo() {
0066   clear();
0067 }
0068 
0069 template <class TYPE>
0070 void CSCLayerInfo<TYPE>::clear() {
0071   CSCDetId tmp;  // nullify theLayerId.
0072   theLayerId = tmp;
0073   // Use the trick from ORCA-days "CommonDet/DetUtilities/interface/reset.h"
0074   // to delete the capacity of the vectors.
0075   std::vector<TYPE> temp_digis;
0076   std::vector<PSimHit> temp_hits;
0077   RecDigis.swap(temp_digis);
0078   SimHits.swap(temp_hits);
0079 }
0080 
0081 // overloaded << operator
0082 template <class TYPE>
0083 std::ostream& operator<<(std::ostream& output, const CSCLayerInfo<TYPE>& info) {
0084   std::vector<TYPE> thisLayerDigis = info.getRecDigis();
0085   // vector<TYPE>::iterator prd; /* upsets pedantic compillation on LINUX */
0086   if (thisLayerDigis.size() > 0) {
0087     output << "Layer: " << std::setw(1) << info.getId().layer();
0088     for (unsigned int i = 0; i < thisLayerDigis.size(); i++) {
0089       output << " RecDigi # " << i + 1 << ": " << thisLayerDigis[i] << '\t';
0090     }
0091   }
0092   std::vector<PSimHit> thisLayerHits = info.getSimHits();
0093   if (!thisLayerHits.empty()) {
0094     output << "Layer: " << std::setw(1) << info.getId().layer();
0095     for (unsigned int i = 0; i < thisLayerHits.size(); i++) {
0096       output << " SimHit # " << i + 1 << ": " << thisLayerHits[i] << '\t';
0097     }
0098     output << std::endl;
0099   }
0100   return output;
0101 }
0102 #endif  // CSCTriggerPrimitives_CSCLayerInfo_H