FEDRA emulsion software from the OPERA Collaboration
EdbCorrectionMapper Class Reference

to calculate correction map More...

#include <EdbCorrectionMapper.h>

Inheritance diagram for EdbCorrectionMapper:
Collaboration diagram for EdbCorrectionMapper:

Public Member Functions

void AddSegCouple (EdbSegP *s1, EdbSegP *s2)
 
void CalculateCorrections ()
 
TCanvasDrawMap (EdbCorrectionMap &map, const char *suffix="")
 
TCanvasDrawSum (const char *suffix)
 
 EdbCorrectionMapper ()
 
void Fill (EdbSegP &s1, EdbSegP &s2)
 
void FillS (EdbSegP *s1, EdbSegP *s2)
 
EdbCorrectionBinGetBin (float x, float y)
 
EdbCorrectionBinGetBin (int i)
 
int InitMap (int nx, float minx, float maxx, int ny, float miny, float maxy)
 
void MakeCorrectionsTable ()
 
EdbH2MapDV (int ivar)
 
EdbH2MapDZ ()
 
void SetCorrDZ ()
 
void SmoothCorrections ()
 
void UpdateLayerWithLocalCorr (EdbLayer &la)
 
void Write (const char *suffix="")
 
virtual ~EdbCorrectionMapper ()
 
- Public Member Functions inherited from EdbCorrectionBin
void AddBin (EdbCorrectionBin &bin)
 
virtual void AddSegCouple (EdbSegP *s1, EdbSegP *s2)
 
virtual void CalculateCorrections ()
 
 EdbCorrectionBin ()
 
virtual ~EdbCorrectionBin ()
 

Public Attributes

EdbH2 eHdtxy
 dtxdty More...
 
EdbH2 eHdty_ty
 
EdbH2 eHdxy
 dxdy More...
 
EdbH1 eHdz
 dz More...
 
EdbH1 eHshr
 
EdbH2 eHtxty1
 
EdbH2 eHtxty2
 
EdbH2 eHxy1
 
EdbH2 eHxy2
 
EdbID eID1
 
EdbID eID2
 
EdbCorrectionMap eMap
 result: corrections map More...
 
EdbCell2 eMapAl
 working object with local alignments More...
 
int eNcpMin
 min number of coincidences to accept correction More...
 
float eZ1
 
float eZ2
 
- Public Attributes inherited from EdbCorrectionBin
EdbAlignmentV eAl
 
EdbLayer eLayer
 

Detailed Description

to calculate correction map

Constructor & Destructor Documentation

◆ EdbCorrectionMapper()

EdbCorrectionMapper::EdbCorrectionMapper ( )
59{
60 eNcpMin = 100;
61}
int eNcpMin
min number of coincidences to accept correction
Definition: EdbCorrectionMapper.h:50

◆ ~EdbCorrectionMapper()

EdbCorrectionMapper::~EdbCorrectionMapper ( )
virtual
64{
65}

Member Function Documentation

◆ AddSegCouple()

void EdbCorrectionMapper::AddSegCouple ( EdbSegP s1,
EdbSegP s2 
)
virtual

Reimplemented from EdbCorrectionBin.

299{
301 EdbCorrectionBin *bin = GetBin(s1->X(),s1->Y());
302 if(bin) bin->AddSegCouple(s1,s2);
303}
corrections bin
Definition: EdbCorrectionMapper.h:11
virtual void AddSegCouple(EdbSegP *s1, EdbSegP *s2)
Definition: EdbCorrectionMapper.h:22
EdbCorrectionBin * GetBin(int i)
Definition: EdbCorrectionMapper.h:57
Float_t X() const
Definition: EdbSegP.h:173
Float_t Y() const
Definition: EdbSegP.h:174
EdbSegP * s1
Definition: tlg2couples.C:29
EdbSegP * s2
Definition: tlg2couples.C:30

◆ CalculateCorrections()

void EdbCorrectionMapper::CalculateCorrections ( )
virtual

Reimplemented from EdbCorrectionBin.

94{
96 int n=eMapAl.Ncell();
97 for(int i=0;i<n; i++) {
98 EdbCorrectionBin *bin = GetBin(i);
100 }
101}
virtual void CalculateCorrections()
Definition: EdbCorrectionMapper.cxx:47
EdbCell2 eMapAl
working object with local alignments
Definition: EdbCorrectionMapper.h:34
int Ncell() const
Definition: EdbCell2.h:49

◆ DrawMap()

TCanvas * EdbCorrectionMapper::DrawMap ( EdbCorrectionMap map,
const char *  suffix = "" 
)
168{
169 TCanvas *corrmap = new TCanvas( Form("corrmap_%s",suffix), Form("corrmap_%s %s -> %s: %d",suffix, eID1.AsString(), eID2.AsString(), map.Ncp() ), 800,800 );
170 corrmap->SetRightMargin(0.14);
171 corrmap->SetLeftMargin(0.08);
172 corrmap->SetFillColor(3);
173 TH2F *h2f = map.DrawH2( Form("mapDZ_%s" ,suffix), corrmap->GetTitle() );
174 h2f->GetXaxis()->SetLabelSize(0.025);
175 h2f->GetYaxis()->SetLabelSize(0.025);
176 h2f->GetZaxis()->SetLabelSize(0.025);
177
178 int n=map.Ncell();
179 for( int i=0; i<n; i++ ) {
180 EdbSegCorr scorr = map.CorrLoc(i);
181 h2f->Fill(map.Xj(i), map.Yj(i), scorr.V(2)-1);
182 }
183 h2f->Draw("colz");
184
185 float xbin = map.Xbin();
186 float ybin = map.Ybin();
187 float scalexy = 300.;
188 float scaletxty = 100000.;
189 for( int i=0; i<n; i++ ) {
190 EdbSegCorr scorr = map.CorrLoc(i);
191 if(map.GetLayer(i)->Ncp()>0) {
192 float dx = scorr.V(0);
193 float dy = scorr.V(1);
194 float dtx = scorr.V(3);
195 float dty = scorr.V(4);
196
197 float x = map.Xj(i);
198 float y = map.Yj(i);
199
200 TArrow *arrowxy = new TArrow(x,y,x+scalexy*dx,y+scalexy*dy,0.005);
201 arrowxy->SetLineWidth(2);
202 arrowxy->SetLineColor(1);
203 arrowxy->Draw();
204
205 TArrow *arrowtxty = new TArrow(x,y,x+scaletxty*dtx,y+scaletxty*dty,0.005);
206 arrowtxty->SetLineWidth(2);
207 arrowtxty->SetLineColor(0);
208 arrowtxty->Draw();
209
210 TText *t = new TText(x-xbin/3,y-ybin/2.5,Form("%d",map.GetLayer(i)->Ncp()));
211 t->SetTextSize(0.02);
212 t->Draw();
213 }
214 }
215
216 // Draw scale
217 float x= map.Xj(0)+xbin/6;
218 float y= map.Yj(0)+ybin/6;
219 TArrow *arrowxy = new TArrow(x,y,x+scalexy*10,y,0.005);
220 arrowxy->SetLineWidth(3);
221 arrowxy->SetLineColor(1);
222 arrowxy->Draw();
223 TText *text = new TText(x,y+ybin/10,"10 microns");
224 text->SetTextSize(0.02);
225 text->Draw();
226
227 //x= map.Xj(0)+xbin/6 + scalexy*10 + xbin/6;
228 x= map.Xj(0)+xbin/6;
229 y= map.Yj(0)+ybin/6 + ybin;
230 TArrow *arrowtxty = new TArrow(x,y,x+scaletxty*0.01,y,0.005);
231 arrowtxty->SetLineWidth(3);
232 arrowtxty->SetLineColor(0);
233 arrowtxty->Draw();
234 TText *textt = new TText(x,y+ybin/10,"10 mrad");
235 textt->SetTextSize(0.02);
236 textt->Draw();
237
238 return corrmap;
239}
TText * text
Definition: Canv_SYSTEMATICS_ALLCOMBINED__RMSEnergy__vs__Energy__ELECTRON.C:164
EdbSegCorr CorrLoc(int j)
Definition: EdbLayer.cxx:235
int Ncp()
Definition: EdbLayer.cxx:210
EdbLayer * GetLayer(float x, float y)
Definition: EdbLayer.h:24
EdbID eID1
Definition: EdbCorrectionMapper.h:47
EdbID eID2
Definition: EdbCorrectionMapper.h:47
float Xj(int j) const
Definition: EdbCell2.h:62
float Ybin() const
Definition: EdbCell2.h:78
float Yj(int j) const
Definition: EdbCell2.h:63
float Xbin() const
Definition: EdbCell2.h:77
TH2F * DrawH2(const char *name="plot2d", const char *title="EdbH2plot2D")
Definition: EdbCell2.cpp:187
char * AsString() const
Definition: EdbID.cxx:26
int Ncp() const
Definition: EdbLayer.h:74
Definition: EdbSegCorr.h:8
float V(int i)
Definition: EdbSegCorr.h:23
TTree * t
Definition: check_shower.C:4
new TCanvas()

◆ DrawSum()

TCanvas * EdbCorrectionMapper::DrawSum ( const char *  suffix)
130{
131 gStyle->SetPalette(1);
132 gStyle->SetOptStat(0);
133 gStyle->SetOptDate(1);
134
135 TCanvas *csum = new TCanvas( Form("csum_%s",suffix), Form("csum_%s",suffix), 800,960 );
136 TPaveText *tsum = new TPaveText(0.01,0.943,0.99,0.998);
137 tsum->AddText( Form("%s -> %s", eID1.AsString(), eID2.AsString() ) );
138 tsum->AddText( Form("z2-z1 = %12.1f - %12.1f = %12.1f", eZ2,eZ1, eZ2-eZ1 ) );
139 tsum->Draw();
140
141 TPad *sum = new TPad("sum","plots",0.01,0.03,0.99,0.94);
142 sum->Divide(2,4); sum->Draw();
143
144 sum->cd(1); eHxy1.DrawH2( Form("Hxy1_%s" ,suffix),"Pattern X vs Y" )->Draw("colz");
145 sum->cd(2); eHtxty1.DrawH2( Form("Htxty1_%s" ,suffix),"Pattern TX vs TY" )->Draw("colz");
146
147 sum->cd(3); eHdxy.DrawH2( Form("Hdxy_%s" ,suffix),"Map DX vs DY" )->Draw("colz");
148 sum->cd(4); eHdtxy.DrawH2( Form("Hdtxy_%s" ,suffix),"Map DTX vs DTY" )->Draw("colz");
149
150 gStyle->SetOptStat(1);
151 sum->cd(5);
152 TH1F *hdz = eHdz.DrawH1( Form("Hdz_%s" ,suffix),"Map DZ" );
153 hdz->Draw();
154 sum->cd(6);
155 TH1F *hshr = eHshr.DrawH1( Form("Hshr_%s" ,suffix),"Map Shr" );
156 hshr->Draw();
157 //printf("meanZ = %f meanShr= %f \n",hdz->GetMean(), hshr->GetMean());
158 gStyle->SetOptStat(0);
159
160 sum->cd(7); eHdty_ty.DrawH2( Form("Hdty_ty_%s" ,suffix),"Map DTY vs TY" )->Draw("colz");
161 sum->cd(8);
162
163 return csum;
164}
EdbH2 eHtxty1
Definition: EdbCorrectionMapper.h:45
EdbH2 eHdty_ty
Definition: EdbCorrectionMapper.h:42
EdbH1 eHshr
Definition: EdbCorrectionMapper.h:40
EdbH1 eHdz
dz
Definition: EdbCorrectionMapper.h:39
EdbH2 eHdtxy
dtxdty
Definition: EdbCorrectionMapper.h:38
float eZ1
Definition: EdbCorrectionMapper.h:48
EdbH2 eHxy1
Definition: EdbCorrectionMapper.h:44
float eZ2
Definition: EdbCorrectionMapper.h:48
EdbH2 eHdxy
dxdy
Definition: EdbCorrectionMapper.h:37
TH1F * DrawH1(const char *name="EdbH1plot", const char *title="EdbH1plot1D")
Definition: EdbCell1.cpp:136

◆ Fill()

void EdbCorrectionMapper::Fill ( EdbSegP s1,
EdbSegP s2 
)
307{
308 eHxy1.Fill( s1.X(),s1.Y() );
309 eHtxty1.Fill( s1.TX(),s1.TY() );
310 eHxy2.Fill( s2.X(),s2.Y() );
311 eHtxty2.Fill( s2.TX(),s2.TY() );
312 eHdxy.Fill( s2.X()-(s1.X()+s1.TX()*(s2.Z()-s1.Z())), s2.Y()-(s1.Y()+s1.TY()*(s2.Z()-s1.Z())) );
313 eHdtxy.Fill( s2.TX()-s1.TX(), s2.TY()-s1.TY() );
314 eHdty_ty.Fill( s1.TY(), s2.TY()-s1.TY() );
315
316 float t1 = s1.Theta();
317 if(t1>.1) {
318 float dz = s2.Z()-s1.Z();
319 float tx = (s2.X()-s1.X())/dz;
320 float ty = (s2.Y()-s1.Y())/dz;
321 float t = TMath::Sqrt(tx*tx+ty*ty);
322 float dzn = dz*t/t1;
323 eHdz.Fill(dzn-dz);
324 }
325
326 if(t1>.1) {
327 float t2 = s2.Theta();
328 float shr = t2/t1;
329 eHshr.Fill(shr);
330 }
331
332}
brick dz
Definition: RecDispMC.C:107
EdbH2 eHxy2
Definition: EdbCorrectionMapper.h:44
EdbH2 eHtxty2
Definition: EdbCorrectionMapper.h:45
int Fill(float x)
Definition: EdbCell1.h:63
int Fill(float x, float y)
Definition: EdbCell2.h:88
Float_t TX() const
tangens = deltaX/deltaZ
Definition: EdbSegP.h:175
Float_t Z() const
Definition: EdbSegP.h:153
Float_t TY() const
tangens = deltaY/deltaZ
Definition: EdbSegP.h:176
Float_t Theta() const
Definition: EdbSegP.h:184

◆ FillS()

void EdbCorrectionMapper::FillS ( EdbSegP s1,
EdbSegP s2 
)
inline
void AddSegCouple(EdbSegP *s1, EdbSegP *s2)
Definition: EdbAlignmentV.h:77
EdbAlignmentV eAl
Definition: EdbCorrectionMapper.h:14

◆ GetBin() [1/2]

EdbCorrectionBin * EdbCorrectionMapper::GetBin ( float  x,
float  y 
)
inline
58{ return (EdbCorrectionBin*)(eMapAl.GetObject(x, y, 0)); }
TObject * GetObject(float x, float y, int ientr) const
Definition: EdbCell2.h:195

◆ GetBin() [2/2]

EdbCorrectionBin * EdbCorrectionMapper::GetBin ( int  i)
inline
57{ return (EdbCorrectionBin*)(eMapAl.GetObject( i, 0)); }

◆ InitMap()

int EdbCorrectionMapper::InitMap ( int  nx,
float  minx,
float  maxx,
int  ny,
float  miny,
float  maxy 
)

assumed that the own histograms of EdbCorrectionMapper are correctly defined

285{
287 int n = eMapAl.InitCell(nx, minx, maxx, ny, miny, maxy, 1);
288 for(int i=0; i<n; i++) {
290 eMapAl.AddObject(i, bin );
291 }
293
294 return n;
295}
int InitCell(EdbCell2 &c)
Definition: EdbCell2.h:167
bool AddObject(float v[2], TObject *obj)
Definition: EdbCell2.h:173
EdbCorrectionBin()
Definition: EdbCorrectionMapper.cxx:28
void Init(EdbCell2 &c)
Definition: EdbLayer.cxx:167
EdbCorrectionMap eMap
result: corrections map
Definition: EdbCorrectionMapper.h:35

◆ MakeCorrectionsTable()

void EdbCorrectionMapper::MakeCorrectionsTable ( )

assuming that all corrections are calculated produce the output eMap object

249{
251 int n = eMapAl.Ncell();
252 for(int i=0; i<n; i++) {
253 EdbCorrectionBin *bin = GetBin(i);
254 EdbLayer *l = eMap.GetLayer(i);
255 l->ApplyCorrections( bin->eLayer );
256 l->SetNcp(bin->eAl.Ncp());
258 }
259}
Int_t Ncp()
Functions applied to the selected parallel arrays.
Definition: EdbAlignmentV.h:76
EdbLayer eLayer
Definition: EdbCorrectionMapper.h:16
Definition: EdbLayer.h:39
void SubstructCorrections(EdbLayer &la)
Definition: EdbLayer.cxx:102
void ApplyCorrections(EdbLayer &la)
Definition: EdbLayer.cxx:81
void SetNcp(int n)
Definition: EdbLayer.h:95

◆ MapDV()

EdbH2 * EdbCorrectionMapper::MapDV ( int  ivar)
105{
106 EdbH2 *h = new EdbH2();
107 h->InitH2(eMapAl);
108 int n=eMapAl.Ncell();
109 for(int i=0;i<n; i++) {
110 EdbCorrectionBin *bin = GetBin(i);
111 h->SetBin( i, (int)(1000*bin->eAl.CalcMeanDiff(ivar)) );
112 }
113 return h;
114}
Float_t CalcMeanDiff(int ivar)
Definition: EdbAlignmentV.cxx:536
fast 2-dim histogram class (used as a basis for EdbCell2)
Definition: EdbCell2.h:19
void SetBin(int ix, int iy, int n)
Definition: EdbCell2.h:90
int InitH2(const EdbH2 &h)
Definition: EdbCell2.cpp:78

◆ MapDZ()

EdbH2 * EdbCorrectionMapper::MapDZ ( )
80{
81 EdbH2 *h = new EdbH2();
82 h->InitH2(eMapAl);
83 int n=eMapAl.Ncell();
84 for(int i=0;i<n; i++) {
85 EdbCorrectionBin *bin = GetBin(i);
86 //h->SetBin( i, (int)(1000*bin->eAl.CalcMeanDZ()) );
87 h->SetBin( i, (int)(1000*bin->eAl.eCorr[0].V(2)) ); // assumed that all corrections are calculated
88 }
89 return h;
90}
EdbSegCorr eCorr[2]
corrections for side 1 and 2 (v[7]) - the result of the alignment
Definition: EdbAlignmentV.h:24

◆ SetCorrDZ()

void EdbCorrectionMapper::SetCorrDZ ( )
69{
70 eAl.eCorr[0].SetV( 2, eZ2-eZ1 );
71 int n=eMapAl.Ncell();
72 for(int i=0;i<n; i++) {
73 EdbCorrectionBin *bin = GetBin(i);
74 bin->eAl.eCorr[0].SetV( 2, eZ2-eZ1 );
75 }
76}
void SetV(int i, float x)
Definition: EdbSegCorr.h:21

◆ SmoothCorrections()

void EdbCorrectionMapper::SmoothCorrections ( )

in case of low pattern: add segments from 3x3 neighbouring and calculate mean alignment

263{
265 int n = eMapAl.Ncell();
266 int ncpGood = 0;
267 for(int i=0; i<n; i++) if( GetBin(i)->eAl.Ncp() >= eNcpMin ) ncpGood++;
268 Log(2,"EdbCorrectionMapper::SmoothCorrections","%d / %d = %6.4f fraction of good alignments (>%d)",
269 ncpGood,n, 1.*ncpGood/n, eNcpMin);
270 for(int j=0; j<n; j++) {
271 EdbCorrectionBin *bin = GetBin(j);
272 if(bin->eAl.Ncp() >= eNcpMin) continue;
273 TObjArray arr;
274 int ne = eMapAl.SelectObjectsCJ(j,1,arr);
275 for(int ie=0; ie<ne; ie++) {
276 EdbCorrectionBin *bine = (EdbCorrectionBin *)(arr.At(ie));
277 if(bine != bin) bin->AddBin(*bine);
278 }
279 }
280
281}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
int SelectObjectsCJ(int j, int ir, TObjArray &arr)
Definition: EdbCell2.h:181
void AddBin(EdbCorrectionBin &bin)
Definition: EdbCorrectionMapper.cxx:37

◆ UpdateLayerWithLocalCorr()

void EdbCorrectionMapper::UpdateLayerWithLocalCorr ( EdbLayer la)
243{
245}
void ApplyCorrections(EdbCorrectionMap &map)
Definition: EdbLayer.cxx:194
EdbCorrectionMap & Map()
Definition: EdbLayer.h:72

◆ Write()

void EdbCorrectionMapper::Write ( const char *  suffix = "")
118{
119 bool batch = gROOT->IsBatch();
120 gROOT->SetBatch();
121 TCanvas *csum = DrawSum(suffix);
122 csum->Write();
123 TCanvas *cdiff = DrawMap(eMap, suffix);
124 cdiff->Write();
125 gROOT->SetBatch(batch);
126}
TCanvas * DrawMap(EdbCorrectionMap &map, const char *suffix="")
Definition: EdbCorrectionMapper.cxx:167
TCanvas * DrawSum(const char *suffix)
Definition: EdbCorrectionMapper.cxx:129

Member Data Documentation

◆ eHdtxy

EdbH2 EdbCorrectionMapper::eHdtxy

dtxdty

◆ eHdty_ty

EdbH2 EdbCorrectionMapper::eHdty_ty

◆ eHdxy

EdbH2 EdbCorrectionMapper::eHdxy

dxdy

◆ eHdz

EdbH1 EdbCorrectionMapper::eHdz

dz

◆ eHshr

EdbH1 EdbCorrectionMapper::eHshr

◆ eHtxty1

EdbH2 EdbCorrectionMapper::eHtxty1

◆ eHtxty2

EdbH2 EdbCorrectionMapper::eHtxty2

◆ eHxy1

EdbH2 EdbCorrectionMapper::eHxy1

◆ eHxy2

EdbH2 EdbCorrectionMapper::eHxy2

◆ eID1

EdbID EdbCorrectionMapper::eID1

◆ eID2

EdbID EdbCorrectionMapper::eID2

◆ eMap

EdbCorrectionMap EdbCorrectionMapper::eMap

result: corrections map

◆ eMapAl

EdbCell2 EdbCorrectionMapper::eMapAl

working object with local alignments

◆ eNcpMin

int EdbCorrectionMapper::eNcpMin

min number of coincidences to accept correction

◆ eZ1

float EdbCorrectionMapper::eZ1

◆ eZ2

float EdbCorrectionMapper::eZ2

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