Changeset 12365
- Timestamp:
- 11/02/11 15:58:34 (13 years ago)
- Location:
- fact/tools/rootmacros
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/FOscilloscope.c
r12166 r12365 1 1 #include <cstdio> 2 #include "FCalibrateEvent.c" 2 3 int FOscilloscope(fits &datafile, vector<int16_t> &data, vector<int16_t> &data_offset, unsigned int &data_num, UInt_t data_px, vector<float> &drs_basemean, vector<float> &drs_gainmean, vector<float> &drs_triggeroffsetmean, UInt_t data_roi, float threshold, TH2* pulseshape, TH1* spectrum) 3 4 //Data, calibration, data_roi, data_num, data_px, threshold, two histograms … … 9 10 UInt_t integration_delay = 5; 10 11 11 float sample, last_sample, integral; 12 vector<float> calevent(data_px*data_roi); //Vector for the calibrated event 13 14 float integral; 12 15 UInt_t drs_calib_offset; 13 16 … … 18 21 cout << "Event number: " << data_num << endl; 19 22 23 FCalibrateEvent(data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, calevent, data_px, data_roi); 24 20 25 //Iterate over the pixels 21 26 for (int j=0; j<data_px; j++) … … 24 29 25 30 //Iterate over the slices 26 drs_calib_offset = (start_sample-1+data_offset[j])%data_roi;27 last_sample = (data[j*data_roi+start_sample-1]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+start_sample-1])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35;28 31 for (UInt_t k=start_sample; k<end_sample; k++) 29 32 { 30 drs_calib_offset = (k+data_offset[j])%data_roi; 31 sample = (data[j*data_roi+k]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35; 32 if((last_sample<threshold)&&(sample>threshold)) 33 if((calevent[j*data_roi+k-1]<threshold)&&(calevent[j*data_roi+k]>threshold)&&(calevent[j*data_roi+k+2]>threshold)) 33 34 { 34 35 integral = 0; 35 36 for(UInt_t l=integration_delay; l<integration_delay+integration_size; l++) 36 37 { 37 drs_calib_offset = (k+l+data_offset[j])%data_roi; 38 integral+=(data[j*data_roi+k+l]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k+l])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35; 38 integral+=calevent[j*data_roi+k+l]; 39 39 } 40 40 // if((integral>60)&&(integral<=300)) { … … 42 42 for(Int_t l=-10; l<60; l++) 43 43 { 44 drs_calib_offset = (k+l+data_offset[j])%data_roi; 45 sample = (data[j*data_roi+k+l]*2000/4096.-drs_basemean[j*data_roi+drs_calib_offset]-drs_triggeroffsetmean[j*data_roi+k+l])/drs_gainmean[j*data_roi+drs_calib_offset]*1907.35; 46 pulseshape->Fill(l,sample); 44 pulseshape->Fill(l,calevent[j*data_roi+k+l]); 47 45 } 48 46 // } … … 52 50 //TBD: mistake that after the deadtime the last_sample must be set new... 53 51 //Solution: first process full pipeline 54 last_sample = sample;55 52 } 56 53 } -
fact/tools/rootmacros/calscope_batch.C
r12363 r12365 75 75 TProfile *pix = new TProfile("pix", title, 1024, -0.5, 1023.5); 76 76 77 //**** 77 //------------------------------------------- 78 //Start the loop 79 //------------------------------------------- 78 80 char temp; 79 81 std::cout << "Plot the spectra out of limits: Enter for next, 'a' to abort." << std::endl; … … 83 85 cout << "Event number: " << data_num << endl; 84 86 87 //------------------------------------------- 88 //Calibrate the event 89 //------------------------------------------- 85 90 FCalibrateEvent(data, data_offset, drs_basemean, drs_gainmean, drs_triggeroffsetmean, calevent, data_px, data_roi); 86 91 92 //------------------------------------------- 93 //Draw the data 94 //------------------------------------------- 87 95 pix->Reset(); 88 96 std::sprintf(title,"Data: %s, DRS: %s, Px %i Ev %i",name,drsname,pixelnr,eventnr); … … 102 110 if(temp=='a') break; 103 111 } 104 105 //****106 107 //-------------------------------------------108 //Get the calibrated event109 //-------------------------------------------110 111 112 //-------------------------------------------113 //Draw the data114 //-------------------------------------------115 112 116 113 return 0; -
fact/tools/rootmacros/peakfinderscope.C
r12303 r12365 18 18 #define n_peaks 4 19 19 20 int peakfinderscope(const char *name, const char *drsname, size_t eventnr, size_tpixelnr)20 int peakfinderscope(const char *name, const char *drsname, size_t pixelnr) 21 21 { 22 22 //****************************************************************************** … … 60 60 //------------------------------------------- 61 61 char title[500]; 62 std::sprintf(title,"Data: %s, DRS: %s, Px %i Ev %i",name,drsname,pixelnr,eventnr);62 std::sprintf(title,"Data: %s, DRS: %s, Px %i",name,drsname,pixelnr); 63 63 TCanvas *canv = new TCanvas( "canv", "Waveform", 200, 10, 700, 500 ); 64 64 // TProfile *pulseshape = new TProfile("pulseshape", title, 70, -10.5, 59.5); … … 73 73 std::sprintf(title_spect,"Spectrum of all pixels (data: %s, DRS: %s)",name,drsname); 74 74 TCanvas *canv_spect = new TCanvas( "canv_spect", "Spectrum", 950, 10, 700, 500 ); 75 TH1F *spectrum = new TH1F("spectrum", title_spect, 300,0,600);75 TH1F *spectrum = new TH1F("spectrum", title_spect,700,-200,1200); 76 76 spectrum->GetXaxis()->SetTitle("Pulse size (a.u.)"); 77 77 spectrum->GetYaxis()->SetTitle("Counts"); … … 139 139 canv_spect->Update(); 140 140 //*********************** 141 fits datafile2("20110804_025.fits");142 if (!datafile2)143 {144 cout << "Couldn't properly open the datafile2." << endl;145 return 1;146 }147 FOpenDataFile(datafile2, data, data_offset, data_num, data_n, data_roi, data_px);148 FOscilloscope(datafile2, data, data_offset, data_num, data_px, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, threshold, pulseshape, spectrum);149 150 canv->cd();151 pulseshape->Draw();152 canv->Modified();153 canv->Update();154 155 canv_spect->cd();156 spectrum->Draw();157 canv_spect->Modified();158 canv_spect->Update();159 //***********************160 fits datafile3("20110804_026.fits");161 if (!datafile3)162 {163 cout << "Couldn't properly open the datafile3." << endl;164 return 1;165 }166 FOpenDataFile(datafile3, data, data_offset, data_num, data_n, data_roi, data_px);167 FOscilloscope(datafile3, data, data_offset, data_num, data_px, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, threshold, pulseshape, spectrum);168 169 canv->cd();170 pulseshape->Draw();171 canv->Modified();172 canv->Update();173 174 canv_spect->cd();175 spectrum->Draw();176 canv_spect->Modified();177 canv_spect->Update();178 //***********************179 fits datafile4("20110804_027.fits");180 if (!datafile4)181 {182 cout << "Couldn't properly open the datafile4." << endl;183 return 1;184 }185 FOpenDataFile(datafile4, data, data_offset, data_num, data_n, data_roi, data_px);186 FOscilloscope(datafile4, data, data_offset, data_num, data_px, drs_basemean, drs_gainmean, drs_triggeroffsetmean, data_roi, threshold, pulseshape, spectrum);187 188 canv->cd();189 pulseshape->Draw();190 canv->Modified();191 canv->Update();192 193 canv_spect->cd();194 spectrum->Draw();195 canv_spect->Modified();196 canv_spect->Update();197 //***********************198 141 spectrum->Fit(f_peaks,"R+"); 199 142 f_peaks->GetParameters(&par[0]);
Note:
See TracChangeset
for help on using the changeset viewer.