RawAnitaEvent.cxx
1 
10 #include "RawAnitaEvent.h"
11 #include "AnitaPacketUtil.h"
12 #include <iostream>
13 #include <fstream>
14 #include <cstring>
15 
16 ClassImp(RawAnitaEvent);
17 
19 {
20  //Default Constructor
21 }
22 
24  //Default Destructor
25 }
26 
27 
29 {
31  //Filling Constructor
32  whichPeds=bdPtr->whichPeds;
33  eventNumber=bdPtr->eventNumber;
34  memcpy(surfEventId,bdPtr->surfEventId,ACTIVE_SURFS*sizeof(UInt_t));
35 
36  for(int chan=0;chan<NUM_DIGITZED_CHANNELS;chan++) {
37  chanId[chan]=bdPtr->channel[chan].header.chanId;
38  chipIdFlag[chan]=bdPtr->channel[chan].header.chipIdFlag;
39  firstHitbus[chan]=bdPtr->channel[chan].header.firstHitbus;
40  lastHitbus[chan]=bdPtr->channel[chan].header.lastHitbus;
41 
42  xMin[chan]=bdPtr->channel[chan].xMin;
43  xMax[chan]=bdPtr->channel[chan].xMax;
44  mean[chan]=bdPtr->channel[chan].mean;
45  rms[chan]=bdPtr->channel[chan].rms;
46 
47  memcpy(data[chan],bdPtr->channel[chan].data,sizeof(Short_t)*MAX_NUMBER_SAMPLES);
48  }
49 }
50 
52 {
53  if(bdPtr->gHdr.code!=PACKET_PED_SUBBED_EVENT ||
54  bdPtr->gHdr.verId!=11 ||
55  bdPtr->gHdr.numBytes!=sizeof(PedSubbedEventBodyVer11_t)) {
56  std::cerr << "Mismatched packet\n"
57  << "code:\t" << bdPtr->gHdr.code << "\t" << PACKET_PED_SUBBED_EVENT
58  << "\nversion:\t" << bdPtr->gHdr.verId
59  << "\t" << 11
60  << "\nsize:\t" << bdPtr->gHdr.numBytes << "\t"
61  << sizeof(PedSubbedEventBodyVer11_t) << std::endl;
62  }
63 
64  //Filling Constructor
65  whichPeds=bdPtr->whichPeds;
66  eventNumber=bdPtr->eventNumber;
67  memcpy(surfEventId,bdPtr->surfEventId,ACTIVE_SURFS*sizeof(UInt_t));
68 
69  for(int chan=0;chan<NUM_DIGITZED_CHANNELS;chan++) {
70  chanId[chan]=bdPtr->channel[chan].header.chanId;
71  chipIdFlag[chan]=bdPtr->channel[chan].header.chipIdFlag;
72  firstHitbus[chan]=bdPtr->channel[chan].header.firstHitbus;
73  lastHitbus[chan]=bdPtr->channel[chan].header.lastHitbus;
74 
75  xMin[chan]=bdPtr->channel[chan].xMin;
76  xMax[chan]=bdPtr->channel[chan].xMax;
77  mean[chan]=bdPtr->channel[chan].mean;
78  rms[chan]=bdPtr->channel[chan].rms;
79 
80  memcpy(data[chan],bdPtr->channel[chan].data,sizeof(Short_t)*MAX_NUMBER_SAMPLES);
81  }
82 }
83 
85 {
86  if(bdPtr->gHdr.code!=PACKET_PED_SUBBED_EVENT ||
87  bdPtr->gHdr.verId!=10 ||
88  bdPtr->gHdr.numBytes!=sizeof(PedSubbedEventBodyVer10_t)) {
89  std::cerr << "Mismatched packet\n"
90  << "code:\t" << bdPtr->gHdr.code << "\t" << PACKET_PED_SUBBED_EVENT
91  << "\nversion:\t" << bdPtr->gHdr.verId
92  << "\t" << 10
93  << "\nsize:\t" << bdPtr->gHdr.numBytes << "\t"
94  << sizeof(PedSubbedEventBodyVer10_t) << std::endl;
95  }
96 
97  //Filling Constructor
98  whichPeds=bdPtr->whichPeds;
99  eventNumber=bdPtr->eventNumber;
100  memset(surfEventId,0,ACTIVE_SURFS*sizeof(UInt_t));
101 
102  for(int chan=0;chan<NUM_DIGITZED_CHANNELS;chan++) {
103  chanId[chan]=bdPtr->channel[chan].header.chanId;
104  chipIdFlag[chan]=bdPtr->channel[chan].header.chipIdFlag;
105  firstHitbus[chan]=bdPtr->channel[chan].header.firstHitbus;
106  lastHitbus[chan]=bdPtr->channel[chan].header.lastHitbus;
107 
108  xMin[chan]=bdPtr->channel[chan].xMin;
109  xMax[chan]=bdPtr->channel[chan].xMax;
110  mean[chan]=bdPtr->channel[chan].mean;
111  rms[chan]=bdPtr->channel[chan].rms;
112 
113  memcpy(data[chan],bdPtr->channel[chan].data,sizeof(Short_t)*MAX_NUMBER_SAMPLES);
114  }
115 }
116 
117 Int_t RawAnitaEvent::getEarliestSample(Int_t chanIndex)
118 {
119  Int_t lastHitBus=this->getLastHitBus(chanIndex);
120  Int_t firstHitbus=this->getFirstHitBus(chanIndex);
121  Int_t wrappedHitBus=this->getWrappedHitBus(chanIndex);
122  Int_t earliestSample=0;
123  if(!wrappedHitBus) {
124  earliestSample=lastHitBus+1;
125  }
126  else {
127  earliestSample=firstHitbus+1;
128  }
129  if(earliestSample==0) earliestSample=1;
130  if(earliestSample<260) return earliestSample;
131  return 1;
132 }
133 
134 Int_t RawAnitaEvent::getLatestSample(Int_t chanIndex)
135 {
136  Int_t lastHitBus=this->getLastHitBus(chanIndex);
137  Int_t firstHitbus=this->getFirstHitBus(chanIndex);
138  Int_t wrappedHitBus=this->getWrappedHitBus(chanIndex);
139  Int_t latestSample=259;
140  if(!wrappedHitBus) {
141  latestSample=firstHitbus-1;
142  }
143  else {
144  latestSample=lastHitBus-1;
145  }
146  if(latestSample>0) return latestSample;
147  return 259;
148 }
149 
UInt_t eventNumber
Event number from software.
Definition: RawAnitaEvent.h:33
unsigned int whichPeds
whichPedestals did we subtract
unsigned char chanId
Channel Id.
Pedestal subtracted event format.
UInt_t whichPeds
Timestamp of pedestals used in subtraction.
Definition: RawAnitaEvent.h:32
UChar_t chipIdFlag[12 *9]
chipIdFlag
Definition: RawAnitaEvent.h:47
short data[260]
Pedestal subtracted and 11bit data.
~RawAnitaEvent()
Destructor.
float rms
Filled by pedestalLib.
Int_t getWrappedHitBus(Int_t chanIndex) const
Return the wrapped hitbus flag for the channel. When the HITBUS is wrapped the waveform runs from fir...
Definition: RawAnitaEvent.h:80
RawAnitaEvent()
Default constructor.
UChar_t chanId[12 *9]
Definition: RawAnitaEvent.h:39
Short_t data[12 *9][260]
The pedestal subtracted waveform data. Note that these arrays must be unwrapped and calibrated to bec...
Definition: RawAnitaEvent.h:67
Int_t getLastHitBus(Int_t chanIndex) const
Returns the lastHitbus value for the channel.
Definition: RawAnitaEvent.h:76
Float_t rms[12 *9]
RMS of the waveform.
Definition: RawAnitaEvent.h:64
unsigned char lastHitbus
Last sample of the hitbus.
Short_t xMin[12 *9]
Minimum value in ADCs???
Definition: RawAnitaEvent.h:62
PedSubbedEventBody_t – No too big.
Int_t getFirstHitBus(Int_t chanIndex) const
Returns the firstHitbus value for the channel.
Definition: RawAnitaEvent.h:73
Int_t getEarliestSample(Int_t chanIndex)
Returns the earliest sample in the waveform.
Short_t xMax[12 *9]
Maximum value in ADCs???
Definition: RawAnitaEvent.h:61
unsigned int whichPeds
whichPedestals did we subtract
Definition: oldStructs.h:876
unsigned char firstHitbus
First sample of the hitbus.
Float_t mean[12 *9]
Mean of the waveform.
Definition: RawAnitaEvent.h:63
UChar_t lastHitbus[12 *9]
Last sample of the hitbus.
Definition: RawAnitaEvent.h:59
UChar_t firstHitbus[12 *9]
First sample of the hitbus.
Definition: RawAnitaEvent.h:53
UInt_t surfEventId[12]
SURF Event Id&#39;s.
Definition: RawAnitaEvent.h:36
unsigned char chipIdFlag
chip id bitmask
Int_t getLatestSample(Int_t chanIndex)
Returns the latest sample in the waveform.
int simplePacketCheck(GenericHeader_t *gHdr, PacketCode_t code)
simplePacketCheck – utility function
float mean
Filled by pedestalLib.
RawAnitaEvent – The Raw ANITA Event Data.
Definition: RawAnitaEvent.h:22