Hi Taylan,
> etree->Draw(tower, tower < 3000);
Since tower is declared as "char tower[256];", this is actually performing pointer arithmetic before calling Draw. I.e. (tower<3000) is zero if the address of the tower array of char is less than 3000.
> etree->Draw(tower, "tower < 3000");
Here tower is a C++ variable which is not known by the TTree object, which leads to the correct error message:
Unknown name : "tower"
Instead you should use:
etree->Draw(tower, Form("%s<3000",tower) );
Or in 3.05/07 and above, you can use
etree->SetAlias("towerAlias",tower);
etree->Draw(tower,"towerAlias<3000");
Also, I am still unclear what is the command that, in your case, lead to the segmentation violation (at least I can not reproduce it with any of the commands you sent so far).
Cheers,
Philippe.
-----Original Message-----
From: taylan yetkin [mailto:tyetkin@fnal.gov]
Sent: Tuesday, August 19, 2003 4:03 AM
To: Philippe Canal
Cc: roottalk@pcroot.cern.ch
Subject: Re: [ROOT] tree and streams
Hi Philippe,
I am getting tons of warning messages starting from
*** Break *** segmentation violation
Generating stack trace...
if I use
etree->Draw(tower, tower < 3000);
or if I change above line as
etree->Draw(tower, "tower < 3000");
I am getting this short warning:
*ERROR 26 :
Unknown name : "tower"
Thanks
Philippe Canal wrote:
Hi,
etree->Draw(tower); <--------------------This also works,
but when I want to put a cut like before root is complaining.
What kind of complain? This should have worked with or without a cut.
rtree->GetBranch("info")->SetAddress(&info);
It would be better to use:
rtree->SetBranchAddress("info",&info);
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of taylan yetkin
Sent: Monday, August 18, 2003 8:36 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] tree and streams
Hi Rooters,
I have a problem with my stream definitions in trees. Below you can see
a part from my code.
while(!input_file.eof()){
char run_no[20];
int tower_no;
input_file >> run_no >> tower_no;
if (input_file.fail()) { break; }
int elmfiber = tower_no - 1;
int hadfiber = tower_no + 12;
char s[256];
char tower[256];
strstream sstream(s, 256, ios::in | ios::out);
sstream << "/reco/data/TB2003_JUL/" << run_no << ends;
strstream sstream(tower,256,ios::in |ios::out);
sstream << "towers[" << elmfiber << "].e+towers[" <<
hadfiber<< "].e" << ends;
TFile f(s);
TTree *rtree = (TTree *)f.Get("Run");
RecoInfo *info = new RecoInfo();
RecoRun *run = new RecoRun();
RecoEvent *event = new RecoEvent();
RecoTrigger *trigger = new RecoTrigger();
RecoPhase *phase = new RecoPhase();
RecoHCAL *hcal = new RecoHCAL();
RecoCluster *cluster = new RecoCluster();
rtree->GetBranch("info")->SetAddress(&info);
rtree->GetBranch("run")->SetAddress(&run);
TTree *etree = (TTree *)f.Get("Event");
etree->GetBranch("event")->SetAddress(&event);
etree->GetBranch("trigger")->SetAddress(&trigger);
etree->GetBranch("phase")->SetAddress(&phase);
etree->GetBranch("hcal")->SetAddress(&hcal);
TCanvas *c1 = new TCanvas("c1","c1",20,10,900,600);
c1->Divide(2,1);
c1->cd(1);
etree->Draw("c3x3.e","c3x3.e<5000");
<---------------This works without any problem.
c1->cd(2);
etree->Draw(tower); <--------------------This also works,
but when I want to put a cut like before root is complaining.
How can I use Draw() method with all options for this tower stream.
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET