Changeset 12683 for fact/tools/rootmacros
- Timestamp:
- 12/02/11 05:23:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/tpeak.C
r12556 r12683 34 34 35 35 #include "fits.h" 36 #include "FOpenCalibFile.c" 36 37 #include "openFits.h" 38 #include "openFits.c" 37 39 38 40 #include "discriminator.h" … … 41 43 #include "zerosearch.C" 42 44 #include "factfir.C" 43 44 #include "FOpenDataFile.h"45 #include "FOpenDataFile.c"46 45 47 46 #include "DrsCalibration.C" … … 64 63 UInt_t NumberOfPixels; 65 64 65 size_t TriggerOffsetROI, RC; 66 66 size_t drs_n; 67 67 vector<float> drs_basemean; … … 120 120 int avg1 = 14, 121 121 int avg2 = 8, 122 123 122 int OverlayWindowLeft = 50, 123 int OverlayWindowRight = 150, 124 124 int verbosityLevel = 1, // different verbosity levels can be implemented here 125 125 bool ProduceGraphic = true … … 127 127 128 128 { 129 hPeakOverlayXaxisLeft = OverlayWindowLeft;130 hPeakOverlayXaxisRight = OverlayWindowRight;131 132 133 129 hPeakOverlayXaxisLeft = OverlayWindowLeft; 130 hPeakOverlayXaxisRight = OverlayWindowRight; 131 132 gStyle->SetPalette(1,0); 133 gROOT->SetStyle("Plain"); 134 134 135 135 //----------------------------------------------------------------------------- … … 141 141 TCanvas *cFiltered = NULL; 142 142 if (spikeDebug){ 143 144 143 cFiltered = new TCanvas("cFiltered","filtered DRS Waveforms", 1,310,400,300); 144 cFiltered->Divide(1, 3); 145 145 } 146 146 // Canvases to show the peak template 147 147 TCanvas *cPeakOverlay = NULL; 148 cPeakOverlay = new TCanvas("cPeakOverlay", "Overlay of detected Peaks", 1, 1, 1200, 600);148 cPeakOverlay = new TCanvas("cPeakOverlay", "Overlay of detected Peaks", 1, 1, 1200, 800); 149 149 cPeakOverlay->Divide(2,1); 150 150 // // All peaks of one Pixel … … 186 186 // Parameters to the data file. So they are filled with 187 187 // raw data as soon as datafile->GetRow(int) is called. 188 NEvents = OpenDataFile( datafilename, &datafile,188 NEvents = openDataFits( datafilename, &datafile, 189 189 AllPixelDataVector, StartCellVector, CurrentEventID, 190 190 RegionOfInterest, NumberOfPixels, PXLxROI, verbosityLevel); … … 207 207 cout <<"of, which "<< npixel << "will be processed"<< endl; 208 208 //Get the DRS calibration 209 FOpenCalibFile( drsfilename,210 drs_basemean,211 drs_gainmean,212 drs_triggeroffsetmean,213 drs_n);214 cout << "test4" << endl; 209 RC = openCalibFits( drsfilename, drs_basemean, drs_gainmean, drs_triggeroffsetmean, TriggerOffsetROI); 210 if (RC == 0){ 211 cout << "return code of openCalibFits:" << drsfilename << endl; 212 cout << "is zero -> aborting." << endl; 213 return 1; 214 } 215 215 // Book the histograms 216 216 BookHistos( ); 217 217 218 218 //----------------------------------------------------------------------------- 219 219 // Loops over Every Event and Pixel 220 220 //----------------------------------------------------------------------------- 221 for ( int ev = firstevent; ev < firstevent + nevents; ev++) { 222 // Get an Event --> consists of 1440 Pixel ...erm....data 223 datafile->GetRow( ev ); 224 225 //------------------------------------- 226 // Loop over every Pixel of Event 227 //------------------------------------- 228 229 for ( int pix = firstpixel; pix < firstpixel + npixel; pix++ ){ 230 231 if (verbosityLevel > 0){ 232 if (pix == firstpixel){ 233 cout << "Processing Event: " << CurrentEventID << "/" << nevents << endl; 234 } 235 } 236 237 applyDrsCalibration( Ameas,pix,12,12, 238 drs_basemean, drs_gainmean, drs_triggeroffsetmean, 239 RegionOfInterest, AllPixelDataVector, StartCellVector); 240 241 // finds spikes in the raw data, and interpolates the value 242 // spikes are: 1 or 2 slice wide, positive non physical artifacts 243 removeSpikes (Ameas, Vcorr); 244 245 // filter Vcorr with sliding average using FIR filter function 246 sliding_avg(Vcorr, Vslide, avg1); 247 // filter Vslide with CFD using FIR filter function 248 factfir(b_cfd , a_cfd, k_cfd, Vslide, Vcfd); 249 // filter Vcfd with sliding average using FIR filter function 250 sliding_avg(Vcfd, Vcfd2, avg2); 251 252 // peaks in Ameas[] are found by searching for zero crossings 253 // in Vcfd2 254 // first Argument 1 means ... *rising* edge 255 // second Argument 1 means ... search with stepsize 1 ... 10 is okay as well 256 vector<Region> * zXings = zerosearch( Vcfd2 , 1 , 1); 257 // zXings means "zero cross ings" 258 EnlargeRegion(*zXings, 10, 10); 259 findAbsMaxInRegions(*zXings, Vslide); 260 removeMaximaBelow( *zXings, 3.0); 261 removeRegionWithMaxOnEdge( *zXings, 2); 262 removeRegionOnFallingEdge( *zXings, 100); 263 264 //following Code should produce the Overlay of peaks 265 vector<Region>::iterator it; 266 267 for (it = zXings->begin() ; it < zXings->end() ; it++){ 268 int Left = it->maxPos - OverlayWindowLeft; 269 int Right = it->maxPos + OverlayWindowRight; 270 if (Left < 0) 271 Left =0; 272 if (Right > (int)Vcorr.size() ) 273 Right=Vcorr.size() ; 274 for ( int pos = Left; pos < Right; pos++){ 275 276 hPeakOverlay->Fill( pos - (it->maxPos), Vslide[pos]) ; 277 // hPixelPeakOverlay->Fill( pos - (it->maxPos), Vcorr[pos]) ; 278 // hEventPeakOverlay->Fill( pos - (it->maxPos), 2*Vcorr[pos]) ; 279 } 280 } 281 282 283 if ( spikeDebug ){ 284 285 286 // TODO do this correct. The vectors should be the rigt ones... this is just luck 287 debugHistos[Ameas_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 288 debugHistos[Vcorr_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 289 debugHistos[Vslide_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 290 debugHistos[Vcfd_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 291 debugHistos[Vcfd2_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 292 293 for ( unsigned int sl = 0; sl < RegionOfInterest; sl++){ 294 debugHistos[Ameas_].SetBinContent(sl, Ameas[sl]); 295 debugHistos[Vcorr_].SetBinContent(sl, Vcorr[sl]); 296 debugHistos[Vslide_].SetBinContent( sl, Vslide[sl] ); 297 debugHistos[Vcfd_].SetBinContent( sl, Vcfd[sl] ); 298 debugHistos[Vcfd2_].SetBinContent( sl, Vcfd2[sl] ); 299 } 221 for ( int ev = firstevent; ev < firstevent + nevents; ev++) { 222 // Get an Event --> consists of 1440 Pixel ...erm....data 223 datafile->GetRow( ev ); 224 225 //------------------------------------- 226 // Loop over every Pixel of Event 227 //------------------------------------- 228 229 for ( int pix = firstpixel; pix < firstpixel + npixel; pix++ ){ 230 if (verbosityLevel > 0){ 231 if (pix == firstpixel){ 232 cout << "Processing Event: " << CurrentEventID << "/" << nevents << endl; 233 } 234 } 235 236 applyDrsCalibration( Ameas,pix,12,12, 237 drs_basemean, drs_gainmean, drs_triggeroffsetmean, 238 RegionOfInterest, AllPixelDataVector, StartCellVector); 239 240 // finds spikes in the raw data, and interpolates the value 241 // spikes are: 1 or 2 slice wide, positive non physical artifacts 242 removeSpikes (Ameas, Vcorr); 243 244 // filter Vcorr with sliding average using FIR filter function 245 sliding_avg(Vcorr, Vslide, avg1); 246 // filter Vslide with CFD using FIR filter function 247 factfir(b_cfd , a_cfd, k_cfd, Vslide, Vcfd); 248 // filter Vcfd with sliding average using FIR filter function 249 sliding_avg(Vcfd, Vcfd2, avg2); 250 251 // peaks in Ameas[] are found by searching for zero crossings 252 // in Vcfd2 253 // first Argument 1 means ... *rising* edge 254 // second Argument 1 means ... search with stepsize 1 ... 10 is okay as well 255 vector<Region> * zXings = zerosearch( Vcfd2 , 1 , 8); 256 // zXings means "zero cross ings" 257 EnlargeRegion(*zXings, 10, 10); 258 findAbsMaxInRegions(*zXings, Vslide); 259 removeMaximaBelow( *zXings, 3.0); 260 removeRegionWithMaxOnEdge( *zXings, 2); 261 removeRegionOnFallingEdge( *zXings, 100); 262 263 //following Code should produce the Overlay of peaks 264 vector<Region>::iterator it; 265 for (it = zXings->begin() ; it < zXings->end() ; it++){ 266 if (it->maxPos < 12 || it->maxPos > RegionOfInterest-12) 267 continue; 268 domstest->Fill(it->maxPos); 269 int Left = it->maxPos - OverlayWindowLeft; 270 int Right = it->maxPos + OverlayWindowRight; 271 if (Left < 0) 272 Left =0; 273 if (Right > (int)Vcorr.size() ) 274 Right=Vcorr.size() ; 275 for ( int pos = Left; pos < Right; pos++){ 276 hPeakOverlay->Fill( pos - (it->maxPos), Vslide[pos]) ; 277 // hPixelPeakOverlay->Fill( pos - (it->maxPos), Vcorr[pos]) ; 278 // hEventPeakOverlay->Fill( pos - (it->maxPos), 2*Vcorr[pos]) ; 279 } 280 } 281 282 283 if ( spikeDebug ){ 284 // TODO do this correct. The vectors should be the rigt ones... this is just luck 285 debugHistos[Ameas_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 286 debugHistos[Vcorr_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 287 debugHistos[Vslide_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 288 debugHistos[Vcfd_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 289 debugHistos[Vcfd2_].GetXaxis()->Set(Ameas.size() , -0.5 , Ameas.size()-0.5); 290 291 for ( unsigned int sl = 0; sl < RegionOfInterest; sl++){ 292 debugHistos[Ameas_].SetBinContent(sl, Ameas[sl]); 293 debugHistos[Vcorr_].SetBinContent(sl, Vcorr[sl]); 294 debugHistos[Vslide_].SetBinContent( sl, Vslide[sl] ); 295 debugHistos[Vcfd_].SetBinContent( sl, Vcfd[sl] ); 296 debugHistos[Vcfd2_].SetBinContent( sl, Vcfd2[sl] ); 297 } 300 298 301 299
Note:
See TracChangeset
for help on using the changeset viewer.