Produces TPIs from raw data read in from UH CAEN. More...
Functions | |
static INT | module_init (void) |
static INT | module_event_caen (EVENT_HEADER *, void *) |
Variables | |
HNDLE | hDB |
TGlobalData * | gData |
Object to hold data used and produced by modules throughout alcapana stage of analysis. | |
TSetupData * | gSetup |
Hardware information about digitizers and detectors to be used during alcapana stage of analysis. | |
static vector< string > | caen_houston_bank_names |
List of UH CAEN bank names for the event loop. | |
static unsigned int | nPreSamples |
Number of samples to record before a trigger. | |
static const int | NCHAN = 8 |
Number of channels in V1724. | |
ANA_MODULE | MV1724ProcessRaw_module |
Produces TPIs from raw data read in from UH CAEN.
INT module_event_caen | ( | EVENT_HEADER * | pheader, | |
void * | pevent | |||
) | [static] |
Definition at line 108 of file MV1724ProcessRaw.cpp.
References caen_houston_bank_names, TGlobalData::fPulseIslandToChannelMap, NCHAN, and nPreSamples.
00109 { 00110 // Some typedefs 00111 00112 typedef map<string, vector<TPulseIsland*> > TStringPulseIslandMap; 00113 typedef pair<string, vector<TPulseIsland*> > TStringPulseIslandPair; 00114 typedef map<string, vector<TPulseIsland*> >::iterator map_iterator; 00115 00116 //printf("===================> %s MIDAS event %i\n",__FILE__,pheader->serial_number); 00117 00118 // Fetch a reference to the gData structure that stores a map 00119 // of (bank_name, vector<TPulseIsland*>) pairs 00120 TStringPulseIslandMap& pulse_islands_map = 00121 gData->fPulseIslandToChannelMap; 00122 00123 // Delete the islands found in the previous block. Don't clear 00124 // the map of (bank_name, vector) pairs. Once we use a bank name 00125 // once, it will have a (possibly empty) entry in this map for the 00126 // whole run. JG: the islands.clear() line causes seg fault for > 1 TPulseIslandPair 00127 /*for(map_iterator iter = pulse_islands_map.begin(); 00128 iter != pulse_islands_map.end(); iter++){ 00129 vector<TPulseIsland*>& islands = iter->second; 00130 // Delete the pointers to TPulseIslands, then clear the vector 00131 for(unsigned int j=0; j<islands.size(); j++) { 00132 if(islands[j]) { delete islands[j]; islands[j] = NULL; } 00133 } 00134 islands.clear(); 00135 pulse_islands_map.erase(iter); // AE: need to erase the key so that blocks after the first will be recorded 00136 }*/ 00137 00138 // Get the event number 00139 int midas_event_number = pheader->serial_number; 00140 00141 BYTE *pdata; 00142 00143 // printf("In caen ER!\n"); 00144 00145 char bank_name[8]; 00146 sprintf(bank_name,"CDG%i",0); // one MIDAS bank per board 00147 unsigned int bank_len = bk_locate(pevent, bank_name, &pdata); 00148 00149 00150 uint32_t *p32 = (uint32_t*)pdata; 00151 uint32_t *p32_0 = (uint32_t*)pdata; 00152 00153 00154 while ( (p32 - p32_0)*4 < bank_len ) 00155 { 00156 00157 uint32_t caen_event_cw = p32[0]>>28; 00158 //printf("CW: %08x\n",caen_event_cw); 00159 if ( caen_event_cw != 0xA ) 00160 { 00161 printf("***ERROR UH CAEN! Wrong data format: incorrect control word 0x%08x\n", caen_event_cw); 00162 return SUCCESS; 00163 } 00164 00165 uint32_t caen_event_size = p32[0] & 0x0FFFFFFF; 00166 //printf("caen event size: %i\n",caen_event_size); 00167 00168 uint32_t caen_channel_mask = p32[1] & 0x000000FF; 00169 // count the number of channels in the event 00170 int nchannels = 0; 00171 for (int ichannel=0; ichannel<NCHAN; ichannel++ ) 00172 { 00173 if ( caen_channel_mask & (1<<ichannel) ) nchannels++; 00174 } 00175 00176 uint32_t caen_event_counter = p32[2] & 0x00FFFFFF; 00177 // printf("caen event counter: %i\n",caen_event_counter); 00178 00179 uint32_t caen_trigger_time = p32[3]; 00180 // printf("caen trigger time: %i\n",caen_trigger_time);// = clock ticks? 00181 00182 // number of samples per channel 00183 unsigned int nsamples = ((caen_event_size-4)*2) / nchannels; 00184 // printf("waveform length: %i\n",nsamples); 00185 00186 // Loop through the channels (i.e. banks) 00187 for (std::vector<std::string>::iterator bankNameIter = caen_houston_bank_names.begin(); 00188 bankNameIter != caen_houston_bank_names.end(); bankNameIter++) { 00189 00190 vector<TPulseIsland*>& pulse_islands = pulse_islands_map[*(bankNameIter)]; 00191 std::vector<int> sample_vector; 00192 int ichannel = bankNameIter - caen_houston_bank_names.begin(); 00193 00194 // printf("TGlobalData bank [%s] ----------------------------------------\n", (*bankNameIter).c_str()); 00195 // printf("Number of TPulseIslands already existing = %d\n", pulse_islands.size()); 00196 // printf("*-- channel %i -------------------------------------------------------------*\n",ichannel); 00197 00198 if ( caen_channel_mask & (1<<ichannel) ) 00199 { 00200 // channel enabled 00201 unsigned int isample = 0; 00202 unsigned int nwords = nsamples/2; 00203 00204 for (int iword=0; iword<nwords; iword++) 00205 { 00206 00207 for (int isubword=0; isubword<2; isubword++) 00208 { 00209 uint32_t adc; 00210 00211 if (isubword == 0 ) 00212 adc = (p32[4+iword+ichannel*nwords] & 0x3fff); 00213 else 00214 adc = ((p32[4+iword+ichannel*nwords] >> 16) & 0x3fff); 00215 00216 //printf("CAEN V1724 channel %d: adc[%i] = %i\n", ichannel, isample, adc); 00217 // h2_v1724_pulses[ichannel]->Fill(isample,adc); 00218 isample++; 00219 00220 sample_vector.push_back(adc); 00221 00222 } 00223 } 00224 00225 pulse_islands.push_back(new TPulseIsland(caen_trigger_time - nPreSamples, sample_vector, *bankNameIter)); 00226 } 00227 } 00228 00229 // align the event by two bytes. 00230 p32 += caen_event_size + (caen_event_size%2); 00231 // printf("offset: %i bank size: %i\n", (int)(p32-p32_0), bank_len); 00232 00233 } 00234 00235 // print for testing 00236 if(midas_event_number == 1) { 00237 // Loop through all the banks and print an output (because this ProcessRaw loops through pulses then banks, it has been put here) 00238 for (std::vector<std::string>::iterator bankNameIter = caen_houston_bank_names.begin(); 00239 bankNameIter != caen_houston_bank_names.end(); bankNameIter++) { 00240 00241 vector<TPulseIsland*>& pulse_islands = pulse_islands_map[*(bankNameIter)]; 00242 printf("TEST MESSAGE: Read %d events from bank %s in event %d\n", 00243 pulse_islands.size(), 00244 (*(bankNameIter)).c_str(), 00245 midas_event_number); 00246 } 00247 } 00248 00249 return SUCCESS; 00250 }
INT module_init | ( | void | ) | [static] |
Definition at line 77 of file MV1724ProcessRaw.cpp.
References caen_houston_bank_names, TSetupData::fBankToDetectorMap, hDB, TSetupData::IsHoustonCAEN(), and nPreSamples.
00078 { 00079 00080 std::map<std::string, std::string> bank_to_detector_map = gSetup->fBankToDetectorMap; 00081 for(std::map<std::string, std::string>::iterator mapIter = bank_to_detector_map.begin(); 00082 mapIter != bank_to_detector_map.end(); mapIter++) { 00083 00084 std::string bankname = mapIter->first; 00085 00086 // We only want the CAEN banks here 00087 if (TSetupData::IsHoustonCAEN(bankname)) 00088 caen_houston_bank_names.push_back(bankname); 00089 } 00090 00091 /*** Get necessary data from ODB ***/ 00092 char key[80]; 00093 int size; 00094 unsigned int post_trigger_percentage, nSamples; 00095 00096 // Get Trigger Time Tag info 00097 // Timestamp will be shifted by number of presamples 00098 sprintf(key, "/Equipment/Crate 4/Settings/CAEN0/waveform length"); 00099 size = sizeof(nSamples); 00100 db_get_value(hDB, 0, key, &nSamples, &size, TID_DWORD, 1); 00101 post_trigger_percentage = 80; // This is hardcoded in the frontend 00102 nPreSamples = (int) (0.01 * ((100 - post_trigger_percentage) * nSamples)); 00103 00104 return SUCCESS; 00105 }
vector<string> caen_houston_bank_names [static] |
List of UH CAEN bank names for the event loop.
Definition at line 49 of file MV1724ProcessRaw.cpp.
Referenced by module_event_caen(), and module_init().
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 |
ANA_MODULE MV1724ProcessRaw_module |
{ "MV1724ProcessRaw", "Vladimir Tishchenko", module_event_caen, NULL, NULL, module_init, NULL, NULL, 0, NULL, }
Definition at line 62 of file MV1724ProcessRaw.cpp.
const int NCHAN = 8 [static] |
Number of channels in V1724.
Definition at line 59 of file MV1724ProcessRaw.cpp.
unsigned int nPreSamples [static] |
Number of samples to record before a trigger.
Number of samples and fraction of sampling window to set aside for after trigger are stored in ODB; this is calculated from those.
Definition at line 56 of file MV1724ProcessRaw.cpp.
Referenced by module_event_caen(), and module_init().