Hi Frederic,
Suppose the following session:
TFile f("junk.root","recreate");
TH1F h("h","h",100,-2,2);
h.Write();
h.Fill(1);
h.Write("",TObject::kOverwrite)
f.ls(); //this will produce
TFile** junk.root
TFile* junk.root
OBJ: TH1F h h : 0
KEY: TH1F h;1 h
As you can see, using the kOverwite flag will force a replacement
of the previous object with the same name.
Rene Brun
On Wed, 29 May 2002, Frederic Villeneuve-Seguier wrote:
>
> Hi,
> I probably gave bad explanation of what I want to do :
> I run on several data files. On each data files I apply a class that
> open/update a root files with some histograms.
> In order to update histograms, I check if they are defined, if not I
> create them, but if they are already define I declare pointers to them.
>
> This is working but in the root files where I store my histograms,
> I have duplicated histos (different cycles of the same histos)
>
> Is there a way to avoid duplication, and to update an histogram ?
>
> thanks,
> frederic.
>
>
>
> On Wed, 29 May 2002, Rene Brun wrote:
>
> > Hi Frederic,
> >
> > You must write the histograms to the file once you have filled them.
> > In your case, add the statement
> > f->Write();
> > just after the loop filling your histograms
> >
> > Rene Brun
> >
> >
> > On Tue, 28 May 2002, Frederic Villeneuve-Seguier wrote:
> >
> > >
> > >
> > > Hi all,
> > >
> > >
> > > I want to study a large number of root files and I can't chain them.
> > > So I study files one by one.
> > > FOr somme coding reason, I need to apply a class inherited from a
> > > MakeClass() on each of the files.
> > > What I'm trying to do is :
> > > I open in the "update" mode, the file where I store the results of my
> > > studies. Then I declare (if it's the first time) or I "point at"
> > > the histograms and fill/update them.
> > > I use this in a C++ standalone mode.
> > >
> > > At the moment the file with the results is empty, and it seems that
> > > the histograms aren't detected. I coded it this way :
> > >
> > > //--- Check if histos exists
> > > TFile * f = TFile::Open("TriggStudies.root");
> > > f->ls();
> > > TH1F * check = NULL;
> > > check = (TH1F * ) f->Get("sJ_nev_mu");
> > > cout << "check = " << check << endl;
> > > if (check == NULL) {
> > > //--- Histograms Creation
> > > cout << "| [#] Create Histograms for Trigger Studies" << endl;
> > > diJets_Nevts_mu = new TH1F("sJ_nev_mu","N evt vs Pt of Jet - L1 mu",75,0,150);
> > > } else {
> > > diJets_Nevts_mu = (TH1F * ) f->Get("sJ_nev_mu");
> > > }
> > >
> > > the problem I have is that data files after data files, the "check"
> > > pointer is everytime empty.
> > >
> > > Does someone has an idea on what could be the source of this problem ?
> > >
> > > In an other way of saying that, Is it possible to fill histograms in a
> > > root file, close it, then reopen this file, update the histograms
> > > and re-close it again, and so on ... ?
> > >
> > >
> > > many thanks,
> > > take care,
> > > frederic.
> > >
> > >
> > > *---------------------------------------------------------*
> > > | Frederic Villeneuve-Seguier PHD - D0 experiment |
> > > | |
> > > | Centre de Physique des Particules de Marseille |
> > > | 163, avenue de Luminy 13288 |
> > > | Marseille Cedex 09 |
> > > | France |
> > > *---------------------------------------------------------*
> > > | Tel : 33 (0)4 91 82 76 13 |
> > > | Fax : 33 (0)4 91 82 72 99 |
> > > | e-mail: villeneuve@cppm.in2p3.fr |
> > > | homepage: http://marwww.in2p3.fr/~villeneu |
> > > *---------------------------------------------------------*
> > >
> >
> >
>
> *---------------------------------------------------------*
> | Frederic Villeneuve-Seguier PHD - D0 experiment |
> | |
> | Centre de Physique des Particules de Marseille |
> | 163, avenue de Luminy 13288 |
> | Marseille Cedex 09 |
> | France |
> *---------------------------------------------------------*
> | Tel : 33 (0)4 91 82 76 13 |
> | Fax : 33 (0)4 91 82 72 99 |
> | e-mail: villeneuve@cppm.in2p3.fr |
> | homepage: http://marwww.in2p3.fr/~villeneu |
> *---------------------------------------------------------*
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET