@@ -26,7 +26,7 @@ int main(int argc, char **argv)
2626
2727
2828 bool drawDebugPulses = false ;
29- drawDebugPulses = true ;
29+ // drawDebugPulses = true;
3030 /* std::string _drawDebugPulses = ParseCommandLine( argv, "--debug" );
3131 bool drawDebugPulses = false;
3232 if ( _drawDebugPulses == "yes" ) {
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
4545 // pFile = fopen ( "multi_event_20170209.dat" , "rb" );
4646 // pFile = fopen ( "falling_single_event_20170209.dat" , "rb" );
4747 // pFile = fopen ( "falling_multi_event_20170209.dat" , "rb" );
48- pFile = fopen ( " wave_0.dat " , " rb" );
48+ pFile = fopen ( argv[ 1 ] , " rb" );
4949 if (pFile==NULL ) {fputs (" File error\n " ,stderr); exit (1 );}
5050
5151 // obtain file size:
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
5757 // allocate memory to contain the whole file:
5858 buffer = (float *) malloc (sizeof (float )*lSize);
5959 if (buffer == NULL ) {fputs (" Memory error\n " ,stderr); exit (2 );}
60-
60+
6161 // define the ouput root file and tree
6262 TFile *f = new TFile (" output.root" ," recreate" );
6363 TTree *tree = new TTree (" data" ," data" );
@@ -69,6 +69,7 @@ int main(int argc, char **argv)
6969 float channel[18 ][1024 ];
7070 float channelCorrected[18 ][1024 ];
7171 float base[18 ];
72+ float amp[18 ];
7273 int baseindex[18 ];
7374 float gauspeak[18 ];
7475 float linearTime0[18 ];
@@ -80,12 +81,13 @@ int main(int argc, char **argv)
8081 float time_resolution;
8182
8283 tree->Branch (" event" , &event, " event/I" );
83- tree->Branch (" bin" , bin, " bin[1024]/I" );
84- tree->Branch (" raw" , raw, " raw[18][1024]/F" );
84+ tree->Branch (" bin" , bin, " bin[1024]/I" );
85+ tree->Branch (" raw" , raw, " raw[18][1024]/F" );
8586 tree->Branch (" channel" , channel, " channel[18][1024]/F" );
8687 tree->Branch (" channelCorrected" , channelCorrected, " channelCorrected[18][1024]/F" );
8788 tree->Branch (" time" , time, " time[2][1024]/F" );
8889 tree->Branch (" base" , base, " base[18]/F" );
90+ tree->Branch (" amp" , amp, " amp[18]/F" );
8991 tree->Branch (" baseindex" , baseindex, " baseindex[18]/I" );
9092 tree->Branch (" gauspeak" , gauspeak, " gauspeak[18]/F" );
9193 tree->Branch (" linearTime0" , linearTime0, " linearTime0[18]/F" );
@@ -117,52 +119,51 @@ int main(int argc, char **argv)
117119 double x;
118120 x = *(buffer+6 );
119121 for (int j = 0 ; j < 18 ; j++)
120- {
122+ {
121123 for (int i = 0 ; i < 1024 ; i++ )
122124 {
123125 raw[j][i] = buffer[i+6 +j*1024 ];
124126 channel[j][i] = ( raw[j][i] - 2047 . )/4096 . ;// converting to volts [V]
125- // std::cout << "i = " << i << " ; j = " << j << " ; raw[j][i] = " << raw[j][i] << " ; channel[j][i] = " << channel[j][i] << std::endl;
127+ // std::cout << "i = " << i << " ; j = " << j << " ; raw[j][i] = " << raw[j][i] << " ; channel[j][i] = " << channel[j][i] << std::endl;
126128 bin[i] = i;
127129 time[0 ][i] = i*0.2 ;
128130 time[1 ][i] = i*0.2 ;
129131 }
130132 }
131133 for (int j = 0 ; j < 18 ; j++)
132- {
133- // Find Peak Location
134- int index_min = FindMin (1024 , channel[j]); // return index of the min
135- // if(j==0) std::cout << j << " index_min = " << index_min << std::endl;
136- baseindex[j] = index_min;
137- // int index_minraw = FindMin (1024, raw[j]); // return index of the min
138- // std::cout << j << " index_minraw = " << index_minraw << std::endl;
139-
140- // Estimate baseline
141- float baseline = GetBaseline ( index_min, channel[j]);
142- // std::cout << j << " baseline = " << baseline << std::endl;
143- // float baselineraw = GetBaseline( index_minraw, raw[j]);
144- // std::cout << j << " baselineraw = " << baselineraw << std::endl;
145- base[j] = baseline;
146-
147- // Correct pulse shape for baseline offset
148- for (int i = 0 ; i < 1024 ; i++ )
149- {
150- channelCorrected[j][i] = channel[j][i] - base[j];
151- }
152-
134+ {
135+ // Find Peak Location
136+ int index_min = FindMin (1024 , channel[j]); // return index of the min
137+ // if(j==0) std::cout << j << " index_min = " << index_min << std::endl;
138+ baseindex[j] = index_min;
139+ // int index_minraw = FindMin (1024, raw[j]); // return index of the min
140+ // std::cout << j << " index_minraw = " << index_minraw << std::endl;
141+ // Estimate baseline
142+ float baseline = GetBaseline ( index_min, channel[j]);
143+ // std::cout << j << " baseline = " << baseline << std::endl;
144+ // float baselineraw = GetBaseline( index_minraw, raw[j]);
145+ // std::cout << j << " baselineraw = " << baselineraw << std::endl;
146+ // base[j] = baseline;
147+ base[j] = 0.0 ;
148+ // Correct pulse shape for baseline offset
149+ for (int i = 0 ; i < 1024 ; i++ )
150+ {
151+ channelCorrected[j][i] = channel[j][i] - base[j];
152+ }
153+ amp[j] = -channel[j][index_min];
153154 // Make Pulse shape Graph
154155 TString pulseName = Form (" pulse_event%d_ch%d" , event, j);
155- TGraphErrors* pulse = GetTGraph ( channelCorrected[j], time[0 ] );
156- // if(j<9) TGraphErrors* pulse = GetTGraph( channelCorrected[j], time[0] );
157- // else TGraphErrors* pulse = GetTGraph( channelCorrected[j], time[1] );
156+ TGraphErrors* pulse = GetTGraph ( channelCorrected[j], time[0 ] );
157+ // if(j<9) TGraphErrors* pulse = GetTGraph( channelCorrected[j], time[0] );
158+ // else TGraphErrors* pulse = GetTGraph( channelCorrected[j], time[1] );
158159
159- // Gauss Time-Stamping
160- double min = 0 .; double low_edge =0 .; double high_edge =0 .; double y = 0 .;
161- pulse->GetPoint (index_min, min, y);
160+ // Gauss Time-Stamping
161+ double min = 0 .; double low_edge =0 .; double high_edge =0 .; double y = 0 .;
162+ pulse->GetPoint (index_min, min, y);
162163 pulse->GetPoint (index_min-3 , low_edge, y); // get the time of the low edge of the fit range
163- pulse->GetPoint (index_min+3 , high_edge, y); // get the time of the upper edge of the fit range
164+ pulse->GetPoint (index_min+3 , high_edge, y); // get the time of the upper edge of the fit range
165+
164166
165-
166167 float timepeak = 0 .;
167168 float timecf0 = 0 ;
168169 float timecf15 = 0 ;
@@ -194,7 +195,7 @@ int main(int argc, char **argv)
194195 linearTime15[j] = timecf15;
195196 linearTime30[j] = timecf30;
196197 linearTime45[j] = timecf45;
197- linearTime60[j] = timecf60;
198+ linearTime60[j] = timecf60;
198199 // if(j==0) std::cout << " timepeak = " << timepeak << std::endl;
199200
200201 }
@@ -211,30 +212,30 @@ int main(int argc, char **argv)
211212*/
212213
213214 // if(deltat!=0) dt->Fill(deltat);
214- // if(deltat!=0) tree->Fill();
215+ // if(deltat!=0) tree->Fill();
215216 dt->Fill (deltat);
216- tree->Fill ();
217+ tree->Fill ();
217218 event++;
218219 }
219-
220+
220221 gStyle ->SetOptFit ();
221222 TF1* fpeak = new TF1 (" fpeak" ," gaus" , 0.02 , 0.035 );
222- // fpeak->SetParameter(1,0.025);
223- TCanvas* c = new TCanvas (" canvas" ," canvas" ,800 ,400 ) ;
223+ // fpeak->SetParameter(1,0.025);
224+ // TCanvas* c = new TCanvas("canvas","canvas",800,400) ;
224225 // dt->GetXaxis()->SetLimits(0.01,0.06);
225226 // dt->GetYaxis()->SetRangeUser(0,100);
226227 // dt->SetMarkerSize(1);
227228 // dt->SetMarkerStyle(20);
228229 dt->Fit ( fpeak," " ," R" );
229230 time_resolution = fpeak->GetParameter (2 );
230- dt->Draw ();
231+ // dt->Draw();
231232 // fpeak->Draw("SAME");
232233 // fpeak->SetLineColor(2);
233- c->SaveAs (" time_resolution.pdf" );
234+ // c->SaveAs("time_resolution.pdf");
234235 delete fpeak;
235236
236237 std::cout << " time resolution = " << time_resolution << std::endl;
237-
238+
238239 // event2
239240/*
240241 result = fread (buffer,1,lSize,pFile);
0 commit comments