StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtStripCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StFgtStripCollection.cxx,v 2.2 2013/11/13 19:18:34 ullrich Exp $
4  * Author: S. Gliske, Oct 2011
5  *
6  ***************************************************************************
7  *
8  * Description: See header file.
9  *
10  ***************************************************************************
11  *
12  * $Log: StFgtStripCollection.cxx,v $
13  * Revision 2.2 2013/11/13 19:18:34 ullrich
14  * Commented unused variable.
15  *
16  * Revision 2.1 2012/04/16 20:20:49 ullrich
17  * Initial Revision
18  *
19  *
20  **************************************************************************/
21 
22 #include "StContainers.h"
23 #include "StFgtStrip.h"
24 #include "StFgtStripCollection.h"
25 #include <cmath>
26 #include <iostream>
27 
28 using namespace std;
29 
30 // deconstructor
31 StFgtStripCollection::~StFgtStripCollection() {/* no op */}
32 
33 // remove all hits with negative geoIds or with clusterSeedType set to
34 // kFgtDeadStrip
35 void StFgtStripCollection::removeFlagged(){
36  if( !mStripVec.empty() ){
37  // container to hold a copy
38  std::vector< StFgtStrip* > copy;
39  copy.reserve( mStripVec.size() );
40  sortByGeoId();
41 
42  // iterators
43  StSPtrVecFgtStripIterator srcIter;
44  // StSPtrVecFgtStripIterator lastCopied=mStripVec.begin()-1;
45 
46  // copy all valid events
47  for( srcIter = mStripVec.begin(); srcIter != mStripVec.end(); ++srcIter )
48  if( (*srcIter) && (*srcIter)->getClusterSeedType() != kFgtDeadStrip && (*srcIter)->getGeoId() >= 0 )
49  copy.push_back( new StFgtStrip( *(*srcIter) ) );
50 
51  if ( copy.size() != mStripVec.size() ){
52  // this deletes the objects
53  mStripVec.clear();
54  // note: ownership of new objects passed to StSPtrVec
55  std::vector< StFgtStrip* >::iterator copyIter;
56  for( copyIter = copy.begin(); copyIter != copy.end(); ++copyIter )
57  mStripVec.push_back( *copyIter );
58  }
59  }
60 }
61 
62 bool StFgtStripCollection::hitGeoIdLessThan( const StFgtStrip* h1, const StFgtStrip* h2 ){
63  return h1->getGeoId() < h2->getGeoId();
64 };
65 
66 void StFgtStripCollection::Clear( Option_t *opt ){
67 
68  // no need to delete the objects in mStripVec, is done within its
69  // clear function.
70 
71  // clear the vector
72  mStripVec.clear();
73 
74  // clear the vector for alternate lookups
75  for (unsigned int i=0; i<mStripElecIdVec.size(); i++) mStripElecIdVec[i] = static_cast< StFgtStrip* >(0);
76 }
77 
78 StFgtStrip* StFgtStripCollection::getStrip( Int_t elecId ){
79  StFgtStrip* &stripPtr = mStripElecIdVec[elecId];
80  if( !stripPtr ){
81  stripPtr = new StFgtStrip();
82  mStripVec.push_back( stripPtr );
83  }
84  return stripPtr;
85 }
86 
87 ClassImp(StFgtStripCollection);