Hi, I created a class with a TSOrtedList containing many istances of objects. When I fill a TTree with this class, I get an error of chunk_free, occurring when a cycle ends and the TTree should go to the further entry. Maybe there is something to be done in the destructor of the collected class (which in my implementation is left void)? Here I attach the code of the collected class I use, for you to give a look to it in a better way.. Thanks alberto #include <stdlib.h> #include <iostream.h> #include <TROOT.h> #include <TObject.h> #include <TMath.h> #include "AliITSRecPoint.h" #include "AliITSgeomMatrix.h" #include "AliITSglobalRecPoint.h" #include "../TPC/AliTPCParam.h" #include "../TPC/AliTPCcluster.h" #include "../CONTAINERS/AliSegmentID.h" ClassImp(AliITSglobalRecPoint) //________________________________________________________________________________________________________________________________________________ AliITSglobalRecPoint::AliITSglobalRecPoint() { // Default constructor: // sets to zero all members fIndex = 0; fLayer = 0; fGX = 0.0; fGY = 0.0; fGZ = 0.0; fGSX = 0.0; fGSY = 0.0; fGSZ = 0.0; fR2 = 0.0; fR3 = 0.0; fPhi = 0.0; fTheta = 0.0; fLabel[0] = -1; fLabel[1] = -1; fLabel[2] = -1; fModule = 0; fPosInModule = 0; fQ = 0.0; fdE = 0.0; fUsed = 0; } //________________________________________________________________________________________________________________________________________________ AliITSglobalRecPoint::AliITSglobalRecPoint(AliITSglobalRecPoint *p) { // Copy constructor which copies the members of // a passed pointer avoiding to make the objects point // to the same memory area Int_t i; if (!p) { Error("(constructor)", "p is NULL"); AliITSglobalRecPoint(); return; } fGX = p->fGX; fGY = p->fGY; fGZ = p->fGZ; fGSX = p->fGSX; fGSY = p->fGSY; fGSZ = p->fGSZ; fLayer = p->fLayer; fIndex = p->fIndex; fModule = p->fModule; fPosInModule = p->fPosInModule; for (i = 0; i < 3; i++) fLabel[i] = p->fLabel[i]; fQ = p->fQ; fdE = p->fdE; fUsed = 0; Calc(); } //________________________________________________________________________________________________________________________________________________ AliITSglobalRecPoint::AliITSglobalRecPoint(AliITSRecPoint *recp, AliITSgeomMatrix *gm) { // This constructor converts the local coordinates of a given AliITSRecPoint // using the correct geomMatrix, and then sets all datamembers like in the // copied recpoint Int_t i, k; Double_t locPos[3], globPos[3], locErr[3][3], globErr[3][3]; if (!recp) { Error("(constructor)", "recp is NULL"); AliITSglobalRecPoint(); return; } if (!gm) { Error("(constructor)", "gm is NULL"); AliITSglobalRecPoint(); return; } for (i = 0; i < 3; i++) { locPos[i] = globPos[i] = 0.0; for (k = 0; k < 3; k++) { locErr[i][k] = 0.0; globErr[i][k] = 0.0; } } // local to global conversions of coords locPos[0] = recp->fX; locPos[1] = 0.0; locPos[2] = recp->fZ; gm->LtoGPosition(locPos, globPos); fGX = globPos[0]; fGY = globPos[1]; fGZ = globPos[2]; // local to global conversions of sigmas locErr[0][0] = recp->fSigmaX2; locErr[2][2] = recp->fSigmaZ2; gm->LtoGPositionError(locErr, globErr); fGSX = TMath::Sqrt(globErr[0][0]); fGSY = TMath::Sqrt(globErr[1][1]); fGSZ = TMath::Sqrt(globErr[2][2]); // copy of other datamembers for (i = 0; i < 3; i++) fLabel[i] = recp->fTracks[i]; fQ = recp->fQ; fdE = recp->fdEdX; // set to zero all indices (use SetModuleData()) fLayer = 0; fIndex = 0; fModule = 0; fPosInModule = 0; fUsed = 0; // calculate cylindrical coordinates Calc(); } //________________________________________________________________________________________________________________________________________________ AliITSglobalRecPoint::AliITSglobalRecPoint (AliTPCcluster *cl, AliTPCParam *par, Int_t isect, Int_t irow) { // Converts a TPC cluster into a AliITSglobalRecPoint // with all necessary operation to express its coordinates // into the global reference frame if (!cl || !par) { Error("(constructor)", "Null arguments passed"); AliITSglobalRecPoint(); return; } Double_t x, y, sigma; Float_t angSin, angCos; // get the parameter for conversion par->AdjustCosSin(isect, angCos, angSin); x = (Double_t)par->GetPadRowRadii(isect, irow); y = (Double_t)cl->GetY(); // convert coordinates fGX = x * (Double_t)angCos - y * (Double_t)angSin; fGY = x * (Double_t)angSin + y * (Double_t)angCos; fGZ = (Double_t)cl->GetZ(); // convert errors sigma = cl->GetSigmaY2(); fGSX = (Double_t)TMath::Sqrt(angSin*angSin*sigma); fGSY = (Double_t)TMath::Sqrt(angCos*angCos*sigma); fGSZ = (Double_t)TMath::Sqrt(cl->GetSigmaZ2()); // ctore charge deposited in cluster (no info about energy loss) fQ = (Double_t)cl->GetQ(); fdE = 0.0; // set to zero all indices (use SetModuleData()) fIndex = 0; fLayer = 0; fModule = 0; fPosInModule = 0; fUsed = 0; // store track label from GEANT fLabel[0] = cl->GetLabel(0); fLabel[1] = cl->GetLabel(1); fLabel[2] = cl->GetLabel(2); // calculate cylindircal coordinates Calc(); } //________________________________________________________________________________________________________________________________________________ void AliITSglobalRecPoint::Calc() { // This method calculates the polar coordinates from the carthesian ones fR2 = TMath::Sqrt(fGX*fGX + fGY*fGY); fR3 = TMath::Sqrt(fGX*fGX + fGY*fGY + fGZ*fGZ); fPhi = TMath::ATan2(fGY, fGX); if (fPhi < 0.0) fPhi += 2.0 * TMath::Pi(); fTheta = TMath::ATan2(fR2, fGZ); } //________________________________________________________________________________________________________________________________________________ Double_t AliITSglobalRecPoint::ErrorR2() { // Square sigma of the 2-D radius: // = X^2 * Sx^2 + Y^2 * Sy^2 Double_t answer = fGX*fGX*fGSX + fGY*fGY*fGSY; return answer / (fR2 * fR2); } //________________________________________________________________________________________________________________________________________________ Double_t AliITSglobalRecPoint::ErrorR3() { // Square sigma of the 3-D radius: // = (X^2 * Sx^2 + Y^2 * Sy^2 + Z^2 * Sz^2) / R^2 // R in 3-D, r in 2-D Double_t answer = fGX*fGX*fGSX + fGY*fGY*fGSY + fGZ*fGZ*fGSZ; return answer / (fR3 * fR3); } //________________________________________________________________________________________________________________________________________________ Double_t AliITSglobalRecPoint::ErrorTheta() { // Square sigma of theta: // = (Z^2 * (X^2 * Sx^2 + Y^2 * Sy^2) + r^4 * Sz^2) / (R^4 * r^2) // R in 3-D, r in 2-D Double_t answer = fGZ*fGZ*(fGX*fGX*fGSX + fGY*fGY*fGSY) + fR2*fR2*fR2*fR2*fGSZ; answer /= (fR3*fR3*fR3*fR3*fR2*fR2); return answer; } //________________________________________________________________________________________________________________________________________________ Double_t AliITSglobalRecPoint::ErrorPhi() { // Square sigma of phi: // = (Y^2 * Sx^2 + X^2 * Sy^2) / r^4 // R in 3-D, r in 2-D Double_t answer = fGY*fGY*fGSX*fGSX + fGX*fGX*fGSY*fGSY; answer /= (fR2 * fR2 * fR2 * fR2); return answer; } //________________________________________________________________________________________________________________________________________________ Double_t AliITSglobalRecPoint::Dist(AliITSglobalRecPoint *p) { Double_t dX, dY, dZ; dX = fGX - p->fGX; dY = fGY - p->fGY; dZ = fGZ - p->fGZ; return TMath::Sqrt(dX*dX + dY*dY + dZ*dZ); } //________________________________________________________________________________________________________________________________________________ Double_t AliITSglobalRecPoint::DPhi(AliITSglobalRecPoint *p) { // Absolute value of the difference // between 'phi' coordinates of two points // controlled in order to avoid that, for // reasons of initial values, it come > 180. degrees Double_t phi = TMath::Abs(fPhi - p->fPhi); if (phi > TMath::Pi()) phi = 2.0 * TMath::Pi() - phi; return phi; } //________________________________________________________________________________________________________________________________________________ Double_t AliITSglobalRecPoint::DTheta(AliITSglobalRecPoint *p) { // Absolute value of the difference // between 'theta' coordinates of two points return TMath::Abs(fTheta - p->fTheta); } //________________________________________________________________________________________________________________________________________________ Int_t AliITSglobalRecPoint::Compare(const TObject *O) const { // Aims to sort in increasing order w.r.t the xy radius AliITSglobalRecPoint *that = (AliITSglobalRecPoint*)O; Int_t thisR = (Int_t)(fR2 * 100.0), thatR = (Int_t)(that->fR2 * 100.0); return (thisR - thatR); } #ifndef ALIITSGLOBALRECPOINT_H #define ALIITSGLOBALRECPOINT_H class AliITSRecPoint; class AliITSgeomMatrix; class AliTPCcluster; class AliTPCParam; class AliSegmentID; class AliITSglobalRecPoint : public TObject { public: // many constructors... AliITSglobalRecPoint(); AliITSglobalRecPoint(AliITSglobalRecPoint *p); AliITSglobalRecPoint(AliITSRecPoint *p, AliITSgeomMatrix *gm); AliITSglobalRecPoint(AliTPCcluster *cl, AliTPCParam *par, Int_t isect, Int_t irow); // destructor... virtual ~AliITSglobalRecPoint() { } void SetCoords(Double_t *x){ fGX = x[0]; fGY = x[1]; fGZ = x[2]; Calc(); } void SetErrors(Double_t *e){ fGSX = e[0]; fGSY = e[1]; fGSZ = e[2]; } void SetModuleData(Int_t layer, Int_t mod, Int_t pos) { fLayer = layer; fModule = mod; fPosInModule = pos; } // error propagation on polar coordinates Double_t ErrorR2(); // cylindrical radius Double_t ErrorR3(); // spherical radius Double_t ErrorPhi(); // azimuthal angle Double_t ErrorTheta(); // polar angle // calculation of polar coords from carthesian void Calc(); // distance from another point Double_t Dist(AliITSglobalRecPoint *p); // difference in azymuthal angle Double_t DPhi (AliITSglobalRecPoint *p); // difference in polar angle Double_t DTheta(AliITSglobalRecPoint *p); // checks if the pt contains a given positive label Bool_t HasID (Int_t ID) { if (ID < 0) return kFALSE; else return (fLabel[0]==ID || fLabel[1]==ID || fLabel[2]==ID); } // checks if the pt shares at least a positive label with another one Bool_t SharesID(AliITSglobalRecPoint *p) { return (HasID(p->fLabel[0]) || HasID(p->fLabel[1]) || HasID(p->fLabel[2])); } // Parameters for sorting Bool_t IsSortable() const { return kTRUE; } Int_t Compare(const TObject *O) const; public: Double_t fGX, fGY, fGZ; // (x,y,z) in the global reference Double_t fR2; // = sqrt(x^2 + y^2) Double_t fR3; // = sqrt(x^2 + y^2 + z^2) Double_t fPhi; // = atan(y/x) Double_t fTheta; // = acos(z/r3) Double_t fGSX; // Double_t fGSY; // sigmas of global coords Double_t fGSZ; // Int_t fIndex; // entry in TreeP Int_t fModule; // ITS module containing the point Int_t fPosInModule; // position in TClonesArray of TreeR Int_t fLayer; // ITS layer containing the point Int_t fLabel[3]; // Generated tracks containing the point Double_t fQ; // charge released within the cluster Double_t fdE; // energy loss Int_t fUsed; // a flag to avoid point recycling ClassDef(AliITSglobalRecPoint, 1) // AliITSglobalRecPoints class }; #endif
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET