StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TrigSet.cxx
1 /*
2  * Created by S. Gliske, Aug 2012
3  *
4  * Description: Container to hold the set of triggers.
5  *
6  */
7 
8 #include "StRoot/StEEmcPool/./EEmcTreeContainers/TrigSet.h"
9 
10 #include <Rtypes.h>
11 #include <TObject.h>
12 
13 #include <set>
14 #include <vector>
15 //#include <iostream>
16 
17 TrigSet::TrigSet() : nTrigs(0), mTrigArray(0) { /* */ };
18 
19 TrigSet::~TrigSet(){
20  if( mTrigArray )
21  delete mTrigArray;
22 };
23 
24 
25 void TrigSet::Clear( const Option_t* opt ){
26  nTrigs = 0;
27  delete mTrigArray;
28  mTrigArray = 0;
29 
30  mTrigSet.clear();
31 };
32 
33 // modifier
34 void TrigSet::insert( const std::vector< UInt_t >& trigVec ){
35 
36  // set size
37  nTrigs = trigVec.size();
38 
39  // dealloc if needed
40  if( mTrigArray )
41  delete mTrigArray;
42 
43  // alloc
44  mTrigArray = new UInt_t[ trigVec.size() ];
45 
46  // copy
47  std::copy( trigVec.begin(), trigVec.end(), mTrigArray );
48  std::copy( trigVec.begin(), trigVec.end(), std::inserter( mTrigSet, mTrigSet.end() ) );
49 };
50 
51 // set the set from the array
52 void TrigSet::resync() const {
53  mTrigSet.clear();
54 
55  std::copy( mTrigArray, &mTrigArray[nTrigs], std::inserter( mTrigSet, mTrigSet.end() ) );
56 
57 // for( UInt_t* p = mTrigArray; p != &mTrigArray[nTrigs]; ++p )
58 // mTrigSet.insert( *p );
59 };
60 
61 void TrigSet::copyToVector( std::vector< UInt_t >& vec ) const {
62  vec.clear();
63  vec.reserve( nTrigs );
64  vec.insert( vec.end(), mTrigArray, &mTrigArray[nTrigs] );
65 };
66 
67 ClassImp( TrigSet );
68 
69 /*
70  * $Id: TrigSet.cxx,v 1.1 2012/11/26 19:04:31 sgliske Exp $
71  * $Log: TrigSet.cxx,v $
72  * Revision 1.1 2012/11/26 19:04:31 sgliske
73  * moved from offline/users/sgliske/StRoot/StEEmcPool/EEmcTreeContainers to StRoot/StEEmcPool/EEmcTreeContainers
74  *
75  *
76  */