-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPulseShapeStruct.h
127 lines (108 loc) · 3.48 KB
/
PulseShapeStruct.h
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef PULSESHAPESTRUCT_H
#define PULSESHAPESTRUCT_H
/// Author: Blair Jamieson (Nov. 2013)
/// Class to parse a v1720 midas bank with PSD info and a waveform
#include <iostream>
#include <stdint.h>
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <string>
#include "TVConstants.h"
// bank structure of individual events from MIDAS
typedef struct {
//uint32_t TimeTag; // Update to 64 bit timestamp -- June 2017
uint64_t TimeTag;
int16_t Channel;
uint16_t ChargeShort;
uint16_t ChargeLong;
int16_t Baseline;
int16_t Pur;
int16_t Length;
} DPP_Bank_Out_t;
void DPP_Bank_Out_Print(DPP_Bank_Out_t *b);
typedef struct{
float fTemp1;
uint16_t fPres;
float fTemp2;
uint32_t fTime;
} slowcntl_Bank_Out_t;
/// DPPBankHanlder takes a bank of data from
/// one v1720 Module and parses it.
class DPPBankHandler{
public:
DPPBankHandler(){
fFirst=true;
verbose=0;
};
~DPPBankHandler(){
if ( fMaxSubEv > 0 ){
for ( int ich=0; ich<PSD_MAXNCHAN; ich++){
if (fDPPInfo[ich]!=NULL) delete [] fDPPInfo[ich];
if (fWaveforms[ich]!=NULL) delete [] fWaveforms[ich];
}
}
};
/// Init takes bank pointer and parses data
/// into a useful format
void Init(char * pdata);
/// Get the maximum number of waveforms per channel
long GetNEvents(){ return fNTotal; };
/// Make a method to clear the number of waveforms
/// for resetting on start of new event
void ClearWaves(){
bzero((void*)fNWaves, PSD_MAXNCHAN*sizeof(int) );
}
/// Get the number of waveforms on a given channel
int GetNWaves(int ichan){ return fNWaves[ichan]; };
/// Get PSD Information for a given
/// sub-event, and channel
DPP_Bank_Out_t * GetPSD(int isubev, int ichan){
if ( fMaxSubEv <= 0 ) return NULL;
if ( ichan <0 || ichan>= PSD_MAXNCHAN ){
if(verbose)
std::cout<<"<PulseShapeStruct::GetPSD> Warning ichan="
<<ichan<<std::endl;
return NULL;
}
if ( isubev <0 || isubev > fNWaves[ichan] ) {
if(verbose)
std::cout<<"<PulseShapeStruct::GetPSD> Warning isubev="
<< isubev << " only "<<fNWaves[ichan]<<std::endl;
return NULL;
}
if (verbose){
std::cout<<"<PulseShapeStruct::GetPSD(isubev="<<isubev<<", ich="<<ichan<<") of "
<<fNWaves[ichan]<<" t="<<fDPPInfo[ichan][isubev]->TimeTag <<std::endl;
}
return fDPPInfo[ichan][isubev];
};
/// Get Waveform Information for a given
/// sub-event, and channel
uint16_t * GetWaveform(int isubev, int ichan){
if ( fMaxSubEv <= 0 ) return NULL;
if ( ichan <0 || ichan>= PSD_MAXNCHAN ) {
if(verbose)
std::cout<<"<PulseShapeStruct::GetWaveform> Warning ichan="
<< ichan << std::endl;
return NULL;
}
if ( isubev <0 || isubev > fNWaves[ichan] ) {
if(verbose)
std::cout<<"<PulseShapeStruct::GetWaveform> Warning ichan="
<< isubev << std::endl;
return NULL;
}
return fWaveforms[ichan][isubev];
};
private:
bool fFirst; /// check if first event loaded
char * fData; /// pointer to memory of start of bank
int fMaxSubEv; /// maximum number of sub events per channel
long fNTotal; /// total number of waveforms
int fNWaves[PSD_MAXNCHAN]; /// number of waveforms by channel
DPP_Bank_Out_t ** fDPPInfo[PSD_MAXNCHAN]; /// [NumChan][NumSubEv]
uint16_t ** fWaveforms[PSD_MAXNCHAN]; /// [NumChan][NumSubEv]
int verbose;
};
#endif