TObjArray in a file

From: Chiara Zampolli <Chiara.Zampolli_at_bo.infn.it>
Date: Fri, 28 Oct 2005 16:11:35 +0200


Dear rooters,  

    I am trying to write a TObjArray in a root file. The TObjArray UCdata I create (see below, a very na´ve example of what I am doing) is made up of AliTOFUncalib data, which inherit from the AliESDtrack class (an AliRoot class which, in turn, inherits from the TObject class). After writing UCdata in the file, when I try to list the content of the file (file->ls();), what I get is the list of all the elements of the TObjArray instead of the TObjArray itself. Morevoer, the elements are described as AliESDtracks and not AliTOFUncalibs! Perhaps this is exactly the way it should be, but since I would need then to retrieve from the file the whole TObjArray, this doesn’t seem the right way to follow (also because there will be few thousands of elements in the TObjArray to be retrieved). In other words, how can I write on a file a TObjArray and then retrieve it as a whole? (I think that then, for each element, the method At() will be ok….).  

    Thank you for your help.
    Cheers,

       Chiara  




#if !defined( __CINT__) || defined(__MAKECINT__)
#include


#endif
 

  class UnCalib:public AliESDtrack{
  public:
    UnCalib(){}
    //UnCalib(AliESDtrack *track){
    ~UnCalib(){}

  private:

    ClassDef(UnCalib,1);
  };  

#ifdef __MAKECINT__
#pragma link C++ UnCalib+;
#endif
 

Int_t UnCalib2()
{

  TObjArray UCdata(10);
    for (Int_t itrk=0; itrk<10; itrk++) {

       AliESDtrack *t=event->GetTrack(itrk);
       UnCalib *ciccio = (UnCalib*) t ;
       UCdata[itrk] = new UnCalib(*ciccio);
       //UCdata[itrk] = ciccio;       
…
       UnCalib *ciccino = (UnCalib*)UCdata.At(itrk);
       //       UCdata[itrk]->SetAll(tdc,tot,cal);
…
     }

   }
   TFile *file = new TFile("UnCalibratedData.root","recreate");    UCdata.Write();
   return 0;
}             Received on Fri Oct 28 2005 - 16:08:27 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET