FEDRA emulsion software from the OPERA Collaboration
AcqTrackScanner Class Reference

#include <AcqTrackScanner.h>

Inheritance diagram for AcqTrackScanner:
Collaboration diagram for AcqTrackScanner:

Public Member Functions

 AcqTrackScanner ()
 
int FastScanFragment (bool IsTop, int AreaId, bool AbsCoord, float X0, float Y0, EdbRun *run, bool RawImages=false)
 
int FindLayer (float Z0, float DZ, int ClusterThreshold, float *z0, float *z1)
 
long ScanAndFillView (float Z0, float DZ, int Side=0, EdbView *View=NULL, bool FillImages=false, float GotoX=0, float GotoY=0)
 
int ScanView (float Z0, float DZ, float GotoX=0, float GotoY=0, bool RawImages=false)
 
bool SetPointers (AcqStage1 *stg, AcqOdyssey *ody)
 
virtual ~AcqTrackScanner ()
 

Public Attributes

AcqOdysseyFG
 
int FPS
 
int Layers
 
int Nx
 
int Ny
 
AcqStage1ST
 
float ViewStepX
 
float ViewStepY
 
float XYViewToViewSpeed
 
float ZBackStrokeSpeed
 

Constructor & Destructor Documentation

◆ AcqTrackScanner()

AcqTrackScanner::AcqTrackScanner ( )
19{
20 ST=NULL; FG=NULL;
21 FPS=200.;
22 Layers=16;
23// Threshold=80;
25 ZBackStrokeSpeed=10000;
26 ViewStepX=320.;
27 ViewStepY=260.;
28 Nx=1; Ny=1;
29
30
31}
AcqStage1 * ST
Definition: AcqTrackScanner.h:36
int Layers
Definition: AcqTrackScanner.h:30
int Ny
Definition: AcqTrackScanner.h:35
AcqOdyssey * FG
Definition: AcqTrackScanner.h:37
float ViewStepY
Definition: AcqTrackScanner.h:34
float XYViewToViewSpeed
Definition: AcqTrackScanner.h:32
float ZBackStrokeSpeed
Definition: AcqTrackScanner.h:33
int Nx
Definition: AcqTrackScanner.h:35
int FPS
Definition: AcqTrackScanner.h:31
float ViewStepX
Definition: AcqTrackScanner.h:34
#define NULL
Definition: nidaqmx.h:84

◆ ~AcqTrackScanner()

AcqTrackScanner::~AcqTrackScanner ( )
virtual
35{
36}

Member Function Documentation

◆ FastScanFragment()

int AcqTrackScanner::FastScanFragment ( bool  IsTop,
int  AreaId,
bool  AbsCoord,
float  X0,
float  Y0,
EdbRun run,
bool  RawImages = false 
)
182{
183 float Pos[50];
184 float DZ;
185 float Z0;
186 int Nc=0;
187 int res=0;
188 int Side;
189 float X,Y;
190 int Vn=0;
191 int vid=0;
192 if(IsTop) printf("Top: "); else printf("Bottom: ");
193 printf("Filling Z breakpoint position buffer\n");
194 if(IsTop){
197 Side=1;
198 }
199 else{
200 Z0=ST->Z->Reference;
202 Side=0;
203 }
204 for(int i=0;i<Layers;i++) Pos[i]=1.*i*DZ/(Layers-1)+Z0;
205 ST->Z->PosMove(Z0+DZ+2,1e4,1e4);
206 ST->X->PosMove(X0,1e9,1e9);
207 ST->Y->PosMove(Y0,1e9,1e9);
208 res=ST->Z->WaitForMoveComplete(3e3);
209 res*=ST->X->WaitForMoveComplete(2e3);
210 res*=ST->Z->WaitForMoveComplete(2e3);
211 printf("XYZ Reached initial Z at %f, res=%d\n",ST->Z->GetPos(),res);
212 if(!res) {printf("Position is not reached! Aborting scan.\n");return 0;}
213 for(int iy=0;iy<Ny;iy++)
214 for(int ix=(iy==0);ix<Nx;ix++)
215 {
216 X=X0+ViewStepX*ix;
217 Y=Y0+ViewStepY*iy;
218// ST->X->PosMove(X,1e9,1e9);
219// ST->Y->PosMove(Y,1e9,1e9);
220// ST->Z->PosMove(Z0+DZ+2,1e4,1e4);
221 run->GetView()->SetCoordXY(ST->X->GetPos(),ST->Y->GetPos());
222 Nc=ScanAndFillView(Z0,DZ,Side,run->GetView(),RawImages,X,Y);
224 run->GetView()->GetHeader()->SetViewID(vid++);
225 run->GetView()->GetHeader()->SetAreaID(AreaId);
227 printf("dbg 0\n");
228 printf("Cluster number: %d\n", Nc);
229 printf("dbg 1\n");
230 run->AddView();
231 printf("dbg 2\n");
232// run->Save();
233
234 res=ST->Y->WaitForMoveComplete(2e3);
235 res*=ST->X->WaitForMoveComplete(2e3);
236 res*=ST->Z->WaitForMoveComplete(2e3);
237
238 if(!res) {
239 ST->X->PosMove(X,1e9,1e9);
240 ST->Y->PosMove(Y,1e9,1e9);
241 ST->Z->PosMove(Z0+DZ+2,1e4,1e4);
242 res=ST->Y->WaitForMoveComplete(2e3);
243 res*=ST->X->WaitForMoveComplete(2e3);
244 res*=ST->Z->WaitForMoveComplete(2e3);
245 if(!res) {printf("Position is not reached! Aborting scan.\n");return 0;}
246 }
247// run->Save();
248
249 }
250// finish last frame
251
252 run->GetView()->SetCoordXY(ST->X->GetPos(),ST->Y->GetPos());
253 if(IsTop) {X=X0; Y=Y0;} //go back to the fragment start to prepare for bottom, otherwise just stop
254 else {X=0;Y=0;}
255 Nc=ScanAndFillView(Z0,DZ,Side,run->GetView(),RawImages,X,Y);
257 run->GetView()->GetHeader()->SetViewID(vid++);
258 run->GetView()->GetHeader()->SetAreaID(AreaId);
259 printf("Cluster number: %d\n", Nc);
260 run->AddView();
261// run->Save();
262
263 res=ST->Y->WaitForMoveComplete(2e3);
264 res*=ST->X->WaitForMoveComplete(2e3);
265 res*=ST->Z->WaitForMoveComplete(2e3);
266
267 if(!res) {
268 ST->X->PosMove(X,1e9,1e9);
269 ST->Y->PosMove(Y,1e9,1e9);
270 ST->Z->PosMove(Z0+DZ+2,1e4,1e4);
271 res=ST->Y->WaitForMoveComplete(2e3);
272 res*=ST->X->WaitForMoveComplete(2e3);
273 res*=ST->Z->WaitForMoveComplete(2e3);
274 if(!res) {printf("Position is not reached! Aborting scan.\n");return 0;}
275 }
276 return Nc;
277
278}
brick X0
Definition: RecDispMC.C:112
void PosMove(float Pos, float Speed, float Acc)
Definition: AcqStage1.cxx:524
float Reference
Definition: AcqStage1.h:72
float GetPos()
Definition: AcqStage1.cxx:599
int WaitForMoveComplete(u32 Timeout)
Definition: AcqStage1.cxx:514
int ReadTemperature()
Definition: AcqStage1.cxx:917
float EmTopLayer
Definition: AcqStage1.h:140
float EmBase
Definition: AcqStage1.h:142
AcqLight * L
Definition: AcqStage1.h:148
float EmBotLayer
Definition: AcqStage1.h:141
AcqAxis * Y
Definition: AcqStage1.h:146
AcqAxis * Z
Definition: AcqStage1.h:147
AcqAxis * X
Definition: AcqStage1.h:145
long ScanAndFillView(float Z0, float DZ, int Side=0, EdbView *View=NULL, bool FillImages=false, float GotoX=0, float GotoY=0)
Definition: AcqTrackScanner.cxx:84
EdbView * GetView() const
Definition: EdbRun.h:110
void AddView()
Definition: EdbRun.cxx:305
void SetAreaID(int id)
Definition: EdbView.h:100
void SetViewID(int id)
Definition: EdbView.h:99
void SetStatus(int st)
Definition: EdbView.h:106
EdbViewHeader * GetHeader() const
Definition: EdbView.h:163
void SetCoordZ(float z1, float z2, float z3, float z4)
Definition: EdbView.h:186
void SetCoordXY(float x, float y)
Definition: EdbView.h:185
Definition: Side.h:11
float Z0
Definition: hwinit.C:67
float DZ
Definition: hwinit.C:66
EdbRun * run
Definition: check_raw.C:38
Double_t X
Definition: tlg2couples.C:76
Double_t Y
Definition: tlg2couples.C:76

◆ FindLayer()

int AcqTrackScanner::FindLayer ( float  Z0,
float  DZ,
int  ClusterThreshold,
float *  z0,
float *  z1 
)
126{
127 // searches for emulsion layer using current Threshold and Image Processing settings
128 // returns 1+2 if both surfaces are found,
129 // 1 if only top surface is found, (&z0)
130 // 2 if only bottom is found (&z1)
131 // 0 if no surface found
132 // uses maximum available number of layers (received from FG object)
133 int retval=0;
134 int res;
135 int Taken=0;
136 float zz0,zz1;
137 int SL=Layers;
139 printf("Find layer scans view...\n");
140 Taken=ScanView(Z0,DZ);
141 FG->eEdbView->Clear();
142 FG->FillView(Layers,1);
143 printf("Taken %d layers ..\n",Taken);
144
145 int *b= new int[Layers];
146 float *z= new float[Layers];
147 EdbFrame * fr;
148 for(int i=0;i<Layers;i++)
149 {
150 fr=(EdbFrame*)(FG->eEdbView->GetFrames()->At(i));
151 b[i]=fr->GetNcl();
152 z[i]=fr->GetZ();
153 printf("Z=%f : %d clusters\n",z[i],b[i]);
154 }
155 int Nu=-1;
156 int Nl=-1;
157 for(int i=0;i<Layers;i++)
158 {
159 if(b[i]>ClusterThreshold && Nu < 0) Nu=i;
160 }
161 for(int i=Layers-1;i>=0;i--)
162 {
163 if(b[i]>ClusterThreshold && Nl < 0) Nl=i;
164 }
165
166 if(Nu>0 && Nu<Layers-1) {zz0=z[Nu]; retval+=1;}
167 if(Nl>0 && Nl<Layers-1) {zz1=z[Nl]; retval+=2;}
168 delete [] b;
169 delete [] z;
170
171 Layers=SL;
172
173
174// if ( findsurf(&zz0, &zz1, ClusterThreshold)==0 ) return 0;
175 printf("Surfaces detected %f -> %f\n",zz0,zz1);
176 *z0=zz0;*z1=zz1;
177 return retval;
178}
brick z0
Definition: RecDispMC.C:106
long FillView(int N, int Side=0, EdbView *View=NULL, bool FillImages=false)
Definition: AcqOdyssey.cxx:866
int MaxNbGrab
Definition: AcqOdyssey.h:181
EdbView * eEdbView
Definition: AcqOdyssey.h:177
int ScanView(float Z0, float DZ, float GotoX=0, float GotoY=0, bool RawImages=false)
Definition: AcqTrackScanner.cxx:39
Definition: EdbFrame.h:20
float GetZ() const
Definition: EdbFrame.h:42
int GetNcl() const
Definition: EdbFrame.h:43
TClonesArray * GetFrames() const
Definition: EdbView.h:167
void Clear()
Definition: EdbView.cxx:79

◆ ScanAndFillView()

long AcqTrackScanner::ScanAndFillView ( float  Z0,
float  DZ,
int  Side = 0,
EdbView View = NULL,
bool  FillImages = false,
float  GotoX = 0,
float  GotoY = 0 
)
85{
86 // scans through the emulsion layer at Z0 with +DZ thickness
87 // provides [Layers] frames for further processing
88 // this is a basic function common for all scanning objects
89 // it uses asyncronous FG->GrabAndFillView to fill the given EdbView
90 // if View==NULL then FG->eEdbView is filled
91 // If X,Y!=0 then after scan starts movement to X,Y,Z0 (next view position)
92
93 float *Pos=new float[Layers];
94 float Speed=FPS*DZ/(Layers-1);
95 int res;
96 int Nclust=0;
97 //FG->Threshold=Threshold;
98 printf("Threshold is set to %d\n",FG->Threshold);
99 printf("Filling Z breakpoint position buffer\n");
100 Speed=1.*FPS*DZ/(Layers-1);
101 for(int i=0;i<Layers;i++) Pos[i]=1.*i*DZ/(Layers-1)+Z0;
102 printf("Z Started to %f..\n",Z0+DZ+2);
103 ST->Z->PosMove(Z0+DZ+2,1e9,1e9);
104 res=ST->Z->WaitForMoveComplete(3e3);
105 printf("Z Reached initial at %f, res=%d\n",ST->Z->GetPos(),res);
108 printf("Armed BP sequence and Z started to %f and \n",Z0-5);
109// ST->Z->PosMove(Z0-2,Speed,Speed*200);
110 if(GotoX==0 || GotoY==0) ST->Z->PosMove(Z0-2,Speed,Speed*200); //old style just scan down
112
113// Taken=FG->GrabImagesONL(Layers,Pos,(DZ+20.)/Speed);
114 Nclust=FG->GrabAndFillView(Layers, Pos,(DZ+20.)/Speed,Side, View, FillImages);
115 res=ST->Z->WaitForMoveComplete(3e3);
116 if(res==1)
117 printf("Z Reached final at %f, found %d clusters.\n",ST->Z->GetPos(),Nclust);
118 else printf("Z movement is not complete within 3 sec! Error.\n");
119
120 delete [] Pos;
121 return Nclust;
122
123}
void ArmBreakpointSequence()
Definition: AcqStage1.cxx:765
void LoadBreakpointSequence(float *Pos, int N)
Definition: AcqStage1.cxx:722
long GrabAndFillView(int N, float *Zs=NULL, double Timeout=0, int Side=0, EdbView *View=NULL, bool FillImages=false)
Definition: AcqOdyssey.cxx:604
int Threshold
Definition: AcqOdyssey.h:174
void ScanToZ0AndGotoXYZ(float Z0, float Z0speed, float Z0acc, float X, float Y, float XYSpeed, float XYAcc, float Z, float Zspeed, float Zacc, u32 Timeout)
Definition: AcqStage1.cxx:231
float Speed
Definition: hwinit.C:69
Definition: tlg2couples.C:89

◆ ScanView()

int AcqTrackScanner::ScanView ( float  Z0,
float  DZ,
float  GotoX = 0,
float  GotoY = 0,
bool  RawImages = false 
)
40{
41 // scans through the emulsion layer at Z0 with +DZ thickness
42 // provides [Layers] frames for further processing
43 // this is a basic function common for all scanning objects
44 // If X,Y!=0 then after scan starts movement to X,Y,Z0 (next view position)
45
46 float *Pos=new float[Layers];
47 float Speed=FPS*DZ/(Layers-1);
48 int res;
49 int Taken;
50 //FG->Threshold=Threshold;
51 printf("threshold is set to %d\n",FG->Threshold);
52 printf("Filling Z breakpoint position buffer\n");
53 Speed=1.*FPS*DZ/(Layers-1);
54 for(int i=0;i<Layers;i++) Pos[i]=1.*i*DZ/(Layers-1)+Z0;
55 printf("Z Started to %f..\n",Z0+DZ+2);
56 ST->Z->PosMove(Z0+DZ+2,1e9,1e9);
57 res=ST->Z->WaitForMoveComplete(3e3);
58 printf("Z Reached initial at %f, res=%d\n",ST->Z->GetPos(),res);
61 printf("Armed BP sequence and Z started to %f and \n",Z0-5);
62 if(GotoX==0 || GotoY==0) ST->Z->PosMove(Z0-2,Speed,Speed*200); //old style just scan down
64 printf("DZ = %f, Speed = %f, (DZ+20.)/Speed = %f\n", DZ, Speed, (DZ+20.)/Speed);
65 if(!RawImages) Taken=FG->GrabImagesONL(Layers,Pos,(DZ+20.)/Speed);
66 else Taken=FG->GrabRawImagesONL(Layers,Pos,(DZ+20.)/Speed);
67 res=ST->Z->WaitForMoveComplete(1e3);
68// if(GotoX!=0 && GotoY!=0) {
69// res=ST->X->WaitForMoveComplete(1e3);
70// res=ST->Y->WaitForMoveComplete(1e3);
71// }
72 if(res==1 && Taken==Layers)
73 printf("Z Reached final at %f, taken %d frames.\n",ST->Z->GetPos(),Taken);
74 if(res==0) printf("Z movement is not complete within 1 sec! Error.\n");
75 if(Taken!=Layers) printf("Expected %d layers, taken only %d! Error.\n", Layers, Taken);
76
77 delete [] Pos;
78 return Taken;
79
80}
int GrabImagesONL(int N, float *Zs=NULL, double Timeout=0)
Definition: AcqOdyssey.cxx:472
int GrabRawImagesONL(int N, float *Zs=NULL, double Timeout=0)
Definition: AcqOdyssey.cxx:549

◆ SetPointers()

bool AcqTrackScanner::SetPointers ( AcqStage1 stg,
AcqOdyssey ody 
)
inline
24{ST=stg ; FG=ody; return 1;};

Member Data Documentation

◆ FG

AcqOdyssey* AcqTrackScanner::FG

◆ FPS

int AcqTrackScanner::FPS

◆ Layers

int AcqTrackScanner::Layers

◆ Nx

int AcqTrackScanner::Nx

◆ Ny

int AcqTrackScanner::Ny

◆ ST

AcqStage1* AcqTrackScanner::ST

◆ ViewStepX

float AcqTrackScanner::ViewStepX

◆ ViewStepY

float AcqTrackScanner::ViewStepY

◆ XYViewToViewSpeed

float AcqTrackScanner::XYViewToViewSpeed

◆ ZBackStrokeSpeed

float AcqTrackScanner::ZBackStrokeSpeed

The documentation for this class was generated from the following files: