diff --git a/dump.cc b/dump.cc index aeb9ef1d7e662a50c350240441c0d4e803097608..965167ede67a7a022e3c62a1ed46c05423b5be1f 100644 --- a/dump.cc +++ b/dump.cc @@ -58,12 +58,17 @@ int main (int argc, char **argv) { // // File reading and processing // + double rt=0., ft=0., tt=0.; cerr << "Reading file" << endl; while(NbPulses!=-1) { NbPulses=Input.ReadOneSecond(&Data,Pulse,MAXPULSEPERSEC); - for (int j=CHANNELS-1; j>=0; j--) - cout << Pulse[0].IsTriggered(j) << " "; - cout << endl; + for (int i=0; i<NbPulses; i++) { + rt = Pulse[i].GetRiseTime(2); + ft = Pulse[i].GetFallTime(2); + tt = Pulse[i].GetFullTime(2); + if (rt>0 && ft>0) + cout << rt << " " << ft << " " << tt << endl; + } } return 0; } diff --git a/lago_data.h b/lago_data.h index c5f582542ed171c9c0b75bfbdf5e2b2b842416dd..ebf05b1d08ee59ffd979da398fe4d67c53a60dae 100644 --- a/lago_data.h +++ b/lago_data.h @@ -139,7 +139,55 @@ class LagoEvent { return charge; } - void dump() { + double GetTfraction(int channel, int fraction) { + if (fraction < 10 || fraction > 100) + return -1; + double charge = (double) GetCharge(channel); + if (!charge) + return -2; + int i=0; + double s = 0.; + double dy = 0.; + double x = 0.; + double limit = fraction / 100.; + for (i=0; i<currentbinfilled; i++) { + dy = 1.0 * (trace[channel][i] - BASELINE) / charge; + s += dy; + if (s >= limit) + break; + } + if (!i) + return -3; + if (!dy)// no changes from previous bin? should not happen thanks to the equal sign in the comparisson, but just in case + return ((i-1.)*BIN); // return previous bin + x = (1.0 * i - ((s - limit) / dy)) * BIN; + return x; + } + + double GetCharTime(int channel, int up, int low) { + if (up < low) + return -1; // stupid user + double Tu=GetTfraction(channel,up); + double Tl=GetTfraction(channel,low); + if (Tu >= 0 && Tl >= 0) + return (Tu-Tl); + else + return -1; + } + + double GetRiseTime (int channel) { + return GetCharTime(channel,50,10); + } + + double GetFallTime (int channel) { + return GetCharTime(channel,90,50); + } + + double GetFullTime (int channel) { + return GetCharTime(channel,90,10); + } + + void dump() { std::cout << "# trg: " << trigger << " cnt: " << counter << " clk: " << clockcount << " " << std::endl; diff --git a/lago_defs.h b/lago_defs.h index b33a19360a184d9fa6c29c943c5f414b924cd4bd..d3d5044fe17b9d09f5789022cb5cb791fcc2ca78 100644 --- a/lago_defs.h +++ b/lago_defs.h @@ -38,5 +38,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND #define CHANNELS 3 #define TRACELEN 12 #define BASELINE 50 +#define BIN 25. #endif