Hi again Rene, I'm afraid that I still can't get the TTree->Draw() command to work with string selections, and I'm wondering if it might be a bug in ROOT v3.0. I tried your example below for instance (minus the extra quote at the beginning) at get segmentation violations both on my linux (Mandrake 7.2) and HP-UX 10.20 root versions. As an example (HP-UX) root [0] .x wah.C <TCanvas::MakeDefCanvas>: created default TCanvas with name c1 *** Break *** segmentation violation ( 0) 0xc3236700 StackTrace__11TUnixSystemFv + 0x28 [/mnt/loki/users4/davidson/loki/usr/local/root/lib/libCore.sl] ( 1) 0xc323517c DispatchSignals__11TUnixSystemF8ESignals + 0x144 [/mnt/loki/users4/davidson/loki/usr/local/root/lib/libCore.sl] ( 2) 0xc3233870 SigHandler__F8ESignals + 0x28 [/mnt/loki/users4/davidson/loki/usr/local/root/lib/libCore.sl] ( 3) 0xc3238224 sighandler__Fi + 0x54 [/mnt/loki/users4/davidson/loki/usr/local/root/lib/libCore.sl] ( 4) 0xc01310b0 _sigreturn [/usr/lib/libc.1] ( 5) 0xc00ad640 _FP8G__valuePCcP8G__parami + 0xfc3d5641 [/mnt/loki/users4/davidson/loki/usr/local/root/lib/libTreePlayer.sl] Stack_Trace: error while unwinding stack where wah.C is simply { //Reset ROOT and connect tree file gROOT->Reset(); TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("Roughness_data.root"); if (!f) { f = new TFile("Roughness_data.root"); } TTree *p1m = p1m; p1m->Draw("rms","strstr(site,\"GD96\")"); } rms (rms/F) and site (site/C) are float and character branches of the tree. The tree itself has about 3000 entries so that I don't think memory is a problem. I'd appreciate any help you can offer on this subject. Regards Malcolm Rene Brun wrote: > Hi Malcom, > > If your branch contains strings (declared as name/C), then you can use > the C function strstr in your cut. Example > > T->Draw(""rms","strstr(field,\"field_cut\")") > > More operators could be introduced to support the search functions > in TString or C++ string. > > Rene Brun > > Malcolm Davidson wrote: > > > > Content-Type: text/plain; charset=us-ascii > > Content-Transfer-Encoding: 7bit > > > > Hi Rene, > > > > Thanks for your reply but I'm afraid I didn't express the root of the problem clearly. > > > > What I actually wanted to ask is whether a cut could be made with the draw command > > > > using a branch containing strings. As an example: > > > > I have a tree T containing two branches one labelled "rms" and contaning floats and the other > > > > labeled "field" and containing strings, then it would be nice to be able to plot a histogram of > > > > all values having field == "Field1" with the commands > > > > TString field_cut = "Field1" > > > > T->Draw("rms","field == field_cut"); > > > > Even better of course would be the ability to use REGEXPs :) but I would be happy if the first > > > > case was already implemented. > > > > Kind regards > > > > Malcolm > > > > >Hi Malcom, > > >There are two TTree::Draw functions: > > > > >Draw(const char* varexp, TCut selection, Option_t* option, ... > > > Draw(const char* varexp, const char* selection, Option_t* option,...) > > > > >What you request with TString is implemented with TCut. > > > > >Rene Brun > > > > Malcolm Davidson wrote: > > > > > > Hello, > > > > > > I was wondering if the selection based on TStrings for the TTree->Draw() > > > command had been implemented yet (based on my attempts not) or whether > > > this useful feature (here I'm quoting from a 1999 email from Rene Brun) > > > will soon be added ? > > > > > > Many thanks in advance > > > > > > Malcolm > > > <>------------------------------------------------<> > > > Malcolm W. J. Davidson > > > > > > Centre D'Etudes Spatiales de la Biosphere (CESBIO) > > > UMR 5639 CNES-CNRS-UPS > > > 18, Avenue Edouard Belin > > > F-31401 Toulouse Cedex 4 > > > FRANCE > > > > > > e-mail : davidson@cesbio.cnes.fr > > > phone (33)(0)5.61.55.85.84 > > > fax (33)(0)5.61.55.85.00 > > > <>------------------------------------------------<> -- <>------------------------------------------------<> Malcolm W. J. Davidson Centre D'Etudes Spatiales de la Biosphere (CESBIO) UMR 5639 CNES-CNRS-UPS 18, Avenue Edouard Belin F-31401 Toulouse Cedex 4 FRANCE e-mail : davidson@cesbio.cnes.fr phone (33)(0)5.61.55.85.84 fax (33)(0)5.61.55.85.00 <>------------------------------------------------<>
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:35 MET