MCAENPulseIslandSortAndStitch
[Raw Data Process]

Sort and stitches the TPIs. More...

Functions

static INT module_event_sort_and_stitch (EVENT_HEADER *pheader, void *pevent)
 This method sorts pulses in time and then stitches them together.
static INT module_init_sort_and_stitch ()
static bool pulse_islands_t_comp (TPulseIsland *a, TPulseIsland *b)
 Ordering of pulse islands in time base on timestamp.
static void pulse_islands_stitch (std::vector< TPulseIsland * > &pulses, unsigned int nSamples)
 Stitch islands together if second of two that are time ordered is less than expected.

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 unsigned int nUHSamples
 Number of samples we expect a UH CAEN pulse to be no shorter than (from ODB).
static unsigned int nBUSamples
 Number of samples we expect a BU CAEN pulse to be no shorter than (from ODB).
static unsigned int nUHPreSamples
 Number of samples saved before a trigger on UH CAEN (from ODB).
static unsigned int nBUPreSamples
 Number of samples saved before a trigger on BU CAEN (from ODB).
ANA_MODULE MCAENPulseIslandSortAndStitch_module

Detailed Description

Sort and stitches the TPIs.

Author:
John R Quirk

First sorts pulses based on time stamp (which is the timing that should be used). Then, if of two consecutive pulses the second is shorter than expected, stitch it to the first.


Function Documentation

INT module_event_sort_and_stitch ( EVENT_HEADER *  pheader,
void *  pevent 
) [static]

This method sorts pulses in time and then stitches them together.

Definition at line 111 of file MCAENPulseIslandSortAndStitch.cpp.

References TGlobalData::fPulseIslandToChannelMap, TSetupData::IsBostonCAEN(), TSetupData::IsHoustonCAEN(), nBUSamples, nUHSamples, pulse_islands_stitch(), and pulse_islands_t_comp().

00112 {
00113   // Some typedefs
00114   typedef std::map<std::string, std::vector<TPulseIsland*> > TStringPulseIslandMap;
00115 
00116   // Fetch a reference to the gData structure that stores a map
00117   // of (bank_name, vector<TPulseIsland*>) pairs
00118   TStringPulseIslandMap& pulse_islands_map = gData->fPulseIslandToChannelMap;
00119 
00120   for (std::map<std::string, std::vector<TPulseIsland*> >::iterator it=pulse_islands_map.begin(); it!=pulse_islands_map.end(); ++it)
00121     {
00122       unsigned int nSamples = 0;
00123       if (TSetupData::IsBostonCAEN(it->first))
00124         nSamples = nBUSamples;
00125       else if (TSetupData::IsHoustonCAEN(it->first))
00126         nSamples = nUHSamples;
00127       if (nSamples != 0) {
00128         std::vector<TPulseIsland*> &v = it->second;
00129         std::sort(v.begin(), v.end(), pulse_islands_t_comp);
00130         pulse_islands_stitch(v, nSamples);
00131       }
00132     }
00133 
00134   return SUCCESS;
00135 }

INT module_init_sort_and_stitch (  )  [static]

Definition at line 80 of file MCAENPulseIslandSortAndStitch.cpp.

References hDB, nBUPreSamples, nBUSamples, nUHPreSamples, and nUHSamples.

00080                                   {
00081 
00082    /*** Get necessary data from ODB ***/
00083   char key[80];
00084   int size;
00085   unsigned int post_trigger_percentage;
00086 
00087   sprintf(key, "/Equipment/Crate 4/Settings/CAEN0/waveform length");
00088   size = sizeof(nUHSamples);
00089   db_get_value(hDB, 0, key, &nUHSamples, &size, TID_DWORD, 1);
00090   post_trigger_percentage = 80; // This is hardcoded in the frontend
00091   nUHPreSamples = (int) (0.01 * ((100 - post_trigger_percentage) * nUHSamples));
00092   
00093   return SUCCESS;
00094 
00095   sprintf(key, "/Equipment/Crate 5/Settings/CAEN/waveform length");
00096   size = sizeof(nBUSamples);
00097   db_get_value(hDB, 0, key, &nBUSamples, &size, TID_DWORD, 1);
00098   sprintf(key, "/Equipment/Crate 5/Settings/CAEN/post_trigger_size");
00099   size = sizeof(post_trigger_percentage);
00100   db_get_value(hDB, 0, key, &post_trigger_percentage, &size, TID_BYTE, 1);
00101   //nBUPreSamples = (int) (0.01 * ((100 - post_trigger_percentage) * nBUSamples));
00102   nBUPreSamples = 20; // From the Golden Data, it looks like there are 20 presamples.
00103                     // The frontend does not seem to correctly load post_trigger_size
00104                     // onto the CAEN.
00105   
00106   return SUCCESS;
00107 }

void pulse_islands_stitch ( std::vector< TPulseIsland * > &  pulses,
unsigned int  nSamples 
) [static]

Stitch islands together if second of two that are time ordered is less than expected.

If a pulse form the CAEN is less than expected, where what's expected is set in the ODB before a run, that usually means that this second pulse was cause by trigger pile-up of the first, and should be stitched onto the end.

Parameters:
[in] pulses Vector of TPIs contained time-sorted CANE pulses to stitch if necessary
[in] nSamples Number of samples we expect a pulse to be no shorter than; if shorter than this, a pulse is stitched to the end of the preceding pulse.
Todo:
Instead stitch together if the timestamps line up appropriately.

Definition at line 162 of file MCAENPulseIslandSortAndStitch.cpp.

References TPulseIsland::GetBankName(), TPulseIsland::GetSamples(), and TPulseIsland::GetTimeStamp().

Referenced by module_event_sort_and_stitch().

00162                                                                                    {
00163   unsigned int nPulses = pulses.size();
00164   if (nPulses == 0) return;
00165   std::vector<int> next_samples, current_samples;
00166   TPulseIsland* temp_pulse;
00167   for (unsigned int iPulse = 0; iPulse < nPulses - 1; ++iPulse) {
00168     next_samples = pulses[iPulse + 1]->GetSamples();
00169     // If the next pulse is less than the set number of samples,
00170     // it's a continuation of this pulse
00171     while (next_samples.size() < nSamples) {
00172       current_samples = pulses[iPulse]->GetSamples();
00173       for (unsigned int i = 0; i < next_samples.size(); ++i)
00174         current_samples.push_back(next_samples[i]);
00175       temp_pulse = pulses[iPulse];
00176       pulses[iPulse] = new TPulseIsland(temp_pulse->GetTimeStamp(), current_samples, temp_pulse->GetBankName());
00177       delete temp_pulse;
00178       delete pulses[iPulse + 1];
00179       pulses.erase(pulses.begin() + iPulse + 1);
00180       if (!(iPulse < --nPulses - 1)) break;
00181       next_samples = pulses[iPulse + 1]->GetSamples();
00182     }
00183   }
00184 }

bool pulse_islands_t_comp ( TPulseIsland a,
TPulseIsland b 
) [static]

Ordering of pulse islands in time base on timestamp.

Definition at line 140 of file MCAENPulseIslandSortAndStitch.cpp.

References TPulseIsland::GetTimeStamp().

Referenced by module_event_sort_and_stitch().

00141 { 
00142   return (a->GetTimeStamp() < b->GetTimeStamp()); 
00143 }


Variable Documentation

Object to hold data used and produced by modules throughout alcapana stage of analysis.

Definition at line 76 of file analyzer.cpp.

Hardware information about digitizers and detectors to be used during alcapana stage of analysis.

Definition at line 80 of file analyzer.cpp.

HNDLE hDB
Initial value:
{
        "MCAENPulseIslandSortAndStitch",   
        "Vladimir Tishchenko",             
        module_event_sort_and_stitch,      
        NULL,                              
        NULL,                              
        module_init_sort_and_stitch,       
        NULL,                              
        NULL,                              
        0,                                 
        NULL,                              
}

Definition at line 62 of file MCAENPulseIslandSortAndStitch.cpp.

unsigned int nBUPreSamples [static]

Number of samples saved before a trigger on BU CAEN (from ODB).

Definition at line 60 of file MCAENPulseIslandSortAndStitch.cpp.

Referenced by module_init_sort_and_stitch().

unsigned int nBUSamples [static]

Number of samples we expect a BU CAEN pulse to be no shorter than (from ODB).

Definition at line 52 of file MCAENPulseIslandSortAndStitch.cpp.

Referenced by module_event_sort_and_stitch(), and module_init_sort_and_stitch().

unsigned int nUHPreSamples [static]

Number of samples saved before a trigger on UH CAEN (from ODB).

Definition at line 56 of file MCAENPulseIslandSortAndStitch.cpp.

Referenced by module_init_sort_and_stitch().

unsigned int nUHSamples [static]

Number of samples we expect a UH CAEN pulse to be no shorter than (from ODB).

Definition at line 48 of file MCAENPulseIslandSortAndStitch.cpp.

Referenced by module_event_sort_and_stitch(), and module_init_sort_and_stitch().


Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1