FEDRA emulsion software from the OPERA Collaboration
emalign.cpp File Reference
#include <string.h>
#include <iostream>
#include <TRint.h>
#include <TEnv.h>
#include "EdbLog.h"
#include "EdbScanProc.h"
Include dependency graph for emalign.cpp:

Functions

int main (int argc, char *argv[])
 
void print_help_message ()
 
void set_default (TEnv &cenv)
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
57 {
58  if (argc < 2) { print_help_message(); return 0; }
59 
60  TEnv cenv("alignenv");
62  gEDBDEBUGLEVEL = cenv.GetValue("emalign.EdbDebugLevel" , 1);
63  const char *env = cenv.GetValue("emalign.env" , "align.rootrc");
64  const char *outdir = cenv.GetValue("emalign.outdir" , "..");
65  const char *reportfileformat = cenv.GetValue("emalign.reportfileformat", "pdf");
66 
67  bool do_ida = false;
68  bool do_idb = false;
69  bool do_new = false; // apply new alignment algorithm
70  bool do_set = false;
71  bool do_check = false;
72  bool do_makeAff = false;
73  bool do_readAff = false;
74  Int_t brick=0, plate=0, major=0, minor=0;
75  Int_t npre=0, nfull=0;
76  EdbID idA,idB;
77 
78  for(int i=1; i<argc; i++ ) {
79  char *key = argv[i];
80 
81  if (!strncmp(key,"-A=",3))
82  {
83  if(strlen(key)>3) sscanf(key+3,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
84  idA.Set(brick,plate,major,minor);
85  do_ida=true;
86  }
87  else if(!strncmp(key,"-B=",3))
88  {
89  if(strlen(key)>3) sscanf(key+3,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
90  idB.Set(brick,plate,major,minor);
91  do_idb=true;
92  }
93  else if(!strncmp(key,"-set=",5))
94  {
95  if(strlen(key)>5) sscanf(key+5,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
96  do_set=true;
97  }
98  else if(!strncmp(key,"-new",4))
99  {
100  do_new=true;
101  }
102  else if(!strncmp(key,"-check",6))
103  {
104  do_check=true;
105  }
106  else if(!strncmp(key,"-env=",5))
107  {
108  if(strlen(key)>5) env=key+5;
109  }
110  else if(!strncmp(key,"-o=",3))
111  {
112  if(strlen(key)>3) outdir = key+3;
113  }
114  else if(!strncmp(key,"-p=",3))
115  {
116  if(strlen(key)>3) npre = atoi(key+3);
117  }
118  else if(!strncmp(key,"-f=",3))
119  {
120  if(strlen(key)>3) nfull = atoi(key+3);
121  }
122  else if(!strncmp(key,"-v=",3))
123  {
124  if(strlen(key)>3) gEDBDEBUGLEVEL = atoi(key+3);
125  }
126  else if(!strncmp(key,"-m",2))
127  {
128  do_makeAff=true;
129  }
130  else if(!strncmp(key,"-readaff",8))
131  {
132  do_readAff=true;
133  }
134  }
135 
136  if(!((do_ida&&do_idb)||do_set)) { print_help_message(); return 0; }
137 
138  cenv.SetValue("emalign.env" , env);
139  cenv.ReadFile( cenv.GetValue("emalign.env" , "align.rootrc") ,kEnvLocal);
140  cenv.SetValue("emalign.outdir" , outdir);
141 
143  sproc.eProcDirClient = cenv.GetValue("emalign.outdir","..");
144 
145  if(do_ida&&do_idb) {
146  printf("\n----------------------------------------------------------------------------\n");
147  printf("align %d.%d.%d.%d and %d.%d.%d.%d\n"
148  ,idA.eBrick,idA.ePlate, idA.eMajor,idA.eMinor
149  ,idB.eBrick,idB.ePlate, idB.eMajor,idB.eMinor
150  );
151  printf("----------------------------------------------------------------------------\n\n");
152 
153  if(do_new) {
154  EdbID id0=idA; id0.ePlate=0;
155  EdbScanSet *ss = sproc.ReadScanSet(id0);
156  if(ss) {
157  EdbAffine2D aff;
158  float dz = -1300;
159  if(ss->GetAffP2P(idA.ePlate, idB.ePlate, aff))
160  dz = ss->GetDZP2P(idA.ePlate, idB.ePlate);
161  sproc.AlignNewNopar(idA,idB,cenv,&aff, dz);
162  }
163  }
164  else sproc.AlignAll(idA,idB, npre, nfull);
165  }
166  else if(do_set) {
167  printf("\n----------------------------------------------------------------------------\n");
168  printf("align set %d.%d.%d.%d\n", brick,plate, major,minor);
169  printf("----------------------------------------------------------------------------\n\n");
170  cenv.WriteFile("align.save.rootrc");
171 
172  EdbID id(brick,plate,major,minor);
174  if(!ss) return 0;
175  ss->Brick().SetID(brick);
176  ss->MakePIDList();
177 
178  if(do_makeAff) sproc.MakeAFFSet(*ss);
179  else if(do_readAff) {
181  sproc.WriteScanSet(id,*ss);
182  }
183  else if(do_new)
184  {
186  sproc.MakeAlignSetSummary(id, reportfileformat);
187  }
188  else if(do_check)
189  {
190  sproc.MakeAlignSetSummary(id, reportfileformat);
191  }
192  else sproc.AlignSet(*ss, npre, nfull);
193 
194  }
195 
196  cenv.WriteFile("align.save.rootrc");
197  return 1;
198 }
brick dz
Definition: RecDispMC.C:107
BRICK brick
Definition: RecDispMC.C:103
Definition: EdbAffine.h:17
Definition: EdbID.h:7
Int_t eBrick
Definition: EdbID.h:10
bool Set(const char *id_string)
Definition: EdbID.cxx:17
Int_t eMinor
Definition: EdbID.h:13
Int_t ePlate
Definition: EdbID.h:11
Int_t eMajor
Definition: EdbID.h:12
Definition: EdbScanProc.h:12
int AlignAll(int id1[4], int id2[4], int npre=1, int nfull=3, const char *opt="-z")
Definition: EdbScanProc.cxx:2661
int WriteScanSet(EdbID id, EdbScanSet &ss)
Definition: EdbScanProc.cxx:1467
void MakeAlignSetSummary(EdbID id, const char *fileformat="pdf")
Definition: EdbScanProc.cxx:2894
bool MakeAFFSet(EdbScanSet &sc)
Definition: EdbScanProc.cxx:394
int AlignNewNopar(EdbID id1, EdbID id2, TEnv &cenv, EdbAffine2D *aff=0, float dz=0)
Definition: EdbScanProc.cxx:485
int AssembleScanSet(EdbScanSet &ss)
Definition: EdbScanProc.cxx:134
TString eProcDirClient
Definition: EdbScanProc.h:14
EdbScanSet * ReadScanSet(EdbID id)
Definition: EdbScanProc.cxx:1521
void AlignSet(EdbID id, int npre, int nfull, const char *opt="-z")
Definition: EdbScanProc.cxx:574
int AlignSetNewNopar(EdbScanSet &sc, TEnv &cenv)
Definition: EdbScanProc.cxx:464
Definition: EdbScanSet.h:11
EdbScanProc * sproc
Definition: comptonmap.cpp:29
void set_default(TEnv &cenv)
Definition: emalign.cpp:36
void print_help_message()
Definition: emalign.cpp:12
TEnv cenv("emrec")
bool do_set
Definition: emrec.cpp:36
const char * outdir
Definition: emrec.cpp:37
gEDBDEBUGLEVEL
Definition: energy.C:7
ss
Definition: energy.C:62
Int_t plate
Definition: merge_Energy_SytematicSources_Electron.C:1
UInt_t id
Definition: tlg2pattern.C:118

◆ print_help_message()

void print_help_message ( )
13 {
14  cout<< "\nUsage: \n\t emalign -A=idA -B=idB[-p=NPRE -f=NFULL -o=DATA_DIRECTORY -v=DEBUG] \n";
15  cout<< "\t emalign -set=ID [-p=NPRE -f=NFULL -o=DATA_DIRECTORY -v=DEBUG -m -env=PARFILE] \n\n";
16  cout<< "\t\t idA - id of the first piece formed as BRICK.PLATE.MAJOR.MINOR \n";
17  cout<< "\t\t idB - id of the second piece formed as BRICK.PLATE.MAJOR.MINOR \n";
18  cout<< "\t\t ID - id of the dataset formed as BRICK.PLATE.MAJOR.MINOR \n";
19  cout<< "\t\t NPRE - number of the prealignments (default is 0)\n";
20  cout<< "\t\t NFULL - number of the fullalignments (default is 0)\n";
21  cout<< "\t\t DEBUG - verbosity level: 0-print nothing, 1-errors only, 2-normal, 3-print all messages\n";
22  cout<< "\t\t PARFILE - for the new alignment: take parameters from here (default: align.rootrc)\n";
23  cout<< "\t\t -m - make the affine files starting from EdbScanSet\n";
24  cout<< "\t\t -new - use the new alignment\n";
25  cout<< "\t\t -check - check the alignment\n";
26  cout<< "\t\t -readaff - read par files and update set file\n";
27  cout<< "\nExample: \n";
28  cout<< "\t emalign -set=4554.0.1.1 -o=/scratch/BRICKS -new -v2\n";
29  cout<< "\n If the data location directory if not explicitly defined\n";
30  cout<< " the current directory will be assumed to be the brick directory \n";
31  cout<< "\n If the parameters file (align.rootrc) is not presented - the default \n";
32  cout<< " parameters will be used. After the execution them are saved into align.save.rootrc file\n";
33  cout<<endl;
34 }

◆ set_default()

void set_default ( TEnv &  cenv)
37 {
38  // default parameters for the new alignment
39  cenv.SetValue("fedra.align.OffsetMax" , 1000. );
40  cenv.SetValue("fedra.align.DZ" , 250. );
41  cenv.SetValue("fedra.align.DPHI" , 0.02 );
42  cenv.SetValue("fedra.align.SigmaR" , 25. );
43  cenv.SetValue("fedra.align.SigmaT" , 0.012);
44  cenv.SetValue("fedra.align.DoFine" , 1 );
45  cenv.SetValue("fedra.readCPcut" , "eCHI2P<2.0&&s.eW>10&&eN1==1&&eN2==1&&s.Theta()>0.05&&s.Theta()<0.99");
46  cenv.SetValue("fedra.readCPcutA" , "1");
47  cenv.SetValue("fedra.readCPcutB" , "1");
48  cenv.SetValue("fedra.align.SaveCouples" , 1 );
49 
50  cenv.SetValue("emalign.outdir" , ".." );
51  cenv.SetValue("emalign.reportfileformat", "pdf");
52  cenv.SetValue("emalign.env" , "align.rootrc");
53  cenv.SetValue("emalign.EdbDebugLevel" , 1 );
54 }