FEDRA emulsion software from the OPERA Collaboration
setSegment.C File Reference

Functions

void a2v (float xa, float ya, EdbMarksSet *mark, EdbView *v, float *xv, float *yv)
 
int even (const int n)
 
void setSegment (const char *file, const char *pred_file=0, const int NumAcq=20, const int NumOfViews=0, const int firstView=0)
 

Function Documentation

◆ a2v()

void a2v ( float  xa,
float  ya,
EdbMarksSet mark,
EdbView v,
float *  xv,
float *  yv 
)
209{
210// EdbRun r(file);
211
212// EdbMarksSet* mark = r->GetMarks();
213//mark->Print();
214
215float a11 = (mark->Abs2Stage()->A11() ); //Perform Stage to Absolute coordinates transform
216float a12 = (mark->Abs2Stage()->A12() ); //Abs2Stage is a pointer to EdbAffine2D
217float a21 = (mark->Abs2Stage()->A21() );
218float a22 = (mark->Abs2Stage()->A22() );
219float b1 = (mark->Abs2Stage()->B1() );
220float b2 = (mark->Abs2Stage()->B2() );
221
222float xs = a11*xa+a12*ya + b1;
223float ys = a21*xa+a22*ya + b2;
224
225//EdbView *v = r.GetEntry(0,1,1,1,1,1);
226EdbViewHeader *vh = v->GetHeader();
227float xV = vh->GetXview();
228float yV = vh->GetYview();
229
230 *xv = xs - xV;
231 *yv = ys - yV;
232
233printf("xa=%f, ya=%f, xv=%f , yv=%f \n",xa,ya,*xv,*yv);
234}
Float_t B2() const
Definition: EdbAffine.h:48
Float_t A22() const
Definition: EdbAffine.h:46
Float_t A21() const
Definition: EdbAffine.h:45
Float_t A12() const
Definition: EdbAffine.h:44
Float_t B1() const
Definition: EdbAffine.h:47
Float_t A11() const
Definition: EdbAffine.h:43
EdbAffine2D * Abs2Stage() const
Definition: EdbFiducial.cxx:271
view identification
Definition: EdbView.h:26
Float_t GetXview() const
Definition: EdbView.h:93
Float_t GetYview() const
Definition: EdbView.h:94
EdbViewHeader * GetHeader() const
Definition: EdbView.h:163

◆ even()

int even ( const int  n)
4{
5 return !(n&1);
6}

◆ setSegment()

void setSegment ( const char *  file,
const char *  pred_file = 0,
const int  NumAcq = 20,
const int  NumOfViews = 0,
const int  firstView = 0 
)
9{
10 char NewRootFile[255],
11 TextFile[255],
12 TextFileTop[255],
13 TextFileBot[255];
14// buf[255];
15// strncpy(NewRootFile,file,strlen(file)-5);
16// Cpy(NewRootFile,file,strlen(file)-5);
17 sprintf(NewRootFile,"%s",file);
18 sprintf(NewRootFile+strlen(file)-5,"%s\0","+seg.root");
19 cout<<strlen(NewRootFile)<<endl;
20// cout<<NewRootFile<<endl;
21// Append(NewRootFile,"+seg.root");
22// strcat(NewRootFile,"+seg.root");
23 cout<<NewRootFile<<endl;
24 sprintf(TextFile,"%s",file);
25 sprintf(TextFile+strlen(file)-5,"%s\0",".txt");
26
27 sprintf(TextFileTop,"%s",file);
28 sprintf(TextFileTop+strlen(file)-5,"%s\0","_top.txt");
29
30 sprintf(TextFileBot,"%s",file);
31 sprintf(TextFileBot+strlen(file)-5,"%s\0","_bot.txt");
32
33// Cpy(TextFile,file,strlen(file)-5);
34// Append(TextFile,".txt");
35 cout<<TextFile<<endl;
36// strcat(strncpy(NewRootFile,file,strlen(file)-5),"+seg.root");
37// strcat(strncpy(TextFile,file,strlen(file)-5),".txt");
38 EdbRun *run = new EdbRun(file,"READ");
39 EdbMarksSet* mark = run->GetMarks();
40 EdbRun *rnew = new EdbRun(*run,NewRootFile); //"test_Jun_2004_5.64+seg.root");
41 rnew->Save();
42 FILE *f=fopen(TextFile,"w"); //("test_Jun_2004_5.64.txt","w");
43 FILE *ftop=fopen(TextFileTop,"w");
44 FILE *fbot=fopen(TextFileBot,"w");
45 FILE *fpred=NULL;
46 int npr = 0;
47 int nv;
48 if (pred_file) fpred = fopen(pred_file,"rt");
49 if (fpred) {
50 if (!fscanf(fpred,"%d",&npr)) npr = 0;
51 }
52 printf("npr=%d\n",npr);
53 int nEntries = run->GetEntries();
54 if (npr) nv = npr*2*NumAcq;
55 else nv = nEntries;
56 if (nv>nEntries) nv = nEntries;
57 if ((NumOfViews>0)&&(NumOfViews+firstView<nv)) nv = NumOfViews+firstView;
58 EdbSegment *s = 0;
59 EdbCluster *c = 0;
60// TClonesArray *cls = 0;
61 EdbView* v=0;
62 fprintf(f,"view,sID,X,Y,Z,Tx,Ty,puls,side\n");
63 fprintf(ftop,"view,sID,X,Y,Z,Tx,Ty,puls,side\n");
64 fprintf(fbot,"view,sID,X,Y,Z,Tx,Ty,puls,side\n");
65 float Xpred[2], Ypred[2], tgXpr[2], tgYpr[2];
66 int cPred = -1;
67 int ner=0;
68 for (int j=firstView; j<nv; j++) {
69 v = run->GetEntry(j,1,1,0,0,1);
71// float S=0.147;
72 float Sx=0.1486;
73 float Sy=0.1488;
74 int pulsthres = 10;
75 float accept = 1.;
76
77 float tgxmin = -0.050;
78 float tgxmax = 0.050;
79 float tgymin = -0.050;
80 float tgymax = 0.050;
81 float tgstep = 0.005;
82
83 float xmin = -15.;
84 float xmax = 15.;
85 float ymin = -15.;
86 float ymax = 15.;
87
88 float xpr, ypr, tgxpr, tgypr;
89 int idpr,pulspr;
90
91 if (fpred) for(;cPred<j/(2*NumAcq);cPred++) {
92 ner = 0;
93 char b[2];
94// cPred = j/(2*NumAcq);
95 fscanf(fpred,"%f %f %f %f %d %d",&xpr,&ypr,&tgxpr,&tgypr,&idpr,&pulspr);
96// fread((void *)buf,sizeof(char),255,fpred);
97 for(int l=0;l<2;l++) {
98 if (fscanf(fpred,"%s %f %f %f %f %d %d", b,&xpr,&ypr,&tgxpr,&tgypr,&idpr,&pulspr)==7) {
99 cout<<b[0]<<" "<<xpr<<" "<<ypr<<endl;
100// ner = 1;
101 if (toupper(b[0])=='T') {
102 Xpred[0] = xpr;
103 Ypred[0] = ypr;
104 tgXpr[0] = tgxpr;
105 tgYpr[0] = tgypr;
106 ner=1;
107 }
108 else if (toupper(b[0])=='B') {
109 Xpred[1] = xpr;
110 Ypred[1] = ypr;
111 tgXpr[1] = tgxpr;
112 tgYpr[1] = tgypr;
113 ner=1;
114 }
115 else printf("<<<<<<<<<< UNKNOWN PREDICTION FILE FORMAT! >>>>>>>>>>>>>>\n");
116 }
117 else
118 printf("<<<<<<<<<< UNKNOWN PREDICTION FILE FORMAT >>>>>>>>>>>>>>\n");
119 }
120 }
121 if (ner) {
122 float xv,yv;
123 if (v->GetNframesTop()) {
124 a2v(Xpred[0],Ypred[0],mark,v,&xv,&yv);
125
126 tgxmin = tgXpr[0]-0.050;
127 tgxmax = tgXpr[0]+0.050;
128 tgymin = tgYpr[0]-0.050;
129 tgymax = tgYpr[0]+0.050;
130
131
132 xmin = xv-30.;
133 xmax = xv+30.;
134 ymin = yv-30.;
135 ymax = yv+30.;
136 }
137 else {
138 a2v(Xpred[1],Ypred[1],mark,v,&xv,&yv);
139
140 tgxmin = tgXpr[1]-0.050;
141 tgxmax = tgXpr[1]+0.050;
142 tgymin = tgYpr[1]-0.050;
143 tgymax = tgYpr[1]+0.050;
144
145
146 xmin = xv-30.;
147 xmax = xv+30.;
148 ymin = yv-30.;
149 ymax = yv+30.;
150 }
151 }
152 cout<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax<<" "<<tgxmin<<" "<<tgxmax<<" "<<tgymin<<" "<<tgymax<<endl<<endl;
153
155
157 TBinTracking *tr = new TBinTracking(tgxmin,tgxmax,tgymin,tgymax,tgstep);
158// TBinTracking *tr = new TBinTracking(tgxmin,tgxmax,tgymin,tgymax,tgstep,0.1,0.1,1.6);
159// ConfigData *Cfg;
160// EstValue(Cfg);
161 EdbView* vnew = tr->AdoptSegment(v,Sx,Sy,xmin,xmax,ymin,ymax,1.7*Sx,pulsthres,accept,1,1,1); //0.3);
162//inside comcluster rep
164 int nseg = vnew->Nsegments();
165// int nclust = vnew->Nclusters();
166 printf("View number=%d, nseg=%d, xView=%f, yView=%f \n",j,nseg,v->GetXview(),v->GetYview());
167 fprintf(f,"View number=%d, nseg=%d \n",j,nseg);
168 for (int i=0; i<nseg; i++) {
169 s = vnew->GetSegment(i);
170 s->Print();
171 fprintf(f,"%d , %d , %f , %f , %f , %f , %f , %d , %d\n",j,s->GetID(),s->GetX0(),s->GetY0(),s->GetZ0(),s->GetTx(),s->GetTy(),s->GetPuls(),s->GetSide());
172 if (even(j)) fprintf(ftop,"%d , %d , %f , %f , %f , %f , %f , %d , %d\n",j,s->GetID(),s->GetX0(),s->GetY0(),s->GetZ0(),s->GetTx(),s->GetTy(),s->GetPuls(),s->GetSide());
173 else fprintf(fbot,"%d , %d , %f , %f , %f , %f , %f , %d , %d\n",j,s->GetID(),s->GetX0(),s->GetY0(),s->GetZ0(),s->GetTx(),s->GetTy(),s->GetPuls(),s->GetSide());
174 int nclust =s->GetNelements();
175 int nn=1;
176 for (int ic=0; ic<nclust; ic++) {
177 c = (EdbCluster *)(s->GetElements()->At(ic));
178// if (c->GetSegment()==s->GetID()) {
179 printf("<<<<<<<< %d: X=%f, Y=%f, Z=%f\n", ic+1, c->GetX(), c->GetY(), c->GetZ());
180 fprintf(f,"<<<<<<<< %d: X=%f, Y=%f, Z=%f\n", ic+1, c->GetX(), c->GetY(), c->GetZ());
181 nn++;
182// }
183 }
184 printf("\n");
185 fprintf(f,"\n");
186// _getch();
187 }
188
189// run->Close();
190
191// delete vnew;
192 rnew->AddView(vnew);
193 rnew->Save();
194 delete tr;
195 }
196 fclose(f);
197 fclose(ftop);
198 fclose(fbot);
199 if (fpred) fclose(fpred);
200 rnew->Close();
201// run->Close();
202
203// return 0;
204}
FILE * f
Definition: RecDispMC.C:150
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
Definition: EdbCluster.h:19
Float_t GetX() const
Definition: EdbCluster.h:51
Float_t GetY() const
Definition: EdbCluster.h:52
Float_t GetZ() const
Definition: EdbCluster.h:53
Definition: EdbFiducial.h:88
Definition: EdbRun.h:75
void Close()
Definition: EdbRun.cxx:439
int GetEntries() const
Definition: EdbRun.h:136
void Save()
Definition: EdbRun.cxx:424
EdbMarksSet * GetMarks() const
Definition: EdbRun.h:120
EdbView * GetEntry(int entry, int ih=1, int icl=0, int iseg=1, int itr=0, int ifr=0)
Definition: EdbRun.cxx:462
void AddView()
Definition: EdbRun.cxx:305
segment of the track
Definition: EdbSegment.h:63
Base scanning data object: entry into Run tree.
Definition: EdbView.h:134
Float_t GetXview() const
Definition: EdbView.h:193
EdbSegment * GetSegment(int i) const
Definition: EdbView.h:219
Int_t GetNframesTop() const
Definition: EdbView.h:207
Int_t Nsegments() const
Definition: EdbView.h:216
Float_t GetYview() const
Definition: EdbView.h:194
Definition: bitview.h:62
EdbRun * run
Definition: check_raw.C:38
s
Definition: check_shower.C:55
TFile * file
Definition: write_pvr.C:3
fclose(pFile)
#define NULL
Definition: nidaqmx.h:84
void a2v(float xa, float ya, EdbMarksSet *mark, EdbView *v, float *xv, float *yv)
Definition: setSegment.C:208
int even(const int n)
Definition: setSegment.C:3