StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtStatusReader.cxx
1 /***************************************************************************
2  *
3  * $Id: StFgtStatusReader.cxx,v 1.1 2012/01/31 08:59:43 sgliske Exp $
4  * Author: C. K. Riley, Nov 2011
5  *
6  ***************************************************************************
7  *
8  * Description: see header.
9  *
10  ***************************************************************************
11  *
12  * $Log: StFgtStatusReader.cxx,v $
13  * Revision 1.1 2012/01/31 08:59:43 sgliske
14  * moved StFgtStatus maker to StFgtPool
15  *
16  * Revision 1.3 2012/01/27 13:38:08 sgliske
17  * updated to correspond with new StatusMakers,
18  * Now keyed by elecId
19  *
20  * Revision 1.2 2011/12/01 00:41:34 ckriley
21  * make compatible with db stuff
22  *
23  * Revision 1.1 2011/11/25 20:22:37 ckriley
24  * creation of statusmaker
25  *
26  *
27  *
28  **************************************************************************/
29 
30 #include <string>
31 #include <iostream>
32 #include <fstream>
33 #include <Rtypes.h>
34 #include "StFgtStatusReader.h"
35 #include "StRoot/StFgtUtil/StFgtConsts.h"
36 
37 // constructor
38 inline StFgtStatusReader::StFgtStatusReader( const Char_t* filename ) :
39  mFilename( filename ) {
40 
41  // set to all 0xFF -- i.e. fail
42  mStatusVec.resize( kFgtNumTimeBins * kFgtNumElecIds );
43 };
44 
45 // initialize
46 Int_t StFgtStatusReader::Init(){
47  Int_t ierr = 0;
48  mStatusVec.assign( kFgtNumTimeBins * kFgtNumElecIds, 0xFF );
49 
50  std::ifstream fin( mFilename.data() );
51 
52  if( !fin ){
53  std::cerr << "Error opening file '" << mFilename << "'" << std::endl;
54  ierr = 1;
55  };
56 
57  if( !ierr ){
58  Int_t elecId, status;
59 
60  while( !fin.eof() && !ierr ){
61  fin >> elecId >> status;
62  mStatusVec[ elecId ] = status;
63  };
64  };
65 
66  return ierr;
67 };
68 
69 ClassImp( StFgtStatusReader );