Skip to content

Commit

Permalink
avoid crash when no tdc timestamps available
Browse files Browse the repository at this point in the history
  • Loading branch information
emx77 committed Apr 9, 2021
1 parent f8b5803 commit 43b3ecf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions tpx3_clusters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int tpx3_clusters(string filename, long nhits=-1) {
ttdc->SetEstimate(-1);
ttdc->Draw("ts","type==0||type==2","goff");
tdc = ttdc->GetV1();
cout << tdc[0] << ' ' << endl;
if (ntrig>0) cout << tdc[0] << ' ' << endl;

const Int_t kMaxPixel=300; // maximum allowed cluster size
Int_t npix;
Expand Down Expand Up @@ -152,8 +152,12 @@ int tpx3_clusters(string filename, long nhits=-1) {
//mx+=xpix[npix];
//my+=ypix[npix];
//etot+=epix[npix];
tof[npix] = (Double_t) (t[j]*1.5625E-9 - t0find(ntrig, tdc, t[j]*1.5625E-9) ) ;
npix++;
if (ntrig>0) {
// calculate ToF only when TDC timestamps are available
tof[npix] = (Double_t) (t[j]*1.5625E-9 - t0find(ntrig, tdc, t[j]*1.5625E-9) ) ;
}
npix++;

}
}
//if (npix!=0) {
Expand Down
2 changes: 1 addition & 1 deletion tpx3_to_root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int tpx3_to_root(string filename, unsigned long nrawpixelhits=0) {
tmpfine = ((tmpfine-1) << 9) / 12; // subtract 1 (as fractions 0 to 11 are numbered 1 to 12), then shift by 9 positions to reduce the error coming from the integer division by 12
int trigtime_fine = (temp & 0x0000000000000E00) | (tmpfine & 0x00000000000001FF); // combine the 3 bits with a size of 3.125 ns with the rest of the fine time from the 12 clock phases
double time_unit=25./4096;
tdc_time = (coarsetime*25E-9 + trigtime_fine*time_unit*1E-9);
tdc_time = ((double)coarsetime*25E-9 + trigtime_fine*time_unit*1E-9);
//if (count<20) {
// cout << count << ' ' << trigcnt << ' ' << hex << temp << dec << endl;
// cout << "tdc_chan: " << tdc_chan << " edge_type: " << edge_type << " tdc_time: " << setprecision(15) << tdc_time << endl;
Expand Down

0 comments on commit 43b3ecf

Please sign in to comment.