FairRoot/PandaRoot
PndGemSensorMonitor.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndGemSensorMonitor source file -----
3 // ----- Created 25/03/2013 by R. Karabowicz -----
4 // -------------------------------------------------------------------------
5 
6 #include "PndGemSensorMonitor.h"
7 
8 #include "PndGemSensor.h"
9 
10 #include "TMath.h"
11 #include "TRandom.h"
12 
13 #include <iostream>
14 #include <list>
15 #include <vector>
16 
17 using std::cout;
18 using std::endl;
19 using std::flush;
20 using std::pair;
21 using std::vector;
22 
23 
24 // ----- Default constructor -------------------------------------------
26  PndGemSensor(),
27  fFLATime(0),
28  fFLACharge(0),
29  fFLADigiNr(0),
30  fFLAEventNr(0),
31  fFMeanTimeD(0),
32  fFNofDigis(0),
33  fFSLChan(0),
34  fBLATime(0),
35  fBLACharge(0),
36  fBLADigiNr(0),
37  fBLAEventNr(0),
38  fBMeanTimeD(0),
39  fBNofDigis(0),
40  fBSLChan(0),
41  fSensorRecoveryTime(100.),
42  fSensorFirstTime(0.),
43  fSensorLastTime(0.)
44 {
45 }
46 // -------------------------------------------------------------------------
47 
48 
49 
50 // ----- Enhanced constructor (by z0 and d) ------------------------------------------
51 PndGemSensorMonitor::PndGemSensorMonitor(TString tempName, Int_t detId, Int_t iType,
54  Double_t innerRad, Double_t outerRad,
55  Double_t d,
56  Double_t stripAngle0, Double_t stripAngle1,
57  Double_t pitch0, Double_t pitch1) :
58  PndGemSensor(tempName,detId,iType,x0,y0,z0,rotation,innerRad,outerRad,d,stripAngle0,stripAngle1,pitch0,pitch1),
59  fFLATime(0),
60  fFLACharge(0),
61  fFLADigiNr(0),
62  fFLAEventNr(0),
63  fFMeanTimeD(0),
64  fFNofDigis(0),
65  fFSLChan(0),
66  fBLATime(0),
67  fBLACharge(0),
68  fBLADigiNr(0),
69  fBLAEventNr(0),
70  fBMeanTimeD(0),
71  fBNofDigis(0),
72  fBSLChan(0),
73  fSensorRecoveryTime(100.),
74  fSensorFirstTime(0.),
75  fSensorLastTime(0.)
76 {
77 }
78 // -------------------------------------------------------------------------
79 
80 // ----- Enhanced constructor (by z0 and d) ------------------------------------------
81 PndGemSensorMonitor::PndGemSensorMonitor(TString tempName, Int_t stationNr, Int_t sectorNr, Int_t iType,
84  Double_t innerRad, Double_t outerRad,
85  Double_t d,
86  Double_t stripAngle0, Double_t stripAngle1,
87  Double_t pitch0, Double_t pitch1) :
88  PndGemSensor(tempName,stationNr,sectorNr,iType,x0,y0,z0,rotation,innerRad,outerRad,d,stripAngle0,stripAngle1,pitch0,pitch1),
89  fFLATime(0),
90  fFLACharge(0),
91  fFLADigiNr(0),
92  fFLAEventNr(0),
93  fFMeanTimeD(0),
94  fFNofDigis(0),
95  fFSLChan(0),
96  fBLATime(0),
97  fBLACharge(0),
98  fBLADigiNr(0),
99  fBLAEventNr(0),
100  fBMeanTimeD(0),
101  fBNofDigis(0),
102  fBSLChan(0),
103  fSensorRecoveryTime(100.),
104  fSensorFirstTime(0.),
105  fSensorLastTime(0.)
106 {
107  fFLATime .resize(this->GetNChannelsFront(),-1.);
108  fFLACharge .resize(this->GetNChannelsFront(),-1.);
109  fFLADigiNr .resize(this->GetNChannelsFront(),-1);
110  fFLAEventNr.resize(this->GetNChannelsFront(),-1);
111  fFMeanTimeD.resize(this->GetNChannelsFront(), 0.);
112  fFNofDigis .resize(this->GetNChannelsFront(), 0);
113  fBLATime .resize(this->GetNChannelsBack (),-1.);
114  fBLACharge .resize(this->GetNChannelsBack (),-1.);
115  fBLADigiNr .resize(this->GetNChannelsBack (),-1);
116  fBLAEventNr.resize(this->GetNChannelsBack (),-1);
117  fBMeanTimeD.resize(this->GetNChannelsBack (), 0.);
118  fBNofDigis .resize(this->GetNChannelsBack (), 0);
119 }
120 // -------------------------------------------------------------------------
121 
122 // ----- Enhanced constructor (by z0 and d) ------------------------------------------
124  PndGemSensor(tempSensor),
125  fFLATime(0),
126  fFLACharge(0),
127  fFLADigiNr(0),
128  fFLAEventNr(0),
129  fFMeanTimeD(0),
130  fFNofDigis(0),
131  fFSLChan(0),
132  fBLATime(0),
133  fBLACharge(0),
134  fBLADigiNr(0),
135  fBLAEventNr(0),
136  fBMeanTimeD(0),
137  fBNofDigis(0),
138  fBSLChan(0),
139  fSensorRecoveryTime(100.),
140  fSensorFirstTime(0.),
141  fSensorLastTime(0.)
142 {
143  fFLATime .resize(this->GetNChannelsFront(),-1.);
144  fFLACharge .resize(this->GetNChannelsFront(),-1.);
145  fFLADigiNr .resize(this->GetNChannelsFront(),-1);
146  fFLAEventNr.resize(this->GetNChannelsFront(),-1);
147  fFMeanTimeD.resize(this->GetNChannelsFront(), 0.);
148  fFNofDigis .resize(this->GetNChannelsFront(), 0);
149  fBLATime .resize(this->GetNChannelsBack (),-1.);
150  fBLACharge .resize(this->GetNChannelsBack (),-1.);
151  fBLADigiNr .resize(this->GetNChannelsBack (),-1);
152  fBLAEventNr.resize(this->GetNChannelsBack (),-1);
153  fBMeanTimeD.resize(this->GetNChannelsBack (), 0.);
154  fBNofDigis .resize(this->GetNChannelsBack (), 0);
155 }
156 // -------------------------------------------------------------------------
157 
158 
159 // ----- Destructor ----------------------------------------------------
161 // -------------------------------------------------------------------------
162 
163 // ----- Activate Channel ----------------------------------------------------
164 void PndGemSensorMonitor::ActivateChannel(Int_t channelNr, Int_t sideId, Int_t eventNr, Int_t digiNr, Double_t channelTime, Double_t channelCharge) {
165  if ( sideId == 0 ) {
166  // had to comment it out. but be careful with stat options here: if this function is called from PndGemFindHits
167  // while looping over clusters, it will cause problems, as digis may belong to different clusters....
168 
169  // if ( channelTime > fFLATime[fFSLChan] + 21 && fFLATime[fFSLChan] > -0.5 ) {
170  // cout << "SENSOR " << GetStationNr() << "." << GetSensorNr() << ".F not hitted for " << channelTime-fFLATime[fFSLChan] << " ns (from "
171  // << fFLATime[fFSLChan] << " to " << channelTime << ")"
172  // << " EVENT " << fFLAEventNr[fFSLChan] << " vs " << eventNr << endl;
173  // }
174  // if ( fFLAEventNr[channelNr] == eventNr ) {
175  // cout << "****** " << GetStationNr() << "." << GetSensorNr() << ".F hitted twice after " << channelTime-fFLATime[channelNr] << " ns (at "
176  // << fFLATime[channelNr] << " and " << channelTime << ")"
177  // << " IN EVENT " << eventNr << endl;
178  // }
179  if ( fFNofDigis[channelNr] > 0 ) {
180  fFMeanTimeD[channelNr] = fFMeanTimeD[channelNr] + (channelTime-fFLATime[channelNr]-fFMeanTimeD[channelNr])/((Double_t)fFNofDigis[channelNr]);
181  }
182  fFLATime [channelNr] = channelTime;
183  fFLACharge [channelNr] = channelCharge;
184  fFLADigiNr [channelNr] = digiNr;
185  fFLAEventNr[channelNr] = eventNr;
186  fFNofDigis [channelNr] += 1;
187  fFSLChan = channelNr;
188  }
189  else {
190  // if ( channelTime > fBLATime[fBSLChan] + 21 && fBLATime[fFSLChan] > -0.5 ) {
191  // cout << "SENSOR " << GetStationNr() << "." << GetSensorNr() << ".B not hitted for " << channelTime-fBLATime[fBSLChan] << " ns (from "
192  // << fBLATime[fBSLChan] << " to " << channelTime << ")"
193  // << " EVENT " << fBLAEventNr[fBSLChan] << " vs " << eventNr << endl;
194  // }
195  // if ( fBLAEventNr[channelNr] == eventNr ) {
196  // cout << "****** " << GetStationNr() << "." << GetSensorNr() << ".F hitted twice after " << channelTime-fBLATime[channelNr] << " ns (at "
197  // << fBLATime[channelNr] << " and " << channelTime << ")"
198  // << " IN EVENT " << eventNr << endl;
199  // }
200  if ( fBNofDigis[channelNr] > 0 ) {
201  fBMeanTimeD[channelNr] = fBMeanTimeD[channelNr] + (channelTime-fBLATime[channelNr]-fBMeanTimeD[channelNr])/((Double_t)fBNofDigis[channelNr]);
202  }
203  fBLATime [channelNr] = channelTime;
204  fBLACharge [channelNr] = channelCharge;
205  fBLADigiNr [channelNr] = digiNr;
206  fBLAEventNr[channelNr] = eventNr;
207  fBNofDigis [channelNr] += 1;
208  fBSLChan = channelNr;
209  }
210  CheckNeighbours(channelNr, sideId, eventNr, digiNr, channelTime, channelCharge);
211 }
212 // -------------------------------------------------------------------------
213 
214 // ----- Check neighbours ----------------------------------------------------
215 void PndGemSensorMonitor::CheckNeighbours(Int_t channelNr, Int_t sideId, Int_t , Int_t , Double_t , Double_t ) { // eventNr digiNr channelTime channelCharge //[R.K.03/2017] unused variable(s)
216  Int_t nChan[3]={-1,-1,-1};
217  Int_t nofChan = GetNeighbours(sideId,channelNr,nChan[0],nChan[1],nChan[2]);
218  // cout << "------ check " << nofChan << " neighbours of channel " << channelNr << " on sensor " << this->GetDetectorId() << "." << sideId << " : " << endl;
219  for ( Int_t ichan = 0 ; ichan < nofChan ; ichan++ ) {
220  // cout << " ---------------- channel " << nChan[ichan] << " at a distance " << GetDistance(sideId,channelNr,nChan[ichan]) << flush;
221  // if ( GetDistance(sideId,channelNr,nChan[ichan]) > 1.1 ||
222  // GetDistance(sideId,channelNr,nChan[ichan]) < 0.9 ) cout << " OOOOOOOOOOOOOOOOOOOOOO" << flush;
223  // cout << " // difference = " << channelNr-nChan[ichan] << flush;
224  // cout << endl;
225  }
226 
227 }
228 // -------------------------------------------------------------------------
229 
230 // ----- Is channel active? ----------------------------------------------------
231 Bool_t PndGemSensorMonitor::ChannelIsActive (Int_t , Int_t , Double_t ) { // channelNr sideId timeNow //[R.K.03/2017] unused variable(s)
232  // Empty function!!
233  return kFALSE;
234 }
235 // -------------------------------------------------------------------------
236 
237 // ----- The last channel activation at... ----------------------------------------------------
238 Double_t PndGemSensorMonitor::ChannelLastActiveAt(Int_t channelNr, Int_t sideId) {
239  if ( sideId == 0 && fFLATime[channelNr] < -0.5 ) return -1.;
240  if ( sideId == 1 && fBLATime[channelNr] < -0.5 ) return -1.;
241 
242  if ( sideId == 0 ) {
243  // if ( eventNr == fFLAEventNr[channelNr] )
244  // cout << "channel " << channelNr << " in sensor " << GetStationNr() << "." << GetSensorNr() << ".F, two hits in ev " << eventNr
245  // << " 1st @ " << fFLATime[channelNr] << ", now @ " << timeNow << " (diffr=" << timeNow-fFLATime[channelNr] << ")" << endl;
246  return fFLATime[channelNr];
247  }
248  else {
249  // if ( eventNr == fBLAEventNr[channelNr] )
250  // cout << "channel " << channelNr << " in sensor " << GetStationNr() << "." << GetSensorNr() << ".B, two hits in ev " << eventNr
251  // << " 1st @ " << fBLATime[channelNr] << ", now @ " << timeNow << " (diffr=" << timeNow-fBLATime[channelNr] << ")" << endl;
252  return fBLATime[channelNr];
253  }
254 }
255 // -------------------------------------------------------------------------
256 
257 // ----- How much time passed since last activation? ----------------------------------------------------
258 Double_t PndGemSensorMonitor::ChannelLastActiveAt(Int_t channelNr, Int_t sideId, Double_t timeNow, Int_t ) { // eventNr //[R.K.03/2017] unused variable(s)
259  if ( sideId == 0 && fFLATime[channelNr] < -0.5 ) return -1.;
260  if ( sideId == 1 && fBLATime[channelNr] < -0.5 ) return -1.;
261 
262  if ( sideId == 0 ) {
263  // if ( eventNr == fFLAEventNr[channelNr] )
264  // cout << "channel " << channelNr << " in sensor " << GetStationNr() << "." << GetSensorNr() << ".F, two hits in ev " << eventNr
265  // << " 1st @ " << fFLATime[channelNr] << ", now @ " << timeNow << " (diffr=" << timeNow-fFLATime[channelNr] << ")" << endl;
266  return timeNow-fFLATime[channelNr];
267  }
268  else {
269  // if ( eventNr == fBLAEventNr[channelNr] )
270  // cout << "channel " << channelNr << " in sensor " << GetStationNr() << "." << GetSensorNr() << ".B, two hits in ev " << eventNr
271  // << " 1st @ " << fBLATime[channelNr] << ", now @ " << timeNow << " (diffr=" << timeNow-fBLATime[channelNr] << ")" << endl;
272  return timeNow-fBLATime[channelNr];
273  }
274 
275 }
276 // -------------------------------------------------------------------------
277 
278 // ----- Last activation data ----------------------------------------------------
279 Bool_t PndGemSensorMonitor::ChannelLastActivation(Int_t , Int_t , Int_t& , Int_t& , Double_t& , Double_t& ) { // channelNr sideId eventNr digiNr channelTime channelCharge //[R.K.03/2017] unused variable(s)
280  // Empty function
281  return kFALSE;
282 }
283 // -------------------------------------------------------------------------
284 
285 // ----- Public method Print -------------------------------------------
287  cout << "---> sensor has " << fFLATime.size() << " Front and " << fBLATime.size() << " Back strips" << endl;
288 
289  for ( size_t ichan = 0 ; ichan < fFLATime.size() ; ichan++ ) {
290  cout << ichan << ":" << fFLATime[ichan] << " . " << flush;
291  }
292  cout << endl;
293 
294  // for ( Int_t ibin = 0 ; ibin < 10 ; ibin++ ) {
295  // cout << " | " << flush;
296  // for ( Int_t ichan = 0 ; ichan < fFLATime.size() ; ichan+=10 ) {
297  // if ( fFNofDigis[ichan] == 0 ) {cout << " " << flush;continue;}
298  // cout << fFNofDigis[ichan] % 2 << flush;
299  // fFNofDigis[ichan] = fFNofDigis[ichan]/2;
300  // }
301  // cout << " | " << endl;
302  // }
303 }
304 // -------------------------------------------------------------------------
305 
306 
Double_t z0
Definition: checkhelixhit.C:62
Double_t ChannelLastActiveAt(Int_t channelNr, Int_t sideId, Double_t timeNow, Int_t eventNr=-1)
Double_t x0
Definition: checkhelixhit.C:70
std::vector< Int_t > fBLADigiNr
void ActivateChannel(Int_t channelNr, Int_t sideId, Int_t eventNr, Int_t digiNr, Double_t channelTime, Double_t channelCharge)
std::vector< Double_t > fBMeanTimeD
TObjArray * d
TGeoRotation rotation
Int_t GetNChannelsBack() const
Definition: PndGemSensor.h:112
std::vector< Double_t > fFLACharge
std::vector< Double_t > fBLACharge
std::vector< Int_t > fFLADigiNr
Double_t
Double_t y0
Definition: checkhelixhit.C:71
std::vector< Double_t > fFMeanTimeD
std::vector< Int_t > fBLAEventNr
std::vector< Int_t > fBNofDigis
std::vector< Double_t > fFLATime
Int_t GetNChannelsFront() const
Definition: PndGemSensor.h:111
std::vector< Int_t > fFLAEventNr
Bool_t ChannelIsActive(Int_t channelNr, Int_t sideId, Double_t timeNow)
std::vector< Double_t > fBLATime
ClassImp(PndAnaContFact)
Int_t GetNeighbours(Int_t iSide, Int_t iChan, Int_t &nChan1, Int_t &nChan2, Int_t &nChan3)
Bool_t ChannelLastActivation(Int_t channelNr, Int_t sideId, Int_t &eventNr, Int_t &digiNr, Double_t &channelTime, Double_t &channelCharge)
std::vector< Int_t > fFNofDigis
void CheckNeighbours(Int_t channelNr, Int_t sideId, Int_t eventNr, Int_t digiNr, Double_t channelTime, Double_t channelCharge)