FEDRA emulsion software from the OPERA Collaboration
run.C File Reference
#include <exception>
Include dependency graph for run.C:
This graph shows which files directly or indirectly include this file:

Functions

void Run (bool AbsCoord=false, float X0, float Y0, float DDX, float DDY, const char *File, bool Images=false)
 
int scanpreds (int PLATE, int MINOR)
 

Function Documentation

◆ Run()

void Run ( bool  AbsCoord = false,
float  X0,
float  Y0,
float  DDX,
float  DDY,
const char *  File,
bool  Images = false 
)
209 {
210  // Scan emulsion zone with the use of faster async function TS->ScanAndFillView
211 
212  // s->L->ON();
213  int res=0;
214  float X,Y;
215  int Vn=0;
216  int vid=0;
217  long start,end,cur;
218  EdbMark *xyz=new EdbMark();
219  xyz->SetX(X0);
220  xyz->SetY(Y0);
221  if(AbsCoord && FM->eFoundMarksSet) xyz->Transform(FM->eFoundMarksSet->Abs2Stage());
222  X0=xyz->X();
223  Y0=xyz->Y();
224  printf("Going to %f, %f\n",X0,Y0);
225  s->X->PosMove(X0,1e6,1e6);
226  s->Y->PosMove(Y0,1e6,1e6);
227  res=s->Y->WaitForMoveComplete(1e4);
228  res*=s->X->WaitForMoveComplete(1e4);
229  if(!res) return;
230  printf("Reached %f, %f\n",s->X->GetPos(),s->Y->GetPos());
231  start=atoi((gSystem->Now()).AsString());
232 
233 // if(!focus(Cluster_Threshold)) return;
234 // finefocus(Cluster_Threshold);
235  end=atoi((gSystem->Now()).AsString());
236 // printf("%d ms spent for focusing\n",end-start);
237 
238  run=new EdbRun(File,"RECREATE");
239  run->SetTitle("Test of libACQ");
240  run->SetComment(" Test run: online data taking with libACQ. \n Parameters are selected to fit OPERA plates \n");
241  EdbRunHeader *header = run->GetHeader();
242  header->SetCCD( o->SizeX , // number of pixels
243  o->SizeY , //
244  -999 , // ccd pixel size in microns
245  -999 , // (is not important for analysis)
246  "MC1310",
247  "Mikrotron CMOS High Speed camera" );
248 
249  header->SetObjective( 50. , // magnification nominal value
250  s->X->Invert*o->SizeX*o->PixelToMicronX, // pixel size X |
251  0. , // |
252  0. , // | CCD2Stage affine
253  s->Y->Invert*o->SizeY*o->PixelToMicronY, // pixel size Y | transformation:
254  0. , // | pixels -> microns
255  0. , // |
256  "NIKON",
257  "Dry Objective " );
258 
259 
260 
261  header->SetArea( TS->Nx*TS->Ny , // number of views/area to scan
262  TS->ViewStepX , // X-step in microns
263  TS->ViewStepY , // Y-step in microns
264  TS->Layers , // NframesTop
265  TS->Layers , // NframesBot
266  0 ); //path
267 
269 
270 
271 
272  header->SetPlate( 6 , // plate ID
273  s->EmTopLayer , // emulsion up
274  s->EmBase , // base
275  s->EmBotLayer , // emulsion down
276  1.0 , // shrinkage up
277  1.0 , // shrinkage down
278  "W2P6R",
279  "Welded brick2, plate 6" );
280 
281 // calculate fragment division
282 int indFragX=0;
283 int indFragY=0;
284 int AreaID=0;
285 float FragStepX = TS->ViewStepX * TS->Nx;
286 float FragStepY = TS->ViewStepY * TS->Ny;
287 int NumFragsX=int(DDX/FragStepX)+1;
288 int NumFragsY=int(DDY/FragStepY)+1;
289 
290 for( indFragY=0; indFragY<NumFragsY; indFragY++)
291 for( indFragX=0; indFragX<NumFragsX; indFragX++)
292 {
293  X=X0+indFragX * FragStepX;
294  Y=Y0+indFragY * FragStepY;
295 //finefocus(Cluster_Threshold,3);
297  {
298  if(!finefocus(Cluster_Threshold,.4)) return;
299  if(!finefocus(Cluster_Threshold,1)) return;
300 
301  }
303  o->Threshold=ThrTop;
304  TS->FastScanFragment(true, AreaID, AbsCoord, X,Y, run, Images);
306  o->Threshold=ThrBot;
307  TS->FastScanFragment(false, AreaID, AbsCoord, X,Y, run, Images);
308  AreaID++;
309 
310 }
311  start=atoi((gSystem->Now()).AsString());
312  printf("%d ms spent for scanning.\n",start-end);
313  run->Save();
314  run->Close();
315  delete xyz;
316 
317 }
EdbMarksSet * eFoundMarksSet
Definition: AcqMarksScanner.h:41
int SizeX
Definition: AcqOdyssey.h:168
float PixelToMicronY
Definition: AcqOdyssey.h:179
int Threshold
Definition: AcqOdyssey.h:174
int SizeY
Definition: AcqOdyssey.h:168
float PixelToMicronX
Definition: AcqOdyssey.h:178
int Layers
Definition: AcqTrackScanner.h:30
int Ny
Definition: AcqTrackScanner.h:35
int FastScanFragment(bool IsTop, int AreaId, bool AbsCoord, float X0, float Y0, EdbRun *run, bool RawImages=false)
Definition: AcqTrackScanner.cxx:181
float ViewStepY
Definition: AcqTrackScanner.h:34
int Nx
Definition: AcqTrackScanner.h:35
float ViewStepX
Definition: AcqTrackScanner.h:34
Definition: EdbFiducial.h:21
Float_t Y() const
Definition: EdbFiducial.h:43
void SetY(float y)
Definition: EdbFiducial.h:45
void SetX(float x)
Definition: EdbFiducial.h:44
Float_t X() const
Definition: EdbFiducial.h:42
EdbAffine2D * Abs2Stage() const
Definition: EdbFiducial.cxx:271
virtual void Transform(const EdbAffine2D *a)
Definition: EdbVirtual.cxx:106
Definition: EdbRunHeader.h:94
void SetArea(int N, float stepx, float stepy, int ft, int fb, int path)
Definition: EdbRunHeader.h:208
void SetCCD(int nx=0, int ny=0, float px=0, float py=0, const char *name="", const char *title="")
Definition: EdbRunHeader.h:178
void SetObjective(float mag, float a, float b, float c, float d, float p, float q, const char *name="", const char *title="")
Definition: EdbRunHeader.h:190
void SetPlate(int id, float up, float base, float down, float shru, float shrd, const char *name="", const char *title="")
Definition: EdbRunHeader.h:199
Definition: EdbRun.h:74
EdbMarksSet * eMarks
Definition: EdbRun.h:100
void Close()
Definition: EdbRun.cxx:466
void Save()
Definition: EdbRun.cxx:451
EdbRunHeader * GetHeader() const
Definition: EdbRun.h:137
void SetTitle(const char *tit)
Definition: EdbRun.h:132
void SetComment(const char *com)
Definition: EdbRun.h:131
Float_t X() const
Definition: EdbSegP.h:170
Float_t Y() const
Definition: EdbSegP.h:171
float X0
Definition: emthickness.cpp:69
float Y0
Definition: emthickness.cpp:70
int ThrBot
Definition: hwinit.C:12
AcqMarksScanner * FM
Definition: hwinit.C:3
AcqOdyssey * o
Definition: hwinit.C:2
int Cluster_Threshold
Definition: hwinit.C:13
int ThrTop
Definition: hwinit.C:11
AcqTrackScanner * TS
Definition: hwinit.C:4
int focus(int clu_thre=300)
Definition: init.C:76
int finefocus(int clu_thre=300, float fineness=4.)
Definition: init.C:109
EdbRun * run
Definition: check_raw.C:38
Definition: tlg2pattern.C:52
Double_t X
Definition: tlg2pattern.C:77
Double_t Y
Definition: tlg2pattern.C:77
EdbSegP * s
Definition: tlg2pattern.C:32

◆ scanpreds()

int scanpreds ( int  PLATE,
int  MINOR 
)
5 {
6 int BRICK=92;
7 
8 bool loadresult;
9 try {loadresult=PC->LoadPlate(BRICK,PLATE,0,0); printf("Load plate returned %d.\n",loadresult);}
10 catch (...) {printf("Exception caught in LoadPlate!\n"); return 0;}
11 if(!loadresult) {printf("can't load plate! Exiting.\n"); return 0;}
12 try { printf("Scanmarks is about to execute..\n"); loadresult=scanmarks();}
13 catch (...) {cout << "Exception caught in scanmarks!" << endl; return 0;}
14 if(!loadresult) return 0;
15  char cmd[128];
16 // Initializing run
17  try
18  {
19  EdbMark *xyz=new EdbMark();
20  if(!FM->eFoundMarksSet) {printf("Marks are not scanned! Exiting.\n"); return 0;}
21  start=atoi((gSystem->Now()).AsString());
22  end=atoi((gSystem->Now()).AsString());
23  sprintf(cmd,"del .\\data\\r.root");
24  gSystem->Exec(cmd);
25  run=new EdbRun(".\\data\\r.root","RECREATE");
26  run->SetTitle("Test of prediction scan");
27  run->SetComment(" Test run: online data taking with libACQ. \n Parameters are selected to fit OPERA plates \n");
28  EdbRunHeader *header = run->GetHeader();
29  header->SetCCD( o->SizeX , // number of pixels
30  o->SizeY , //
31  -999 , // ccd pixel size in microns
32  -999 , // (is not important for analysis)
33  "MC1310",
34  "Mikrotron CMOS High Speed camera" );
35 
36  header->SetObjective( 50. , // magnification nominal value
37  s->X->Invert*o->SizeX*o->PixelToMicronX, // pixel size X |
38  0. , // |
39  0. , // | CCD2Stage affine
40  s->Y->Invert*o->SizeY*o->PixelToMicronY, // pixel size Y | transformation:
41  0. , // | pixels -> microns
42  0. , // |
43  "NIKON",
44  "Dry Objective " );
45 
46 
47 
48  header->SetArea( TS->Nx*TS->Ny , // number of views/area to scan
49  TS->ViewStepX , // X-step in microns
50  TS->ViewStepY , // Y-step in microns
51  TS->Layers , // NframesTop
52  TS->Layers , // NframesBot
53  0 ); //path
54 
55  if(run->eMarks) delete (run->eMarks);
57  printf("Markset written to file:\n");
58  (run->eMarks)->Print();
59 
60 
61 
62  header->SetPlate( 6 , // plate ID
63  s->EmTopLayer , // emulsion up
64  s->EmBase , // base
65  s->EmBotLayer , // emulsion down
66  1.0 , // shrinkage up
67  1.0 , // shrinkage down
68  "W2P6R",
69  "Welded brick2, plate 6" );
70  }
71  catch (...) {cout << "Exception caught in Run initialization!" << endl; return 0;}
72 
73 // run initialized
74 
75 int scan_zone_id=98;
76 int proc_zone_id=94;
77 bool data_ready=false;
78 int proctracks=0;
79 int dummy;
80 
81 char fname[128];
82 sprintf(fname,".\\data\\pred%d.%d.0.%d.txt",BRICK,PLATE,MINOR);
83 FILE* fp=fopen(fname,"r");
84 if(fp==NULL) {printf("Prediction file %s can't be opened.\n",fname); return 0;}
85 char line[256];
86 int id;
87 float XX0,YY0,X,Y,TX,TY;
88 int AreaID=0;
89 
90 try while(fgets(line,256,fp)!=NULL) //main loop
91  {
92 // if(kbhit()){getch();printf("Paused. Continue? (y/n)"); if(getchar()=='n') break;}
93  sscanf(line,"%d %f %f %f %f",&id,&X,&Y,&TX,&TY);
94  printf("Predicted segment N %d: %f %f %f %f\n",id,X,Y,TX,TY);
95  xyz->SetX(X);
96  xyz->SetY(Y);
98  X=xyz->X();
99  Y=xyz->Y();
100  printf("Stage coordinates: %f %f \n",X,Y);
101  if(proctracks==0)
103  {
104  if(!finefocus(Cluster_Threshold,.4)) return 0;
105  if(!finefocus(Cluster_Threshold,1)) return 0;
106 
107  }
108 
109  if(proctracks>0)
110  {
112  {
113  if(!finefocus(Cluster_Threshold,.4)) {
114  s->X->PosMove(X,1e9,1e9);
115  s->Y->PosMove(Y,1e9,1e9);
116  s->X->WaitForMoveComplete(1e4);
117  s->Y->WaitForMoveComplete(1e4);
118  XX0=X; YY0=Y;
119  proctracks++;
120  continue;
121  }
122  if(!finefocus(Cluster_Threshold,1)) {
123  s->X->PosMove(X,1e9,1e9);
124  s->Y->PosMove(Y,1e9,1e9);
125  s->X->WaitForMoveComplete(1e4);
126  s->Y->WaitForMoveComplete(1e4);
127  XX0=X; YY0=Y;
128  proctracks++;
129  continue;
130  }
131 
132  }
133 
134  TS->Layers=Layers;
136  o->Threshold=ThrTop;
137  // TS->FocusScanPrediction(true, AreaID, true, XX0, YY0, run, false, 0, 0);
138  TS->FastScanPrediction(true, AreaID, true, XX0, YY0, run, false, 0, 0);
139 // o->ShowImage(4);
140 // AreaID++;
142  o->Threshold=ThrBot;
143 // TS->FocusScanPrediction(false, AreaID, true, XX0, YY0, run, false, X, Y);
144  TS->FastScanPrediction(false, AreaID, true, XX0, YY0, run, false, X, Y);
145 // o->ShowImage(4);
146  AreaID++;
147  }
148  XX0=X; YY0=Y; //to remember previous
149  proctracks++;
150  printf("Prepared to scan %d predictions\n",proctracks);
151  }
152 
153  catch (...) {cout << "Exception caught in main loop!" << endl; return 0;}
154 
155  // eND OF MAIN LOOP
156  try {
158  {
159  if(!finefocus(Cluster_Threshold,.4)) return 0;
160  if(!finefocus(Cluster_Threshold,1)) return 0;
161 
162  }
163 
164  TS->Layers=Layers;
166  o->Threshold=ThrTop;
167 // TS->FocusScanPrediction(true, AreaID, true, X, Y, run, false, 0, 0);
168  TS->FastScanPrediction(true, AreaID, true, X, Y, run, false, 0, 0);
169 // o->ShowImage(4);
170 // AreaID++;
172  o->Threshold=ThrBot;
173  // TS->FocusScanPrediction(false, AreaID, true, X, Y, run, false, 0, 0);
174  TS->FastScanPrediction(false, AreaID, true, X, Y, run, false, 0, 0);
175 // o->ShowImage(4);
176  AreaID++;
177 
178 run->Save();
179 run->Close();
180 delete run;
181  }
182  catch (...) {cout << "Exception caught in Postprocessing!" << endl; return 0;}
183 
184 char rootfname[128];
185  sprintf(rootfname,"data\\tst%d.%d.0.%d.root",BRICK,PLATE,MINOR);
186 //else sprintf(rootfname,"%s",ofile);
187 printf("move data\\r.root %s\n",rootfname);
188 sprintf(cmd,"move data\\r.root %s",rootfname);
189 gSystem->Exec(cmd);
190 /*Link1(BRICK,PLATE,98,false);
191  sprintf(cmd,"mv data/%02d_098.cp.root data/%02d_%03d.cp.root ",PLATE,PLATE,MINOR);
192  printf("mv data/%02d_098.cp.root data/%02d_%03d.cp.root\n ",PLATE,PLATE,MINOR);
193  gSystem->Exec(cmd);
194  sprintf(cmd,"mv data/tst%d.%d.0.%d.root data/tst%d.%d.0.%d.root",BRICK,PLATE,98,BRICK,PLATE,MINOR);
195  printf("mv data/tst%d.%d.0.%d.root data/tst%d.%d.0.%d.root\n",BRICK,PLATE,98,BRICK,PLATE,MINOR);
196  gSystem->Exec(cmd);
197 */
198 
199 fclose(fp);
200 start=atoi((gSystem->Now()).AsString());
201 printf("%d ms spent for scanning.\n",start-end);
202 delete xyz;
203 return 1;
204 }
int LoadPlate(IdentifierS id)
Definition: AcqSerialPlateChanger.cxx:783
Alg Print()
int Layers
Definition: hwinit.C:65
AcqSerialPlateChanger * PC
Definition: hwinit.C:5
int scanmarks()
Definition: init.C:368
const char * fname
Definition: mc2raw.cxx:41
Int_t dummy
Definition: merge_Energy_SytematicSources_Electron.C:7
fclose(pFile)
Double_t TY
Definition: tlg2pattern.C:79
Double_t TX
Definition: tlg2pattern.C:79
UInt_t id
Definition: tlg2pattern.C:118
int PLATE
Definition: shower_btr.C:18
#define NULL
Definition: nidaqmx.h:84
Definition: RecDispMC.C:95