AlcapDAQ  1
Functions | Variables
MOctalFADCPacketLoss.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <utility>
#include "midas.h"
#include <TH2.h>
#include "TOctalFADCIsland.h"
#include "TOctalFADCBankReader.h"
#include "TGlobalData.h"
#include "TSetupData.h"

Go to the source code of this file.

Functions

INT MOctalFADCPacketLoss_init (void)
 
INT MOctalFADCPacketLoss_BOR (INT run_number)
 
INT MOctalFADCPacketLoss (EVENT_HEADER *, void *)
 

Variables

HNDLE hDB
 
TGlobalDatagData
 
TSetupDatagSetup
 
static TH1 * hNOctalFADCAvgPacketLoss
 
static TH1 * hNOctalFADCEventsWithPacketLoss
 
static TH1 * hNOctalFADCEventsWithPacketLossPercent
 
static int midas_events
 
ANA_MODULE MOctalFADCPacketLoss_module
 

Function Documentation

INT MOctalFADCPacketLoss ( EVENT_HEADER *  pheader,
void *  pevent 
)

This method processes one MIDAS block, producing a vector of TOctalFADCIsland objects from the raw Octal FADC data.

Definition at line 111 of file MOctalFADCPacketLoss.cpp.

References hNOctalFADCAvgPacketLoss, hNOctalFADCEventsWithPacketLoss, hNOctalFADCEventsWithPacketLossPercent, i, midas_events, and SUCCESS.

112 {
113  // Get the event number
114  int midas_event_number = pheader->serial_number;
115 
116  // Want the average and since I'll scale by 1/midas_event_number at the end, I should undo it now before I add the new data
117  //if (midas_event_number > 1)
118  // hNOctalFADCAvgPacketLoss->Scale(midas_event_number-1);
119 
120  unsigned int* raw; // Points at the raw data
121  int bankSize = bk_locate(pevent,"NLSS",&raw);
122 
123  int board_number = 0;
124  int packet_lost = 0;
125  int n_packets_lost = 0;
126 
127  bool Boards[256]; // We can have maximally 256 FADC boards due to the address space
128  for(int i=0; i<256; ++i) Boards[i] = false;
129 
130  for (int i = 0; i < bankSize; i+=2) {
131  board_number = *(raw+i);
132  packet_lost = *(raw+i+1);
133 
134  if(*(raw+i) >= 0 && *(raw+i) < 255) Boards[i] = true;
135 
136  n_packets_lost++;
137  // printf("Event #%d: Board %d lost packet #%d\n", midas_event_number, board_number, packet_lost);
138 
139  // Fill Diagnostic histogram
140  hNOctalFADCAvgPacketLoss->Fill(board_number, 1);
141  }
142 
143  for(int i=0; i<256; ++i){
144  if(Boards[i] == true){
145  int bin = hNOctalFADCEventsWithPacketLoss->FindBin(i+1);
148  }
149  }
150 
151  ++midas_events;
152 
153  // Scale down for the average, the final midas event should leave this correct
154  //hNOctalFADCAvgPacketLoss->Scale(1.0 / midas_event_number);
155 
156  return SUCCESS;
157 }
INT MOctalFADCPacketLoss_BOR ( INT  run_number)

This method executes at the start of each run

Definition at line 101 of file MOctalFADCPacketLoss.cpp.

References midas_events, and SUCCESS.

102 {
103  midas_events = 1;
104 
105  return SUCCESS;
106 }
INT MOctalFADCPacketLoss_init ( )

This method initializes histograms.

Definition at line 65 of file MOctalFADCPacketLoss.cpp.

References hNOctalFADCAvgPacketLoss, hNOctalFADCEventsWithPacketLoss, hNOctalFADCEventsWithPacketLossPercent, and SUCCESS.

66 {
67  // This histogram has the bank names labeled on the X-axis, and the midas
68  // block number on the Y-axis.
69  // This uses the TH1::kCanRebin mechanism to expand automatically to the
70  // number of FADC banks.
71  hNOctalFADCAvgPacketLoss = new TH1F(
72  "hNOctalFADCAvgPacketLoss",
73  "Number of FADC packets lost per board",
74  4,128, 132);
75  hNOctalFADCAvgPacketLoss->SetBit(TH1::kCanRebin);
76  hNOctalFADCAvgPacketLoss->GetXaxis()->SetTitle("FADC Board Number");
77  hNOctalFADCAvgPacketLoss->GetYaxis()->SetTitle("Number of Packets Lost");
78 
80  "hNOctalFADCEventsWithPacketLoss",
81  "Number of MIDAS Events with FADC packet loss per board",
82  4,128, 132);
83  hNOctalFADCEventsWithPacketLoss->SetBit(TH1::kCanRebin);
84  hNOctalFADCEventsWithPacketLoss->GetXaxis()->SetTitle("FADC Board Number");
85  hNOctalFADCEventsWithPacketLoss->GetYaxis()->SetTitle("Number of Events with lost packets");
86 
88  "hNOctalFADCEventsWithPacketLossPercent",
89  "Percentage of MIDAS Events with FADC packet loss per board",
90  4,128, 132);
91  hNOctalFADCEventsWithPacketLossPercent->SetBit(TH1::kCanRebin);
92  hNOctalFADCEventsWithPacketLossPercent->GetXaxis()->SetTitle("FADC Board Number");
93  hNOctalFADCEventsWithPacketLossPercent->GetYaxis()->SetTitle("Average Number of Events with lost packets");
94 
95  return SUCCESS;
96 }

Variable Documentation

TGlobalData* gData

Definition at line 54 of file analyzer.cpp.

TSetupData* gSetup

Definition at line 55 of file analyzer.cpp.

HNDLE hDB

Definition at line 11 of file mucap_compress.cpp.

TH1* hNOctalFADCAvgPacketLoss
static

Definition at line 43 of file MOctalFADCPacketLoss.cpp.

Referenced by MOctalFADCPacketLoss(), and MOctalFADCPacketLoss_init().

TH1* hNOctalFADCEventsWithPacketLoss
static

Definition at line 44 of file MOctalFADCPacketLoss.cpp.

Referenced by MOctalFADCPacketLoss(), and MOctalFADCPacketLoss_init().

TH1* hNOctalFADCEventsWithPacketLossPercent
static

Definition at line 45 of file MOctalFADCPacketLoss.cpp.

Referenced by MOctalFADCPacketLoss(), and MOctalFADCPacketLoss_init().

int midas_events
static

Definition at line 46 of file MOctalFADCPacketLoss.cpp.

Referenced by MOctalFADCPacketLoss(), and MOctalFADCPacketLoss_BOR().

ANA_MODULE MOctalFADCPacketLoss_module
Initial value:
=
{
"MOctalFADCPacketLoss",
"Andrew Edmonds",
NULL,
NULL,
NULL,
0,
NULL,
}

Definition at line 49 of file MOctalFADCPacketLoss.cpp.