Changeset 12379 for fact/tools/rootmacros
- Timestamp:
- 11/04/11 20:18:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/fpeak_cdf.C
r12371 r12379 37 37 #include "DrsCalibration.h" 38 38 39 #include "SpikeRemoval.h" 40 #include "SpikeRemoval.C" 41 39 42 bool breakout=false; 40 43 … … 53 56 54 57 vector<float> Ameas(FAD_MAX_SAMPLES); // copy of the data (measured amplitude 55 vector<float> N1mean(FAD_MAX_SAMPLES); // mean of the +1 -1 ch neighbors56 58 vector<float> Vcorr(FAD_MAX_SAMPLES); // corrected Values 57 vector<float> Vdiff(FAD_MAX_SAMPLES); // numerical derivative58 59 59 vector<float> Vslide(FAD_MAX_SAMPLES); // sliding average result 60 60 vector<float> Vcfd(FAD_MAX_SAMPLES); // CDF result 61 61 vector<float> Vcfd2(FAD_MAX_SAMPLES); // CDF result + 2nd sliding average 62 63 64 //float getValue( int, int );65 void computeN1mean( int );66 void removeSpikes( int );67 62 68 63 // histograms … … 130 125 131 126 fits * datafile; 127 // Opens the raw data file and 'binds' the variables given as 128 // Parameters to the data file. So they are filled with 129 // raw data as soon as datafile->GetRow(int) is called. 132 130 NEvents = OpenDataFile( datafilename, &datafile, 133 131 AllPixelDataVector, StartCellVector, CurrentEventID, … … 177 175 RegionOfInterest, AllPixelDataVector, StartCellVector); 178 176 179 // operates on Ameas[] and writes to N1mean[] 180 computeN1mean( RegionOfInterest ); 181 182 // operates on Ameas[] and N1mean[], then writes to Vcorr[] 183 removeSpikes( RegionOfInterest ); 177 // finds spikes in the raw data, and interpolates the value 178 // spikes are: 1 or 2 slice wide, positive non physical artifacts 179 removeSpikes (Ameas, Vcorr); 184 180 185 181 // filter Vcorr with sliding average using FIR filter function … … 288 284 } 289 285 290 void removeSpikes(int Samples){291 292 const float fract = 0.8;293 float x, xp, xpp, x3p;294 295 // assume that there are no spikes296 for ( int i = 0; i < Samples; i++) Vcorr[i] = Ameas[i];297 298 // find the spike and replace it by mean value of neighbors299 for ( int i = 0; i < Samples; i++) {300 301 302 x = Ameas[i] - N1mean[i];303 304 if ( x < -5. ){ // a spike candidate305 // check consistency with a single channel spike306 xp = Ameas[i+1] - N1mean[i+1];307 xpp = Ameas[i+2] - N1mean[i+2];308 x3p = Ameas[i+3] - N1mean[i+3];309 310 311 if ( Ameas[i+2] - ( Ameas[i] + Ameas[i+3] )/2. > 10. ){312 Vcorr[i+1] = ( Ameas[i] + Ameas[i+3] )/2.;313 Vcorr[i+2] = ( Ameas[i] + Ameas[i+3] )/2.;314 i = i + 3;315 }316 else{317 318 if ( ( xp > -2.*x*fract ) && ( xpp < -10. ) ){319 Vcorr[i+1] = N1mean[i+1];320 N1mean[i+2] = (Ameas[i+1] - Ameas[i+3] / 2.);321 i = i + 2;//do not care about the next sample it was the spike322 }323 // treatment for the end of the pipeline must be added !!!324 }325 }326 else{327 // do nothing328 }329 } // end of spike search and correction330 for ( int i = 0; i < Samples; i++ ) debugHistos[ Vcorr_ ].SetBinContent( i, Vcorr[i] );331 }332 333 void computeN1mean( int Samples ){334 // compute the mean of the left and right neighbors of a channel335 336 for( int i = 2; i < Samples - 2; i++){337 /* if (i == 0){ // use right sample es mean338 N1mean[i] = Ameas[i+1];339 }340 else if ( i == Samples-1 ){ //use left sample as mean341 N1mean[i] = Ameas[i-1];342 }343 else{344 N1mean[i] = ( Ameas[i-1] + Ameas[i+1] ) / 2.;345 }346 */347 N1mean[i] = ( Ameas[i-1] + Ameas[i+1] ) / 2.;348 }349 } // end of computeN1mean computation350 351 352 286 // booking and parameter settings for all histos 353 287 void BookHistos( ){
Note:
See TracChangeset
for help on using the changeset viewer.