CbmRoot
Loading...
Searching...
No Matches
CbmMvdSensorFrameBuffer.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2015 Institut fuer Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Philipp Sitzmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMvdSensorFrameBuffer source file -----
7// ----- Created 02.02.2012 by M. Deveaux -----
8// -------------------------------------------------------------------------
10
11#include "CbmMvdPoint.h" // for CbmMvdPoint
12#include "CbmMvdSensor.h" // for CbmMvdSensor
13#include "CbmMvdSensorDataSheet.h" // for CbmMvdSensorDataSheet
14
15#include <Logger.h> // for LOG, Logger
16
17#include "TClonesArray.h" // for TClonesArray
18
19
20// ----- Default constructor -------------------------------------------
23 , fCurrentEvent(nullptr)
24 , fOutputPoints(nullptr)
25 , lastFrame(-1)
26 , thisFrame(-1)
27 , fSensorData(nullptr)
28 , bOverflow(kFALSE)
29 , currentTime(0.)
30{
31 fBuffer = nullptr;
32 bFlag = false;
33}
34// -------------------------------------------------------------------------
35
36// ----- Destructor ----------------------------------------------------
42// -------------------------------------------------------------------------
43
45{
46
47 bOverflow = false;
48 bFlag = false;
49 fSensor = mySensor;
51 fBuffer = new TClonesArray("CbmMvdPoint", 1000);
52
53 fCurrentEvent = new TClonesArray("CbmMvdPoint", 1000);
54
55 fOutputPoints = new TClonesArray("CbmMvdPoint", 1000);
56
57
58 LOG(info) << "Initialisation of sensor " << fSensor->GetName();
59
60 lastFrame = 0;
61};
62// -------------------------------------------------------------------------
63
65{
66
67 SetPluginReady(false);
70
71 if (thisFrame > lastFrame) {
72 //LOG(info) << "Detected full Frame "<< lastFrame << " on sensor " << fSensor->GetName();
73 fOutputPoints->AbsorbObjects(fCurrentEvent);
74 //
76
77 if (fOutputPoints->GetEntriesFast() > 0) {
78 SetPluginReady(true);
79 // LOG(info) << "Buffer is ready for readout on sensor " << fSensor->GetName();
80 // fOutputPoints->Print();
81 }
82 }
83 BuildMimosaFrame(thisFrame); // compute all hits in this frame for this Event
84 ClearFrame(thisFrame); // delete all hits in this frame from input
85}
86
87
88// -------------------------------------------------------------------------
89
90void CbmMvdSensorFrameBuffer::SendInputArray(TClonesArray* inputStream)
91{
92
93 CbmMvdPoint* point;
94 Int_t nEntries = inputStream->GetEntriesFast();
95 Int_t i = 0;
96 while (i < nEntries) {
97 point = (CbmMvdPoint*) inputStream->At(i);
98 //LOG(info) <<"check if point belongs to this sensor";
99 if (point->GetDetectorID() == fSensor->GetDetectorID()) {
100
101 new ((*fBuffer)[fBuffer->GetEntriesFast()]) CbmMvdPoint(*((CbmMvdPoint*) inputStream->At(i)));
102 nEntries = inputStream->GetEntriesFast();
103 // LOG(info) << "New Input registered at " << fSensor->GetName();
104 };
105 i++;
106 };
107}
108
109// -------------------------------------------------------------------------
110
112{
113
114 new ((*fBuffer)[fBuffer->GetEntriesFast()]) CbmMvdPoint(*((CbmMvdPoint*) point));
115}
116// -------------------------------------------------------------------------
117
119{
120
136 CbmMvdPoint* point;
137 CbmMvdPoint* myEvent;
138 Int_t pointFrameNumber;
139 Double_t position[3];
140 Int_t pixelX, pixelY;
141 Int_t nPoints;
142
143
144 for (Int_t i = 0; i < fBuffer->GetEntriesFast(); i++) {
145
146 point = (CbmMvdPoint*) fBuffer->At(i);
147 //compute pixel number related to the frameNumber
148 position[0] = point->GetX();
149 position[1] = point->GetY();
150 position[2] = point->GetZ();
151
152
153 fSensor->TopToPixel(position, pixelX, pixelY);
154
155 //Get frame number from the CbmMvdSensor according to assumed position of the
156 //rolling shutter.
157 pointFrameNumber = fSensor->GetFrameNumber(point->GetAbsTime(), pixelY);
158 // LOG(info) << "current pointFrameNumber " << pointFrameNumber;
159
160 if (pointFrameNumber < frameNumber) { LOG(info) << "super error"; }
161
162 // if it belongs to the frame, copy it to the event buffer
163 if (pointFrameNumber == frameNumber) {
164 nPoints = fCurrentEvent->GetEntriesFast();
165 new ((*fCurrentEvent)[nPoints]) CbmMvdPoint(*point);
166 myEvent = (CbmMvdPoint*) fCurrentEvent->At(nPoints);
167 myEvent->SetTime(((pixelY * (115e3 / 576)) + (115000 * (frameNumber))));
168 myEvent->SetFrameNr(frameNumber);
169 // LOG(info) << "new Point in frame " << frameNumber << " in row " << pixelY;
170 // LOG(info) << "at time " << point->GetAbsTime();
171 // LOG(info) << "readouttime is " << myEvent->GetTime() << " ns";
172 // LOG(info) << "at station " << point->GetStationNr();
173 }
174 };
175};
176
178{
179
186 CbmMvdPoint* point;
187 Int_t pointFrameNumber;
188 Double_t position[3];
189 Int_t pixelX, pixelY;
190
191 for (Int_t i = 0; i < fBuffer->GetEntriesFast(); i++) {
192
193 //compute pixel number related to the frameNumber
194
195 point = (CbmMvdPoint*) fBuffer->At(i);
196 position[0] = point->GetX();
197 position[1] = point->GetY();
198 position[2] = point->GetZ();
199
200 fSensor->TopToPixel(position, pixelX, pixelY);
201
202 //Get frame number from the CbmMvdSensor according to assumed position of the
203 //rolling shutter.
204 pointFrameNumber = fSensor->GetFrameNumber(point->GetAbsTime(), pixelY);
205
206 // if it belongs to the frame, delete it from the internal buffer
207
208 if (pointFrameNumber == frameNumber) {
209 fBuffer->RemoveAt(i);
210 //LOG(info) << "new Point in frame " << frameNumber << " removed from Buffer";
211 };
212 };
213
214 fBuffer->Compress(); //defrag buffer
215};
216
217void CbmMvdSensorFrameBuffer::ClearTimeSlice(Double_t tStart, Double_t tStop)
218{
219
220 CbmMvdPoint* point;
221
222 for (Int_t i = 0; i < fBuffer->GetEntriesFast(); i++) {
223
224 point = (CbmMvdPoint*) fBuffer->At(i);
225 if ((point->GetTime() > tStart) && (point->GetTime() < tStop)) { fBuffer->RemoveAt(i); }
226 };
227
228 fBuffer->Compress(); // defrag
229};
230
231
ClassImp(CbmConverterManager)
int32_t GetAbsTime()
void SetFrameNr(int32_t frame)
Definition CbmMvdPoint.h:91
void SendInputArray(TClonesArray *inputStream)
virtual void ClearFrame(Int_t frameNumber)
virtual void ClearTimeSlice(Double_t tStart, Double_t tStop)
CbmMvdSensorDataSheet * fSensorData
virtual void InitBuffer(CbmMvdSensor *mySensor)
virtual void BuildMimosaFrame(Int_t frameNumber)
void SetPluginReady(bool flag)
Int_t GetFrameNumber(Double_t absoluteTime, Int_t pixelNumberY=0) const
Double_t GetCurrentEventTime() const
Int_t GetDetectorID() const
void TopToPixel(Double_t *lab, Int_t &pixelNumberX, Int_t &pixelNumberY)
CbmMvdSensorDataSheet * GetDataSheet()