Class Reference for E1039 Core & Analysis Software
UtilTdc.cc
Go to the documentation of this file.
1 #include <ktracker/SRawEvent.h>
2 #include "UtilTdc.h"
3 using namespace std;
4 
6 
10 void UtilTdc::FindTaiwanTdcBinning(int& n_bin, double& time_lo, double& time_hi)
11 {
12  const double DT = 4.0/9.0; // ns
13  if (n_bin <= 0) return;
14  if (time_hi == 0) {
15  time_hi = time_lo + n_bin * DT;
16  } else {
17  int n_dt = 1;
18  while (n_dt * DT * n_bin < time_hi - time_lo) n_dt++;
19  n_bin = (int)((time_hi - time_lo) / (n_dt * DT));
20  int bin_ce = (int)((time_hi + time_lo) / 2 / DT);
21  time_lo = DT * (bin_ce - n_bin / 2.0);
22  time_hi = DT * (bin_ce + n_bin / 2.0);
23  }
24 }
25 
27 
34 void UtilTdc::GetOccupancy(SRawEvent* raw, const bool in_time, int occ_det[N_DET+1])
35 {
36  memset(occ_det, 0, sizeof(int[N_DET+1]));
37  for (int i_hit = 0; i_hit < raw->getNHitsAll(); i_hit++) {
38  Hit hit = raw->getHit(i_hit);
39  if (in_time && (!hit.isInTime())) continue;
40  occ_det[hit.detectorID]++;
41  }
42 }
43 
45 
52 void UtilTdc::GetOccupancy(SRawEvent* raw, const bool in_time, int& occ_D0, int& occ_D1, int& occ_D2, int& occ_D3)
53 {
54  int occ_det[N_DET+1];
55  GetOccupancy(raw, in_time, occ_det);
56 
57  occ_D0 = occ_D1 = occ_D2 = occ_D3 = 0;
58  for (int i = 1; i <= 6; i++) occ_D0 += occ_det[i];
59  for (int i = 7; i <= 12; i++) occ_D1 += occ_det[i];
60  for (int i = 13; i <= 18; i++) occ_D2 += occ_det[i];
61  for (int i = 19; i <= 30; i++) occ_D3 += occ_det[i];
62 }
Definition of hit structure.
Definition: SRawEvent.h:35
bool isInTime() const
Definition: SRawEvent.h:49
Short_t detectorID
Definition: SRawEvent.h:78
Int_t getNHitsAll()
Definition: SRawEvent.h:118
Hit getHit(Int_t index)
Definition: SRawEvent.h:144
void FindTaiwanTdcBinning(int &n_bin, double &time_lo, double &time_hi)
Find a proper set of "n_bin", "time_lo" and "time_hi".
Definition: UtilTdc.cc:10
static const int N_DET
Definition: UtilTdc.h:7
void GetOccupancy(SRawEvent *raw, const bool in_time, int occ_det[N_DET+1])
Get the occupancy of each detector (plane).
Definition: UtilTdc.cc:34