AlcapDAQ  1
Functions | Variables
MCommonOnlineDisplayPlots.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#include "midas.h"
#include <TH1.h>
#include <TH2.h>
#include "TGlobalData.h"
#include "TSetupData.h"
#include "TPulseIsland.h"

Go to the source code of this file.

Functions

INT MCommonOnlineDisplayPlots_init (void)
 
INT MCommonOnlineDisplayPlots_bor (INT)
 
INT MCommonOnlineDisplayPlots (EVENT_HEADER *, void *)
 

Variables

HNDLE hDB
 
TGlobalDatagData
 
TSetupDatagSetup
 
map< std::string, TH1I * > height_histograms_map
 
map< std::string, TH1I * > time_histograms_map
 
map< std::string, TH2D * > shape_histograms_map
 
map< std::string, TH1I * > latest_pulse_histograms_map
 
static TH1I * hPulseRawCount
 
ANA_MODULE MCommonOnlineDisplayPlots_module
 

Function Documentation

INT MCommonOnlineDisplayPlots ( 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 158 of file MCommonOnlineDisplayPlots.cpp.

References TGlobalData::fPulseIslandToChannelMap, TSetupData::GetDetectorName(), hPulseRawCount, and SUCCESS.

159 {
160  // Get the event number
161  int midas_event_number = pheader->serial_number;
162 
163  // Some typedefs
164  typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap;
165  typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair;
166  typedef map<string, vector<TPulseIsland*> >::iterator map_iterator;
167 
168  // Fetch a reference to the gData structure that stores a map
169  // of (bank_name, vector<TPulseIsland*>) pairs
170  TStringPulseIslandMap& pulse_islands_map =
172 
173  // Loop over the map and get each bankname, vector pair
174  for (map_iterator theMapIter = pulse_islands_map.begin(); theMapIter != pulse_islands_map.end(); theMapIter++)
175  {
176  std::string bankname = theMapIter->first;
177  std::string detname = gSetup->GetDetectorName(bankname);
178  std::vector<TPulseIsland*> thePulses = theMapIter->second;
179 
180  // Loop over the TPulseIslands and plot the histogram
181  for (std::vector<TPulseIsland*>::iterator pulseIter = thePulses.begin(); pulseIter != thePulses.end(); pulseIter++) {
182 
183  // Make sure the histograms exist and then fill them
184  // Also check that this pulse didn't underflow (i.e. has a sample value at any point of 4096)
185  bool underflow = false;
186  if (shape_histograms_map.find(bankname) != shape_histograms_map.end()) {
187  TH2* shape_histogram = shape_histograms_map[bankname];
188  TH1* latest_pulse_histogram = latest_pulse_histograms_map[bankname];
189 
190  latest_pulse_histogram->Reset();
191 
192  std::vector<int> theSamples = (*pulseIter)->GetSamples();
193  for (std::vector<int>::iterator sampleIter = theSamples.begin(); sampleIter != theSamples.end(); sampleIter++) {
194  int sample_number = sampleIter - theSamples.begin();
195  int sample_value = *sampleIter;
196 
197  if (sample_value == 4096) {
198  underflow = true;
199  break;
200  }
201  shape_histogram->Fill(sample_number, sample_value);
202  latest_pulse_histogram->SetBinContent(sample_number, sample_value);
203  }
204  }
205 
206  if (underflow == false) {
207  if (height_histograms_map.find(bankname) != height_histograms_map.end())
208  height_histograms_map[bankname]->Fill((*pulseIter)->GetPulseHeight());
209 
210  if (time_histograms_map.find(bankname) != time_histograms_map.end())
211  time_histograms_map[bankname]->Fill((*pulseIter)->GetPulseTime());
212  }
213  }
214 
215  hPulseRawCount->Fill(bankname.c_str(), thePulses.size());
216  }
217  return SUCCESS;
218 }
INT MCommonOnlineDisplayPlots_bor ( INT  run_number)

Definition at line 138 of file MCommonOnlineDisplayPlots.cpp.

References TSetupData::fBankToDetectorMap, and hPulseRawCount.

138  {
139 
140  std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap;
141  for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin();
142  mapIter != bank_to_detector_map.end(); mapIter++) {
143 
144  std::string bankname = mapIter->first;
145  height_histograms_map[bankname]->Reset();
146  time_histograms_map[bankname]->Reset();
147  shape_histograms_map[bankname]->Reset();
148  latest_pulse_histograms_map[bankname]->Reset();
149 
150  }
151 
152  hPulseRawCount->Reset();
153 }
INT MCommonOnlineDisplayPlots_init ( )

This method initializes histograms.

Definition at line 67 of file MCommonOnlineDisplayPlots.cpp.

References TSetupData::fBankToDetectorMap, TSetupData::GetDetectorName(), hPulseRawCount, TSetupData::IsBostonCAEN(), TSetupData::IsFADC(), TSetupData::IsHoustonCAEN(), and SUCCESS.

68 {
69  // The following histograms are created for each channel:
70  // hPulseHeights: ADC value (x-axis) vs number of pulses (y-axis)
71  // hPulseTimes: time stamp (x-axis) vs number of pulses (y-axis)
72  // hPulseRawCount: number of pulses (y-axis) - channels on x-axis?
73  // hPulseShapes: sample number (x-axis) vs ADC value (y-axis) vs pulse (z-axis)
74 
75  std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap;
76  for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin();
77  mapIter != bank_to_detector_map.end(); mapIter++) {
78 
79  std::string bankname = mapIter->first;
80  std::string detname = gSetup->GetDetectorName(bankname);
81 
82  int n_digitizer_bits = 0;
83  if (TSetupData::IsFADC(bankname))
84  n_digitizer_bits = 12;
85  else if (TSetupData::IsHoustonCAEN(bankname))
86  n_digitizer_bits = 14; //?
87  else if (TSetupData::IsBostonCAEN(bankname))
88  n_digitizer_bits = 12;
89 
90  long max_adc_value = std::pow(2, n_digitizer_bits);
91 
92  // hPulseHeights
93  std::string histname = "h" + bankname + "_Heights";
94  std::string histtitle = "Plot of the pulse heights in the " + detname + " channels";
95  TH1I* hPulseHeights = new TH1I(histname.c_str(), histtitle.c_str(), max_adc_value,0,max_adc_value);
96  hPulseHeights->GetXaxis()->SetTitle("Pulse Height [ADC value]");
97  hPulseHeights->GetYaxis()->SetTitle("Number of Pulses");
98  height_histograms_map[bankname] = hPulseHeights;
99 
100  // hPulseTimes
101  histname = "h" + bankname + "_Times";
102  histtitle = "Plot of the pulse times in the " + detname + " channels";
103  TH1I* hPulseTimes = new TH1I(histname.c_str(), histtitle.c_str(), 2000, 0, 2e8);
104  hPulseTimes->GetXaxis()->SetTitle("Time");
105  hPulseTimes->GetYaxis()->SetTitle("Number of Pulses");
106  time_histograms_map[bankname] = hPulseTimes;
107 
108  // hPulseShapes
109  histname = "h" + bankname + "_Shapes";
110  histtitle = "Plot of the pulse shapes in the " + detname + " channels";
111  TH2D* hPulseShapes = new TH2D(histname.c_str(), histtitle.c_str(), 400,-0.5,399.5,max_adc_value+1,0,max_adc_value+1);
112  hPulseShapes->GetXaxis()->SetTitle("Time Stamp");
113  hPulseShapes->GetYaxis()->SetTitle("ADC Value");
114  shape_histograms_map[bankname] = hPulseShapes;
115 
116  //hLatestPulse
117  histname = "h" + bankname + "_LatestPulse";
118  histtitle = "Plot of the latest pulse in the " + detname + " channels";
119  TH1I* hLatestPulse = new TH1I(histname.c_str(), histtitle.c_str(), 64,-0.5,63.5);
120  hLatestPulse->GetXaxis()->SetTitle("Time Stamp");
121  hLatestPulse->GetYaxis()->SetTitle("ADC Value");
122  latest_pulse_histograms_map[bankname] = hLatestPulse;
123 
124  }
125 
126  // hPulseRawCount
127  std::string histname = "hPulseRawCount";
128  std::string histtitle = "Plot of the raw counts in each channels";
129  hPulseRawCount = new TH1I(histname.c_str(), histtitle.c_str(), 1,0,1);
130  hPulseRawCount->GetXaxis()->SetTitle("Channel");
131  hPulseRawCount->GetYaxis()->SetTitle("Number of Pulses");
132  hPulseRawCount->SetBit(TH1::kCanRebin);
133 
134  return SUCCESS;
135 }

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.

map<std::string, TH1I*> height_histograms_map

Definition at line 45 of file MCommonOnlineDisplayPlots.cpp.

TH1I* hPulseRawCount
static
map<std::string, TH1I*> latest_pulse_histograms_map

Definition at line 48 of file MCommonOnlineDisplayPlots.cpp.

ANA_MODULE MCommonOnlineDisplayPlots_module
Initial value:
=
{
"MCommonOnlineDisplayPlots",
"Andrew Edmonds",
NULL,
NULL,
NULL,
0,
NULL,
}

Definition at line 51 of file MCommonOnlineDisplayPlots.cpp.

map<std::string, TH2D*> shape_histograms_map

Definition at line 47 of file MCommonOnlineDisplayPlots.cpp.

map<std::string, TH1I*> time_histograms_map

Definition at line 46 of file MCommonOnlineDisplayPlots.cpp.