FEDRA emulsion software from the OPERA Collaboration
EdbMarksSet Class Reference

#include <EdbFiducial.h>

Inheritance diagram for EdbMarksSet:
Collaboration diagram for EdbMarksSet:

Public Member Functions

EdbAffine2DAbs2Stage () const
 
Int_t ChangeMapStringSpacer (TString &str, char oldspacer, char newspacer)
 
void DrawA (Option_t *opt="") const
 
void DrawS (Option_t *opt="") const
 
 EdbMarksSet ()
 
 EdbMarksSet (const EdbMarksSet &ms)
 
EdbMarksBoxGetAbsolute () const
 
Int_t GetN () const
 
Int_t GetNa () const
 
Int_t GetNs () const
 
EdbMarksBoxGetStage () const
 
void Print (Option_t *opt="") const
 
Int_t ReadDA (char *file)
 
Int_t ReadDB (char *file)
 
Int_t ReadDollar (char *file, EdbMarksBox *mbox)
 
Int_t ReadMap (char *file, char spacer='_', char shape='S')
 
Int_t ReadMap2 (char *file, char spacer='_', char shape='S')
 
EdbAffine2DStage2Abs () const
 
Int_t WriteMap (char *file, char spacer='_', char shape='S', int plate=1)
 
Int_t WriteMap2 (char *file, char spacer='_', char shape='S', int plate=1)
 
virtual ~EdbMarksSet ()
 

Public Attributes

Long_t eBrick
 
Float_t eXmax
 
Float_t eXmin
 
Float_t eYmax
 
Float_t eYmin
 

Private Attributes

EdbMarksBoxeAbsolute
 fiducial marks in absolute coord ($b) More...
 
EdbMarksBoxeStage
 fiducial marks in stage coord ($a) More...
 

Constructor & Destructor Documentation

◆ EdbMarksSet() [1/2]

EdbMarksSet::EdbMarksSet ( )
213{
215 eAbsolute = new EdbMarksBox();
216 eStage = new EdbMarksBox();
217}
Definition: EdbFiducial.h:55
Long_t eBrick
Definition: EdbFiducial.h:98
Float_t eXmin
Definition: EdbFiducial.h:96
Float_t eYmin
Definition: EdbFiducial.h:97
Float_t eYmax
Definition: EdbFiducial.h:97
EdbMarksBox * eAbsolute
fiducial marks in absolute coord ($b)
Definition: EdbFiducial.h:92
EdbMarksBox * eStage
fiducial marks in stage coord ($a)
Definition: EdbFiducial.h:93
Float_t eXmax
Definition: EdbFiducial.h:96

◆ EdbMarksSet() [2/2]

EdbMarksSet::EdbMarksSet ( const EdbMarksSet ms)
221{
222 eXmin=ms.eXmin;
223 eXmax=ms.eXmax;
224 eYmin=ms.eYmin;
225 eYmax=ms.eYmax;
226 eBrick=ms.eBrick;
227 if(ms.GetAbsolute()) eAbsolute = new EdbMarksBox( *(ms.GetAbsolute()) );
228 else eAbsolute = new EdbMarksBox();
229 if(ms.GetStage()) eStage = new EdbMarksBox( *(ms.GetStage()) );
230 else eStage = new EdbMarksBox();
231}
EdbMarksBox * GetAbsolute() const
Definition: EdbFiducial.h:109
EdbMarksBox * GetStage() const
Definition: EdbFiducial.h:110

◆ ~EdbMarksSet()

EdbMarksSet::~EdbMarksSet ( )
virtual
235{
236 if(eAbsolute) delete eAbsolute;
237 if(eStage) delete eStage;
238}

Member Function Documentation

◆ Abs2Stage()

EdbAffine2D * EdbMarksSet::Abs2Stage ( ) const
272{
273 EdbAffine2D *aff = new EdbAffine2D();
275 return aff;
276}
Definition: EdbAffine.h:17
Int_t Calculate(EdbPointsBox2D *b1, EdbPointsBox2D *b2)
Definition: EdbAffine.cxx:231
collection of 2D points
Definition: EdbVirtual.h:150

◆ ChangeMapStringSpacer()

Int_t EdbMarksSet::ChangeMapStringSpacer ( TString &  str,
char  oldspacer,
char  newspacer 
)

Changes the spacer inside the map string with a new character

386{
388 for (int is=0;is<str.Length();is++)
389 if(str[is]==oldspacer) str[is]=newspacer;
390
391 return(1);
392}

◆ DrawA()

void EdbMarksSet::DrawA ( Option_t *  opt = "") const
242{
243 if(eAbsolute) eAbsolute->Draw( 23, 4, 1. );
244}
void Draw(int style=23, int col=4, float size=1., float tsiz=.03)
Definition: EdbFiducial.cxx:675

◆ DrawS()

void EdbMarksSet::DrawS ( Option_t *  opt = "") const
248{
249 if(eStage) eStage->Draw( 22, 3, 1. );
250}

◆ GetAbsolute()

EdbMarksBox * EdbMarksSet::GetAbsolute ( ) const
inline
109{ return eAbsolute; }

◆ GetN()

Int_t EdbMarksSet::GetN ( ) const
254{
255 return TMath::Min( GetNa(), GetNs() );
256}
Int_t GetNa() const
Definition: EdbFiducial.cxx:259
Int_t GetNs() const
Definition: EdbFiducial.cxx:265

◆ GetNa()

Int_t EdbMarksSet::GetNa ( ) const
260{
261 if(eAbsolute) return eAbsolute->GetN(); else return 0;
262}
Int_t GetN() const
Definition: EdbFiducial.cxx:703

◆ GetNs()

Int_t EdbMarksSet::GetNs ( ) const
266{
267 if(eStage) return eStage->GetN(); else return 0;
268}

◆ GetStage()

EdbMarksBox * EdbMarksSet::GetStage ( ) const
inline
110{ return eStage; }

◆ Print()

void EdbMarksSet::Print ( Option_t *  opt = "") const
594{
595 printf("EdbMarksSet: eBrick = %ld\n", eBrick);
596 printf("EdbMarksSet: eXmin, eYmin, eXmax, eYmax = %f %f %f %f\n", eXmin, eYmin, eXmax, eYmax);
597 printf("EdbMarksSet: Absolute mark set:\n");
599 printf("EdbMarksSet: Stage mark set:\n");
600 if(eStage) eStage->Print();
601}
void Print(Option_t *opt="") const
other functions
Definition: EdbFiducial.cxx:695

◆ ReadDA()

Int_t EdbMarksSet::ReadDA ( char *  file)
294{
295 int mod, pln, prg, plt, pos;
296 float sftx, sfty, gap, rot;
297 float pnm, eml, bas, shr0, shr1;
298 int n;
299 float x0,y0,z0, x1,y1,z1;
300
301 int nmarks=0;
302 int ncols=0;
303
304 FILE *fp = fopen( file,"r");
305 char buffer[256]="";
306
307 if (fgets (buffer, 256, fp) == NULL) return 0;
308 ncols = sscanf( buffer,"%d %d %d %d %d", &mod, &pln, &prg, &plt, &pos );
309 if( ncols < 4 )
310 { printf("ERROR: EdbMarksSet::ReadDA: wrong format\n"); return 0; }
311 if (fgets (buffer, 256, fp) == NULL) return 0;
312 ncols = sscanf( buffer,"%f %f %f %f", &sftx, &sfty, &gap, &rot );
313 if (fgets (buffer, 256, fp) == NULL) return 0;
314 ncols = sscanf( buffer,"%f %f %f %f %f", &pnm, &eml, &bas, &shr0, &shr1 );
315 if( ncols < 4 )
316 { printf("ERROR: EdbMarksSet::ReadDA: wrong format\n"); return 0; }
317
318 for(int i=0; i<10000; i++) {
319 if (fgets (buffer, 256, fp) == NULL) break;
320 ncols = sscanf( buffer,"%d %f %f %f %f %f %f",
321 &n, &x0, &y0, &z0, &x1, &y1, &z1 );
322 if( ncols < 7 ) break;
323 eAbsolute->AddMark(n,x0,y0);
324 eStage->AddMark(n,x1,y1);
325 nmarks++;
326 }
327
328 printf("%d marks are read from file %s\n", nmarks, file);
329 return nmarks;
330}
brick z0
Definition: RecDispMC.C:106
void AddMark(int id, float x, float y, int flag=0)
members access functions
Definition: EdbFiducial.cxx:716
TFile * file
Definition: write_pvr.C:3
#define NULL
Definition: nidaqmx.h:84

◆ ReadDB()

Int_t EdbMarksSet::ReadDB ( char *  file)
288{
289 return ReadDollar( file, eStage );
290}
Int_t ReadDollar(char *file, EdbMarksBox *mbox)
Definition: EdbFiducial.cxx:333

◆ ReadDollar()

Int_t EdbMarksSet::ReadDollar ( char *  file,
EdbMarksBox mbox 
)

$B - Fiducial marks (Chorus coordinates): -> NFID
mod pln prd plt pos
2 5 11 -1 <- plate line
sftx sfty gap rot
0. 0. 0. 0. <- position correction line
pnm eml bas shr0 shr1
0. 100. 850. 2. <- emulsion thikness line
n x y z
10 -339667. -209560. 0. <- X-ray marks line
12 -39704. -209630. 0.
13 -339646. -59477. 0.
15 -39746. -59533. 0.

334{
348
349 int mod, pln, prg, plt, pos;
350 float sftx, sfty, gap, rot;
351 float pnm, eml, bas, shr0, shr1;
352 int n;
353 float x,y,z;
354
355 int nmarks=0;
356 int ncols=0;
357
358 FILE *fp = fopen( file,"r");
359 char buffer[256]="";
360
361 if (fgets (buffer, 256, fp) == NULL) return 0;
362 ncols = sscanf( buffer,"%d %d %d %d %d", &mod, &pln, &prg, &plt, &pos );
363 if( ncols < 4 )
364 { printf("ERROR: EdbMarksSet::ReadDA: wrong format\n"); return 0; }
365 if (fgets (buffer, 256, fp) == NULL) return 0;
366 ncols = sscanf( buffer,"%f %f %f %f", &sftx, &sfty, &gap, &rot );
367 if (fgets (buffer, 256, fp) == NULL) return 0;
368 ncols = sscanf( buffer,"%f %f %f %f %f", &pnm, &eml, &bas, &shr0, &shr1 );
369 if( ncols < 4 )
370 { printf("ERROR: EdbMarksSet::ReadDA: wrong format\n"); return 0; }
371
372 for(int i=0; i<10000; i++) {
373 if (fgets (buffer, 256, fp) == NULL) break;
374 ncols = sscanf( buffer,"%d %f %f %f", &n, &x, &y, &z );
375 if( ncols < 3 ) break;
376 mbox->AddMark(n,x,y);
377 nmarks++;
378 }
379
380 printf("%d marks are read from file %s\n", nmarks, file);
381 return nmarks;
382}

◆ ReadMap()

Int_t EdbMarksSet::ReadMap ( char *  file,
char  spacer = '_',
char  shape = 'S' 
)

Reads map file and adds informations to eAbsolute
If shape is 'S', then the "Front X-Ray Mark Map or Optical Mark Map" format is assumed
If shape is 'L', then the "Lateral X-Ray Mark Map" format is assumed

396{
400 Int_t nmarks = 0;
401 Int_t mark, flag;
402 Float_t x, y;
403
404 FILE *fp = fopen( file,"r");
405
406 TString str_header;
407 TString str_mark;
408
409 if (shape=='S'||shape=='X') {
410 str_header = "mapext:_%ld_%*d_%*d_%*d;_%d_%f_%f_%f_%f";
411 str_mark = ";_%d_%f_%f_%*f_%*f_%*d_%*d_%d";
412 } else if (shape=='L') {
413 str_header = "mapx:_%ld_%*d_%*d_%*d;_%d_%f_%f_%f_%f";
414 str_mark = ";_%d_%f_%f_%*f_%*f_%*d_%*d_%d";
415 } else {
416 Log(1,"EdbMarksSet::ReadMap","ERROR: shape '%c' is not implemented\n", shape); return 0;
417 }
418
419 ChangeMapStringSpacer(str_header,'_',spacer);
420 ChangeMapStringSpacer(str_mark,'_',spacer);
421
422 if(!fp)
423 { Log(1,"EdbMarksSet::ReadMap","ERROR: can not open file %s\n", file); return 0; }
424
425 if ( fscanf(fp, str_header.Data(), &eBrick,&nmarks,&eXmin,&eYmin,&eXmax,&eYmax) != 6 )
426 { Log(1,"EdbMarksSet::ReadMap","ERROR: file %s is empty or wrong format\n", file); return 0; }
427
428 GetAbsolute()->GetMarks()->Clear("C");
429
430 for (int imarks=0;imarks<nmarks;imarks++)
431 {
432 if (fscanf(fp, str_mark.Data(), &mark, &x, &y, &flag) != 4)
433 { Log(1,"EdbMarksSet::ReadMap","ERROR: file %s is empty or wrong format\n", file); return 0; }
434 GetAbsolute()->AddMark(mark,x,y,flag);
435 }
436
437 fclose(fp);
438
439 Log(3,"EdbMarksSet::ReadMap","%d marks are read from file %s\n", nmarks, file);
440 return nmarks;
441}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
TClonesArray * GetMarks() const
Definition: EdbFiducial.h:72
Int_t ChangeMapStringSpacer(TString &str, char oldspacer, char newspacer)
Definition: EdbFiducial.cxx:385
fclose(pFile)

◆ ReadMap2()

Int_t EdbMarksSet::ReadMap2 ( char *  file,
char  spacer = '_',
char  shape = 'S' 
)

Reads map file and adds informations to eAbsolute and eStage
If shape is 'S', then the "Front X-Ray Mark Map or Optical Mark Map" format is assumed
If shape is 'L', then the "Lateral X-Ray Mark Map" format is assumed

445{
449 Int_t nmarks = 0;
450 Int_t mark, flag;
451 Float_t xabs, yabs, xst, yst;
452
453 FILE *fp = fopen( file,"r");
454
455 TString str_header;
456 TString str_mark;
457
458 if (shape=='S'||shape=='X') {
459 str_header = "mapext:_%ld_%*d_%*d_%*d;_%d_%f_%f_%f_%f";
460 str_mark = ";_%d_%f_%f_%f_%f_%*d_%*d_%d";
461 } else if (shape=='L') {
462 str_header = "mapx:_%ld_%*d_%*d_%*d;_%d_%f_%f_%f_%f";
463 str_mark = ";_%d_%f_%f_%f_%f_%*d_%*d_%d";
464 } else {
465 Log(1,"EdbMarksSet::ReadMap2","ERROR: shape '%c' is not implemented\n", shape); return 0;
466 }
467
468 ChangeMapStringSpacer(str_header,'_',spacer);
469 ChangeMapStringSpacer(str_mark,'_',spacer);
470
471 if(!fp)
472 { Log(1,"EdbMarksSet::ReadMap2","ERROR: can not open file %s\n", file); return 0; }
473
474 if ( fscanf(fp, str_header.Data(), &eBrick,&nmarks,&eXmin,&eYmin,&eXmax,&eYmax) != 6 )
475 { Log(1,"EdbMarksSet::ReadMap2","ERROR: file %s is empty or wrong format\n", file); return 0; }
476
477 GetAbsolute()->GetMarks()->Clear("C");
478 GetStage()->GetMarks()->Clear("C");
479
480 for (int imarks=0;imarks<nmarks;imarks++)
481 {
482 if (fscanf(fp, str_mark.Data(), &mark, &xabs, &yabs, &xst, &yst, &flag) != 6)
483 { Log(1,"EdbMarksSet::ReadMap2","ERROR: file %s is empty or wrong format\n", file); return 0; }
484 GetAbsolute()->AddMark(mark,xabs,yabs,flag);
485 GetStage()->AddMark(mark,xst,yst,flag);
486 }
487
488 fclose(fp);
489
490 Log(3,"EdbMarksSet::ReadMap","%d marks are read from file %s\n", nmarks, file);
491 return nmarks;
492}

◆ Stage2Abs()

EdbAffine2D * EdbMarksSet::Stage2Abs ( ) const
280{
281 EdbAffine2D *aff = new EdbAffine2D();
283 return aff;
284}

◆ WriteMap()

Int_t EdbMarksSet::WriteMap ( char *  file,
char  spacer = '_',
char  shape = 'S',
int  plate = 1 
)

Create a map string starting from the informations stored in this class
and in the EdbMarksBox object eAbsolute
If shape is 'S', then the "Front X-Ray Mark Map or Optical Mark Map" format is assumed
If shape is 'L', then the "Lateral X-Ray Mark Map" format is assumed

496{
501
502 FILE *fp = fopen( file,"w");
503
504 TString str_header;
505 TString str_mark;
506
507 if (shape=='S'||shape=='X') {
508 str_header = "mapext:_%ld_%02d_0_0;_%d_%.4f_%.4f_%.4f_%.4f";
509 str_mark = ";_%d_%0.0f_%0.0f_%0.0f_%0.0f_1_1_%d";
510 } else if (shape=='L') {
511 str_header = "mapx:_%ld_%02d_0_0;_%d_%.4f_%.4f_%.4f_%.4f";
512 str_mark = ";_%d_%0.0f_%0.0f_%0.0f_%0.0f_1_1_%d";
513 } else {
514 Log(1,"EdbMarksSet::ReadMap","ERROR: shape '%c' is not implemented\n", shape); return 0;
515 }
516
517 ChangeMapStringSpacer(str_header,'_',spacer);
518 ChangeMapStringSpacer(str_mark,'_',spacer);
519
520 if(!fp)
521 { Log(1,"EdbMarksSet::ReadMap","ERROR: can not open file %s\n", file); return 0; }
522
523 int nmarks = GetAbsolute()->GetN();
524
525 fprintf(fp, str_header.Data(), eBrick,plate,nmarks,eXmin,eYmin,eXmax,eYmax);
526
527 for (int imarks=0;imarks<nmarks;imarks++)
528 {
529 EdbMark *mark = GetAbsolute()->GetMark(imarks);
530 fprintf(fp, str_mark.Data(), mark->GetID(),mark->GetX(),mark->GetY(),mark->GetX(),mark->GetY(),mark->Flag());
531 }
532
533 fclose(fp);
534
535 Log(3,"EdbMarksSet::WriteMap","%d marks are written as string map in the file %s\n", nmarks, file);
536 return nmarks;
537}
Definition: EdbFiducial.h:21
Float_t GetY() const
Definition: EdbFiducial.h:36
Float_t GetX() const
Definition: EdbFiducial.h:35
Int_t Flag() const
Definition: EdbFiducial.h:39
Int_t GetID() const
Definition: EdbFiducial.h:34
EdbMark * GetMark(int i) const
Definition: EdbFiducial.cxx:709
Int_t plate
Definition: merge_Energy_SytematicSources_Electron.C:1

◆ WriteMap2()

Int_t EdbMarksSet::WriteMap2 ( char *  file,
char  spacer = '_',
char  shape = 'S',
int  plate = 1 
)

Create a map string starting from the informations stored in this class: eAbsolute and eStage
If shape is 'S', then the "Front X-Ray Mark Map or Optical Mark Map" format is assumed
If shape is 'L', then the "Lateral X-Ray Mark Map" format is assumed

541{
545
546 FILE *fp = fopen( file,"w");
547
548 TString str_header;
549 TString str_mark;
550
551 if (shape=='S'||shape=='X') {
552 str_header = "mapext:_%ld_%02d_0_0;_%d_%.4f_%.4f_%.4f_%.4f";
553 str_mark = ";_%d_%0.0f_%0.0f_%0.0f_%0.0f_1_1_%d";
554 } else if (shape=='L') {
555 str_header = "mapx:_%ld_%02d_0_0;_%d_%.4f_%.4f_%.4f_%.4f";
556 str_mark = ";_%d_%0.0f_%0.0f_%0.0f_%0.0f_1_1_%d";
557 } else {
558 Log(1,"EdbMarksSet::WriteMap2","ERROR: shape '%c' is not implemented\n", shape); return 0;
559 }
560
561 ChangeMapStringSpacer(str_header,'_',spacer);
562 ChangeMapStringSpacer(str_mark,'_',spacer);
563
564 if(!fp)
565 { Log(1,"EdbMarksSet::WriteMap2","ERROR: can not open file %s\n", file); return 0; }
566
567 int nmarksAbs = GetAbsolute()->GetN();
568 int nmarksSt = GetStage()->GetN();
569 if(nmarksAbs!=nmarksSt)
570 {
571 Log(1,"EdbMarksSet::WriteMap2","ERROR: nmarksAbs != nmarksSt: %d %d use only Abs!\n", nmarksAbs, nmarksSt );
572 return 0;
573 };
574
575 fprintf(fp, str_header.Data(), eBrick,plate,nmarksAbs,eXmin,eYmin,eXmax,eYmax);
576
577 for (int imarks=0;imarks<nmarksAbs;imarks++)
578 {
579 EdbMark *markAbs = GetAbsolute()->GetMark(imarks);
580 EdbMark *markSt = 0;
581 if(nmarksAbs!=nmarksSt) markSt = markAbs;
582 else markSt = GetStage()->GetMark(imarks);
583 fprintf(fp, str_mark.Data(), markAbs->GetID(),markAbs->GetX(),markAbs->GetY(),markSt->GetX(),markSt->GetY(),markAbs->Flag());
584 }
585
586 fclose(fp);
587
588 Log(3,"EdbMarksSet::WriteMap2","%d marks are written as string map in the file %s\n", nmarksAbs, file);
589 return nmarksAbs;
590}

Member Data Documentation

◆ eAbsolute

EdbMarksBox* EdbMarksSet::eAbsolute
private

fiducial marks in absolute coord ($b)

◆ eBrick

Long_t EdbMarksSet::eBrick

◆ eStage

EdbMarksBox* EdbMarksSet::eStage
private

fiducial marks in stage coord ($a)

◆ eXmax

Float_t EdbMarksSet::eXmax

◆ eXmin

Float_t EdbMarksSet::eXmin

◆ eYmax

Float_t EdbMarksSet::eYmax

◆ eYmin

Float_t EdbMarksSet::eYmin

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