#if !defined(__CINT__) || defined(__MAKECINT__) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif void calib(char* infile="rivelatore.root",bool output=1, float slope=2.3,float interc=10) { TNtuple *pjmca_calib; if(output){ char str_in[50]=infile; char str_out[50]; int nb=strlen(str_in)-5; strncpy(str_out,str_in,nb); str_out[nb]='\0'; strcat(str_out,"_calib.root"); // strcat(str_out,"root"); TFile *fout=new TFile(str_out,"RECREATE"); cout<<"output file "<< str_out<Get("pjmca"); float ch1, ch2,ch3,ch0,temp,ene; pjmca->SetBranchAddress("ch0",&ch0); pjmca->SetBranchAddress("ch1",&ch1); pjmca->SetBranchAddress("ch2",&ch2); pjmca->SetBranchAddress("ch3",&ch3); int nentries=pjmca->GetEntries(); for(int i=0;iGetEntry(i); //instruction for a cut if(ch0>10 && ch1<1000){} h0->Fill(ch0); h1->Fill(ch1); h3->Fill(ch3); //the new value for the third channel, a calibrated value! ene=ch2*slope+interc; //trick for the binning Float_t random = gRandom->Rndm(1); ene+=random-0.5; h2->Fill(ene); //fill the new ntuple if(output) pjmca_calib->Fill(ch0,ch1,ene,ch3); } if(!output)h2->Draw(); if(output){ fout->cd(); fout->Write(); fout->Close(); } }