void CsICalib::Bisection(Int_t A, Double_t chan) //UShort_t chan { IGNORE_UNUSED(chan); Int_t middle, it = 0; good_bisection = kTRUE; if ((A - 5) > 0) { left = A - 5; } else { left = 1; } right = A + 10; Int_t factor = 1; Double_t difference = 0.; Double_t diffright = 0.; SetFragmentA(left); CompleteSimulation(); difference = eEnergySi - sEnergySi; if (difference > 0) { factor = -1; } difference *= factor; SetFragmentA(right); CompleteSimulation(); difference = eEnergySi - sEnergySi; if (difference > 0) good_bisection = kFALSE; difference *= factor; diffright = difference; if (difference < 0) { while (diffright < 0) { if ((left - 1) > 0) left = left - 1; else left = 1; SetFragmentA(left); CompleteSimulation(); difference = eEnergySi - sEnergySi; if (difference > 0) { factor = -1; } diffright *= factor; if (left == 1) { cout << "Bisection error : Lower value of A not found" << endl; good_bisection = kFALSE; break; } } } //loop: bisection while ((right - left) > 1) { middle = (left + right + 1) / 2; SetFragmentA(middle); CompleteSimulation(); esi2 = sEnergySi; ecsi2 = sEnergyCsI; difference = factor * (eEnergySi - sEnergySi); if (difference < 0) { left = middle; } else right = middle; it++; } //simulated energies for two values of A closest to the point of zero //difference between the simulated energy for Si and the one from calibration SetFragmentA(left); CompleteSimulation(); esi1 = sEnergySi; ecsi1 = sEnergyCsI; SetFragmentA(right); CompleteSimulation(); esi2 = sEnergySi; ecsi2 = sEnergyCsI; }
void CsICalib::Bisection(Int_t A, Double_t chan){ //UShort_t chan Int_t middle, it=0; //L->Log<<"------------"<<endl; //L->Log<<"Valeur de A : "<<A<<endl; //L->Log<<"Energy Si Reference : "<<eEnergySi<<endl; if(A-5>0) left=A-5.; //left and right are integer!! A is a double else left=1; right=A+10; //L->Log<<"-----------------------------------BISECTION-------------------"<<endl;//paola //new bisection method //=== Test SetFragmentA(left); CompleteSimulation(chan); Int_t factor = 1; Double_t difference = 0.; difference = eEnergySi - sEnergySi; if(difference>0){ factor = -1; } difference *= factor; //L->Log<<"A left : "<<left<<" ESi measured : "<<eEnergySi<<" ESi calculated : "<<sEnergySi<<" difference : "<<difference<<" factor : "<<factor<<endl; SetFragmentA(right); CompleteSimulation(chan); difference = eEnergySi - sEnergySi; difference *= factor; //L->Log<<"A right : "<<right<<" ESi measured : "<<eEnergySi<<" ESi calculated : "<<sEnergySi<<" difference : "<<difference<<" factor : "<<factor<<endl; if(difference<0){ //L->Log<<"Bisection error"<<endl; } // === End test //loop: bisection while(right-left>1){ //L->Log<<"-------------------loop bisection------------"<<endl; //L->Log<<"LightCsI : "<<LightCsI<<endl; //cout<<"LightCsI : "<<LightCsI<<endl; middle=(left+right+1)/2; //simulated energies stored for middle A SetFragmentA(middle); CompleteSimulation(chan); esi2=sEnergySi; ecsi2=sEnergyCsI; //new bisection method //=== Test difference = factor*(eEnergySi - sEnergySi); //L->Log<<"difference : "<<difference<<endl; if(difference<0){ left = middle; } else right = middle; // === End test /*if(esi2>eEnergySi){ right=middle; } else left=middle;*/ //L->Log<<"A2 (middle) : "<<middle<<" ESi2= "<<sEnergySi<<" ECsI2= "<<sEnergyCsI<<endl; //paola it++; //L->Log<<"----------------iteration= "<<it<<endl; } //end of bisection loop //simulated energies for two values of A closest to the point of zero //difference between the simulated energy for Si and the one from calibration SetFragmentA(left); CompleteSimulation(chan); esi1=sEnergySi; ecsi1=sEnergyCsI; //L->Log<<"esi1 : "<<esi1<<" ecsi1 : "<<ecsi1<<endl; SetFragmentA(right); CompleteSimulation(chan); esi2=sEnergySi; ecsi2=sEnergyCsI; //L->Log<<"esi2 : "<<esi2<<" ecsi2 : "<<ecsi2<<endl; }