Hi - I have some pretty simple code that is resulting in a seg violation. ROOT hangs at “Generating stack trace . . .” for some reason as well (I always have to kill manually). If I run the code line by line interactively, I don’t have this problem.
I’m using 3.04/02.
The output is:
edward@muon06</data1/babar/edward/root> root -l
root [0] .x bchd0picheck.cc(0)
Added ntuples
Warning: Automatic variable myCutLepCharge allocated in global scope FILE:esigkmpctfdoccnepiorpidkgsr2le.cc LINE:94
TCanvas::MakeDefCanvas: created default TCanvas with name c1
Finished here
*** Break *** segmentation violation
Generating stack trace…
Any suggestions for how to debug this error would be very much appreciated. Thanks.
(I can’t seem to add a .cc file as an attachment, and the link to “Allowed Extensions and Sizes” gives me the message You are not allowed to call this file (ID:2), so instead of attaching the code, I’m going to paste it here.)
void bchd0picheck(Int_t truthType=0){
// Truth:
// 0 = Don’t use
// 1 = Use
// 2 = Use anti
TH1F * nuEESig = new TH1F(“nuEESig”,“nuEESig”,100,0,4);
TH1F * actNuEESig = new TH1F(“actNuEESig”,“actNuEESig”,100,-4,4);
TH1F * truNuEESig = new TH1F(“truNuEESig”,“truNuEESig”,100,0,4);
TH1F * nuEDiffESig = new TH1F(“nuEDiffESig”,“nuEDiffESig”,100,-3,2);
TH1F * R2ESig = new TH1F(“R2ESig”,“R2ESig”,100,0,1);
TH1F * MESESig = new TH1F(“MESESig”,“MESESig”,80,5.14,5.3);
TH1F * E2ESig = new TH1F(“E2ESig”,“E2ESig”,80,0,8);
TH1F * coslgESig = new TH1F(“coslgESig”,“coslgESig”,110,-1.1,1.1);
TH1F * costheblgESig = new TH1F(“costheblgESig”,“costheblgESig”,120,-1.2,1.2);
TH1F * leptonEESig = new TH1F(“leptonEESig”,“leptonEESig”,100,1,3.5);
TH1F * photonEESig = new TH1F(“photonEESig”,“photonEESig”,70,0,3.5);
TH1F * nuEPMESig = new TH1F(“nuEPMESig”,“nuEPMESig”,100,-2.5,2.5);
TH1F * acthrustESig = new TH1F(“acthrustESig”,“acthrustESig”,50,0,1);
TH1F * LCTPESig = new TH1F(“LCTPESig”,“LCTPESig”,100,-1.0,1.0);
TH1F * LCTMESig = new TH1F(“LCTMESig”,“LCTMESig”,100,-1.0,1.0);
TH1F * nuECon = new TH1F(“nuECon”,“nuECon”,100,0,4);
TH1F * actNuECon = new TH1F(“actNuECon”,“actNuECon”,100,-4,4);
TH1F * filterNuCon = new TH1F(“filterNuECon”,“filterNuECon”,100,0,4);
TH1F * nuEDiffCon = new TH1F(“nuEDiffCon”,“nuEDiffCon”,100,-3,2);
TH1F * R2Con = new TH1F(“R2Con”,“R2Con”,100,0,1);
TH1F * MESCon = new TH1F(“MESCon”,“MESCon”,80,5.14,5.3);
TH1F * E2Con = new TH1F(“E2Con”,“E2Con”,80,0,8);
TH1F * coslgCon = new TH1F(“coslgSig”,“coslgCon”,110,-1.1,1.1);
TH1F * costheblgCon = new TH1F(“costheblgCon”,“costheblgCon”,120,-1.2,1.2);
TH1F * leptonECon = new TH1F(“leptonECon”,“leptonECon”,100,1,3.5);
TH1F * photonECon = new TH1F(“photonECon”,“photonECon”,70,0,3.5);
TH1F * nuEPMCon = new TH1F(“nuEPMCon”,“nuEPMCon”,100,-2.5,2.5);
TH1F * acthrustCon = new TH1F(“acthrustCon”,“acthrustCon”,50,0,1);
TH1F * LCTPCon = new TH1F(“LCTPCon”,“LCTPCon”,100,-1.0,1.0);
TH1F * LCTMCon = new TH1F(“LCTMCon”,“LCTMCon”,100,-1.0,1.0);
TCut cTL = “(1==1)”;
TCut cTG = “(1==1)”;
TCut cTLG = “(1==1)”;
TString theFileSuffix = “”;
/*
if (truthType == 1){
cTL = “issiglg[0]==1”;
cTG = “issiggg[0]==1”;
cTLG = (cTL)&&(cTG);
theFileSuffix = “Truth”;
}
else if (truthType == 2){
cTL = “issiglg[0]==1”;
cTG = “issiggg[0]==1”;
cTLG = !((cTL)&&(cTG));
theFileSuffix = “AntiTruth”;
}
*/
// Electron signal
gROOT->Macro(“esigkmpctfdoccnepiorpidkgsr2le.cc”);
ntp1->Draw(“nuE[0]>>nuEESig”,cTLG);
ntp1->Draw(“actNuE[0]>>actNuEESig”,cTLG);
ntp1->Draw(“nuCMpMC[0]>>truNuEESig”,cTLG);
ntp1->Draw("(actNuE[0]-nuCMpMC[0])>>nuEDiffESig",cTLG);
ntp1->Draw(“myR2All>>R2ESig”,cTLG);
ntp1->Draw(“recBSEM[0]>>MESESig”,cTLG);
ntp1->Draw(“actRecE[0]>>E2ESig”,cTLG);
ntp1->Draw(“coslg[0]>>coslgESig”,cTLG);
ntp1->Draw(“costheblg[0]>>costheblgESig”,cTLG);
ntp1->Draw(“abs(lE[0])>>leptonEESig”,cTLG);
ntp1->Draw(“abs(gE[0])>>photonEESig”,cTLG);
ntp1->Draw(“nuEP[0]>>nuEPMESig”,cTLG);
ntp1->Draw(“abs(cosLPrecoilThrust[0])>>acthrustESig”,cTLG);
cout << “Finished here” << endl;
ntp1->Draw("(lPZ[0]/abs(lPM[0]))>>LCTPESig",“lCharge[0]==1&&lPM[0]!=0”&&cTLG);
ntp1->Draw("(lPZ[0]/abs(lPM[0]))>>LCTMESig",“lCharge[0]==-1&&lPM[0]!=0”&&cTLG);
cout << “Finished here” << endl;
delete ntp1;
// Bch to D0 piControl sample
gROOT->Macro(“esigbchd0pictfdoccnepidkgsr2le.cc”);
ntp1->Draw(“nuE[0]>>nuECon”);
ntp1->Draw(“actNuE[0]>>actNuECon”);
ntp1->Draw(“abs(conNuCME)>>filterNuECon”);
ntp1->Draw("(actNuE[0]-abs(conNuCME))>>nuEDiffCon");
ntp1->Draw(“myR2All>>R2Con”);
ntp1->Draw(“recBSEM[0]>>MESCon”);
ntp1->Draw(“actRecE[0]>>E2Con”);
ntp1->Draw(“coslg[0]>>coslgCon”);
ntp1->Draw(“costheblg[0]>>costheblgCon”);
ntp1->Draw(“abs(lE[0])>>leptonECon”);
ntp1->Draw(“abs(gE[0])>>photonECon”);
ntp1->Draw(“nuEPM[0]>>nuEPMCon”);
ntp1->Draw(“abs(cosLPrecoilThrust[0])>>acthrustCon”);
ntp1->Draw("(lPZ[0]/abs(lPM[0]))>>LCTPCon",“lCharge[0]==1&&lPM[0]!=0”);
ntp1->Draw("(lPZ[0]/abs(lPM[0]))>>LCTMCon",“lCharge[0]==-1&&lPM[0]!=0”);
delete ntp1;
TFile * theOutputFile = new TFile(“plots/bchd0picheck”+theFileSuffix+".root",“recreate”);
gROOT->GetList()->Write();
delete theOutputFile;
}