StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtStripCollection.h
1 /***************************************************************************
2  *
3  * $Id: StFgtStripCollection.h,v 2.2 2013/01/08 19:52:43 ullrich Exp $
4  * Author: S. Gliske, Oct 2011
5  *
6  ***************************************************************************
7  *
8  * Description: A collection of StFgtStrip classes for StEvent.
9  * Basically a wrapper for an StSPtrVecFgtStrip
10  *
11  ***************************************************************************
12  *
13  * $Log: StFgtStripCollection.h,v $
14  * Revision 2.2 2013/01/08 19:52:43 ullrich
15  * Changes in streamer.
16  *
17  * Revision 2.1 2012/04/16 20:20:49 ullrich
18  * Initial Revision
19  *
20  *
21  **************************************************************************/
22 
23 #ifndef _ST_FGT_STRIP_COLLECTION_H_
24 #define _ST_FGT_STRIP_COLLECTION_H_
25 
26 #include "StObject.h"
27 #include "StContainers.h"
28 #include "StFgtStrip.h"
29 
30 using namespace std;
31 
33 public:
34  // constructors
35  StFgtStripCollection( short disc = 0 );
36  // StFgtStripCollection( const StFgtStripCollection& other ); ---> use default
37  // StFgtStripCollection& operator=( const StFgtStripCollection& other ); ---> use default
38 
39  // deconstructor
41 
42  // accessors for the underlying vector. WARNING: never use
43  // getStripVec().push_back() or equivelants. Instead use
44  // StFgtStripCollection::getStrip to add a new strip.
45  StSPtrVecFgtStrip& getStripVec();
46  const StSPtrVecFgtStrip& getStripVec() const;
47 
48  // sort internal vector by geoId
49  void sortByGeoId();
50 
51  // remove all hits with negative geoIds
52  void removeFlagged();
53 
54  // size of internal vector
55  size_t getNumStrips() const;
56 
57  // modify/access the discId
58  short getDisc() const;
59  void setDisc( short disc );
60 
61  // Clear
62  void Clear( Option_t *opt = "" );
63 
64  // Get pointer to a strip -- note: this is the only way to modify a
65  // strip. New strip is created if it does not exist, but only
66  // using StFgtStrip() constructor. Ownership is retained by the
67  // collection.
68  StFgtStrip* getStrip( int elecId );
69 
70 protected:
71  // function used for sorting strips by geoId
72  static bool hitGeoIdLessThan( const StFgtStrip* h1, const StFgtStrip* h2 );
73 
74 protected:
75  // the data members
76  Short_t mDisc;
77  StSPtrVecFgtStrip mStripVec;
78 
79  // temporary copy of the pointers, indexed by elec Id.
80  // used for the addStripInfo class
81  StPtrVecFgtStrip mStripElecIdVec;
82 
83 private:
84  ClassDef(StFgtStripCollection,2);
85 };
86 
87 
88 // inline functions
89 
90 inline StFgtStripCollection::StFgtStripCollection( short disc ) : StObject(), mDisc( disc ) {
91  mStripElecIdVec.resize( kFgtNumElecIds );
92  for (unsigned int i=0; i<mStripElecIdVec.size(); i++)
93  mStripElecIdVec[i] = static_cast< StFgtStrip* >(0);
94 };
95 
96 inline StSPtrVecFgtStrip& StFgtStripCollection::getStripVec() {
97  return mStripVec;
98 };
99 
100 inline const StSPtrVecFgtStrip& StFgtStripCollection::getStripVec() const{
101  return mStripVec;
102 };
103 
104 // sort by geoId
105 inline void StFgtStripCollection::sortByGeoId(){
106  std::sort( mStripVec.begin(), mStripVec.end(), &StFgtStripCollection::hitGeoIdLessThan );
107  return;
108 };
109 
110 inline size_t StFgtStripCollection::getNumStrips() const {
111  return mStripVec.size();
112 };
113 
114 inline void StFgtStripCollection::setDisc( short discId ) {
115  mDisc = discId;
116 };
117 
118 inline short StFgtStripCollection::getDisc() const {
119  return mDisc;
120 };
121 
122 #endif