CbmRoot
CbmMvdSensorFrameBuffer.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmMvdSensorFrameBuffer source file -----
3 // ----- Created 02.02.2012 by M. Deveaux -----
4 // -------------------------------------------------------------------------
6 
7 #include "CbmMvdPoint.h"
8 #include "TClonesArray.h"
9 #include "TObjArray.h"
10 
11 
12 // ----- Default constructor -------------------------------------------
15  , fCurrentEvent(NULL)
16  , fOutputPoints(NULL)
17  , lastFrame(-1)
18  , thisFrame(-1)
19  , fSensorData(NULL)
20  , bOverflow(kFALSE)
21  , currentTime(0.) {
22  fBuffer = NULL;
23  bFlag = false;
24 }
25 // -------------------------------------------------------------------------
26 
27 // ----- Destructor ----------------------------------------------------
29  fBuffer->Delete();
30  delete fBuffer;
31 }
32 // -------------------------------------------------------------------------
33 
35 
36  bOverflow = false;
37  bFlag = false;
38  fSensor = mySensor;
40  fBuffer = new TClonesArray("CbmMvdPoint", 1000);
41 
42  fCurrentEvent = new TClonesArray("CbmMvdPoint", 1000);
43 
44  fOutputPoints = new TClonesArray("CbmMvdPoint", 1000);
45 
46 
47  cout << "-I- " << GetName() << ": Initialisation of sensor "
48  << fSensor->GetName() << endl;
49 
50  lastFrame = 0;
51 };
52 // -------------------------------------------------------------------------
53 
55 
56  SetPluginReady(false);
59 
60  if (thisFrame > lastFrame) {
61  //cout << endl << "Detected full Frame "<< lastFrame << " on sensor " << fSensor->GetName() << endl;
62  fOutputPoints->AbsorbObjects(fCurrentEvent);
63  //
65 
66  if (fOutputPoints->GetEntriesFast() > 0) {
67  SetPluginReady(true);
68  // s cout << endl << "Buffer is ready for readout on sensor " << fSensor->GetName()<< endl << endl;
69  // fOutputPoints->Print();
70  }
71  }
72  BuildMimosaFrame(thisFrame); // compute all hits in this frame for this Event
73  ClearFrame(thisFrame); // delete all hits in this frame from input
74 }
75 
76 
77 // -------------------------------------------------------------------------
78 
79 void CbmMvdSensorFrameBuffer::SendInputArray(TClonesArray* inputStream) {
80 
81  CbmMvdPoint* point;
82  Int_t nEntries = inputStream->GetEntriesFast();
83  Int_t i = 0;
84  while (i < nEntries) {
85  point = (CbmMvdPoint*) inputStream->At(i);
86  //cout << endl <<"check if point belongs to this sensor" << endl;
87  if (point->GetDetectorID() == fSensor->GetDetectorID()) {
88 
89  new ((*fBuffer)[fBuffer->GetEntriesFast()])
90  CbmMvdPoint(*((CbmMvdPoint*) inputStream->At(i)));
91  nEntries = inputStream->GetEntriesFast();
92  // cout << endl << "New Input registered at " << fSensor->GetName() << endl;
93  };
94  i++;
95  };
96 }
97 
98 // -------------------------------------------------------------------------
99 
101 
102  new ((*fBuffer)[fBuffer->GetEntriesFast()])
103  CbmMvdPoint(*((CbmMvdPoint*) point));
104 }
105 // -------------------------------------------------------------------------
106 
108 
124  CbmMvdPoint* point;
125  CbmMvdPoint* myEvent;
126  Int_t pointFrameNumber;
127  Double_t position[3];
128  Int_t pixelX, pixelY;
129  Int_t nPoints;
130 
131 
132  for (Int_t i = 0; i < fBuffer->GetEntriesFast(); i++) {
133 
134  point = (CbmMvdPoint*) fBuffer->At(i);
135  //compute pixel number related to the frameNumber
136  position[0] = point->GetX();
137  position[1] = point->GetY();
138  position[2] = point->GetZ();
139 
140 
141  fSensor->TopToPixel(position, pixelX, pixelY);
142 
143  //Get frame number from the CbmMvdSensor according to assumed position of the
144  //rolling shutter.
145  pointFrameNumber = fSensor->GetFrameNumber(pixelY, point->GetAbsTime());
146  // cout << endl << "current pointFrameNumber " << pointFrameNumber << endl;
147 
148  if (pointFrameNumber < frameNumber) {
149  cout << endl << "super error" << endl;
150  }
151 
152  // if it belongs to the frame, copy it to the event buffer
153  if (pointFrameNumber == frameNumber) {
154  nPoints = fCurrentEvent->GetEntriesFast();
155  new ((*fCurrentEvent)[nPoints]) CbmMvdPoint(*point);
156  myEvent = (CbmMvdPoint*) fCurrentEvent->At(nPoints);
157  myEvent->SetTime(((pixelY * (115e3 / 576)) + (115000 * (frameNumber))));
158  myEvent->SetFrameNr(frameNumber);
159  // cout << endl << "new Point in frame " << frameNumber << " in row " << pixelY << endl;
160  // cout << "at time " << point->GetAbsTime() << endl;
161  // cout << "readouttime is " << myEvent->GetTime() << " ns" << endl;
162  // cout << "at station " << point->GetStationNr() << endl << endl;
163  }
164  };
165 };
166 
167 void CbmMvdSensorFrameBuffer::ClearFrame(Int_t frameNumber) {
168 
175  CbmMvdPoint* point;
176  Int_t pointFrameNumber;
177  Double_t position[3];
178  Int_t pixelX, pixelY;
179  Int_t nPoints;
180 
181  for (Int_t i = 0; i < fBuffer->GetEntriesFast(); i++) {
182 
183  //compute pixel number related to the frameNumber
184 
185  point = (CbmMvdPoint*) fBuffer->At(i);
186  position[0] = point->GetX();
187  position[1] = point->GetY();
188  position[2] = point->GetZ();
189 
190  fSensor->TopToPixel(position, pixelX, pixelY);
191 
192  //Get frame number from the CbmMvdSensor according to assumed position of the
193  //rolling shutter.
194  pointFrameNumber = fSensor->GetFrameNumber(pixelY, point->GetAbsTime());
195 
196  // if it belongs to the frame, delete it from the internal buffer
197 
198  if (pointFrameNumber == frameNumber) {
199  fBuffer->RemoveAt(i);
200  //cout << endl << "new Point in frame " << frameNumber << " removed from Buffer" << endl;
201  };
202  };
203 
204  fBuffer->Compress(); //defrag buffer
205 };
206 
207 void CbmMvdSensorFrameBuffer::ClearTimeSlice(Double_t tStart, Double_t tStop) {
208 
209  CbmMvdPoint* point;
210 
211  for (Int_t i = 0; i < fBuffer->GetEntriesFast(); i++) {
212 
213  point = (CbmMvdPoint*) fBuffer->At(i);
214  if ((point->GetTime() > tStart) && (point->GetTime() < tStop)) {
215  fBuffer->RemoveAt(i);
216  }
217  };
218 
219  fBuffer->Compress(); // defrag
220 };
221 
222 
CbmMvdSensor::GetDetectorID
Int_t GetDetectorID() const
Definition: CbmMvdSensor.h:63
CbmMvdSensorFrameBuffer::currentTime
Double_t currentTime
Definition: CbmMvdSensorFrameBuffer.h:105
CbmMvdSensorFrameBuffer::SetInput
void SetInput(CbmMvdPoint *point)
Definition: CbmMvdSensorFrameBuffer.cxx:100
CbmMvdSensorFrameBuffer::ExecChain
virtual void ExecChain()
Definition: CbmMvdSensorFrameBuffer.cxx:54
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmMvdSensorFrameBuffer::ClearTimeSlice
virtual void ClearTimeSlice(Double_t tStart, Double_t tStop)
Definition: CbmMvdSensorFrameBuffer.cxx:207
CbmMvdSensorFrameBuffer::bOverflow
Bool_t bOverflow
Definition: CbmMvdSensorFrameBuffer.h:104
CbmMvdSensorFrameBuffer::thisFrame
Int_t thisFrame
Definition: CbmMvdSensorFrameBuffer.h:102
CbmMvdPoint::SetFrameNr
void SetFrameNr(Int_t frame)
Definition: CbmMvdPoint.h:93
CbmMvdSensorFrameBuffer::~CbmMvdSensorFrameBuffer
virtual ~CbmMvdSensorFrameBuffer()
Definition: CbmMvdSensorFrameBuffer.cxx:28
CbmMvdSensorFrameBuffer.h
CbmMvdPoint.h
CbmMvdSensor
Definition: CbmMvdSensor.h:40
CbmMvdSensorBuffer::fBuffer
TClonesArray * fBuffer
Definition: CbmMvdSensorBuffer.h:78
CbmMvdPoint
Definition: CbmMvdPoint.h:28
CbmMvdSensorFrameBuffer::InitBuffer
virtual void InitBuffer(CbmMvdSensor *mySensor)
Definition: CbmMvdSensorFrameBuffer.cxx:34
CbmMvdSensorFrameBuffer::fOutputPoints
TClonesArray * fOutputPoints
Definition: CbmMvdSensorFrameBuffer.h:100
CbmMvdSensorPlugin::GetName
virtual const char * GetName() const
Definition: CbmMvdSensorPlugin.h:62
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMvdSensorPlugin::bFlag
bool bFlag
Definition: CbmMvdSensorPlugin.h:70
CbmMvdSensorBuffer::fSensor
CbmMvdSensor * fSensor
Definition: CbmMvdSensorBuffer.h:83
CbmMvdSensorFrameBuffer::fCurrentEvent
TClonesArray * fCurrentEvent
Definition: CbmMvdSensorFrameBuffer.h:99
CbmMvdSensorFrameBuffer::ClearFrame
virtual void ClearFrame(Int_t frameNumber)
Definition: CbmMvdSensorFrameBuffer.cxx:167
CbmMvdSensor::GetDataSheet
CbmMvdSensorDataSheet * GetDataSheet()
Definition: CbmMvdSensor.h:83
CbmMvdSensorPlugin::SetPluginReady
void SetPluginReady(bool flag)
Definition: CbmMvdSensorPlugin.h:60
CbmMvdSensorFrameBuffer
Definition: CbmMvdSensorFrameBuffer.h:29
CbmMvdSensorFrameBuffer::fSensorData
CbmMvdSensorDataSheet * fSensorData
Definition: CbmMvdSensorFrameBuffer.h:103
CbmMvdSensorFrameBuffer::SendInputArray
void SendInputArray(TClonesArray *inputStream)
Definition: CbmMvdSensorFrameBuffer.cxx:79
CbmMvdSensorFrameBuffer::BuildMimosaFrame
virtual void BuildMimosaFrame(Int_t frameNumber)
Definition: CbmMvdSensorFrameBuffer.cxx:107
CbmMvdSensorFrameBuffer::lastFrame
Int_t lastFrame
Definition: CbmMvdSensorFrameBuffer.h:102
CbmMvdSensor::GetFrameNumber
Int_t GetFrameNumber(Int_t pixelNumberY, Double_t absoluteTime) const
Definition: CbmMvdSensor.cxx:643
CbmMvdSensorDataSheet::GetNPixelsY
virtual Int_t GetNPixelsY()
Definition: CbmMvdSensorDataSheet.h:84
CbmMvdSensor::TopToPixel
void TopToPixel(Double_t *lab, Int_t &pixelNumberX, Int_t &pixelNumberY)
Definition: CbmMvdSensor.cxx:633
CbmMvdPoint::GetAbsTime
Int_t GetAbsTime()
Definition: CbmMvdPoint.cxx:84
CbmMvdSensor::GetCurrentEventTime
Double_t GetCurrentEventTime() const
Definition: CbmMvdSensor.h:79
CbmMvdSensorFrameBuffer::CbmMvdSensorFrameBuffer
CbmMvdSensorFrameBuffer()
Definition: CbmMvdSensorFrameBuffer.cxx:13
CbmMvdSensorBuffer
Definition: CbmMvdSensorBuffer.h:28