Hi,
Sorry in case you double receive this mail... I sent it yestarday, but I'm not sure it was properly received...
Here it is.
Cheers,
Chiara
Hi,
I have a problem when trying to write an object containing a variable length array of TString to a file. In fact, the object contains a variable length array of different types, which are initialized only if the corresponding constructor is called.
In the attached file you can fine the class (AliDCSArray.h/cxx) where the array is, and a macro (test1.C) to write an object of that class in a file. The TString array is not initialized, in this example, while I initialize the Bool_t one.
Here's what I get when exectuting the macro:
root [0] .x test1.C
Info in <TUnixSystem::ACLiC>: creating shared library
/home/zampolli/FileDCSLHC/ForROOT/././AliDCSArray_cxx.so
Error in <TStreamerInfo::WriteBufferAux>: The pointer to element
AliDCSArray::fString type 501 (TString*) is null
root [1] .q
I know the error is related to that: the streamer can't write the TString pointer object if it is null. But why doesn't it complain for the other types? Am I doing something wrong? Am I missing somthing? Is there a workaround? Is this not supported at all? Do I need my own streamer? :-)
Thanks, and cheers,
Chiara
#ifndef ALI_DCS_ARRAY_H
#define ALI_DCS_ARRAY_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
/* $Id$ */
//////////////////////////////////////////////////////////////////////////////// // // // This class represents the value(s) of a the LHC DPs at a given timestamp // // // ////////////////////////////////////////////////////////////////////////////////#include <TString.h>
#include <TObject.h>
class AliDCSArray : public TObject {
public:
enum Type {
kInvalid = 0,
kBool = 1,
kChar = 2,
kInt = 3,
kUInt = 4,
kFloat = 5,
kString = 6
};
AliDCSArray();
AliDCSArray(const AliDCSArray& c);
virtual ~AliDCSArray();
AliDCSArray& operator=(const AliDCSArray& c);
AliDCSArray(Int_t nentries, Bool_t* value, TTimeStamp* timeStamp);
AliDCSArray(Int_t nentries, Char_t* value, TTimeStamp* timeStamp);
AliDCSArray(Int_t nentries, Int_t* value, TTimeStamp* timeStamp);
AliDCSArray(Int_t nentries, UInt_t* value, TTimeStamp* timeStamp);
AliDCSArray(Int_t nentries, Float_t* value, TTimeStamp* timeStamp);
AliDCSArray(Int_t nentries, TString* value, TTimeStamp* timeStamp);
Int_t GetNEntries() const { return fnentries;}
Bool_t* GetBool() const { return fBool; }
Char_t* GetChar() const { return fChar; }
Int_t* GetInt() const { return fInt; }
UInt_t* GetUInt() const { return fUInt; }
Float_t* GetFloat() const { return fFloat; }
TString* GetString() const { return fString; }
Type GetType() const { return fType; }
TTimeStamp* GetTimeStamp() const { return fTimeStamp; }
void SetTimeStamp(TTimeStamp* timeStamp) { fTimeStamp = timeStamp; }
protected:
void Init();
Type fType; // type of the value stored
Int_t fnentries; // n. of entries at the same timestamp Bool_t* fBool; //[fnentries] bool value Char_t* fChar; //[fnentries] char value Int_t* fInt; //[fnentries] int value UInt_t* fUInt; //[fnentries] uint value Float_t* fFloat; //[fnentries] float value TString* fString; //[fnentries] string value TTimeStamp* fTimeStamp; // timestamp of this value ClassDef(AliDCSArray, 1);
#endif
void test1(){
gROOT->LoadMacro("./AliDCSArray.cxx++g");
Int_t nentries =2;
Bool_t b[2]={kTRUE,kFALSE};
TTimeStamp* time = new TTimeStamp(17457698);
AliDCSArray* dcs = new AliDCSArray(nentries, b, time);
TFile* f = new TFile("test.root","RECREATE");
dcs->Write();
f->Close();
return;
This archive was generated by hypermail 2.2.0 : Wed Aug 05 2009 - 11:50:03 CEST