19 _is_initialized =
false;
29 _is_initialized =
false;
32 Init(h_, Xm, Ym, pdx, pdy);
82 if (!strcmp(option,
"ON EN A MARRE DES WARNING !!!!"))
return;
88 _is_initialized =
false;
108 if (!TestHistogram(h_))
return;
120 TH1D* hx = _htot->ProjectionX();
121 TH1D* hy = _htot->ProjectionY();
127 if ((pdx < 0.) || (pdy < 0.)) _htot->
GetMaximumBin(x0, y0, z0);
133 while ((!foundx) && (j >= 0)) {
142 while (!foundy && (j >= 0)) {
153 if ((!foundx) || (!foundy)) {
154 cout <<
"ERROR: KVSpiderIdentificator::Init(): Invalid Histogram !" << endl;
160 if (Xm > 0.) _xm = Xm;
161 if (Ym > 0.) _ym = Ym;
165 _is_initialized =
true;
198 if (!TestHistogram(h_))
return 0;
200 double a0 = d_->
GetA0();
208 if (th <= thetam) mma = _xmax / costh;
209 else mma = _ymax / sinth;
211 int mmb = (int)mma / (rebin_ * _bfactor);
217 int nbins =
xbins * ybins;
218 if (_debug)cout <<
"DEBUG: GetProjection(): total number of bins : '" << nbins <<
"'." << endl;
223 Double_t xx = _alea.Uniform(bminx, bmaxx);
224 if (xx == bmaxx) xx = bminx;
226 for (
int y = 0;
y <= ybins;
y++) {
229 Double_t yy = _alea.Uniform(bminy, bmaxy);
230 if (yy == bmaxy) yy = bminy;
235 Double_t x1 = xx * costh + yy * sinth;
237 if (content > 0.)
h1->
Fill(x1, content);
262 cout <<
"ERROR: KVSpiderIdentificator::TestHistogram(): Invalid pointer on 'TH2F' histogram !" << endl;
266 cout <<
"ERROR: KVSpiderIdentificator::SetHistogram(): Invalid histogram for SpIDer identification !" << endl;
279 TList* ll = CreateHistograms(th_, th_, 1,
true, alpha_);
291 if (!TestHistogram(_htot))
return 0;
292 else if (!_is_initialized) {
293 cout <<
"ERROR: KVSpiderIdentificator::CreateHistogram(): Invalid range of theta [" << thmin_ <<
";" << thmax_ <<
"] !" << endl;
296 else if ((thmin_ > thmax_) || (thmin_ < 0.) || (thmin_ >= 90.) || (thmax_ <= 0.) || (thmax_ > 90.)) {
297 cout <<
"ERROR: KVSpiderIdentificator::CreateHistogram(): Invalid range of theta [" << thmin_ <<
";" << thmax_ <<
"] !" << endl;
300 else if (nth_ <= 0) {
301 cout <<
"ERROR: KVSpiderIdentificator::CreateHistogram(): Invalid number of step '" << nth_ <<
"' !" << endl;
307 if (_auto) aa = _alpha;
324 if ((thmin_ == thmax_) || (nth_ == 1)) step = 10;
325 else step = (max - min) / ((nth_ - 1) * 1.);
327 int xbins = _htot->GetNbinsX();
328 int ybins = _htot->GetNbinsY();
331 double bminx = _htot->GetXaxis()->GetBinLowEdge(
x);
332 double bmaxx = _htot->GetXaxis()->GetBinUpEdge(
x);
333 for (
int y = 0;
y <= ybins;
y++) {
334 int content = (int) _htot->GetBinContent(
x,
y);
336 double bminy = _htot->GetXaxis()->GetBinLowEdge(
y);
337 double bmaxy = _htot->GetXaxis()->GetBinUpEdge(
y);
340 for (
int i = 0; i < content; i++) {
341 xx = _alea.Uniform(bminx, bmaxx);
342 yy = _alea.Uniform(bminy, bmaxy);
343 if (xx == bmaxx) xx = bminx;
344 if (yy == bmaxy) yy = bminy;
346 for (
double cth = min; cth < max + 0.0001 * step; cth += step) {
358 if ((yy <= _y0 + (xx - _x0)*tmax) && (yy >= _y0 + (xx - _x0)*tmin)) {
359 if (!(_htemp = (
TH2F*)_hlist.FindObject(
Form(
"CUT_%06.3lf", theta)))) {
360 _htemp =
new TH2F(
Form(
"CUT_%06.3lf", theta),
Form(
"CUT_%06.3lf", theta), 1024, 0, _xmax, 1024, 0, _ymax);
361 _hlist.AddLast(_htemp);
364 dd->
SetName(_htemp->GetName());
367 _htemp->Fill(xx, yy);
388 if (!TestHistogram(h1_)) {
389 Warning(
"SearchPeack",
"Bad histo...");
393 _dtemp = (
KVDroite*)_dlist.FindObject(
Form(
"CUT_%06.3lf", theta_));
394 TF1* ff = _dtemp->GetFunction();
399 if (_nAngleUp == 0 && _nAngleDown == 0) {
403 int nfound = _ss.Search(h1_, sigma_, opt_.
Data(), (peakmin_ / h1_->
GetMaximum()));
405 if (_debug && _nAngleUp == 0 && _nAngleDown == 0) {
406 h1_->
SaveAs(
"/home/dgruyer/e613/thesis/doc/proj.root");
421 double theta = _dtemp->GetTheta();
426 #if ROOT_VERSION_CODE > ROOT_VERSION(5,99,01)
427 Double_t* xpeaks = _ss.GetPositionX();
429 Float_t* xpeaks = _ss.GetPositionX();
432 for (
int p = 0; p < nfound; p++) {
433 double xp = xpeaks[p];
448 list<double>::iterator it;
449 for (it = lx.begin(); it != lx.end(); ++it) {
453 double xx = xp * costh;
454 double yy = ff->
Eval(xx);
460 bool TrueAss =
false;
463 _invalid->SetPoint(_invalid->GetN(), xx, yy);
465 double d =
TMath::Sqrt((xx - ox) * (xx - ox) + (yy - oy) * (yy - oy));
471 _llist.AddLast(_spline);
478 if (create_ == 0) caca = 0.6;
480 if ((p >= 4) && (
d <= caca *
dist) && (valid)) {
484 _spline->SetStatus(
false);
486 double xmoy = (_spline->GetX() * npp + xx) / (npp + 1);
487 double ymoy = (_spline->GetY() * npp + yy) / (npp + 1);
489 if (_spline->TestPoint(xmoy, ymoy,
dist * 0.3, _useFit)) {
490 _spline->ReplaceLastPoint(xmoy, ymoy);
491 _spline->SetStatus(
true);
492 TrueZ = _spline->GetZ();
499 if ((p >= 4) && (valid)) {
500 if ((yy >= 4000.) || (xx >= 4000.)) valid =
false;
503 if ((create_ == 0) && (valid)) {
504 if ((p >= 10) && (
d >= 1.7 *
dist)) {
509 _spline->AddPoint(xx, yy);
510 _spline->SetStatus(
true);
511 TrueZ = _spline->GetZ();
517 _invalid->SetPoint(_invalid->GetN(), xx, yy);
520 if ((create_ != 0) && (valid)) {
530 while ((!assoc) && (valid)) {
535 if ((d2 > d1) ||
test) {
537 if (_spline->TestPoint(xx, yy, -1., _useFit)) {
538 _spline->AddPoint(xx, yy);
539 _spline->SetStatus(
true);
540 TrueZ = _spline->GetZ();
559 if (!valid) p += ii - 2;
562 if (TrueZ == OTZ) npp++;
565 if ((_spline = (
KVSpiderLine*)_llist.FindObject(
Form(
"Z=%d", TrueZ))) && (TrueZ != OTZ)) {
566 xx = _spline->GetInterpolateX();
567 yy = _spline->GetInterpolateY();
570 ox = _spline->GetInterpolateX();
571 oy = _spline->GetInterpolateY();
577 dist =
TMath::Sqrt((xx - ox) * (xx - ox) + (yy - oy) * (yy - oy)) / (TrueZ - OTZ);
581 if (TrueAss) OTZ = TrueZ;
600 Int_t angle_proc = 0;
603 CreateHistograms(_ftheta, _ftheta, 1,
true, _alpha);
604 TIter nexti(&_hlist);
605 while ((_htemp = (
TH2F*)nexti())) {
606 _dtemp = (
KVDroite*)_dlist.FindObject(_htemp->GetName());
607 TH1F* hh = GetProjection(_htemp, _dtemp, 12);
608 SearchPeack(hh, _dtemp->GetTheta(), cre, 2., 1., 12, 5);
610 Increment((
Float_t) angle_proc);
616 TIter nextl1(&_llist);
618 if (_spline->GetN() == 0) _llist.Remove(_spline);
620 _spline->SetAcceptedPoints(2);
621 _spline->ResetCounter();
626 CreateHistograms(_ftheta + 1., 89.2, _nAngleUp,
true, _alpha * 0.6 / 1.7);
629 while ((_htemp = (
TH2F*)next())) {
630 _dtemp = (
KVDroite*)_dlist.FindObject(_htemp->GetName());
631 TH1F* hh = GetProjection(_htemp, _dtemp, 17);
632 SearchPeack(hh, _dtemp->GetTheta(), -1, 2., 1., 17, 5);
634 TIter nextl2(&_llist);
636 _spline->SetStatus(
false);
637 _spline->ResetCounter();
640 Increment((
Float_t) angle_proc);
646 TIter nextl(&_llist);
649 _spline->ResetCounter();
655 CreateHistograms(1.5, _ftheta - 1., _nAngleDown,
true, _alpha * 1. / 1.7);
658 TIter nextt(&_hlist);
659 while ((_htemp = (
TH2F*)nextt())) {
660 _dtemp = (
KVDroite*)_dlist.FindObject(_htemp->GetName());
661 TH1F* hh = GetProjection(_htemp, _dtemp, 15);
662 SearchPeack(hh, _dtemp->GetTheta(), cre, 2., 1., 15, 5);
665 TIter nextl3(&_llist);
667 _spline->SetStatus(
false);
668 _spline->ResetCounter();
671 Increment((
Float_t) angle_proc);
692 TIter nextli(&_llist);
708 CreateHistograms(_ftheta, _ftheta, 1,
true, alpha_);
709 TIter nexti(&_hlist);
710 while ((_htemp = (
TH2F*)nexti())) {
711 _dtemp = (
KVDroite*)_dlist.FindObject(_htemp->GetName());
712 TH1F* hh = GetProjection(_htemp, _dtemp);
713 SearchPeack(hh, _dtemp->GetTheta(), 0, 2., 3., 1, 5);
718 if (npoints_ == 1)
return false;
721 CreateHistograms(_ftheta + 1., _ftheta + 1. + npoints_, npoints_,
true, alpha_);
724 while ((_htemp = (
TH2F*)next())) {
725 _dtemp = (
KVDroite*)_dlist.FindObject(_htemp->GetName());
726 TH1F* hh = GetProjection(_htemp, _dtemp);
727 SearchPeack(hh, _dtemp->GetTheta(), -1, 2., 3., 1, 5);
751 _invalid->SetMarkerColor(
kBlack);
752 _invalid->SetMarkerSize(0.7);
753 _invalid->SetMarkerStyle(21);
754 _invalid->Draw(
"Psame");
762 TIter nextd(&_dlist);
774 if (
id % 3 == 0) ff->
Draw(
"same");
782 _spline->Draw(option.
Data());
784 TF1* ff = _spline->GetFunction();
809 cc->Print(
Form(
"%s/%s.pdf", path_,
cc->GetName()),
"pdf");
834 cout <<
"WARNING: KVSpiderIdentificator::GetLine(): unknown line 'Z=" << z_ <<
"' !" << endl;
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
TCanvas with mouse-controlled dynamic zoom and pan & scan.
Apparently, a straight line.
Semi-automatic identification grid generator.
TList * CreateHistograms(double thmin_, double thmax_, int nth_, bool cos_=true, double alpha_=-1.)
bool CheckPath(const Char_t *path_)
void Init(TH2F *h_=0, Double_t Xm=-1, Double_t Ym=-1, Double_t X0=-1, Double_t Y0=-1)
void SaveAsPdf(Option_t *opt_="", const Char_t *path_=".")
bool SearchPeack(TH1F *h1_, double theta_, int create_, double sigma_=2., double peakmin_=1., int rebin_=10, int smooth_=5, TString opt_="goff")
bool ProcessIdentification()
TH1F * GetProjection(TH2F *h_, KVDroite *d_, int rebin_=10)
virtual ~KVSpiderIdentificator()
void SetHistogram(TH2F *h_=0, Double_t Xm=-1, Double_t Ym=-1)
bool GetLines(int npoints_=1, double alpha_=1.)
TH2F * CreateHistogram(double th_, double alpha_=-1.)
KVSpiderLine * GetLine(int z_)
void Clear(Option_t *option="")
bool TestHistogram(TH1 *h_=0)
void SetParameters(double bining_=1.)
void Draw(Option_t *opt_="")
KVSpiderLine specialized for PSA matrix.
Part of Spider Identification.
int GetInterpolateN() const
double GetDistance(double x_, double y_)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual Double_t GetBinLowEdge(Int_t bin) const
virtual Double_t GetBinUpEdge(Int_t bin) const
virtual void Draw(Option_t *option="")
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual void Smooth(Int_t ntimes=1, Option_t *option="")
virtual Int_t GetNbinsY() const
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
virtual Int_t GetNbinsX() const
virtual Int_t Fill(const char *name, Double_t w)
virtual Double_t Integral(Int_t binx1, Int_t binx2, Option_t *option="") const
virtual Int_t GetMaximumBin() const
virtual Double_t GetBinContent(Int_t bin) const
virtual Double_t GetBinContent(Int_t bin) const
virtual TObject * At(Int_t idx) const
virtual const char * GetName() const
virtual const char * GetTitle() const
virtual void Clear(Option_t *option="")
virtual void SetName(const char *name)
virtual TObject * FindObject(const char *name) const
virtual void SaveAs(const char *filename="", Option_t *option="") const
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void * OpenDirectory(const char *name)
virtual int MakeDirectory(const char *name)
virtual Bool_t ProcessEvents()
const long double cc
volumes
double dist(AxisAngle const &r1, AxisAngle const &r2)
constexpr Double_t DegToRad()
Double_t Sqrt(Double_t x)
constexpr Double_t RadToDeg()
const double xbins[xbins_n]