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

Go to the source code of this file.

Functions

INT MPulseTimeSeparation_init (void)
 
INT MPulseTimeSeparation (EVENT_HEADER *, void *)
 
vector< string > GetAllBankNames ()
 
double GetClockTickForChannel (string bank_name)
 

Variables

HNDLE hDB
 
TGlobalDatagData
 
TSetupDatagSetup
 
static vector
< TOctalFADCBankReader * > 
fadc_bank_readers
 
static std::map< std::string,
TH1 * > 
time_separation_histogram_map
 
static std::map< std::string,
TH1 * > 
time_separation_wrt_first_pulse_histogram_map
 
ANA_MODULE MPulseTimeSeparation_module
 

Function Documentation

vector<string> GetAllBankNames ( )
double GetClockTickForChannel ( string  bank_name)
INT MPulseTimeSeparation ( 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 101 of file MPulseTimeSeparation.cpp.

References TGlobalData::fPulseIslandToChannelMap, and SUCCESS.

102 {
103  // Get the event number
104  int midas_event_number = pheader->serial_number;
105 
106  // Some typedefs
107  typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap;
108  typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair;
109  typedef map<string, vector<TPulseIsland*> >::iterator map_iterator;
110 
111  // Fetch a reference to the gData structure that stores a map
112  // of (bank_name, vector<TPulseIsland*>) pairs
113  TStringPulseIslandMap& pulse_islands_map =
115 
116  // Loop over the map and get each bankname, vector pair
117  for (map_iterator theMapIter = pulse_islands_map.begin(); theMapIter != pulse_islands_map.end(); theMapIter++)
118  {
119  std::string bankname = theMapIter->first;
120  std::vector<TPulseIsland*> thePulses = theMapIter->second;
121 
122  // Loop over the TPulseIslands and plot the histogram
123  for (std::vector<TPulseIsland*>::iterator thePulseIter = thePulses.begin(); thePulseIter != thePulses.end(); thePulseIter++) {
124 
125  // if ((*thePulseIter)->GetPulseLength() == 4) {
126  if (thePulseIter!=thePulses.begin())
127  time_separation_histogram_map[bankname]->Fill( ((*thePulseIter)->GetTimeStamp() - (*(thePulseIter-1))->GetTimeStamp()) * (*thePulseIter)->GetClockTickInNs() * 1e-6); // ns->ms
128 
129  int initial_time_stamp = (*thePulses.begin())->GetTimeStamp();
130 
131  double pulse_frequency = 65; // Hz
132  double pulse_period = (1 / pulse_frequency) * 1e9; // ns
133 
134  if (initial_time_stamp * (*thePulseIter)->GetClockTickInNs() > pulse_period) {
135  initial_time_stamp += pulse_period / (*thePulseIter)->GetClockTickInNs();
136  }
137 
138  time_separation_wrt_first_pulse_histogram_map[bankname]->Fill( ((*thePulseIter)->GetTimeStamp() - initial_time_stamp) * (*thePulseIter)->GetClockTickInNs() * 1e-6); // ns->ms
139  // }
140  }
141  }
142  return SUCCESS;
143 }
INT MPulseTimeSeparation_init ( )

This method initializes histograms.

Definition at line 66 of file MPulseTimeSeparation.cpp.

References TSetupData::fBankToDetectorMap, TSetupData::GetDetectorName(), and SUCCESS.

67 {
68  // This histogram has the pulse times on the X-axis and the number of pulses on the Y-axis
69  // One histogram is created for each detector
70 
71  std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap;
72  for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin();
73  mapIter != bank_to_detector_map.end(); mapIter++) {
74 
75  std::string detname = gSetup->GetDetectorName(mapIter->first);
76  std::string histname = "h" + detname + "_PulseSeparation";
77  std::string histtitle = "Plot of the time difference between consecutive pulses for the " + detname + " detector";
78  TH1I* hPulseTimeDiff = new TH1I(histname.c_str(),histtitle.c_str(),200,0,200);
79  hPulseTimeDiff->GetXaxis()->SetTitle("Time Difference Between Consecutive Pulses [ms]");
80  hPulseTimeDiff->GetYaxis()->SetTitle("Number of pulse pairs");
81  hPulseTimeDiff->SetBit(TH1::kCanRebin);
82 
83  time_separation_histogram_map[mapIter->first] = hPulseTimeDiff;
84 
85  histname = "h" + detname + "_PulseSeparationWRTFirstPulse";
86  histtitle = "Plot of the time difference wrt the first pulse for the " + detname + " detector";
87  hPulseTimeDiff = new TH1I(histname.c_str(), histtitle.c_str(),200,0,200);
88  hPulseTimeDiff->GetXaxis()->SetTitle("Time Difference Between wrt the First Pulse [ms]");
89  hPulseTimeDiff->GetYaxis()->SetTitle("Number of pulse pairs");
90  hPulseTimeDiff->SetBit(TH1::kCanRebin);
91 
92  time_separation_wrt_first_pulse_histogram_map[mapIter->first] = hPulseTimeDiff;
93  }
94 
95  return SUCCESS;
96 }

Variable Documentation

vector<TOctalFADCBankReader*> fadc_bank_readers
static

Definition at line 46 of file MPulseTimeSeparation.cpp.

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.

ANA_MODULE MPulseTimeSeparation_module
Initial value:
=
{
"MPulseTimeSeparation",
"Joe Grange",
NULL,
NULL,
NULL,
NULL,
0,
NULL,
}

Definition at line 50 of file MPulseTimeSeparation.cpp.

std::map<std::string, TH1*> time_separation_histogram_map
static

Definition at line 47 of file MPulseTimeSeparation.cpp.

std::map<std::string, TH1*> time_separation_wrt_first_pulse_histogram_map
static

Definition at line 48 of file MPulseTimeSeparation.cpp.