Re: [Fwd: BOUNCE roottalk@root.cern.ch: Admin request: /^subject:\s*help\b/i]

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Oct 13 1999 - 15:33:56 MEST


Could you add the statement marker //<======
in your code below and let me know the result.
When are you browsing the file ? Do you have a Browse function in the
class
or do you use the one in TObject ?

Rene Brun


> To: roottalk@hpsalo.cern.ch
> Content-Type: multipart/mixed;
>  boundary="------------D4DDC92CBB4B92FB7BDF0DCA"
> Sender: <Santo.Vanadia@CT.INFN.IT>
> From: Vanadia Santo <santo.vanadia@CT.INFN.IT>
> Subject: Help in writing ROOT files
> 
> This is a multi-part message in MIME format.
> --------------D4DDC92CBB4B92FB7BDF0DCA
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> Dear experts,
> 
> we are using ROOT 2.22/10 on Linux RedHat 6.0 and we are experiencing a
> funny problem in writing ROOT files.
> In the attached macro we try to write ten object into the file, if you
> inspect the first of them you'll see that it's correctly in
> memory...when you try to browse the file you see the ten objects but
> they are empty!
> 
> Where are we wrong? Any help will be greatly appreciated
> 
> Regards, Santo Vanadia
> --------------D4DDC92CBB4B92FB7BDF0DCA
> Content-Type: text/plain; charset=us-ascii;
>  name="hitsfile.C"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline;
>  filename="hitsfile.C"
> 
> void hitsfile (Int_t evNumber=0)
> {
> 
> // Dynamically link some shared libs
>    if (gClassTable->GetID("AliRun") < 0) {
>       gROOT->LoadMacro("loadlibs.C");
>       loadlibs();
>    } // end if gClassTable...
> 
> // Connect the Root Galice file containing Geometry, Kine and Hits
>    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
>    if (!file) file = new TFile("galice.root");
> 
> // Get AliRun object from file or create it if not on file
>    if (!gAlice) {
>       gAlice = (AliRun*)file->Get("gAlice");
>       if (gAlice) printf("AliRun object found on file\n");
>       if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
>    }
> 
> // Import the Kine and Hits Trees for the event evNumber in the file
>    Int_t nparticles = gAlice->GetEvent(evNumber);
>    if (nparticles <= 0) return;
>    Float_t x,y,z,mass,e,r;
>    Int_t nbytes = 0;
>    Int_t j,hit,ipart;
>    Int_t nhits, n_hit, conta, hitcount;
>    Int_t layerno,ladderno,detno,indexno,flag;
>    TParticle *particle;
> 
>    AliITShit  *itsHit;
>    AliITSmodule *itsMod;
> 
>    vett = new TObjArray(10000);
> 
> 
> // Get pointers to Alice detectors and Hits containers
>    AliDetector *ITS  = gAlice->GetDetector("ITS");
>    TClonesArray *Particles = gAlice->Particles();
> 
>    if (ITS) TClonesArray *ITShits   = ITS->Hits();
> 
>    TTree *TH = gAlice->TreeH();
>    Int_t ntracks    = TH->GetEntries();
>    Int_t i=0, index=0;
> 
>         for (Int_t track=0; track<ntracks; track++) {
>            gAlice.ResetHits();
>            nbytes += TH.GetEvent(track);
>            if (ITS) {
>               nhits = ITShits.GetEntriesFast();
>               for (hit=0;hit<nhits;hit++) {
>                  itsHit = (AliITShit*)ITShits.UncheckedAt(hit);
>                  if (itsHit.fDestep > 0) {
>                    index = itsHit.GetModule();
>                    itsMod = new AliITSmodule(index,itsHit.fLayer,itsHit.fLadder,itsHit.fDet,itsHit.fHitId);
>                    vett.Add(itsMod);
> 
> 
>                  } /* end if */
>               } /* end for */
>            } /* end if */
>         } /* end for */
> 
>         n_hit = vett.GetEntries();
>         printf("Hits Total Number = %d\n",n_hit);
>         printf("Please Wait...\n");
> 
> 
>         // Calcolo numero di hit per modulo (1..2270)
> 
>         for (Int_t k=1;k<2271;k++) {
>            conta = 0;
>            for (Int_t j=0; j<n_hit; j++) {
>               AliITSmodule *cursore = (AliITSmodule *)vett.At(j);
>               if (cursore.fIndex == k) conta++;
>            }
>            for (Int_t j=0; j<n_hit; j++) {
>               AliITSmodule *cursore = (AliITSmodule *)vett.At(j);
>               if (cursore.fIndex == k) cursore.fNhitsM = conta;
>            }
>         }
> 
>         file.Close();
> 
>         printf("Done!\n");
> 
>         TFile hfile("hitITS.root","RECREATE");
> 
>         for (Int_t j=0; j<10; j++) {
>            AliITSmodule *w = (AliITSmodule *)vett.At(j);
             w->Dump(); //<==============
>            w.Write();
>         }
> 
          hfile.ls();  //<===============
>         hfile.Close();
> 
>         AliITSmodule *v = (AliITSmodule *)vett.At(0);
> 
>         v.Inspect();
> 
> 
> 
> }
> 
> --------------D4DDC92CBB4B92FB7BDF0DCA--



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:40 MET