Please read tips for efficient and successful posting and posting code
Please fill also the fields below. Note that root -b -q
will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug
from the ROOT prompt to pre-populate a topic.
ROOT Version: ROOT 6.26/10
Platform: Ubuntu
My code is as follows
#include <iostream>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <TFile.h>
#include <TTree.h>
#include <TROOT.h>
#include <TChain.h>
#include <TSelector.h>
#include <TMath.h>
#include <TBenchmark.h>
#include <TF1.h>
#include <TObjArray.h>
#include <TCutG.h>
int ana(){
//========================= loading DCR-parameter
//========================= DCR-file
string DCRfileName = "14_964_1_PA1706-585.txt";
string DCRFile = "14_964_1_PA1706-585";
TFile *juno = new TFile((DCRFile+".root").c_str(),"recreate");
TTree *data = new TTree("data","Experiment data");
printf("-----loading DCR-file : %s. \n", DCRfileName.c_str());
ifstream file;
int i=0;
double DCR,Voltage;
vector<int>volt;//default voltage
vector<double>dcr;
volt.resize(500);
file.open(DCRfileName.c_str());
if( file.is_open() )
{
int a;
while( file >> a )
{
//dcr[i] = a;
dcr.push_back(a);
i = i+1;
}
printf("..done \n");
}
else{ printf("...fail open \n"); }
for(int v =0;v<dcr.size();v++)
{
volt[v] =2000;
}
file.close();
//========================Create root file
data->Branch("DCR", &DCR, "DCR/D");
data->Branch("Voltage", &Voltage, "voltage/I" );
//data->Branch("date",);
//data->Branch("time",);
for(int number = 0; number < dcr.size();number++)
{
DCR = dcr[number];
Voltage = volt[number];
data->Fill();
}
data ->Write();
juno ->Close();
printf("------Finish!!!! \n");
return 0;
}
Here’s the message.
Attaching file 14_964_1_PA1706-585.root as _file0...
(TFile *) 0x564673c27920
root [1] data->Print()
ROOT_prompt_1:1:1: error: reference to overloaded function could not be resolved; did you mean to call it?
data->Print()
^~~~
/usr/include/c++/11/bits/range_access.h:290:5: note: possible target for call
data(_Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/11/bits/range_access.h:300:5: note: possible target for call
data(const _Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/11/bits/range_access.h:310:5: note: possible target for call
data(_Tp (&__array)[_Nm]) noexcept
^
/usr/include/c++/11/bits/range_access.h:319:5: note: possible target for call
data(initializer_list<_Tp> __il) noexcept