10 #include "AnitaPacketUtil.h" 11 #include "AnitaGeomTool.h" 12 #include "AnitaEventCalibrator.h" 16 #include "AnitaVersion.h" 41 memcpy(
upperWords,surfPtr->upperWords,
sizeof(UShort_t)*ACTIVE_SURFS);
44 int rawSurfToTrigSurf[ACTIVE_SURFS]={-1,-1,0,1,2,3,4,5,6,7,-1,-1};
47 for(
int surf=0;surf<ACTIVE_SURFS;surf++) {
48 if(rawSurfToTrigSurf[surf]>=0) {
50 for(
int l1=0;l1<L1S_PER_SURF;l1++) {
51 l1Scaler[surf][l1]=surfPtr->l1Scaler[rawSurfToTrigSurf[surf]][l1];
53 for(
int l2=0;l2<L2S_PER_SURF;l2++) {
54 l2Scaler[surf][l2]=surfPtr->l2Scaler[rawSurfToTrigSurf[surf]][l2];
56 for(
int i=0;i<12;i++) {
57 scaler[surf][i]=surfPtr->scaler[rawSurfToTrigSurf[surf]][i];
58 threshold[surf][i]=surfPtr->threshold[rawSurfToTrigSurf[surf]][i];
59 setThreshold[surf][i]=surfPtr->setThreshold[rawSurfToTrigSurf[surf]][i];
64 for(
int l1=0;l1<L1S_PER_SURF;l1++) {
67 for(
int l2=0;l2<L2S_PER_SURF;l2++) {
70 for(
int i=0;i<12;i++) {
77 memcpy(
rfPower,surfPtr->rfPower,
sizeof(UShort_t)*ACTIVE_SURFS*RFCHAN_PER_SURF);
86 surfPtr->gHdr.verId!=VER_SURF_HK ||
90 <<
"\ncode:\t" << (int)surfPtr->gHdr.code <<
"\t" <<
PACKET_SURF_HK 91 <<
"\nversion:\t" << (
int)surfPtr->gHdr.verId
92 <<
"\t" << VER_SURF_HK
93 <<
"\nsize:\t" << surfPtr->gHdr.numBytes <<
"\t" 105 memcpy(
upperWords,surfPtr->upperWords,
sizeof(UShort_t)*ACTIVE_SURFS);
107 for(
int surf=0;surf<ACTIVE_SURFS;surf++) {
108 for(
int l1=0;l1<L1S_PER_SURF;l1++) {
109 l1Scaler[surf][l1]=surfPtr->l1Scaler[surf][l1];
111 for(
int i=0;i<12;i++) {
112 scaler[surf][i]=surfPtr->scaler[surf][i];
113 threshold[surf][i]=surfPtr->threshold[surf][i];
117 memcpy(
rfPower,surfPtr->rfPower,
sizeof(UShort_t)*ACTIVE_SURFS*RFCHAN_PER_SURF);
118 memcpy(
surfTrigBandMask,surfPtr->surfTrigBandMask,
sizeof(UShort_t)*ACTIVE_SURFS);
127 surfPtr->gHdr.verId!=VER_SURF_HK ||
131 <<
"\ncode:\t" << (int)surfPtr->gHdr.code <<
"\t" <<
PACKET_SURF_HK 132 <<
"\nversion:\t" << (
int)surfPtr->gHdr.verId
133 <<
"\t" << VER_SURF_HK
134 <<
"\nsize:\t" << surfPtr->gHdr.numBytes <<
"\t" 147 memcpy(
upperWords,surfPtr->upperWords,
sizeof(UShort_t)*ACTIVE_SURFS);
148 memcpy(
scaler,surfPtr->scaler,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF_V30);
149 memcpy(
threshold,surfPtr->threshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF_V30);
150 memcpy(
setThreshold,surfPtr->setThreshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF_V30);
151 memcpy(
rfPower,surfPtr->rfPower,
sizeof(UShort_t)*ACTIVE_SURFS*RFCHAN_PER_SURF);
152 memcpy(
surfTrigBandMask,surfPtr->surfTrigBandMask,
sizeof(UShort_t)*ACTIVE_SURFS);
160 surfPtr->gHdr.verId!=14 ||
164 <<
"\ncode:\t" << (int)surfPtr->gHdr.code <<
"\t" <<
PACKET_SURF_HK 165 <<
"\nversion:\t" << (
int)surfPtr->gHdr.verId
167 <<
"\nsize:\t" << surfPtr->gHdr.numBytes <<
"\t" 180 memcpy(
upperWords,surfPtr->upperWords,
sizeof(UShort_t)*ACTIVE_SURFS);
181 memcpy(
scaler,surfPtr->scaler,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
182 memcpy(
threshold,surfPtr->threshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
183 memcpy(
setThreshold,surfPtr->setThreshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
184 memcpy(
rfPower,surfPtr->rfPower,
sizeof(UShort_t)*ACTIVE_SURFS*RFCHAN_PER_SURF);
185 memcpy(
surfTrigBandMask,surfPtr->surfTrigBandMask,
sizeof(UShort_t)*ACTIVE_SURFS);
192 surfPtr->gHdr.verId!=13 ||
196 <<
"\ncode:\t" << (int)surfPtr->gHdr.code <<
"\t" <<
PACKET_SURF_HK 197 <<
"\nversion:\t" << (
int)surfPtr->gHdr.verId
199 <<
"\nsize:\t" << surfPtr->gHdr.numBytes <<
"\t" 210 memcpy(
scalerGoals,surfPtr->scalerGoals,
sizeof(UShort_t)*BANDS_PER_ANT);
211 for(
int band=0;band<BANDS_PER_ANT;band++)
213 memcpy(
upperWords,surfPtr->upperWords,
sizeof(UShort_t)*ACTIVE_SURFS);
214 memcpy(
scaler,surfPtr->scaler,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
215 memcpy(
threshold,surfPtr->threshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
216 memcpy(
setThreshold,surfPtr->setThreshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
217 memcpy(
rfPower,surfPtr->rfPower,
sizeof(UShort_t)*ACTIVE_SURFS*RFCHAN_PER_SURF);
218 memcpy(
surfTrigBandMask,surfPtr->surfTrigBandMask,
sizeof(UShort_t)*ACTIVE_SURFS);
225 surfPtr->gHdr.verId!=12 ||
229 <<
"\ncode:\t" << (int)surfPtr->gHdr.code <<
"\t" <<
PACKET_SURF_HK 230 <<
"\nversion:\t" << (
int)surfPtr->gHdr.verId
232 <<
"\nsize:\t" << surfPtr->gHdr.numBytes <<
"\t" 243 for(
int band=0;band<BANDS_PER_ANT;band++) {
247 memcpy(
upperWords,surfPtr->upperWords,
sizeof(UShort_t)*ACTIVE_SURFS);
248 memcpy(
scaler,surfPtr->scaler,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
249 memcpy(
threshold,surfPtr->threshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
250 memcpy(
setThreshold,surfPtr->setThreshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
251 memcpy(
rfPower,surfPtr->rfPower,
sizeof(UShort_t)*ACTIVE_SURFS*RFCHAN_PER_SURF);
252 memcpy(
surfTrigBandMask,surfPtr->surfTrigBandMask,
sizeof(UShort_t)*ACTIVE_SURFS);
259 UInt_t tpayloadTimeUs,
260 UShort_t tglobalThreshold,
262 UShort_t tscalerGoals[BANDS_PER_ANT],
263 UShort_t tscalerGoalsNadir[BANDS_PER_ANT],
264 UShort_t tupperWords[ACTIVE_SURFS],
265 UShort_t tscaler[ACTIVE_SURFS][SCALERS_PER_SURF],
266 UShort_t tthreshold[ACTIVE_SURFS][SCALERS_PER_SURF],
267 UShort_t tsetThreshold[ACTIVE_SURFS][SCALERS_PER_SURF],
268 UShort_t trfPower[ACTIVE_SURFS][RFCHAN_PER_SURF],
269 UShort_t tsurfTrigBandMask[ACTIVE_SURFS],
279 memcpy(
scalerGoals,tscalerGoals,
sizeof(UShort_t)*BANDS_PER_ANT);
281 memcpy(
upperWords,tupperWords,
sizeof(UShort_t)*ACTIVE_SURFS);
282 memcpy(
scaler,tscaler,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
283 memcpy(
threshold,tthreshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
284 memcpy(
setThreshold,tsetThreshold,
sizeof(UShort_t)*ACTIVE_SURFS*SCALERS_PER_SURF);
285 memcpy(
rfPower,trfPower,
sizeof(UShort_t)*ACTIVE_SURFS*RFCHAN_PER_SURF);
295 if (AnitaVersion::get() == 4)
298 AnitaGeomTool::getSurfL1TriggerChanFromPhiPol(phi,pol,surf,l1Scl);
300 if((surf>=0 && surf<ACTIVE_SURFS) && (l1Scl>=0 && l1Scl<L1S_PER_SURF)) {
309 if (AnitaVersion::get() == 3)
return -1;
313 if((surf>=0 && surf<ACTIVE_SURFS) && (l2Scl>=0 && l2Scl<L2S_PER_SURF)) {
325 if((surf>=0 && surf<ACTIVE_SURFS) && (scl>=0 && scl<SCALERS_PER_SURF))
334 if((surf>=0 && surf<ACTIVE_SURFS) && (scl>=0 && scl<SCALERS_PER_SURF))
344 if((surf>=0 && surf<ACTIVE_SURFS) && (scl>=0 && scl<SCALERS_PER_SURF))
354 if((surf>=0 && surf<ACTIVE_SURFS) && (scl>=0 && scl<SCALERS_PER_SURF))
363 return scl +surf*SCALERS_PER_SURF;
378 return getScalerGoalRing(ring);
383 if(surf<0 || surf>=ACTIVE_SURFS)
385 if(chan<0 || chan>=RFCHAN_PER_SURF)
387 Int_t adc=
rfPower[surf][chan]&0x7fff
389 if(adc==0)
return 290;
392 if(TMath::IsNaN(kelvin))
return 290;
393 if(kelvin<0)
return 290;
394 if(kelvin>1e6)
return 290;
412 if(surf<0 || surf>=ACTIVE_SURFS)
414 if(chan<0 || chan>=RFCHAN_PER_SURF)
416 UShort_t adc=
rfPower[surf][chan]&0x7FFF;
420 UInt_t SurfHk::getRFPowerTimeOffset(
int surf,
int chan)
423 if(surf<0 || surf>=ACTIVE_SURFS)
425 if(chan<0 || chan>=RFCHAN_PER_SURF)
428 int zeroPhaseChan = 0;
429 UInt_t startPhase =
rfPower[surf][0]&0x8000;
430 for (
int chani =0; chani<=RFCHAN_PER_SURF; chani++) {
431 if ((
rfPower[surf][chani]&0x8000) != startPhase) {
432 zeroPhaseChan = chani;
436 UInt_t PhaseOffset = 0;
437 if (chan < zeroPhaseChan) {
438 PhaseOffset = zeroPhaseChan - chan; }
439 if (chan >= zeroPhaseChan) {
440 PhaseOffset = (zeroPhaseChan+8) - chan; }
446 UInt_t SurfHk::getRFPowerPayloadTime(UInt_t surf, UInt_t chan)
448 if( surf>=ACTIVE_SURFS)
450 if( chan>=RFCHAN_PER_SURF)
453 UInt_t zeroPhaseChan = 0;
454 UInt_t startPhase =
rfPower[surf][0]&0x8000;
455 for (UInt_t chani =0; chani<=RFCHAN_PER_SURF; chani++) {
456 if ((
rfPower[surf][chani]&0x8000) != startPhase) {
457 zeroPhaseChan = chani;
461 UInt_t PhaseOffset = 0;
462 if (chan < zeroPhaseChan) {
463 PhaseOffset = zeroPhaseChan - chan; }
464 if (chan >= zeroPhaseChan) {
465 PhaseOffset = (zeroPhaseChan+8) - chan;}
474 UInt_t SurfHk::getRFPowerPayloadTimeUs(UInt_t surf, UInt_t chan)
476 if(surf>=ACTIVE_SURFS)
478 if(chan>=RFCHAN_PER_SURF)
481 UInt_t zeroPhaseChan = 0;
482 UInt_t startPhase =
rfPower[surf][0]&0x8000;
483 for (UInt_t chani=0; chani<=RFCHAN_PER_SURF; chani++) {
484 if ((
rfPower[surf][chani]&0x8000) != startPhase) {
485 zeroPhaseChan = chani;
489 UInt_t PhaseOffset = 0;
490 if (chan < zeroPhaseChan) {
491 PhaseOffset = zeroPhaseChan - chan; }
492 if (chan >= zeroPhaseChan) {
493 PhaseOffset = (zeroPhaseChan+8) - chan;}
UShort_t scalerGoals[4]
Scaler goal for each ring, only use 3.
Int_t intFlag
Interpolation flag, should be zero for raw data.
SurfHk()
Default constructor.
UShort_t scalerGoalsNadir[4]
Deprecated.
UShort_t l2Scaler[12][2]
L2 Scaler values.
UShort_t l1Scaler[12][6]
L1 Scaler values.
unsigned short scalerGoalsNadir[4]
What are we aiming for with the scaler rate.
static AnitaEventCalibrator * Instance(int version=0)
Instance generator.
UShort_t surfTrigBandMask[12]
Which bands are masked off?
Int_t getThreshold(int phi, AnitaRing::AnitaRing_t ring, AnitaTrigPol::AnitaTrigPol_t pol)
Returns readback threhsold value for given ring-phi-pol.
Left-circular polarisation (e.g. A4)
unsigned short errorFlag
Will define at some point.
UInt_t realTime
Time in unixTime.
Double_t getRawRFPower(int surf, int chan)
Returns the measured adc value of the RF power while masking the top bit (the "phase" bit) ...
Int_t getL2Scaler(int phi)
Returns the L2 scaler value for given phi-pol.
Double_t getRFPowerInK(int surf, int chan)
Returns the pseudo-calibrated RF power in K.
Int_t getSetThreshold(int phi, AnitaRing::AnitaRing_t ring, AnitaTrigPol::AnitaTrigPol_t pol)
Returns set threshold value for given ring-phi-pol.
unsigned short errorFlag
Will define at some point.
UShort_t upperWords[12]
Upper words of each SURF... for debugging.
SurfHk – The raw SURF scaler+threshold data.
UInt_t payloadTimeUs
Subsecond time of readout in us.
unsigned short scalerGoals[3]
What are we aiming for with the scaler rate.
unsigned short errorFlag
Will define at some point.
enum AnitaRing::EAnitaRing AnitaRing_t
Ring enumeration.
enum AnitaTrigPol::EAnitaTrigPol AnitaTrigPol_t
Polarisation enumeration.
const char * packetCodeAsString(PacketCode_t code)
packetCodeAsString – utility function
unsigned short scalerGoals[4]
What are we aiming for with the scaler rate.
Int_t getL1Scaler(int phi, AnitaPol::AnitaPol_t pol, AnitaRing::AnitaRing_t ring)
Returns the L1 scaler value for given phi-ring-pol.
UShort_t globalThreshold
Global threshold if set.
unsigned short globalThreshold
set to zero if there isn't one
unsigned short globalThreshold
set to zero if there isn't one
UShort_t setThreshold[12][16]
Threshold values intedned, should match threshold array exactly.
UShort_t scaler[12][16]
Scaler values, multiple by 1000 to get Hz.
UShort_t errorFlag
Error flag.
Int_t isMasked(int phi, AnitaRing::AnitaRing_t ring, AnitaTrigPol::AnitaTrigPol_t pol)
Returns 1 if given phi-ring-pol is masked.
unsigned short errorFlag
Will define at some point.
Int_t getLogicalIndex(int phi, AnitaRing::AnitaRing_t ring, AnitaTrigPol::AnitaTrigPol_t pol)
Returns logical pol index.
unsigned short scalerGoalsNadir[4]
What are we aiming for with the scaler rate.
Int_t getScaler(int phi, AnitaRing::AnitaRing_t ring, AnitaTrigPol::AnitaTrigPol_t pol)
Returns scaler value for given ring-phi-pol.
unsigned short scalerGoals[4]
What are we aiming for with the scaler rate.
unsigned short globalThreshold
set to zero if there isn't one
unsigned short globalThreshold
set to zero if there isn't one
unsigned short scalerGoals[3]
What are we aiming for with the scaler rate.
UShort_t rfPower[12][8]
RF power per input channel in ADC counts.
enum AnitaPol::EAnitaPol AnitaPol_t
Polarisation enumeration.
Int_t getScalerGoal(int surf, int scl)
Returns scaler goal of surf-scaler.
Int_t isBandMasked(int surf, int scl)
Returns 1 if band is masked.
Int_t run
Run number from offline.
UShort_t threshold[12][16]
Threshold values in DAC counts.
UInt_t payloadTime
Time in unixTime.
int simplePacketCheck(GenericHeader_t *gHdr, PacketCode_t code)
simplePacketCheck – utility function