Hello,
I currently have a text file (attached), from which I need to draw data and fit in a histogram. The fitting part I know how to do, but I am having trouble extracting the data from the .txt and drawing it in a histogram. I’ve got two versions of my code, neither of which really work.
This one draws only the first event:
[quote]
TTree NoiseTree = new TTree(“NoiseTree”, “NoiseTree”);
NoiseTree->ReadFile("/11_noPreamble.txt", “mV”);
TH1F NoiseHist = new TH1F(“Signal And Noise”, “Signal And Noise”, 200, -160, 40);
NoiseTree->Draw(“mV>>NoiseHist”);[/quote]
While this one draws the first event, and a few value=0 events it gets from I don’t know where:
[quote]TTree NoiseTree = new TTree(“NoiseTree”, “NoiseTree”);
NoiseTree->ReadFile("/11_noPreamble.txt", “mV”);
TH1F NoiseHist = new TH1F(“Signal And Noise”, “Signal And Noise”, 200, -160, 40);
int entries = NoiseTree.GetEntry();
for(int i = 0; i < entries; i++) {
NoiseHist->Fill(NoiseTree.GetEntry(i));
}
NoiseHist->Draw();[/quote]
The problem is that the file has 20,000 events, and thus the histogram should be quite a bit bigger than one event. Does anyone know how to get the code to draw every event?
11_noPreamble.txt (117 KB)