This is driving me crazy. I tried to reproduce it in a simplescript. You will need the file to run this, i copied it at /afs/cern.ch/user/m/marios/public.
The second script which is the one i want to use with more than 2 iterations obviously, throughs a segmentation error when i run it with .x from rint. In the first script I am reproducing what the loop was supposed to do. The problem on the second iteration is when h->Fit is invoked.
I am working on lxplus , My ROOTSYS is
/afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00b/slc4_ia32_gcc34/root/
THIS WORKS
[code]{
TFile nf(“newFile”);
TTree * t = (TTree*) nf.Get(“newTree”);
TFile tmp(“tmpFile”,“RECREATE”);
TString stripCut;
TF1 *f1 = new TF1(“f1”,"[0]*x+[1]",0,200);
//for(int strip=1;strip<3;strip++){
int strip=1;
stripCut=Form(“stripH==%d && stripL==%d”,strip,strip);
t->Draw(“ymaxL:ymaxH>>h(200,0,200,60,0,60)”,stripCut && “ymaxH/20 + 3 > ymaxL && ymaxH/20 -3 <ymaxL”);
h->Fit(“f1”,"","",10,200);
h->Write();
strip++;
stripCut=Form("stripH==%d && stripL==%d",strip,strip);
t->Draw("ymaxL:ymaxH>>h(200,0,200,60,0,60)",stripCut && "ymaxH/20 + 3 > ymaxL && ymaxH/20 -3 <ymaxL");
h->Fit("f1","","",10,200);
h->Write();
tmp.Close();
}[/code]
THIS WILL NOT WORK
[code]{
TFile nf(“newFile”);
TTree * t = (TTree*) nf.Get(“newTree”);
TFile tmp(“tmpFile”,“RECREATE”);
TString stripCut;
TF1 *f1 = new TF1(“f1”,"[0]*x+[1]",0,200);
//for(int strip=1;strip<3;strip++){
int strip=1;
while(strip<3){
stripCut=Form("stripH==%d && stripL==%d",strip,strip);
t->Draw("ymaxL:ymaxH>>h(200,0,200,60,0,60)",stripCut && "ymaxH/20 + 3 > ymaxL && ymaxH/20 -3 <ymaxL");
h->Fit("f1","","",10,200);
h->Write();
strip++;
}
tmp.Close();
}[/code]