QwAnalysis
QwDelayLine.cc
Go to the documentation of this file.
1 //
2 // C++ Implementation: QwDelayLine
3 //
4 // Description:
5 //
6 //
7 // Author: siyuan yang <sxyang@linux-ehar>, (C) 2009
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 
13 #include "QwDelayLine.h"
14 
15 #include "QwParameterFile.h"
16 
17 const Double_t QwDelayLine::kTimeStep=2.6;
18 const Int_t QwDelayLine::kWireStep=8;
19 
20 void QwDelayLine::Wirenumber(Double_t& time){
21  Double_t f1tdc_resolution_ns = 0.116312881651642913;
22  Int_t temp = 0;
23  vector<Int_t> tempwire;
24  Int_t Guess = (Int_t) (f1tdc_resolution_ns*(time-(Windows.at( 0 ).first+Windows.at( 0 ).second) /2)/kTimeStep);
25  // there's two conditions:
26  // first, that the value of time-average value of the first window can not be smaller than -2.6;
27  // second, the right bound of the last window minus the left bound of the first window should be
28  // smaller than Windows.size()*kTimeStep(because we must require that Guess shoulde be smaller than
29  // the Windows.size(),otherwise, the first command below Window.at(Guess) will be out of boundary!!)
30 
31  if(Guess >= (Int_t) Windows.size()) Guess = (Int_t) Windows.size() - 1;
32  if(time < Windows.at(Guess).second)
33  {
34  for(Int_t i= Guess; i >= 0 ; --i)
35  {
36  if(time < Windows.at( i ).second && time >= Windows.at( i ).first)
37  {
38  temp=fFirstWire+i*kWireStep;
39  tempwire.push_back ( temp );
40  Wire.push_back ( tempwire );
41  Ambiguous=false;
42  break;
43  }
44  else if(time < Windows.at( i ).first && time >= Windows.at( i-1 ).second)
45  {
46  temp= fFirstWire + i*kWireStep;
47  tempwire.push_back(temp);
48  tempwire.push_back ( temp-kWireStep );
49  Wire.push_back ( tempwire );
50  Ambiguous=true;
51  break;
52  }
53 
54  }
55  }
56  else
57  {
58  for(size_t i=Guess+1;i<Windows.size();i++)
59  {
60  if (time < Windows.at( i ).second && time >= Windows.at( i ).first)
61  {
62  temp=fFirstWire+i*kWireStep;
63  tempwire.push_back(temp);
64  Wire.push_back(tempwire);
65  Ambiguous=false;
66  break;
67  }
68  else if(time < Windows.at( i ).first && time >= Windows.at( i-1 ).second)
69  {
70  temp= fFirstWire + i*kWireStep;
71  tempwire.push_back(temp);
72  tempwire.push_back(temp-kWireStep);
73  Wire.push_back(tempwire);
74  Ambiguous=true;
75  break;
76  }
77  }
78  }
79 }
80 
81 void QwDelayLine::ProcessHits(Bool_t k){
82  // The loop over the hits is assumming that both lists are ordered forwards in time.
83  Double_t delta_t=0;
84  Int_t hitscount=LeftHits.size();
85  Int_t hitscount_R=RightHits.size();
86  Int_t wincount=Windows.size();
87  //Int_t first_match=0;
88 
89  if(hitscount ==0 || hitscount_R ==0){
90  }// do nothing
91  else{
92  for(Int_t i=0;i<hitscount;i++)
93  {
94  //for(Int_t j=first_match;j<hitscount_R;j++)
95  for(Int_t j=0;j<hitscount_R;j++)
96  {
97  if(k==false)
98  delta_t=-(LeftHits.at( i )-RightHits.at( j ));
99  else delta_t= LeftHits.at( i )-RightHits.at( j );
100 
101  if(delta_t < Windows.at ( 0 ).first)
102  {
103  // std::cout << " delta_t is unphysical,continue" << std::endl;
104  continue;
105  }
106  else if(delta_t > Windows.at ( wincount-1 ).second)
107  {
108  // std::cout << " delta_t is unphysical,continue" << std::endl;
109  continue;
110  }
111  else
112  {
113  Wirenumber(delta_t);
114  std::pair<Int_t,Int_t> hitspair(i,j);
115  Hitscount.push_back (hitspair);
116  //first_match = j+1;
117  }
118  }
119  }
120  }
121  Processed = true;
122 }
123 
124 
125 
126 
128 {
129 }
130 
Bool_t Processed
Definition: QwDelayLine.h:49
vector< vector< Int_t > > Wire
Definition: QwDelayLine.h:52
static const Double_t kTimeStep
Definition: QwDelayLine.h:57
void ProcessHits(Bool_t k)
Definition: QwDelayLine.cc:81
Int_t fFirstWire
Definition: QwDelayLine.h:45
vector< std::pair< Double_t, Double_t > > Windows
Definition: QwDelayLine.h:54
vector< Double_t > RightHits
Definition: QwDelayLine.h:56
static const Int_t kWireStep
Definition: QwDelayLine.h:58
virtual ~QwDelayLine()
Definition: QwDelayLine.cc:127
vector< Double_t > LeftHits
Definition: QwDelayLine.h:55
vector< std::pair< Int_t, Int_t > > Hitscount
Definition: QwDelayLine.h:53
void Wirenumber(Double_t &)
Definition: QwDelayLine.cc:20
Bool_t Ambiguous
Definition: QwDelayLine.h:50