FEDRA emulsion software from the OPERA Collaboration
EdbCorrectionMapper Class Reference

#include <EdbCorrectionMapper.h>

Inheritance diagram for EdbCorrectionMapper:
Collaboration diagram for EdbCorrectionMapper:

Public Member Functions

void AddSegCouple (EdbSegP *s1, EdbSegP *s2)
 
void CalculateCorrections ()
 
TCanvas * DrawMap (EdbCorrectionMap &map, const char *suffix="")
 
TCanvas * DrawSum (const char *suffix)
 
 EdbCorrectionMapper ()
 
void Fill (EdbSegP &s1, EdbSegP &s2)
 
void FillS (EdbSegP *s1, EdbSegP *s2)
 
EdbCorrectionBin * GetBin (float x, float y)
 
EdbCorrectionBin * GetBin (int i)
 
int InitMap (int nx, float minx, float maxx, int ny, float miny, float maxy)
 
void MakeCorrectionsTable ()
 
EdbH2 * MapDV (int ivar)
 
EdbH2 * MapDZ ()
 
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)
 
 EdbCorrectionBin ()
 
virtual ~EdbCorrectionBin ()
 

Public Attributes

EdbH2 eHdtxy
 
EdbH2 eHdty_ty
 
EdbH2 eHdxy
 
EdbH1 eHdz
 
EdbH1 eHshr
 
EdbH2 eHtxty1
 
EdbH2 eHtxty2
 
EdbH2 eHxy1
 
EdbH2 eHxy2
 
EdbID eID1
 
EdbID eID2
 
EdbCorrectionMap eMap
 
EdbCell2 eMapAl
 
int eNcpMin
 
float eZ1
 
float eZ2
 
- Public Attributes inherited from EdbCorrectionBin
EdbAlignmentV eAl
 
EdbLayer eLayer
 

Constructor & Destructor Documentation

◆ EdbCorrectionMapper()

EdbCorrectionMapper::EdbCorrectionMapper ( )
58 {
59  eNcpMin = 100;
60 }
int eNcpMin
Definition: EdbCorrectionMapper.h:50

◆ ~EdbCorrectionMapper()

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

Member Function Documentation

◆ AddSegCouple()

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

Reimplemented from EdbCorrectionBin.

298 {
300  EdbCorrectionBin *bin = GetBin(s1->X(),s1->Y());
301  if(bin) bin->AddSegCouple(s1,s2);
302 }
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:170
Float_t Y() const
Definition: EdbSegP.h:171
float bin
Definition: emthickness.cpp:98
EdbSegP * s1
Definition: tlg2pattern.C:30
EdbSegP * s2
Definition: tlg2pattern.C:31

◆ CalculateCorrections()

void EdbCorrectionMapper::CalculateCorrections ( )
virtual

Reimplemented from EdbCorrectionBin.

93 {
95  int n=eMapAl.Ncell();
96  for(int i=0;i<n; i++) {
98  bin->CalculateCorrections();
99  }
100 }
virtual void CalculateCorrections()
Definition: EdbCorrectionMapper.cxx:46
EdbCell2 eMapAl
Definition: EdbCorrectionMapper.h:34
int Ncell() const
Definition: EdbCell2.h:49

◆ DrawMap()

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

◆ DrawSum()

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

◆ Fill()

void EdbCorrectionMapper::Fill ( EdbSegP &  s1,
EdbSegP &  s2 
)
306 {
307  eHxy1.Fill( s1.X(),s1.Y() );
308  eHtxty1.Fill( s1.TX(),s1.TY() );
309  eHxy2.Fill( s2.X(),s2.Y() );
310  eHtxty2.Fill( s2.TX(),s2.TY() );
311  eHdxy.Fill( s2.X()-(s1.X()+s1.TX()*(s2.Z()-s1.Z())), s2.Y()-(s1.Y()+s1.TY()*(s2.Z()-s1.Z())) );
312  eHdtxy.Fill( s2.TX()-s1.TX(), s2.TY()-s1.TY() );
313  eHdty_ty.Fill( s1.TY(), s2.TY()-s1.TY() );
314 
315  float t1 = s1.Theta();
316  if(t1>.1) {
317  float dz = s2.Z()-s1.Z();
318  float tx = (s2.X()-s1.X())/dz;
319  float ty = (s2.Y()-s1.Y())/dz;
320  float t = TMath::Sqrt(tx*tx+ty*ty);
321  float dzn = dz*t/t1;
322  eHdz.Fill(dzn-dz);
323  }
324 
325  if(t1>.1) {
326  float t2 = s2.Theta();
327  float shr = t2/t1;
328  eHshr.Fill(shr);
329  }
330 
331 }
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
Definition: EdbSegP.h:172
Float_t Z() const
Definition: EdbSegP.h:150
Float_t TY() const
Definition: EdbSegP.h:173
Float_t Theta() const
Definition: EdbSegP.h:181

◆ FillS()

void EdbCorrectionMapper::FillS ( EdbSegP *  s1,
EdbSegP *  s2 
)
inline
65 { eAl.AddSegCouple(s1,s2); }
void AddSegCouple(EdbSegP *s1, EdbSegP *s2)
Definition: EdbAlignmentV.h:78
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:199

◆ 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 
)
284 {
285  // assumed that the own histograms of EdbCorrectionMapper are correctly defined
286  int n = eMapAl.InitCell(nx, minx, maxx, ny, miny, maxy, 1);
287  for(int i=0; i<n; i++) {
289  eMapAl.AddObject(i, bin );
290  }
291  eMap.Init(eMapAl);
292 
293  return n;
294 }
int InitCell(EdbCell2 &c)
Definition: EdbCell2.h:170
bool AddObject(float v[2], TObject *obj)
Definition: EdbCell2.h:176
EdbCorrectionBin()
Definition: EdbCorrectionMapper.cxx:27
void Init(EdbCell2 &c)
Definition: EdbLayer.cxx:168
EdbCorrectionMap eMap
Definition: EdbCorrectionMapper.h:35
int nx
Definition: emthickness.cpp:60
int ny
Definition: emthickness.cpp:62

◆ MakeCorrectionsTable()

void EdbCorrectionMapper::MakeCorrectionsTable ( )
248 {
249  // assuming that all corrections are calculated produce the output eMap object
250  int n = eMapAl.Ncell();
251  for(int i=0; i<n; i++) {
253  EdbLayer *l = eMap.GetLayer(i);
254  l->ApplyCorrections( bin->eLayer );
255  l->SetNcp(bin->eAl.Ncp());
257  }
258 }
EdbLayer eLayer
Definition: EdbCorrectionMapper.h:16
Definition: EdbLayer.h:40
void SubstructCorrections(EdbLayer &la)
Definition: EdbLayer.cxx:103
void ApplyCorrections(EdbLayer &la)
Definition: EdbLayer.cxx:82
void SetNcp(int n)
Definition: EdbLayer.h:96

◆ MapDV()

EdbH2 * EdbCorrectionMapper::MapDV ( int  ivar)
104 {
105  EdbH2 *h = new EdbH2();
106  h->InitH2(eMapAl);
107  int n=eMapAl.Ncell();
108  for(int i=0;i<n; i++) {
110  h->SetBin( i, (int)(1000*bin->eAl.CalcMeanDiff(ivar)) );
111  }
112  return h;
113 }
Definition: EdbCell2.h:19
void SetBin(int ix, int iy, int n)
Definition: EdbCell2.h:91
int InitH2(const EdbH2 &h)
Definition: EdbCell2.cpp:79

◆ MapDZ()

EdbH2 * EdbCorrectionMapper::MapDZ ( )
79 {
80  EdbH2 *h = new EdbH2();
81  h->InitH2(eMapAl);
82  int n=eMapAl.Ncell();
83  for(int i=0;i<n; i++) {
85  //h->SetBin( i, (int)(1000*bin->eAl.CalcMeanDZ()) );
86  h->SetBin( i, (int)(1000*bin->eAl.eCorr[0].V(2)) ); // assumed that all corrections are calculated
87  }
88  return h;
89 }

◆ SetCorrDZ()

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

◆ SmoothCorrections()

void EdbCorrectionMapper::SmoothCorrections ( )
262 {
263  // in case of low pattern: add segments from 3x3 neighbouring and calculate mean alignment
264  int n = eMapAl.Ncell();
265  int ncpGood = 0;
266  for(int i=0; i<n; i++) if( GetBin(i)->eAl.Ncp() >= eNcpMin ) ncpGood++;
267  Log(2,"EdbCorrectionMapper::SmoothCorrections","%d / %d = %6.4f fraction of good alignments (>%d)",
268  ncpGood,n, 1.*ncpGood/n, eNcpMin);
269  for(int j=0; j<n; j++) {
271  if(bin->eAl.Ncp() >= eNcpMin) continue;
272  TObjArray arr;
273  int ne = eMapAl.SelectObjectsCJ(j,1,arr);
274  for(int ie=0; ie<ne; ie++) {
275  EdbCorrectionBin *bine = (EdbCorrectionBin *)(arr.At(ie));
276  if(bine != bin) bin->AddBin(*bine);
277  }
278  }
279 
280 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
Int_t Ncp()
Definition: EdbAlignmentV.h:77
int SelectObjectsCJ(int j, int ir, TObjArray &arr)
Definition: EdbCell2.h:185

◆ UpdateLayerWithLocalCorr()

void EdbCorrectionMapper::UpdateLayerWithLocalCorr ( EdbLayer &  la)
242 {
243  la.Map().ApplyCorrections(eMap);
244 }
void ApplyCorrections(EdbCorrectionMap &map)
Definition: EdbLayer.cxx:206
EdbCorrectionMap & Map()
Definition: EdbLayer.h:73

◆ Write()

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

Member Data Documentation

◆ eHdtxy

EdbH2 EdbCorrectionMapper::eHdtxy

◆ eHdty_ty

EdbH2 EdbCorrectionMapper::eHdty_ty

◆ eHdxy

EdbH2 EdbCorrectionMapper::eHdxy

◆ eHdz

EdbH1 EdbCorrectionMapper::eHdz

◆ 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

◆ eMapAl

EdbCell2 EdbCorrectionMapper::eMapAl

◆ eNcpMin

int EdbCorrectionMapper::eNcpMin

◆ eZ1

float EdbCorrectionMapper::eZ1

◆ eZ2

float EdbCorrectionMapper::eZ2

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