Newer
Older
//*-- Author : Ole Hansen August 2006
// Extracted from Bob Michaels' THaHelicity CVS 1.19
////////////////////////////////////////////////////////////////////////
//
// THcHelicityReader
//
////////////////////////////////////////////////////////////////////////
#include "THcHelicityReader.h"
#include "THaEvData.h"
#include "THcGlobals.h"
#include "THcParmList.h"
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
#include "TMath.h"
#include "TError.h"
#include "VarDef.h"
#include "THaAnalysisObject.h" // For LoadDB
#include <iostream>
#include <vector>
#include "TH1F.h"
using namespace std;
//____________________________________________________________________
THcHelicityReader::THcHelicityReader()
: fTITime(0), fTITime_last(0), fTITime_rollovers(0),
fHaveROCs(kFALSE)
{
// Default constructor
}
//____________________________________________________________________
THcHelicityReader::~THcHelicityReader()
{
// Destructor
// Histograms will be deleted by ROOT
// for( Int_t i = 0; i < NHISTR; ++i ) {
// delete fHistoR[i];
// }
}
//____________________________________________________________________
void THcHelicityReader::Clear( Option_t* )
{
fIsMPS = fIsQrt = fIsHelp = fIsHelm = kFALSE;
}
//_____________________________________________________________________________
Int_t THcHelicityReader::ReadDatabase( const char* /*dbfilename*/,
const char* /*prefix*/,
const TDatime& /*date*/,
int /*debug_flag*/ )
{
// Eventually get these from the parameter file
SetROCinfo(kHel,2,14,9);
SetROCinfo(kHelm,2,14,8);
SetROCinfo(kMPS,2,14,10);
SetROCinfo(kQrt,2,14,7);
SetROCinfo(kTime,2,21,2);
fADCThreshold = 8000;
DBRequest list[] = {
{"helicity_adcthreshold",&fADCThreshold, kInt, 0, 1},
{0}
};
gHcParms->LoadParmValues(list, "");
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
return THaAnalysisObject::kOK;
}
//_____________________________________________________________________________
void THcHelicityReader::Begin()
{
// static const char* const here = "THcHelicityReader::Begin";
// cout<<here<<endl;
fTITime_last = 0;
fTITime = 0;
fTITime_rollovers = 0;
return;
}
//____________________________________________________________________
void THcHelicityReader::End()
{
// static const char* const here = "THcHelicityReader::End";
// cout<<here<<endl;
return;
}
//____________________________________________________________________
Int_t THcHelicityReader::ReadData( const THaEvData& evdata )
{
// Obtain the present data from the event for QWEAK helicity mode.
static const char* here = "THcHelicityReader::ReadData";
// std::cout<<" kHel, kTime, kRing="<< kHel<<" "<<kTime<<" "<<kRing<<endl;
// for (int jk=0; jk<3; jk++)
// {
// std::cout<<" which="<<jk
// <<" roc="<<fROCinfo[jk].roc
// <<" header="<<fROCinfo[jk].header
// <<" index="<<fROCinfo[jk].index
// <<endl;
// }
// std::cout<<" fHaveROCs="<<fHaveROCs<<endl;
if( !fHaveROCs ) {
::Error( here, "ROC data (detector map) not properly set up." );
return -1;
}
// Get the TI Data
// Int_t fTIType = evData.GetData(fTICrate, fTISlot, 0, 0);
// Int_t fTIEvNum = evData.GetData(fTICrate, fTISlot, 1, 0);
UInt_t titime = (UInt_t) evdata.GetData(fROCinfo[kTime].roc,
fROCinfo[kTime].slot,
fROCinfo[kTime].index, 0);
//cout << fTITime_last << " " << titime << endl;
if(titime < fTITime_last) {
fTITime_rollovers++;
}
fTITime = titime + fTITime_rollovers*4294967296;
fTITime_last = titime;
const_cast<THaEvData&>(evdata).SetEvTime(fTITime);
// Get the helicity control signals. These are from the pedestals
// acquired by FADC channels.
Int_t helpraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kHel].roc,
fROCinfo[kHel].slot,
fROCinfo[kHel].index, 0);
Int_t helmraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kHelm].roc,
fROCinfo[kHelm].slot,
fROCinfo[kHelm].index, 0);
Int_t mpsraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kMPS].roc,
fROCinfo[kMPS].slot,
fROCinfo[kMPS].index, 0);
Int_t qrtraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kQrt].roc,
fROCinfo[kQrt].slot,
fROCinfo[kQrt].index, 0);
fIsQrt = qrtraw > fADCThreshold;
fIsMPS = mpsraw > fADCThreshold;
fIsHelp = helpraw > fADCThreshold;
fIsHelm = helmraw > fADCThreshold;
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
return 0;
}
//TODO: this should not be needed once LoadDB can fill fROCinfo directly
//____________________________________________________________________
Int_t THcHelicityReader::SetROCinfo( EROC which, Int_t roc,
Int_t slot, Int_t index )
{
// Define source and offset of data. Normally called by ReadDatabase
// of the detector that is a THcHelicityReader.
//
// "which" is one of { kHel, kKelm, kQrt, kTime }.
// You must define at least the kHel and kTime ROCs.
// Returns <0 if parameter error, 0 if success
if( which<kHel || which>=kCount )
return -1;
if( roc <= 0 || roc > 255 )
return -2;
fROCinfo[which].roc = roc;
fROCinfo[which].slot = slot;
fROCinfo[which].index = index;
//cout << "SetROCInfo: " << which << " " << fROCinfo[kHel].roc << " " << fROCinfo[kTime].roc << endl;
fHaveROCs = ( fROCinfo[kHel].roc > 0 && fROCinfo[kTime].roc > 0 );
return 0;
}
//____________________________________________________________________
ClassImp(THcHelicityReader)