Changeset 12168 for fact/tools/rootmacros/fana.C
- Timestamp:
- 10/11/11 14:59:16 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/fana.C
r12166 r12168 50 50 51 51 vector<float> Vslide(FAD_MAX_SAMPLES); // sliding average result 52 vector<float> Vcfd(FAD_MAX_SAMPLES); // CDF result53 vector<float> Vcfd _slide(FAD_MAX_SAMPLES); // CDF result sliding averaged again52 vector<float> Vcfd(FAD_MAX_SAMPLES); // CDF result 53 vector<float> Vcfd2(FAD_MAX_SAMPLES); // CDF result + 2nd sliding average 54 54 55 55 #include "factfir.C" … … 60 60 61 61 // histograms 62 const int Ntypes = 6; 63 const unsigned int tAmeas = 0, 62 const int Ntypes = 7; 63 const unsigned int // arranged by Dominik 64 tAmeas = 0, 64 65 tN1mean = 1, 65 tVcorr = 2,66 tV slide = 3,67 tV cfd = 4,68 tVcfd _slide = 5;69 66 tVcorr = 2, 67 tVtest = 3, 68 tVslide = 4, 69 tVcfd = 5, 70 tVcfd2 = 6; 70 71 71 72 TH1F* h; … … 78 79 // Create a canvas 79 80 TCanvas* CW; 80 81 int spikeDebug = 0; 82 83 84 int fana( const char *datafilename = "/media/daten_platte/FACT/data/20111009_013.fits", 85 const char *drsfilename = "/media/daten_platte/FACT/data/20111009_009.drs.fits", 86 int pixelnr = 0, 87 int firstevent = 0, 88 int nevents = -1 ) 89 { 81 TCanvas* cFilter; 82 83 int spikeDebug = 1; 84 85 86 int fana( 87 char *datafilename = "../raw/20110916_025.fits", 88 const char *drsfilename = "../raw/20110916_024.drs.fits", 89 int pixelnr = 0, 90 int firstevent = 0, 91 int nevents = -1 ){ 92 // read and analyze FACT raw data 93 90 94 // sliding window filter settings 91 95 int k_slide = 16; … … 100 104 a_cfd[k_cfd-1]=-1.; 101 105 102 103 106 // 2nd slinding window filter 104 107 int ks2 = 16; 105 108 vector<double> as2(ks2, 1); 106 109 double bs2 = ks2; 107 108 110 gROOT->SetStyle("Plain"); 109 111 … … 148 150 149 151 float value; 150 float integral =0; 151 152 TH1F * sp = new TH1F("spektrum", "test of Stepktrum", 256, -0.5, 63.5); 152 TH1F * sp = new TH1F("spektrum", "test of Stepktrum", 256, -0.5, 63.5); 153 153 154 154 for ( int ev = firstevent; ev < firstevent + nevents; ev++) { 155 155 156 156 datafile.GetRow( ev ); 157 if (ev % 50 ==0) 158 cout << "Event number: " << data_num << endl; 159 157 158 if (ev % 50 ==0){ 159 cout << "Event number: " << data_num << endl; 160 } 161 160 162 for ( int pix = 0; pix < 1440; pix++ ){ 161 163 hStartCell->Fill( pix, data_offset[pix] ); … … 177 179 } 178 180 179 // calculate sliding mean using FIR filter function 180 factfir(b_slide , a_slide, k_slide, Vcorr, Vslide); 181 // calculate CDF 182 factfir(b_cfd , a_cfd, k_cfd, Vslide, Vcfd); 183 // calculate i2nd sliding mean 184 factfir(b_slide , a_slide, k_slide, Vcfd, Vcfd_slide); 181 // filter Vcorr with sliding average using FIR filter function 182 factfir(b_slide , a_slide, k_slide, Vcorr, Vslide); 183 184 // filter Vslide with CFD using FIR filter function 185 factfir(b_cfd , a_cfd, k_cfd, Vslide, Vcfd); 186 // filter Vcfd with sliding average using FIR filter function 187 factfir(b_slide , a_slide, k_slide, Vcfd, Vcfd2); 188 189 if ( spikeDebug ){ 190 for ( unsigned int sl = 0; sl < data_roi; sl++){ 191 h[tVslide].SetBinContent( sl, Vslide[sl] ); 192 h[tVcfd].SetBinContent( sl, Vcfd[sl] ); 193 h[tVcfd2].SetBinContent( sl, Vcfd2[sl] ); 194 } 195 } 196 197 vector<int> * zeros = zerosearch( Vcfd2, -1, 10, 20 ); 198 if (zeros->size() == 0 ){ 199 continue; 200 } 201 // check value of Vside at zero position 202 for ( int i=0; i<zeros->size(); i++){ 203 cout << zeros->at(i) << ":\t" << Vslide[ zeros->at(i) ]<<endl; 204 sp->Fill(Vslide[zeros->at(i)]); 205 } 185 206 186 for ( unsigned int sl = 0; sl < data_roi; sl++){ 187 h[tVcfd].SetBinContent(sl, Vcfd[sl]); 188 h[tVslide].SetBinContent(sl, Vslide[sl]); 189 h[tVcfd_slide].SetBinContent(sl, Vcfd_slide[sl]); 190 } 191 192 193 vector<int> * zeros = zerosearch(Vcfd_slide,-1,10,20); 194 if (zeros->size() ==0) 195 continue; 196 197 // check value of Vside at zero position 198 for ( int i=0; i<zeros->size(); i++){ 199 cout << zeros->at(i) << ":\t" << Vslide[zeros->at(i)]<<endl; 200 sp->Fill(Vslide[zeros->at(i)]); 201 } 202 203 /* 204 205 vector<int> goodzeros; 206 if (zeros->size() > 1){ 207 for ( int i=0; i<zeros->size(); i++){ 208 if (i==0) { 209 if ( abs(zeros->at(i) - zeros->at(i+1)) > 90 ) 210 goodzeros.push_back(zeros->at(i)); 211 } else if ( i==zeros->size()-1){ 212 if (abs(zeros->at(i) - zeros->at(i-1)) > 90) 213 goodzeros.push_back(zeros->at(i)); 214 } else { 215 if (abs(zeros->at(i) - zeros->at(i-1)) > 90 && 216 abs(zeros->at(i) - zeros->at(i+1)) > 90 ) 217 goodzeros.push_back(zeros->at(i)); 218 } 219 } 220 } else { 221 goodzeros.push_back(zeros->at(0)); 222 } 223 224 // compute integrals around the good zeros. 225 // from -30 to +80 around it. 226 for (int i=0; i<goodzeros.size(); i++){ 227 // cout << goodzeros[i]; 228 integral =0; 229 for (int sl = goodzeros[i]-30; sl < goodzeros[i]+80; sl++){ 230 if ( Ameas[sl] > integral) 231 integral = Ameas[sl]; 232 } 233 // cout << "\t-->" << integral << endl; 234 sp->Fill(integral); 235 } 236 237 */ 238 239 240 if ( spikeDebug ){ 207 if ( spikeDebug ){ 241 208 242 209 CW->cd( tAmeas + 1); … … 252 219 h[tVcorr].Draw(); 253 220 254 CW->cd( tVslide + 1); 255 gPad->SetGrid(); 256 h[tVslide].Draw(); 221 // CW->cd( tVtest + 1); 222 // gPad->SetGrid(); 223 // h[tVtest].Draw(); 224 225 cFilter->cd( Ntypes - tVslide ); 226 cFilter->cd(1); 227 gPad->SetGrid(); 228 h[tVslide].Draw(); 257 229 258 CW->cd( tVcfd + 1); 259 gPad->SetGrid(); 260 h[tVcfd].Draw(); 261 TLine zeroline(0,0,1024,0); 262 zeroline.SetLineColor(kBlue); 263 zeroline.Draw(); 230 cFilter->cd( Ntypes - tVcfd ); 231 cFilter->cd(2); 232 gPad->SetGrid(); 233 h[tVcfd].Draw(); 234 235 TLine zeroline(0, 0, 1024, 0); 236 zeroline.SetLineColor(kBlue); 237 zeroline.Draw(); 238 239 cFilter->cd( Ntypes - tVcfd2 ); 240 cFilter->cd(3); 241 gPad->SetGrid(); 242 h[tVcfd2].Draw(); 243 244 zeroline.Draw(); 264 245 265 CW->cd( tVcfd_slide + 1); 266 gPad->SetGrid(); 267 h[tVcfd_slide].Draw(); 268 zeroline.Draw(); 269 270 CW->Update(); 246 CW->Update(); 247 cFilter->Update(); 271 248 272 249 //Process gui events asynchronously during input … … 284 261 cSpektrum->cd(); 285 262 sp->Draw(); 286 287 288 TCanvas * cStartCell = new TCanvas(); 263 TCanvas * cStartCell = new TCanvas(); 289 264 cStartCell->cd(); 290 265 hStartCell->Draw(); 291 266 hPixelCellData.Draw(); 292 delete cStartCell; 267 268 delete cStartCell; 269 293 270 return( 0 ); 294 271 } … … 410 387 } 411 388 CW = new TCanvas("CW","DRS Waveform",10,10,800,600); 412 CW->Divide(1, Ntypes); 389 CW->Divide(1, 3); 390 cFilter = new TCanvas("cFilter","filtered DRS Waveforms",10,10,800,600); 391 cFilter->Divide(1, 3); 413 392 414 393 hStartCell = new TH2F("StartCell", "StartCell", 1440, 0., 1440., 1024, 0., 1024);
Note:
See TracChangeset
for help on using the changeset viewer.