Double and Segmentation Violation

Hi!
I’m using ROOT 4.04/02, and I’m writing a macro with the following class:

class Jet {
public:
  Jet();
  
  Double_t JetWeight;
  Int_t    Label;
  Int_t PdgCode; 
  Int_t Goodness;
  Float_t Eta;
  Float_t Phi;
  float pT; 

  bool operator<(const Jet& jet) const { 
	return this->JetWeight>jet.JetWeight;

	}
};


Jet::Jet(){

  JetWeight=0;
  Label=0;
  PdgCode=0;
  Goodness=0;
  Eta=0;
  Phi=0;
  pT=0;
}

Where JetWeight, PdgCode, Eta, Phi and pT are taken from ntuple by:

 vector <Jet> jet;
    for (int i=0; i<PJet_N; i++) {
 
      Jet tmp;
      tmp.JetWeight= (*PJet_weight)[i];
      tmp.PdgCode=(*PJet_pdgId)[i];
      tmp.Label= i;
      tmp.Eta=(*PJet_eta)[i];
      tmp.Phi=(*PJet_phi)[i];
      tmp.pT=(*PJet_p_T)[i];
     
      jet.push_back(tmp);
    }

This code it’s all right until I change the definition of a (anyone) variable with Double… for example:


[...]  Double_t JetWeight;
  Int_t    Label;
  [color=red]Double_t[/color] PdgCode; 
  Int_t Goodness;
  Float_t Eta;
  Float_t Phi;
  float pT; 
[...]

I obtain the following message:

*** Break *** segmentation violation

Do you have any suggestion?
thanks,
gio
[/quote]
macro.C (10 KB)

Can you swap the variables to see whether the problem persists:

[code]class Jet {
public:
Jet();
// Put ALL your Double_t first
Double_t JetWeight;
Double_t PdgCode;
Int_t Label;
Int_t Goodness;
Float_t Eta;
Float_t Phi;
float pT;

bool operator<(const Jet& jet) const {
return this->JetWeight>jet.JetWeight;

}
}; [/code]

Hi,

Because of the vector and the length of your code, I strongly recommend you try compile your code via ACLiC. I.e. instead of .L macro.C do .L macro.C+

Cheers,
Philippe.

[quote=“fine”]Can you swap the variables to see whether the problem persists:
[/quote]

I’ve tried, but it doesn’t work…
thanks,

gio

[quote]I’ve tried, but it doesn’t work… [/quote]Even via ACLiC?

Philippe

[quote=“pcanal”]Hi,

Because of the vector and the length of your code, I strongly recommend you try compile your code via ACLiC. I.e. instead of .L macro.C do .L macro.C+

Cheers,
Philippe.[/quote]

I’ve already tried, but except some warning concerning other part of the macro, I’ve no error that could explain the segmentation violation!
thanks
gio

[quote]I’ve already tried, but except some warning concerning other part of the macro, I’ve no error that could explain the segmentation violation! [/quote]You could try using valgrind to discover the cause. I tried to compiled your code but I am missing the header CollectionTree.h

Cheers,
Philippe

Gio,

Could you post all the necessary files (Collectiontree.h and data file) such that we can help you?

Rene