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[] 
)
54{
55 if (argc < 2) { print_help_message(); return 0; }
56
57 TEnv cenv("alignenv");
59 gEDBDEBUGLEVEL = cenv.GetValue("emalign.EdbDebugLevel" , 1);
60 const char *env = cenv.GetValue("emalign.env" , "align.rootrc");
61 const char *outdir = cenv.GetValue("emalign.outdir" , "..");
62
63 bool do_ida = false;
64 bool do_idb = false;
65 bool do_new = false; // apply new alignment algorithm
66 bool do_set = false;
67 bool do_check = false;
68 bool do_makeAff = false;
69 bool do_readAff = false;
70 Int_t brick=0, plate=0, major=0, minor=0;
71 Int_t npre=0, nfull=0;
72 EdbID idA,idB;
73
74 for(int i=1; i<argc; i++ ) {
75 char *key = argv[i];
76
77 if (!strncmp(key,"-A=",3))
78 {
79 if(strlen(key)>3) sscanf(key+3,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
80 idA.Set(brick,plate,major,minor);
81 do_ida=true;
82 }
83 else if(!strncmp(key,"-B=",3))
84 {
85 if(strlen(key)>3) sscanf(key+3,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
86 idB.Set(brick,plate,major,minor);
87 do_idb=true;
88 }
89 else if(!strncmp(key,"-set=",5))
90 {
91 if(strlen(key)>5) sscanf(key+5,"%d.%d.%d.%d",&brick,&plate,&major,&minor);
92 do_set=true;
93 }
94 else if(!strncmp(key,"-new",4))
95 {
96 do_new=true;
97 }
98 else if(!strncmp(key,"-check",6))
99 {
100 do_check=true;
101 }
102 else if(!strncmp(key,"-env=",5))
103 {
104 if(strlen(key)>5) env=key+5;
105 }
106 else if(!strncmp(key,"-o=",3))
107 {
108 if(strlen(key)>3) outdir = key+3;
109 }
110 else if(!strncmp(key,"-p=",3))
111 {
112 if(strlen(key)>3) npre = atoi(key+3);
113 }
114 else if(!strncmp(key,"-f=",3))
115 {
116 if(strlen(key)>3) nfull = atoi(key+3);
117 }
118 else if(!strncmp(key,"-v=",3))
119 {
120 if(strlen(key)>3) gEDBDEBUGLEVEL = atoi(key+3);
121 }
122 else if(!strncmp(key,"-m",2))
123 {
124 do_makeAff=true;
125 }
126 else if(!strncmp(key,"-readaff",8))
127 {
128 do_readAff=true;
129 }
130 }
131
132 if(!((do_ida&&do_idb)||do_set)) { print_help_message(); return 0; }
133
134 cenv.SetValue("emalign.env" , env);
135 cenv.ReadFile( cenv.GetValue("emalign.env" , "align.rootrc") ,kEnvLocal);
136 cenv.SetValue("emalign.outdir" , outdir);
137
139 sproc.eProcDirClient = cenv.GetValue("emalign.outdir","..");
140
141 if(do_ida&&do_idb) {
142 printf("\n----------------------------------------------------------------------------\n");
143 printf("align %d.%d.%d.%d and %d.%d.%d.%d\n"
144 ,idA.eBrick,idA.ePlate, idA.eMajor,idA.eMinor
145 ,idB.eBrick,idB.ePlate, idB.eMajor,idB.eMinor
146 );
147 printf("----------------------------------------------------------------------------\n\n");
148
149 if(do_new) {
150 EdbID id0=idA; id0.ePlate=0;
152 if(ss) {
153 EdbAffine2D aff;
154 float dz = -1300;
155 if(ss->GetAffP2P(idA.ePlate, idB.ePlate, aff))
156 dz = ss->GetDZP2P(idA.ePlate, idB.ePlate);
157 sproc.AlignNewNopar(idA,idB,cenv,&aff, dz);
158 }
159 }
160 else sproc.AlignAll(idA,idB, npre, nfull);
161 }
162 else if(do_set) {
163 printf("\n----------------------------------------------------------------------------\n");
164 printf("align set %d.%d.%d.%d\n", brick,plate, major,minor);
165 printf("----------------------------------------------------------------------------\n\n");
166 cenv.WriteFile("align.save.rootrc");
167
168 EdbID id(brick,plate,major,minor);
170 if(!ss) return 0;
171 ss->Brick().SetID(brick);
172 ss->MakePIDList();
173
174 if(do_makeAff) sproc.MakeAFFSet(*ss);
175 else if(do_readAff) {
177 sproc.WriteScanSet(id,*ss);
178 }
179 else if(do_new)
180 {
183 }
184 else if(do_check)
185 {
187 }
188 else sproc.AlignSet(*ss, npre, nfull);
189
190 }
191
192 cenv.WriteFile("align.save.rootrc");
193 return 1;
194}
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:19
Int_t eMinor
Definition: EdbID.h:13
Int_t ePlate
Definition: EdbID.h:11
Int_t eMajor
Definition: EdbID.h:12
scanned data processing
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:2595
int WriteScanSet(EdbID id, EdbScanSet &ss)
Definition: EdbScanProc.cxx:1428
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
void MakeAlignSetSummary(EdbID id)
Definition: EdbScanProc.cxx:2828
int AssembleScanSet(EdbScanSet &ss)
Definition: EdbScanProc.cxx:135
TString eProcDirClient
directory path for root data
Definition: EdbScanProc.h:14
EdbScanSet * ReadScanSet(EdbID id)
Definition: EdbScanProc.cxx:1482
void AlignSet(EdbID id, int npre, int nfull, const char *opt="-z")
Definition: EdbScanProc.cxx:534
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: tlg2couples.C:117

◆ 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.align.SaveCouples" , 1 );
47
48 cenv.SetValue("emalign.outdir" , ".." );
49 cenv.SetValue("emalign.env" , "align.rootrc");
50 cenv.SetValue("emalign.EdbDebugLevel" , 1 );
51}