/* This script calculate the desired voltages for HAND scintillators in two cases: 1. Cosmic run=1; 2. Beam (run=0) The difference is the desired ADC channel at each layer. For cosmic, the energy deposit is different between layer because of different heights of bars. The ADC channel location is added based on the minimum ionizing particlas with 2.2 MeV/cm Energy deposit. In the beam case, all bars have same width, however the kinetic energy of protons is decreasing as we moving from layer 1 to 6. Correct values for the ADC channels must be added to the code. This script must be run with "read_gain.C" and gain curve parameter must be available in the corresponding .dat file. The output of this script are two files, one for left side and second for the right side, with voltage values. */ #include "read_gains.C" #include void desired_voltage() { const int nbars[7]={32,30,24,22,12,12,12}; //======================== read_gains.C ==================== double c_L1[30]={0},c_R1[30]={0}, c_L2[24]={0},c_R2[24]={0}, c_L3[22]={0},c_R3[22]={0}, c_L4[12]={0},c_R4[12]={0}, c_L5[12]={0},c_R5[12]={0}, c_L6[12]={0},c_R6[12]={0}; // K*V**n+const : K = c_ , n = p_ , const = cnst_ double cnst_L1[30]={0},cnst_R1[30]={0}, cnst_L2[24]={0},cnst_R2[24]={0}, cnst_L3[22]={0},cnst_R3[22]={0}, cnst_L4[12]={0},cnst_R4[12]={0}, cnst_L5[12]={0},cnst_R5[12]={0}, cnst_L6[12]={0},cnst_R6[12]={0}; int p_L1[30],p_R1[30], p_L2[24],p_R2[24], p_L3[22],p_R3[22], p_L4[12],p_R4[12], p_L5[12],p_R5[12], p_L6[12],p_R6[12]; //============================================================ double V1R[30]={0}, V2R[24]={0}, V3R[22]={0}, V4R[12]={0}, V5R[12]={0}, V6R[12]={0}; double V1L[30]={0}, V2L[24]={0}, V3L[22]={0}, V4L[12]={0}, V5L[12]={0}, V6L[12]={0}; int run=-1; cout<<" It's cosmic run ? (yes =1 no =0) "<>run; double DL,DR, A; if(run==1) {double ADC[7]={0,1200,1500,1800,3000,3000,3000};} if(run==0) {double ADC[7]={0,1200,1200,1200,1200,1200,1200};} if(run!=1 && run!=0) {cout<<"Bad Choise"<=0 && c_R1[j]>0) {V1R[j]=(DR/c_R1[j])**(1/p_R1[j]);} else cout<<" Problem with layer 1, RIGHT bar "<=0 && c_L2[j]>0) {V2L[j]=(DL/c_L2[j])**(1./p_L2[j]);} else cout<<" Problem with layer 2, LEFT bar "<=0 && c_R2[j]>0) {V2R[j]=(DR/c_R2[j])**(1./p_R2[j]);} else cout<<" Problem with layer 2, RIGHT bar "<15) { DL=ADC[i]-cnst_L3[j]; DR=ADC[i]-cnst_R3[j]; if(DL>=0 && c_L3[j]>0) {V3L[j]=(DL/c_L3[j])**(1./p_L3[j]);} else cout<<" Problem with layer 3, LEFT bar "<=0 && c_R3[j]>0) {V3R[j]=(DR/c_R3[j])**(1./p_R3[j]);} else cout<<" Problem with layer 3, RIGHT bar "<=6 && j<=9)||(j>=12 && j<=15)) { DL=ADC[i-1]-cnst_L3[j]; DR=ADC[i-1]-cnst_R3[j]; if(DL>=0 && c_L3[j]>0) {V3L[j]=(DL/c_L3[j])**(1./p_L3[j]);} else cout<<" Problem with layer 3, LEFT bar "<=0 && c_R3[j]>0) {V3R[j]=(DR/c_R3[j])**(1./p_R3[j]);} else cout<<" Problem with layer 3, RIGHT bar "<=0 && c_L3[j]>0) {V3L[j]=(DL/c_L3[j])**(1./p_L3[j]);} else cout<<" Problem with layer 3, LEFT bar "<=0 && c_R3[j]>0) {V3R[j]=(DR/c_R3[j])**(1./p_R3[j]);} else cout<<" Problem with layer 3, RIGHT bar "<=0 && c_L3[j]>0) {V3L[j]=(DL/c_L3[j])**(1./p_L3[j]);} else cout<<" Problem with layer 3, LEFT bar "<=0 && c_R3[j]>0) {V3R[j]=(DR/c_R3[j])**(1./p_R3[j]);} else cout<<" Problem with layer 3, RIGHT bar "<=0 && c_L4[j]>0) {V4L[j]=(DL/c_L4[j])**(1./p_L4[j]);} else cout<<" Problem with layer 4, LEFT bar "<=0 && c_R4[j]>0) {V4R[j]=(DR/c_R4[j])**(1./p_R4[j]);} else cout<<" Problem with layer 4, RIGHTbar "<=0 && c_L5[j]>0) {V5L[j]=(DL/c_L5[j])**(1./p_L5[j]);} else cout<<" Problem with layer 5, LEFT bar "<=0 && c_R5[j]>0) {V5R[j]=(DR/c_R5[j])**(1./p_R5[j]);} else cout<<" Problem with layer 5, RIGHTbar "<=0 && c_L6[j]>0) {V6L[j]=(DL/c_L6[j])**(1./p_L6[j]);} else cout<<" Problem with layer 6, LEFT bar "<=0 && c_R6[j]>0) {V6R[j]=(DR/c_R6[j])**(1./p_R6[j]);} else cout<<" Problem with layer 6, RIGHTbar "<