src/common/MPulseLengths.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include "midas.h"
#include <TH2.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 MPulseLengths_init (void)
INT MPulseLengths (EVENT_HEADER *, void *)
double GetClockTickForChannel (string bank_name)

Variables

HNDLE hDB
TGlobalDatagData
 Object to hold data used and produced by modules throughout alcapana stage of analysis.
TSetupDatagSetup
 Hardware information about digitizers and detectors to be used during alcapana stage of analysis.
static vector
< TOctalFADCBankReader * > 
fadc_bank_readers
static TH2I * average_length_histogram
map< std::string, TH1I * > length_histograms_map
ANA_MODULE MPulseLengths_module

Function Documentation

double GetClockTickForChannel ( string  bank_name  ) 
INT MPulseLengths ( 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 99 of file MPulseLengths.cpp.

References average_length_histogram, TGlobalData::fPulseIslandToChannelMap, and length_histograms_map.

00100 {
00101         // Get the event number
00102         int midas_event_number = pheader->serial_number;
00103 
00104         // Some typedefs
00105         typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap;
00106         typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair;
00107         typedef map<string, vector<TPulseIsland*> >::iterator map_iterator;
00108 
00109         // Fetch a reference to the gData structure that stores a map
00110         // of (bank_name, vector<TPulseIsland*>) pairs
00111         TStringPulseIslandMap& pulse_islands_map =
00112                 gData->fPulseIslandToChannelMap;
00113 
00114         // Loop over the map and get each bankname, vector pair
00115         for (map_iterator theMapIter = pulse_islands_map.begin(); theMapIter != pulse_islands_map.end(); theMapIter++) 
00116         {
00117           std::string bankname = theMapIter->first;
00118           std::vector<TPulseIsland*> thePulses = theMapIter->second;
00119           
00120           if (thePulses.size() != 0) {
00121             // Loop over the TPulseIslands and plot the histogram
00122             double total_length_of_pulses = 0;
00123             for (std::vector<TPulseIsland*>::iterator thePulseIter = thePulses.begin(); thePulseIter != thePulses.end(); thePulseIter++) {
00124               length_histograms_map[bankname]->Fill((*thePulseIter)->GetPulseLength());
00125               total_length_of_pulses += (*thePulseIter)->GetPulseLength();
00126             }
00127             // Fill the histogram
00128             average_length_histogram->Fill(bankname.c_str(), midas_event_number, total_length_of_pulses / thePulses.size());
00129           }
00130         }
00131         return SUCCESS;
00132 }

INT MPulseLengths_init (  ) 

This method initializes histograms.

Definition at line 65 of file MPulseLengths.cpp.

References average_length_histogram, TSetupData::fBankToDetectorMap, TSetupData::GetDetectorName(), and length_histograms_map.

00066 {
00067   // This histogram has the pulse lengths on the X-axis and the number of pulses on the Y-axis
00068   // One histogram is created for each detector
00069   
00070   std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap;
00071   for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin(); 
00072       mapIter != bank_to_detector_map.end(); mapIter++) { 
00073 
00074     std::string bankname = mapIter->first;
00075     std::string detname = gSetup->GetDetectorName(bankname);
00076     std::string histname = "h" + detname + "_Lengths";
00077     std::string histtitle = "Plot of the pulse lengths for the " + detname + " detector";
00078     TH1I* hDetLengths = new TH1I(histname.c_str(), histtitle.c_str(), 100,0,100);
00079     hDetLengths->GetXaxis()->SetTitle("Pulse Lengths [N Samples]");
00080     hDetLengths->GetYaxis()->SetTitle("Arbitrary Unit");
00081     hDetLengths->SetBit(TH1::kCanRebin);
00082 
00083     length_histograms_map[bankname] = hDetLengths;
00084   }
00085 
00086   std::string histname = "hAvgPulseLengthsPerChannel";
00087   std::string histtitle = "Plot of the average pulse lengths per event for the each channel";
00088   average_length_histogram = new TH2I(histname.c_str(), histtitle.c_str(), 1,0,1, 5000,0,5000);
00089   average_length_histogram->GetXaxis()->SetTitle("Bank Name");
00090   average_length_histogram->GetYaxis()->SetTitle("MIDAS Event Number");
00091   average_length_histogram->SetBit(TH1::kCanRebin);
00092 
00093   return SUCCESS;
00094 }


Variable Documentation

TH2I* average_length_histogram [static]

Definition at line 46 of file MPulseLengths.cpp.

Referenced by MPulseLengths(), and MPulseLengths_init().

vector<TOctalFADCBankReader*> fadc_bank_readers [static]

Definition at line 45 of file MPulseLengths.cpp.

HNDLE hDB
map<std::string, TH1I*> length_histograms_map

Definition at line 47 of file MPulseLengths.cpp.

Referenced by MPulseLengths(), and MPulseLengths_init().

Initial value:
{
        "MPulseLengths",                    
        "Andrew Edmonds",              
        MPulseLengths,                      
        NULL,                          
        NULL,                          
        MPulseLengths_init,                 
        NULL,                          
        NULL,                          
        0,                             
        NULL,                          
}

Definition at line 49 of file MPulseLengths.cpp.


Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1