Histogram with ntuple using CERN ROOTSetting up CERN ROOT with an IDEGraphing with Cern ROOTCERN ROOT Graph Style IssuesCERN ROOT Making a Tree with event headersUsing ROOT (cern) with mingw32ROOT (cern) : gClient, gApplicationAdding a second x axis to a TGraph in the CERN ROOT programcern root gSystem errorROOT cern install errorROOT cern in visual studio 2017

Why does wrapping Aluminium foil around my food help it keep warm, aluminium be good conductor should have no effect?

Why does every calorie tracking app give a different target calorie count for the same goals?

Postgres trigram match acting strange for specific characters

Does a wizard need their hands free in order to cause their familiar from the Find Familiar spell to reappear?

Can i use larger/smaller circular saw blades on my circular / plunge / table / miter saw?

Is there a nice way to implement a conditional type with default fail case?

Can I play a mimic PC?

Having decision making power over someone's assets

How do we handle pauses in a dialogue?

Chorophyll and photosynthesis in plants with coloured leaves

"was fiction" vs "were fictions"

How to drill holes in 3/8" steel plates?

How to know if blackberries are safe to eat

Are there any sports for which the world's best player is female?

The origin of a particular self-reference paradox

Credit score and financing new car

Addressing unnecessary daily meetings with manager?

How to design a CMC (Common Mode Choke) footprint to allow no-pop solution

Should I include code in my research paper?

What is /bin/red

When did "&" stop being taught alongside the alphabet?

How can a dictatorship government be beneficial to a dictator in a post-scarcity society?

Did the Ottoman empire suppress the printing press?

Party going through airport security at separate times?



Histogram with ntuple using CERN ROOT


Setting up CERN ROOT with an IDEGraphing with Cern ROOTCERN ROOT Graph Style IssuesCERN ROOT Making a Tree with event headersUsing ROOT (cern) with mingw32ROOT (cern) : gClient, gApplicationAdding a second x axis to a TGraph in the CERN ROOT programcern root gSystem errorROOT cern install errorROOT cern in visual studio 2017






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Can't obtain/fill histogram starting from ntuple using ROOT.



I have been looking for previous answers and they all use ttree, including root documentation. I dont have one. Not new to root, but i struggle A LOT using it. None of the methods found work with my code (or i dont know how to implement them).



This is more or less what i have found everywhere:



https://root.cern.ch/root/roottalk/roottalk03/2620.html



but no, i am doing TH1F and i have no ttree (see code below)



{ 
gROOT->Reset();

#include "Riostream.h"
#include <iostream>
#include <fstream>

in.open( "somefile.dat");

TNtuple *ntuple = new TNtuple("ntuple","some data from ascii file","index1:index2:index3");

//declare variables, create histograms
Double_t x,y,Price[215000],Diff[215000],Ret[215000],trend, Data[215000];
TFile *f = new TFile("TrendsCountBove.root","RECREATE");
TH1F *h1 = new TH1F("h1","Retornos",100,-0.3,0.3);
TH1F *histo = new TH1F ("hist_from_ntuple", "some title", nbins, min,max);

//do some stuff (didn't paste all calculations i do, but that works fine)

for (Int_t i = 0; i+1 < nlines-1; i++)
Diff[i] = Price[i+1]-Price[i];
Ret[i] = TMath::Log(Price[i+1])-TMath::Log(Price[i]);
h1->Fill(Ret[i]);
ntuple->Fill(i*1.0,Ret[i],Price[i+1]);



So, it all works fine, no problem at all. But then again if please somebody could explain me as detailed as possible how can i fill histo with, say, index1, or 2 or 3. I suck at c++ and i dont really like it nor understand it.



I expect a beautiful histogram where i can set all things like title, max and minimum, stat box, etc. By default root does it via ntuple but it's not what i need.



Thank so much in advance.










share|improve this question
























  • TNtuple inherits from TTree, so I what you can do with a TTree can also be done with a TNtuple. So if you saw examples with a tree, you should be able to just use them. I.e. ntuple->Draw("branchname>>histname");.

    – pseyfert
    Mar 26 at 17:00











  • If you don't like C++ why not try using Python with PyROOT - root.cern.ch/pyroot. Or even ditch ROOT entirely and try something like NumPy / MatPlotlib matplotlib.org?

    – Nick Edwards
    Mar 27 at 19:42











  • Other nice python interfaces: root_numpy and root_pandas. That is limited, but great for loading ROOT trees into Numpy arrays or Pandas dataframes and work mostly without ROOT after.

    – Keldorn
    Apr 3 at 3:45

















0















Can't obtain/fill histogram starting from ntuple using ROOT.



I have been looking for previous answers and they all use ttree, including root documentation. I dont have one. Not new to root, but i struggle A LOT using it. None of the methods found work with my code (or i dont know how to implement them).



This is more or less what i have found everywhere:



https://root.cern.ch/root/roottalk/roottalk03/2620.html



but no, i am doing TH1F and i have no ttree (see code below)



{ 
gROOT->Reset();

#include "Riostream.h"
#include <iostream>
#include <fstream>

in.open( "somefile.dat");

TNtuple *ntuple = new TNtuple("ntuple","some data from ascii file","index1:index2:index3");

//declare variables, create histograms
Double_t x,y,Price[215000],Diff[215000],Ret[215000],trend, Data[215000];
TFile *f = new TFile("TrendsCountBove.root","RECREATE");
TH1F *h1 = new TH1F("h1","Retornos",100,-0.3,0.3);
TH1F *histo = new TH1F ("hist_from_ntuple", "some title", nbins, min,max);

//do some stuff (didn't paste all calculations i do, but that works fine)

for (Int_t i = 0; i+1 < nlines-1; i++)
Diff[i] = Price[i+1]-Price[i];
Ret[i] = TMath::Log(Price[i+1])-TMath::Log(Price[i]);
h1->Fill(Ret[i]);
ntuple->Fill(i*1.0,Ret[i],Price[i+1]);



So, it all works fine, no problem at all. But then again if please somebody could explain me as detailed as possible how can i fill histo with, say, index1, or 2 or 3. I suck at c++ and i dont really like it nor understand it.



I expect a beautiful histogram where i can set all things like title, max and minimum, stat box, etc. By default root does it via ntuple but it's not what i need.



Thank so much in advance.










share|improve this question
























  • TNtuple inherits from TTree, so I what you can do with a TTree can also be done with a TNtuple. So if you saw examples with a tree, you should be able to just use them. I.e. ntuple->Draw("branchname>>histname");.

    – pseyfert
    Mar 26 at 17:00











  • If you don't like C++ why not try using Python with PyROOT - root.cern.ch/pyroot. Or even ditch ROOT entirely and try something like NumPy / MatPlotlib matplotlib.org?

    – Nick Edwards
    Mar 27 at 19:42











  • Other nice python interfaces: root_numpy and root_pandas. That is limited, but great for loading ROOT trees into Numpy arrays or Pandas dataframes and work mostly without ROOT after.

    – Keldorn
    Apr 3 at 3:45













0












0








0








Can't obtain/fill histogram starting from ntuple using ROOT.



I have been looking for previous answers and they all use ttree, including root documentation. I dont have one. Not new to root, but i struggle A LOT using it. None of the methods found work with my code (or i dont know how to implement them).



This is more or less what i have found everywhere:



https://root.cern.ch/root/roottalk/roottalk03/2620.html



but no, i am doing TH1F and i have no ttree (see code below)



{ 
gROOT->Reset();

#include "Riostream.h"
#include <iostream>
#include <fstream>

in.open( "somefile.dat");

TNtuple *ntuple = new TNtuple("ntuple","some data from ascii file","index1:index2:index3");

//declare variables, create histograms
Double_t x,y,Price[215000],Diff[215000],Ret[215000],trend, Data[215000];
TFile *f = new TFile("TrendsCountBove.root","RECREATE");
TH1F *h1 = new TH1F("h1","Retornos",100,-0.3,0.3);
TH1F *histo = new TH1F ("hist_from_ntuple", "some title", nbins, min,max);

//do some stuff (didn't paste all calculations i do, but that works fine)

for (Int_t i = 0; i+1 < nlines-1; i++)
Diff[i] = Price[i+1]-Price[i];
Ret[i] = TMath::Log(Price[i+1])-TMath::Log(Price[i]);
h1->Fill(Ret[i]);
ntuple->Fill(i*1.0,Ret[i],Price[i+1]);



So, it all works fine, no problem at all. But then again if please somebody could explain me as detailed as possible how can i fill histo with, say, index1, or 2 or 3. I suck at c++ and i dont really like it nor understand it.



I expect a beautiful histogram where i can set all things like title, max and minimum, stat box, etc. By default root does it via ntuple but it's not what i need.



Thank so much in advance.










share|improve this question
















Can't obtain/fill histogram starting from ntuple using ROOT.



I have been looking for previous answers and they all use ttree, including root documentation. I dont have one. Not new to root, but i struggle A LOT using it. None of the methods found work with my code (or i dont know how to implement them).



This is more or less what i have found everywhere:



https://root.cern.ch/root/roottalk/roottalk03/2620.html



but no, i am doing TH1F and i have no ttree (see code below)



{ 
gROOT->Reset();

#include "Riostream.h"
#include <iostream>
#include <fstream>

in.open( "somefile.dat");

TNtuple *ntuple = new TNtuple("ntuple","some data from ascii file","index1:index2:index3");

//declare variables, create histograms
Double_t x,y,Price[215000],Diff[215000],Ret[215000],trend, Data[215000];
TFile *f = new TFile("TrendsCountBove.root","RECREATE");
TH1F *h1 = new TH1F("h1","Retornos",100,-0.3,0.3);
TH1F *histo = new TH1F ("hist_from_ntuple", "some title", nbins, min,max);

//do some stuff (didn't paste all calculations i do, but that works fine)

for (Int_t i = 0; i+1 < nlines-1; i++)
Diff[i] = Price[i+1]-Price[i];
Ret[i] = TMath::Log(Price[i+1])-TMath::Log(Price[i]);
h1->Fill(Ret[i]);
ntuple->Fill(i*1.0,Ret[i],Price[i+1]);



So, it all works fine, no problem at all. But then again if please somebody could explain me as detailed as possible how can i fill histo with, say, index1, or 2 or 3. I suck at c++ and i dont really like it nor understand it.



I expect a beautiful histogram where i can set all things like title, max and minimum, stat box, etc. By default root does it via ntuple but it's not what i need.



Thank so much in advance.







root-framework






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 20:54









pseyfert

9651 gold badge10 silver badges31 bronze badges




9651 gold badge10 silver badges31 bronze badges










asked Mar 25 at 23:55









John DoeJohn Doe

11 bronze badge




11 bronze badge












  • TNtuple inherits from TTree, so I what you can do with a TTree can also be done with a TNtuple. So if you saw examples with a tree, you should be able to just use them. I.e. ntuple->Draw("branchname>>histname");.

    – pseyfert
    Mar 26 at 17:00











  • If you don't like C++ why not try using Python with PyROOT - root.cern.ch/pyroot. Or even ditch ROOT entirely and try something like NumPy / MatPlotlib matplotlib.org?

    – Nick Edwards
    Mar 27 at 19:42











  • Other nice python interfaces: root_numpy and root_pandas. That is limited, but great for loading ROOT trees into Numpy arrays or Pandas dataframes and work mostly without ROOT after.

    – Keldorn
    Apr 3 at 3:45

















  • TNtuple inherits from TTree, so I what you can do with a TTree can also be done with a TNtuple. So if you saw examples with a tree, you should be able to just use them. I.e. ntuple->Draw("branchname>>histname");.

    – pseyfert
    Mar 26 at 17:00











  • If you don't like C++ why not try using Python with PyROOT - root.cern.ch/pyroot. Or even ditch ROOT entirely and try something like NumPy / MatPlotlib matplotlib.org?

    – Nick Edwards
    Mar 27 at 19:42











  • Other nice python interfaces: root_numpy and root_pandas. That is limited, but great for loading ROOT trees into Numpy arrays or Pandas dataframes and work mostly without ROOT after.

    – Keldorn
    Apr 3 at 3:45
















TNtuple inherits from TTree, so I what you can do with a TTree can also be done with a TNtuple. So if you saw examples with a tree, you should be able to just use them. I.e. ntuple->Draw("branchname>>histname");.

– pseyfert
Mar 26 at 17:00





TNtuple inherits from TTree, so I what you can do with a TTree can also be done with a TNtuple. So if you saw examples with a tree, you should be able to just use them. I.e. ntuple->Draw("branchname>>histname");.

– pseyfert
Mar 26 at 17:00













If you don't like C++ why not try using Python with PyROOT - root.cern.ch/pyroot. Or even ditch ROOT entirely and try something like NumPy / MatPlotlib matplotlib.org?

– Nick Edwards
Mar 27 at 19:42





If you don't like C++ why not try using Python with PyROOT - root.cern.ch/pyroot. Or even ditch ROOT entirely and try something like NumPy / MatPlotlib matplotlib.org?

– Nick Edwards
Mar 27 at 19:42













Other nice python interfaces: root_numpy and root_pandas. That is limited, but great for loading ROOT trees into Numpy arrays or Pandas dataframes and work mostly without ROOT after.

– Keldorn
Apr 3 at 3:45





Other nice python interfaces: root_numpy and root_pandas. That is limited, but great for loading ROOT trees into Numpy arrays or Pandas dataframes and work mostly without ROOT after.

– Keldorn
Apr 3 at 3:45












1 Answer
1






active

oldest

votes


















0














Thank you so much guys, first answer worked just right.
Now, i'd love to use python instead of ROOT. Problem is, my thesis directors (both physicists, both from particles) never wanted to do so. As a result, suffering for about six months with c++ and ROOT. Such a drag.



Thanks again!






share|improve this answer























  • hm, still Nick Edwards comment correctly pointed out that python and ROOT don't rule each other out, root can be used from c++ and from python, so as long as your directors only insist on root and not on c++, you could use the python API and they'd still be able to read your .root files. anyway leaving it up to them to decide what they want you to do.

    – pseyfert
    Apr 1 at 14:56










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348021%2fhistogram-with-ntuple-using-cern-root%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Thank you so much guys, first answer worked just right.
Now, i'd love to use python instead of ROOT. Problem is, my thesis directors (both physicists, both from particles) never wanted to do so. As a result, suffering for about six months with c++ and ROOT. Such a drag.



Thanks again!






share|improve this answer























  • hm, still Nick Edwards comment correctly pointed out that python and ROOT don't rule each other out, root can be used from c++ and from python, so as long as your directors only insist on root and not on c++, you could use the python API and they'd still be able to read your .root files. anyway leaving it up to them to decide what they want you to do.

    – pseyfert
    Apr 1 at 14:56















0














Thank you so much guys, first answer worked just right.
Now, i'd love to use python instead of ROOT. Problem is, my thesis directors (both physicists, both from particles) never wanted to do so. As a result, suffering for about six months with c++ and ROOT. Such a drag.



Thanks again!






share|improve this answer























  • hm, still Nick Edwards comment correctly pointed out that python and ROOT don't rule each other out, root can be used from c++ and from python, so as long as your directors only insist on root and not on c++, you could use the python API and they'd still be able to read your .root files. anyway leaving it up to them to decide what they want you to do.

    – pseyfert
    Apr 1 at 14:56













0












0








0







Thank you so much guys, first answer worked just right.
Now, i'd love to use python instead of ROOT. Problem is, my thesis directors (both physicists, both from particles) never wanted to do so. As a result, suffering for about six months with c++ and ROOT. Such a drag.



Thanks again!






share|improve this answer













Thank you so much guys, first answer worked just right.
Now, i'd love to use python instead of ROOT. Problem is, my thesis directors (both physicists, both from particles) never wanted to do so. As a result, suffering for about six months with c++ and ROOT. Such a drag.



Thanks again!







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 22:00









John DoeJohn Doe

11 bronze badge




11 bronze badge












  • hm, still Nick Edwards comment correctly pointed out that python and ROOT don't rule each other out, root can be used from c++ and from python, so as long as your directors only insist on root and not on c++, you could use the python API and they'd still be able to read your .root files. anyway leaving it up to them to decide what they want you to do.

    – pseyfert
    Apr 1 at 14:56

















  • hm, still Nick Edwards comment correctly pointed out that python and ROOT don't rule each other out, root can be used from c++ and from python, so as long as your directors only insist on root and not on c++, you could use the python API and they'd still be able to read your .root files. anyway leaving it up to them to decide what they want you to do.

    – pseyfert
    Apr 1 at 14:56
















hm, still Nick Edwards comment correctly pointed out that python and ROOT don't rule each other out, root can be used from c++ and from python, so as long as your directors only insist on root and not on c++, you could use the python API and they'd still be able to read your .root files. anyway leaving it up to them to decide what they want you to do.

– pseyfert
Apr 1 at 14:56





hm, still Nick Edwards comment correctly pointed out that python and ROOT don't rule each other out, root can be used from c++ and from python, so as long as your directors only insist on root and not on c++, you could use the python API and they'd still be able to read your .root files. anyway leaving it up to them to decide what they want you to do.

– pseyfert
Apr 1 at 14:56








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348021%2fhistogram-with-ntuple-using-cern-root%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현