Vuko,
I suspect that your program crashes when computing the first argument of
TTree::Draw. Could you do;
TString expression = scalerName(ilay+1)+":time >> srhist";
t1->draw(expression,cutString);
Check the definition of your variable scalerName. It seems that you have an
access out of range in the last iteration.
Rene Brun
Vuko Brigljevic wrote:
>
> Hi Rene,
>
> I think I now understand what you meant. However, the
> code with your modification still crashes, though
> only in the last iteration. What I run (your suggestion
> and some printout):
>
> TH2F *srhistos[10];
> int ilay;
> TString hname = "rhist_";
> for (ilay=0; ilay<4; ilay++) {
> cout << "Drawing layer : " << ilay << endl;
> t1->Draw(scalerName(ilay+1)+":time >> srhist",cutString);
> cout << "Cloninng layer : " << ilay << endl;
> srhistos[ilay]= (TH2F*)srhist->Clone(hname+ilay);
> cout << "Done Cloninng layer : " << ilay << endl;
> }
>
> The output:
>
> Drawing layer : 0
> Cloninng layer : 0
> Done Cloninng layer : 0
> Drawing layer : 1
> Cloninng layer : 1
> Done Cloninng layer : 1
> Drawing layer : 2
> Cloninng layer : 2
> Done Cloninng layer : 2
> Drawing layer : 3
>
> *** Break *** segmentation violation
> Root > Function scalerName() busy flag cleared
> Function makePlots() busy flag cleared
> Function doPlots() busy flag cleared
>
> Any idea?
>
> Vuko
>
> Rene Brun wrote:
> >
> > Vuko,
> >
> > Sorry if I was not clear enough in my previous mail. I suggest to replace:
> > int ilay;
> > for (ilay=0; ilay<4; ilay++) {
> > t1->Draw(scalerName(ilay+1)+":time >> srhist",cutString);
> > srhistos[ilay]= new TH2F(*srhist);
> > by
> > int ilay;
> > TString hname = "rhist_";
> > for (ilay=0; ilay<4; ilay++) {
> > t1->Draw(scalerName(ilay+1)+":time >> srhist",cutString);
> > srhistos[ilay]= (TH2F*)srhist->Clone(hname+ilay);
> >
> > Rene Brun
> >
> >
> > Vuko Brigljevic wrote:
> > >
> > > Hi Rene,
> > >
> > > Thanks for helping!
> > >
> > > Rene Brun wrote:
> > > >
> > > > Hi Vuko,
> > > >
> > > > Give a different name to each of your histograms.
> > >
> > > To which histogram should I give a different name, to the one named
> > > "srhist" (see my code below in my 1st message) to which I am copying the
> > > output of Tree->Draw? But then I can't use a loop, but that would be
> > > rather
> > > annoying. I am probably misunderstanding...
> > >
> > > > In your case, t1->Draw will delete the previous histogram named "srhist"
> > > > and your pointers in srhistos[] will be dangling pointers.
> > >
> > > Really? I am confused, I would have thought that the line:
> > >
> > > srhistos[ilay]= new TH2F(*srhist);
> > >
> > > creates a new TH2F (srhistos is an array of pointers to TH2F
> > > objects) using the copy constructor, i.e. *(srhistos[ilay])
> > > is a COPY of *srhist, and not the same object, or does the copy
> > > constructor just let some parts of TH2F point to the original
> > > one? If the latter is the case, that does not seem to be the point
> > > of a copy constructor IMHO.
> > >
> > > Can you please clarify this, thanks.
> > >
> > > Vuko
> > >
> > > > On Tue, 26 Mar 2002, Vuko Brigljevic wrote:
> > > >
> > > > > Hi all,
> > > > >
> > > > > The following is done using root 3.02/07 on SunOS,
> > > > > I see the same problem on Linux.
> > > > >
> > > > > I am trying to use the same 2D histo several times in a row
> > > > > as output of a Tree->Draw() and I am crashing. The code:
> > > > >
> > > > >
> > > > > TH2F *srhistos[10];
> > > > >
> > > > > int ilay;
> > > > > for (ilay=0; ilay<4; ilay++) {
> > > > > t1->Draw(scalerName(ilay+1)+":time >> srhist",cutString);
> > > > > srhistos[ilay]= new TH2F(*srhist);
> > > > > srhistos[ilay]->GetXaxis()->SetTimeDisplay(1);
> > > > > srhistos[ilay]->GetXaxis()->SetTimeFormat("%d/%m");
> > > > > srhistos[ilay]->Draw();
> > > > > gPad->SaveAs(TString(prefix+"singles-layer"+ilay+".eps"));
> > > > > // srhist.Reset(); tried this as well: does not help
> > > > > delete srhist;
> > > > > }
> > > > >
> > > > > Whether I am deleting the temporary histogram (srhist),
> > > > > resetting it or doing neither of both, I am always
> > > > > crashing with the following output:
> > > > >
> > > > > Info in <TPad::Print>: PostScript file lastDays/singles-layer1.eps has
> > > > > been created
> > > > >
> > > > > *** Break *** segmentation violation
> > > > > Root > Function makePlots() busy flag cleared
> > > > > Function doPlots() busy flag cleared
> > > > >
> > > > > How am I supposed to do something like that?
> > > > >
> > > > > Thanks for any help!
> > > > >
> > > > > Vuko
> > > > >
> > > > >
> > > > > ========================================================================
> > > > > Vuko Brigljevic | Mail : SLAC, Mail Stop 41
> > > > > Lawrence Livermore National Laboratory | P.O. Box 4349, Stanford
> > > > > Nuclear and Particle Physics Division | CA 94309, USA
> > > > > | SLAC-Office : B280- room 143
> > > > > Member of the BaBar Collaboration | Phone : +1-650-926 8512
> > > > > <vuko@slac.stanford.edu> <http://www.slac.stanford.edu/~vuko>
> > > > > ========================================================================
> > > > >
> > >
> > > --
> > >
> > > ========================================================================
> > > Vuko Brigljevic | Mail : SLAC, Mail Stop 41
> > > Lawrence Livermore National Laboratory | P.O. Box 4349, Stanford
> > > Nuclear and Particle Physics Division | CA 94309, USA
> > > | SLAC-Office : B280- room 143
> > > Member of the BaBar Collaboration | Phone : +1-650-926 8512
> > > <vuko@slac.stanford.edu> <http://www.slac.stanford.edu/~vuko>
> > > ========================================================================
>
> --
>
> ========================================================================
> Vuko Brigljevic | Mail : SLAC, Mail Stop 41
> Lawrence Livermore National Laboratory | P.O. Box 4349, Stanford
> Nuclear and Particle Physics Division | CA 94309, USA
> | SLAC-Office : B280- room 143
> Member of the BaBar Collaboration | Phone : +1-650-926 8512
> <vuko@slac.stanford.edu> <http://www.slac.stanford.edu/~vuko>
> ========================================================================
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:47 MET