Logo ROOT  
Reference Guide
Src4.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_spectrum
3/// \notebook
4/// Example to illustrate high resolution peak searching function (class TSpectrum2).
5///
6/// \macro_image
7/// \macro_output
8/// \macro_code
9///
10/// \authors Miroslav Morhac, Olivier Couet
11
12#include <TSpectrum2.h>
13
14void Src4()
15{
16 const Int_t nbinsx = 64;
17 const Int_t nbinsy = 64;
18 std::vector<Double_t *> source(nbinsx), dest(nbinsx);
19 for (Int_t i = 0; i < nbinsx; i++) {
20 source[i] = new Double_t[nbinsy];
21 dest[i] = new Double_t[nbinsy];
22 }
23 TString dir = gROOT->GetTutorialDir();
24 TString file = dir + "/spectrum/TSpectrum2.root";
25 TFile *f = TFile::Open(file.Data());
27 auto search = (TH2F *)f->Get("search2");
29 for (Int_t i = 0; i < nbinsx; i++) {
30 for (Int_t j = 0; j < nbinsy; j++) {
31 source[i][j] = search->GetBinContent(i + 1, j + 1);
32 }
33 }
34 Int_t nfound = s.SearchHighRes(source.data(), dest.data(), nbinsx, nbinsy, 3, 5, kFALSE, 10, kTRUE, 3);
35 printf("Found %d candidate peaks\n", nfound);
36 Double_t *PositionX = s.GetPositionX();
37 Double_t *PositionY = s.GetPositionY();
38 search->Draw("CONT");
39 TMarker m;
40 m.SetMarkerStyle(23);
42 for (Int_t i = 0; i < nfound; i++) {
43 printf("posx= %d, posy= %d, value=%d\n", (Int_t)(PositionX[i] + 0.5), (Int_t)(PositionY[i] + 0.5),
44 (Int_t)source[(Int_t)(PositionX[i] + 0.5)][(Int_t)(PositionY[i] + 0.5)]);
45 m.DrawMarker(PositionX[i], PositionY[i]);
46 }
47
48 for (Int_t i = 0; i < nbinsx; i++) {
49 delete[] source[i];
50 delete[] dest[i];
51 }
52}
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:45
const Bool_t kFALSE
Definition: RtypesCore.h:101
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
@ kRed
Definition: Rtypes.h:66
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
#define gROOT
Definition: TROOT.h:404
R__EXTERN TStyle * gStyle
Definition: TStyle.h:414
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:4053
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:257
Manages Markers.
Definition: TMarker.h:22
virtual TMarker * DrawMarker(Double_t x, Double_t y)
Draw this marker with new coordinates.
Definition: TMarker.cxx:203
Advanced 2-dimensional spectra processing.
Definition: TSpectrum2.h:18
Basic string class.
Definition: TString.h:136
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition: TStyle.cxx:1589
static constexpr double s
Definition: file.py:1
TMarker m
Definition: textangle.C:8