FEDRA emulsion software from the OPERA Collaboration
emlink.cpp File Reference
#include <string.h>
#include <iostream>
#include <TEnv.h>
#include <TRint.h>
#include "EdbLog.h"
#include "EdbScanProc.h"
Include dependency graph for emlink.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[] 
)
88 {
89  if (argc < 2) { print_help_message(); return 0; }
90 
91  TEnv cenv("linkenv");
93  gEDBDEBUGLEVEL = cenv.GetValue("emlink.EdbDebugLevel" , 1);
94  const char *env = cenv.GetValue("emlink.env" , "link.rootrc");
95  const char *outdir = cenv.GetValue("emlink.outdir" , "..");
96 
97  bool do_id = false;
98  bool do_set = false;
99  bool do_new = false;
100  bool do_check = false;
101  bool do_check_view = false;
102  Int_t brick=0, plate=0, major=0, minor=0;
103  Int_t npre=0, nfull=0;
104  Int_t ix = -1, iy = -1; //cell numbers
105  Int_t correct_ang=0;
106 
107  for(int i=1; i<argc; i++ ) {
108  char *key = argv[i];
109 
110  if (!strncmp(key,"-id=",4))
111  {
112  if(strlen(key)>4) sscanf(key+4,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
113  do_id=true;
114  }
115  else if(!strncmp(key,"-set=",5))
116  {
117  if(strlen(key)>5) sscanf(key+5,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
118  do_set=true;
119  }
120  else if(!strncmp(key,"-o=",3))
121  {
122  if(strlen(key)>3) outdir=key+3;
123  }
124  else if(!strncmp(key,"-p=",3))
125  {
126  if(strlen(key)>3) npre = atoi(key+3);
127  }
128  else if(!strncmp(key,"-f=",3))
129  {
130  if(strlen(key)>3) nfull = atoi(key+3);
131  }
132  else if(!strncmp(key,"-a",2))
133  {
134  correct_ang=1;
135  }
136  else if(!strncmp(key,"-new",4))
137  {
138  do_new=true;
139  }
140  else if(!strncmp(key,"-check",6))
141  {
142  do_check=true;
143  }
144  else if(!strncmp(key,"-view",5))
145  {
146  do_check_view=true;
147  }
148  else if(!strncmp(key,"-v=",3))
149  {
150  if(strlen(key)>3) gEDBDEBUGLEVEL = atoi(key+3);
151  }
152  else if(!strncmp(key,"-ix=",4))
153  {
154  if(strlen(key)>4) ix = atoi(key+4);
155  }
156  else if(!strncmp(key,"-iy=",4))
157  {
158  if(strlen(key)>4) iy = atoi(key+4);
159  }
160  }
161 
162  if(!(do_id||do_set)) { print_help_message(); return 0; }
163 
164  cenv.SetValue("emlink.env" , env);
165  cenv.ReadFile( cenv.GetValue("emlink.env" , "link.rootrc") ,kEnvLocal);
166 
167  const char* reportfileformat = cenv.GetValue("emlink.reportfileformat","pdf");
168  cenv.SetValue("emlink.outdir" , outdir);
169  cenv.WriteFile("link.save.rootrc");
170 
171 
174  if(do_id) {
175  printf("\n----------------------------------------------------------------------------\n");
176  printf("link run with id= %d.%d.%d.%d\n", brick,plate, major,minor);
177  printf("----------------------------------------------------------------------------\n\n");
178 
179  EdbID id(brick,plate,major,minor);
180  if(do_new) {
181  EdbID id0=id; id0.ePlate=0;
182  EdbScanSet *ss = sproc.ReadScanSet(id0);
183  if(ss) {
184  EdbPlateP *plate = ss->GetPlate(id.ePlate);
185  printf("test0, %d, %d",ix,iy);
186  if(plate) sproc.LinkRunTest(id, *plate, cenv, ix, iy);
187  }
188  }
189  else if(do_check_view) sproc.CheckViewOverlaps(id, cenv);
190  else if(npre+nfull>0) sproc.LinkRunAll(id, npre, nfull, correct_ang);
191  }
192  if(do_set) {
193  printf("\n----------------------------------------------------------------------------\n");
194  printf("link set with id= %d.%d.%d.%d\n", brick,plate, major,minor);
195  printf("----------------------------------------------------------------------------\n\n");
196 
197  EdbID id(brick,plate,major,minor);
199  if(ss) {
200  if(do_new) {
201  sproc.LinkSetNewTest(*ss, cenv, ix, iy);
202  sproc.MakeLinkSetSummary(id, reportfileformat);
203  }
204  else if(npre+nfull>0) sproc.LinkSet(*ss, npre, nfull, correct_ang);
205  }
206 
207  if(do_check)
208  {
209  //int argc2=1;
210  //char *argv2[]={"-l"};
211  //TRint app("APP",&argc2, argv2);
212  sproc.MakeLinkSetSummary(id, reportfileformat);
213  //app.Run();
214  }
215  }
216  cenv.WriteFile("link.save.rootrc");
217 
218  return 1;
219 }
BRICK brick
Definition: RecDispMC.C:103
Definition: EdbID.h:7
Int_t ePlate
Definition: EdbID.h:11
Definition: EdbBrick.h:13
Definition: EdbScanProc.h:12
int LinkSet(EdbScanSet &sc, int npre=3, int nfull=1, int correct_ang=1)
Definition: EdbScanProc.cxx:662
void MakeLinkSetSummary(EdbID id, const char *fileformat="pdf")
Definition: EdbScanProc.cxx:2976
void CheckViewOverlaps(EdbID id, TEnv &cenv)
Definition: EdbScanProc.cxx:3305
void LinkSetNewTest(EdbScanSet &sc, TEnv &cenv, Int_t ix=-1, Int_t iy=-1)
Definition: EdbScanProc.cxx:3345
void LinkRunTest(EdbID id, EdbPlateP &plate, TEnv &cenv, Int_t ix=-1, Int_t iy=-1)
Definition: EdbScanProc.cxx:3204
int LinkRunAll(int id[4], int npre=3, int nfull=1, int correct_ang=1)
Definition: EdbScanProc.cxx:1104
TString eProcDirClient
Definition: EdbScanProc.h:14
EdbScanSet * ReadScanSet(EdbID id)
Definition: EdbScanProc.cxx:1521
Definition: EdbScanSet.h:11
EdbScanProc * sproc
Definition: comptonmap.cpp:29
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 ( )
14 {
15  cout<< "\nUsage: \n\t emlink -id=ID [-p=NPRE -f=NFULL -o=DATA_DIRECTORY -a -v=DEBUG] \n";
16  cout<< "\t emlink -set=ID [-p=NPRE -f=NFULL -o=DATA_DIRECTORY -a -v=DEBUG] \n\n";
17  cout<< "\t\t ID - id of the data piece or dataset formed as BRICK.PLATE.MAJOR.MINOR \n";
18  cout<< "\t\t NPRE - number of the prealignments (default is 0)\n";
19  cout<< "\t\t NFULL - number of the fullalignments (default is 0)\n";
20  cout<< "\t\t -a - apply the angular correction when do prelinking (default is not)\n";
21  cout<< "\t\t -new - new linking (renewed 06-04-11)\n";
22  cout<< "\t\t -view - check view overlaps\n";
23  cout<< "\t\t DEBUG - verbosity level: 0-print nothing, 1-errors only, 2-normal, 3-print all messages\n";
24  cout<< "\t\t -ix - x cell bin\n";
25  cout<< "\t\t -iy - y cell bin\n";
26  cout<< "\nExample: \n";
27  cout<< "\t emlink -id=4554.10.1.0 -o=/scratch/BRICKS \n";
28  cout<< "\n If the data location directory is not explicitly defined\n";
29  cout<< " the current directory assumed to be the brick directory \n";
30  cout<< "\n If the parameters file (link.rootrc) is not presented - the default \n";
31  cout<< " parameters are used. After the execution them will be saved into link.save.rootrc\n";
32  cout<<endl;
33 }

◆ set_default()

void set_default ( TEnv &  cenv)
37 {
38  // default parameters for the new linking
39  cenv.SetValue("fedra.link.AFID" , 1 ); // 1 is usually fine for scanned data; for the db-read data use 0!
40  cenv.SetValue("fedra.link.DoImageCorr" , 0 );
41  cenv.SetValue("fedra.link.ImageCorrSide1" , "1. 1. 0.");
42  cenv.SetValue("fedra.link.ImageCorrSide2" , "1. 1. 0.");
43 
44  cenv.SetValue("fedra.link.DoImageMatrixCorr" , 0 );
45  cenv.SetValue("fedra.link.ImageMatrixCorrSide1" , "");
46  cenv.SetValue("fedra.link.ImageMatrixCorrSide2" , "");
47 
48  cenv.SetValue("fedra.link.CheckUpDownOffset" , 1 ); // check dXdY offsets between up and correspondent down views
49  cenv.SetValue("fedra.link.BinOK" , 6. );
50  cenv.SetValue("fedra.link.NcorrMin" , 100 );
51  cenv.SetValue("fedra.link.DoCorrectShrinkage" , true );
52  cenv.SetValue("fedra.link.read.InvertSides" , 0 );
53  cenv.SetValue("fedra.link.read.HeaderCut" , "1" );
54  cenv.SetValue("fedra.link.read.UseDensityAsW" , false );
55  cenv.SetValue("fedra.link.read.ICUT" , "-1 -500. 500. -500. 500. -1. 1. -1. 1. 0. 50.");
56  cenv.SetValue("fedra.link.RemoveDoublets" , "1 5. .1 1"); //yes/no dr dt checkview(0,1,2)
57  cenv.SetValue("fedra.link.DumpDoubletsTree" , false );
58  cenv.SetValue("fedra.link.shr.NsigmaEQ" , 7.5 );
59  cenv.SetValue("fedra.link.shr.Shr0" , .9 );
60  cenv.SetValue("fedra.link.shr.DShr" , .3 );
61  cenv.SetValue("fedra.link.shr.ThetaLimits" ,"0.005 1.");
62  cenv.SetValue("fedra.link.DoCorrectAngles" , true );
63  cenv.SetValue("fedra.link.ang.Chi2max" , 1.5 );
64  cenv.SetValue("fedra.link.DoFullLinking" , true );
65  cenv.SetValue("fedra.link.full.NsigmaEQ" , 5.5 );
66  cenv.SetValue("fedra.link.full.DR" , 30. );
67  cenv.SetValue("fedra.link.full.DT" , 0.1 );
68  cenv.SetValue("fedra.link.full.CHI2Pmax" , 3. );
69  cenv.SetValue("fedra.link.DoSaveCouples" , true );
70  cenv.SetValue("fedra.link.DumpDoubletsTree" , false);
71  cenv.SetValue("fedra.link.Sigma0" , "1 1 0.013 0.013");
72  cenv.SetValue("fedra.link.PulsRamp0" , "6 9");
73  cenv.SetValue("fedra.link.PulsRamp04" , "6 9");
74  cenv.SetValue("fedra.link.Degrad" , 5 );
75 
76  cenv.SetValue("fedra.link.LLfunction" , "0.256336-0.16489*x+2.11098*x*x" );
77  cenv.SetValue("fedra.link.CPRankingAlg" , 0 );
78 
79  cenv.SetValue("emlink.reportfileformat" , "pdf" );
80 
81  cenv.SetValue("emlink.outdir" , "..");
82  cenv.SetValue("emlink.env" , "link.rootrc");
83  cenv.SetValue("emlink.EdbDebugLevel" , 1);
84 }