1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
//StTamuRelLum.cxx

#include "StTamuRelLum.h"
#include <assert.h>

#ifdef __ROOT__
ClassImp(StTamuRelLum)
#endif

//have to initialize the static instance to zero
StTamuRelLum* StTamuRelLum::sInstance = 0;

StTamuRelLum::StTamuRelLum(const string infile)
{
	cout <<"creating a new instance of StTamuRelLum"<<endl;

	//store static pointer for later
	sInstance = this;

	cout <<"\n------------------------------- open file:\t"<<infile<<"\tfor reading"<<endl;
	

	ifstream myin(infile.c_str());

	cout <<"\n------------------------------- Read file header"<<endl;
	char name[256];
	myin.getline(name, 256);
	cout <<name<<endl;

	cout <<"\n------------------------------- Begin Read Loop"<<endl;
	//double r3,dr3;
	while (1) {
		TamuRelLum rl;
		myin >> rl.fill >> rl.runId >> rl.board >> rl.bbcTimeBin >> rl.uu >> rl.du >> rl.ud >> rl.dd;<--- Uninitialized struct member: rl.runId<--- Uninitialized struct member: rl.fill<--- Uninitialized struct member: rl.board<--- Uninitialized struct member: rl.bbcTimeBin<--- Uninitialized struct member: rl.uu<--- Uninitialized struct member: rl.du<--- Uninitialized struct member: rl.ud<--- Uninitialized struct member: rl.dd
		//	>> r3 >> dr3;
		if (!myin.good()) break;

		//cout <<rl<<endl;

		//add to map
		RelLumMap::iterator where = mMap.find(rl);
		if (where!=mMap.end()) {//oops, it's already in the map
			cout <<"StTamuRelLum::StTamuRelLum() -- Error:\trunId:\t"<<rl.runId<<"\tis already stored in map!"<<endl;
			assert(0);
		}
		else {
			mMap[rl] = rl;
		}

	}

	cout <<"---------------- Read:\t"<<mMap.size()<<"\tentries from file"<<endl;
}

void StTamuRelLum::print()
{
	
	cout <<"\n -------------- void StTamuRelLum::print() -------------------"<<endl;
	cout <<"\n contents of map \n"<<endl;

	for (RelLumMap::iterator it=mMap.begin(); it!=mMap.end(); ++it) {
		const TamuRelLum& rl = (*it).second;
		cout <<rl<<endl;
	}
}

const TamuRelLum* StTamuRelLum::getRelLum(int runId, int board, int timeBin)
{
	TamuRelLum key;
	key.runId = runId;
	key.board = board;
	key.bbcTimeBin = timeBin;
	
	RelLumMap::iterator where = mMap.find(key);
	if (where!=mMap.end()) {
		const TamuRelLum& rl = (*where).second;
		const TamuRelLum* rlp = &rl;
		return rlp;
	}
	else {
		return 0;
	}
}

StTamuRelLum::~StTamuRelLum()
{
	cout <<"killing StTamuRelLum"<<endl;
}

bool TamuRelLumLessThan::operator()(const TamuRelLum& lhs, const TamuRelLum& rhs) const
{
	if (lhs.runId<rhs.runId) {
		return true;
	}
	else if (lhs.runId>rhs.runId) {
		return false;
	}
	else {
		if (lhs.board<rhs.board) {
			return true;
		}
		else if (lhs.board>rhs.board) {
			return false;
		}
		else {
			return lhs.bbcTimeBin<rhs.bbcTimeBin;
		}
	}
}