Skip to content
Snippets Groups Projects
Commit 032ca081 authored by Hernán Asorey's avatar Hernán Asorey
Browse files

Baseline average calculation in monitoring analysis

parent b411f0d2
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,8 @@ If you want to contribute to this project please send me an email (asoreyh@gmail ...@@ -27,7 +27,8 @@ If you want to contribute to this project please send me an email (asoreyh@gmail
FILE ENCODING: UTF8 (please use iconv -f YOUR_ENCODING -t UTF-8 file_to_convert > converted_file before to push) FILE ENCODING: UTF8 (please use iconv -f YOUR_ENCODING -t UTF-8 file_to_convert > converted_file before to push)
LANGUAGE: English (preferred) LANGUAGE: English (preferred)
INDENT STYLE: Stroustrup (see http://en.wikipedia.org/wiki/Indent_style#Variant:_Stroustrup) INDENT STYLE: Stroustrup (see http://en.wikipedia.org/wiki/Indent_style#Variant:_Stroustrup)
1 tab = 4 columns wide (for vim setup see http://tedlogan.com/techblog3.html) 1 tab = 4 columns wide (for vim setup use: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab
in general see http://tedlogan.com/techblog3.html)
Avoid evil whitespaces, use tab instead (Don't commit evil into your repo: http://bit.ly/1K0vQnf ) Avoid evil whitespaces, use tab instead (Don't commit evil into your repo: http://bit.ly/1K0vQnf )
If you prefer, please use: astyle -t4 -A4 -y file_to_convert before to push If you prefer, please use: astyle -t4 -A4 -y file_to_convert before to push
VERSIONING: Sequence-based identifiers, v<version>r<release>. First public release: v1r0 VERSIONING: Sequence-based identifiers, v<version>r<release>. First public release: v1r0
......
...@@ -101,6 +101,15 @@ class LagoEvent { ...@@ -101,6 +101,15 @@ class LagoEvent {
return peak; return peak;
} }
double GetPulseBase(int channel) {
/* get first and the last two bins and return the average as
* the bl for this pulse
* */
//double bl=trace[channel][0]+trace[channel][TRACELEN-2]+trace[channel][TRACELEN-1];
//return (bl/3.);
return trace[channel][0];
}
int GetBase(int channel) { int GetBase(int channel) {
return trace[channel][0]; return trace[channel][0];
} }
......
...@@ -82,9 +82,19 @@ double tim_ap = 0., tim_map = 0.; ...@@ -82,9 +82,19 @@ double tim_ap = 0., tim_map = 0.;
// ALL PULSE DATA ANALYSIS // ALL PULSE DATA ANALYSIS
int all_trg = 0; int all_trg = 0;
ofstream cal, tim, mon; // DATA STREAMS
FILE *scl, *sol, *all, *rte, *flx; ofstream cal, tim;
FILE *scl, *sol, *all, *rte, *flx, *mon;
// BASELINE ANALYSIS
double mon_avg_bl[CHANNELS];
double mon_av2_bl[CHANNELS];
double mon_pulse_bl;
double mon_avg_bl_tmp;
double mon_dev_bl_tmp;
int mon_bl_counts;
// AUXILIARY ARRAYS
int Peak[CHANNELS][1024]; int Peak[CHANNELS][1024];
int Base[CHANNELS][1024]; int Base[CHANNELS][1024];
int Charge[CHANNELS][4096]; int Charge[CHANNELS][4096];
...@@ -104,15 +114,25 @@ void TreatSecond(LagoGeneric *Data, LagoEvent*Pulse, int NbPulses) { ...@@ -104,15 +114,25 @@ void TreatSecond(LagoGeneric *Data, LagoEvent*Pulse, int NbPulses) {
} }
if (iall) if (iall)
fprintf(all, "# %d %d %.2f %.2f\n", Data->second, Data->clockfrequency, Data->temperature, Data->pressure); fprintf(all, "# %d %d %.2f %.2f\n", Data->second, Data->clockfrequency, Data->temperature, Data->pressure);
if (imon) if (imon)
mon << Data->second << " " << Data->clockfrequency << " " << Data->temperature << " " << Data->pressure << " " << endl; fprintf(mon, "%d %d %.2f %.2f", Data->second, Data->clockfrequency, Data->temperature, Data->pressure);
for (int j=0; j<CHANNELS; j++) for (int j=0; j<CHANNELS; j++)
scl_flux[j] = 0; mon_avg_bl[j] = mon_av2_bl[j] = 0.;
mon_pulse_bl=0.;
mon_avg_bl_tmp = 0.;
mon_dev_bl_tmp = 0.;
mon_bl_counts=0;
for (int j=0; j<CHANNELS; j++)
scl_flux[j] = 0;
int scl_idx = 0; int scl_idx = 0;
int scl_peak = 0; int scl_peak = 0;
// processing pulses
for (int i=0; i<NbPulses; i++) { for (int i=0; i<NbPulses; i++) {
// only count for triggered channel
int trg_drop = 0; int trg_drop = 0;
if (itrg) if (itrg)
for (int j=0; j<CHANNELS; j++) for (int j=0; j<CHANNELS; j++)
...@@ -121,7 +141,8 @@ void TreatSecond(LagoGeneric *Data, LagoEvent*Pulse, int NbPulses) { ...@@ -121,7 +141,8 @@ void TreatSecond(LagoGeneric *Data, LagoEvent*Pulse, int NbPulses) {
trg_drop++; trg_drop++;
if (itrg && trg_drop) if (itrg && trg_drop)
continue; continue;
for (int j=0; j<CHANNELS; j++) { //count all channels, not only those triggered //count all channels, not only those triggered
for (int j=0; j<CHANNELS; j++) {
Peak[j][Pulse[i].GetPeak(j)]++; Peak[j][Pulse[i].GetPeak(j)]++;
Charge[j][Pulse[i].GetCharge(j,ineg[j])]++; Charge[j][Pulse[i].GetCharge(j,ineg[j])]++;
Base[j][Pulse[i].GetBase(j)]++; Base[j][Pulse[i].GetBase(j)]++;
...@@ -175,8 +196,32 @@ void TreatSecond(LagoGeneric *Data, LagoEvent*Pulse, int NbPulses) { ...@@ -175,8 +196,32 @@ void TreatSecond(LagoGeneric *Data, LagoEvent*Pulse, int NbPulses) {
tim_pc = Pulse[i].counter; tim_pc = Pulse[i].counter;
tim_pt = Pulse[i].clockcount; tim_pt = Pulse[i].clockcount;
} // end of tim and all sector } // end of tim and all sector
if (imon) { // baseline analysis for each pulse
for (int j=0; j<CHANNELS; j++) {
mon_pulse_bl = Pulse[i].GetPulseBase(j);
mon_avg_bl[j] += mon_pulse_bl;
mon_av2_bl[j] += mon_pulse_bl * mon_pulse_bl;
}
mon_bl_counts++;
}
} // close loop for all pulses } // close loop for all pulses
if (imon) { // print baselines
if (mon_bl_counts) {
for (int j=0; j<CHANNELS; j++) {
mon_avg_bl_tmp = mon_avg_bl[j] / mon_bl_counts;
mon_dev_bl_tmp = sqrt(mon_av2_bl[j] / mon_bl_counts - mon_avg_bl_tmp * mon_avg_bl_tmp);
fprintf(mon, " %.3f %.3f", mon_avg_bl_tmp, mon_dev_bl_tmp);
}
fprintf(mon, "\n");
}
else {
for (int j=0; j<CHANNELS; j++)
fprintf(mon, " 0.000 0.000");
fprintf(mon, "\n");
}
}
if (iflx) { if (iflx) {
if (flx_time == flx_default) { if (flx_time == flx_default) {
// averages // averages
...@@ -524,7 +569,10 @@ int main (int argc, char *argv[]) ...@@ -524,7 +569,10 @@ int main (int argc, char *argv[])
if (imon) { if (imon) {
snprintf(nfi,256,"%s.mon",ifile); snprintf(nfi,256,"%s.mon",ifile);
mon.open(nfi); if ((mon = fopen(nfi,"w"))==NULL) {
fprintf(stderr,"Failed to open monitoring file. Abort.\n");
exit(1);
}
} }
if (irte) { if (irte) {
snprintf(nfi,256,"%s.rte",ifile); snprintf(nfi,256,"%s.rte",ifile);
...@@ -627,10 +675,10 @@ int main (int argc, char *argv[]) ...@@ -627,10 +675,10 @@ int main (int argc, char *argv[])
} }
if (imon) { if (imon) {
mon << "# # # p 1 mon " << PROJECT << " " << VERSION << endl; fprintf(mon, "# # # p 1 all %s %s\n", PROJECT, VERSION);
mon << "# # L1 level file (processed raw data, use at your own risk or contact lago@lagoproject.org)" << endl; fprintf(mon, "# # L1 level file (processed raw data, use at your own risk or contact lago@lagoproject.org)\n");
mon << "# # This is a monitoring file." << endl; fprintf(mon, "# # This is a monitoring file.\n");
mon << "# # Format is second frequency temperature pressure" << endl; fprintf(mon, "# # Format is second frequency temperature pressure average_baseline_chN dev_baseline_chN\n");
} }
if (iscl) { if (iscl) {
...@@ -762,7 +810,7 @@ int main (int argc, char *argv[]) ...@@ -762,7 +810,7 @@ int main (int argc, char *argv[])
if (iraw) if (iraw)
raw.close(); raw.close();
if (imon) if (imon)
mon.close(); fclose(mon);
if (irte) if (irte)
fclose(rte); fclose(rte);
if (iflx) if (iflx)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment