diff --git a/BP_analysis.cpp b/BP_analysis.cpp index 48cc3ad..f1a8b00 100644 --- a/BP_analysis.cpp +++ b/BP_analysis.cpp @@ -131,8 +131,8 @@ int main(int argc, char* argv[]) { mapcanvas->cd(); - TH1F* g0_grad_hist = 0; - if (module_str == "351" || + TH1F* g0_grad_hist = 0; + if (module_str == "351" || // List of 450um modules module_str == "351_fullspeed" || module_str == "352" || module_str == "352_fullspeed" || @@ -149,7 +149,11 @@ int main(int argc, char* argv[]) { module_str == "307" || module_str == "307_fullspeed" || module_str == "272_halfspeedtest" || - module_str == "272_fullspeedtest") { + module_str == "272_fullspeedtest" || + module_str == "668" || + module_str == "668_200V" || + module_str == "668_180V" || + module_str == "668_fullspeedtest") { g0_grad_hist = new TH1F("g0_grad_hist","",100,3,8); } else { g0_grad_hist = new TH1F("g0_grad_hist","",100,5,10); @@ -174,7 +178,11 @@ int main(int argc, char* argv[]) { module_str == "307" || module_str == "307_fullspeed" || module_str == "272_halfspeedtest" || - module_str == "272_fullspeedtest") { + module_str == "272_fullspeedtest" || + module_str == "668" || + module_str == "668_200V" || + module_str == "668_180V" || + module_str == "668_fullspeedtest") { g1_grad_hist = new TH1F("g1_grad_hist","",100,-0.25,-0.1); } else { g1_grad_hist = new TH1F("g1_grad_hist","",100,-0.3,-0.15); @@ -788,12 +796,35 @@ int main(int argc, char* argv[]) { mapcanvas->SetRightMargin(0.13); c1->cd(); - g0_grad_hist->GetXaxis()->SetTitle("G0 gradient"); g0_grad_hist->Draw(); sprintf(savename,"plots/M%s/%s/g0_grad_hist_M%s.png", module_str.c_str(), plotfolder_str.c_str(), module_str.c_str()); c1->SaveAs((const char *)(savename)); + TPaveText *pave1 = new TPaveText(0.6,0.8,0.94,0.94,"blNDC"); + pave1->SetBorderSize(0); + pave1->SetFillStyle(0); + pave1->SetTextSize(0.04); + pave1->SetTextAlign(32); + + + g0_grad_hist->Fit("gaus"); + g0_grad_hist->Draw(); + c1->Update(); + + TF1* g0_grad_hist_gaus = g0_grad_hist->GetFunction("gaus"); + if (g0_grad_hist_gaus) { + sprintf(savename,"Mean %0.4f #pm %0.4f", g0_grad_hist_gaus->GetParameter(1), g0_grad_hist_gaus->GetParError(1)); + pave1->AddText((const char *)(savename)); + sprintf(savename,"Sigma %0.4f #pm %0.4f", g0_grad_hist_gaus->GetParameter(2), g0_grad_hist_gaus->GetParError(2)); + pave1->AddText((const char *)(savename)); + pave1->Draw(); + } + g0_grad_hist->SetStats(kFALSE); + sprintf(savename,"plots/M%s/%s/g0_grad_histfit_M%s.png", module_str.c_str(), plotfolder_str.c_str(),module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + g0_grader_hist->GetXaxis()->SetTitle("#sigma_{G0 gradient}"); g0_grader_hist->Draw(); sprintf(savename,"plots/M%s/%s/g0_grader_hist_M%s.png", module_str.c_str(), plotfolder_str.c_str(), module_str.c_str()); @@ -804,6 +835,31 @@ int main(int argc, char* argv[]) { sprintf(savename,"plots/M%s/%s/g1_grad_hist_M%s.png", module_str.c_str(), plotfolder_str.c_str(), module_str.c_str()); c1->SaveAs((const char *)(savename)); + TPaveText *pave3 = new TPaveText(0.6,0.8,0.94,0.94,"blNDC"); + pave3->SetBorderSize(0); + pave3->SetFillStyle(0); + pave3->SetTextSize(0.04); + pave3->SetTextAlign(32); + + + g1_grad_hist->Fit("gaus"); + g1_grad_hist->Draw(); + c1->Update(); + + TF1* g1_grad_hist_gaus = g1_grad_hist->GetFunction("gaus"); + if (g1_grad_hist_gaus) { + sprintf(savename,"Mean %0.4f #pm %0.4f", g1_grad_hist_gaus->GetParameter(1), g1_grad_hist_gaus->GetParError(1)); + pave3->AddText((const char *)(savename)); + sprintf(savename,"Sigma %0.4f #pm %0.4f", g1_grad_hist_gaus->GetParameter(2), g1_grad_hist_gaus->GetParError(2)); + pave3->AddText((const char *)(savename)); + pave3->Draw(); + } + g1_grad_hist->SetStats(kFALSE); + sprintf(savename,"plots/M%s/%s/g1_grad_histfit_M%s.png", module_str.c_str(), plotfolder_str.c_str(),module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + + g1_grader_hist->GetXaxis()->SetTitle("#sigma_{G1 gradient}"); g1_grader_hist->Draw(); sprintf(savename,"plots/M%s/%s/g1_grader_hist_M%s.png", module_str.c_str(), plotfolder_str.c_str(), module_str.c_str()); @@ -843,7 +899,7 @@ int main(int argc, char* argv[]) { g0_grad_map->Draw("colz"); pave->AddText("G0 [ADU/mV]"); pave->Draw(); - if (module_str == "351" || + if (module_str == "351" || // List 450um modules module_str == "351_fullspeed" || module_str == "352" || module_str == "352_fullspeed" || @@ -860,8 +916,12 @@ int main(int argc, char* argv[]) { module_str == "307" || module_str == "307_fullspeed" || module_str == "272_halfspeedtest" || - module_str == "272_fullspeedtest") { - g0_grad_map->GetZaxis()->SetRangeUser(3,4); + module_str == "272_fullspeedtest"|| + module_str == "668" || + module_str == "668_200V" || + module_str == "668_180V" || + module_str == "668_fullspeedtest") { + g0_grad_map->GetZaxis()->SetRangeUser(3.5,6.5); } else { g0_grad_map->GetZaxis()->SetRangeUser(5,10); } @@ -894,7 +954,7 @@ int main(int argc, char* argv[]) { } else if (module_str == "021" || module_str == "022" || module_str == "044") { g1_grad_map->GetZaxis()->SetRangeUser(-0.3,-0.23); } else if (module_str == "351" || - module_str == "351_fullspeed" || + module_str == "351_fullspeed" || // List modules 450um module_str == "352" || module_str == "352_fullspeed" || module_str == "261" || @@ -910,8 +970,12 @@ int main(int argc, char* argv[]) { module_str == "307" || module_str == "307_fullspeed" || module_str == "272_halfspeedtest" || - module_str == "272_fullspeedtest") { - g1_grad_map->GetZaxis()->SetRangeUser(-0.15,-0.1); + module_str == "272_fullspeedtest" || + module_str == "668" || + module_str == "668_200V" || + module_str == "668_180V" || + module_str == "668_fullspeedtest") { + g1_grad_map->GetZaxis()->SetRangeUser(-0.2,-0.15); } else { g1_grad_map->GetZaxis()->SetRangeUser(-0.25,-0.2); } diff --git a/BP_analysis_M431 b/BP_analysis_M431 index cf3bc98..dc0ee32 100755 Binary files a/BP_analysis_M431 and b/BP_analysis_M431 differ diff --git a/BP_analysis_M431.cpp b/BP_analysis_M431.cpp index 1e6b224..a804c13 100644 --- a/BP_analysis_M431.cpp +++ b/BP_analysis_M431.cpp @@ -1,5 +1,5 @@ -// to analyse the backplane pulsing data per module // changes by VH 210906: to eliminate hardcoded absolute paths, uses location of the analysis root files as additional input argument (accordingly changed in filename_creator.sh) +// to analyse the backplane pulsing data per module // works for single chip only (chip 5) #include "sls_detector_calibration/jungfrauCommonHeader.h" @@ -288,11 +288,6 @@ int main(int argc, char* argv[]) { } for (int i = 0; i < NCH; i++) { - - if((i/NC<256 || i/NC>511) || (i%NC<256 || i%NC>511)){ - continue; - } - avg_adcG0_map[framecounter/100]->SetBinContent((i%NC)+1,(i/NC)+1,pedestalObjectG0->pedestalOfChannel(i)); avg_adcG0er_map[framecounter/100]->SetBinContent((i%NC)+1,(i/NC)+1,pedestalObjectG0->semOfChannel(i)); @@ -382,10 +377,6 @@ int main(int argc, char* argv[]) { mapcanvas->SetRightMargin(0.05); for (int i = 0; i < NCH; i++) { - if((i/NC<256 || i/NC>511) || (i%NC<256 || i%NC>511)){ - continue; - } - vector r0_adc; vector r0_filter; diff --git a/BP_scan.sh b/BP_scan.sh index 0eb74f6..524dae2 100644 --- a/BP_scan.sh +++ b/BP_scan.sh @@ -16,160 +16,228 @@ # last data file (000002.dat) should be 2097184000 bytes - +PulseWidth=0.000040 #80us Normal measurement: #40us +PulseDelay=0.000001 #10us NOrmal measurement: #1us KILLRCV="killall ju_udp_receiver_3threads_2_0" $KILLRCV +if [[ "$0" == *"BP_scan.sh"* ]]; then + echo "script changes env. variables: should be invoked with source, not sh " + exit +fi -sls_detector_put stop #just in case +if [ ! -v $1 & ! -v $2 ]; then + echo $0 + echo "Readout speed is" $2 + echo "printing filenames for module" $1 + ROBspeed=$2 + + if [[ "$2" == "full_speed" ]]; then + source filename_creator.sh $1"_fullspeed" Y + elif [[ "$2" == "half_speed" ]]; then + source filename_creator.sh $1 Y + else + echo "Readout speed has to be specified as half_speed or full_speed" + exit + fi + + sls_detector_put stop #just in case + + sls_detector_put powerchip 1 + + sls_detector_put delay 0 + #sls_detector_put triggers 1 + #sls_detector_put frames 100 + sls_detector_put period 0.005 + sls_detector_put exptime $PulseWidth + sls_detector_put highvoltage 0 -sls_detector_put powerchip 1 + # configure for receiver on pc-jungfrau-01/pc-jungfrau-test/pc-jungfrau-02 + # source pccalib.sh with pc (pc-jungfrau-01/pc-jungfrau-test/pc-jungfrau-02) + + sls_detector_put udp_dstport 32410 + sls_detector_put udp_dstip $DSTIP #10.1.4.105 + sls_detector_put udp_dstmac $DSTMAC #3C:FD:FE:A2:14:D8 + sls_detector_put udp_srcip $SRCIP #10.1.4.9 + sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 + + #sls_detector_put configuremac 0 + sls_detector_put readoutspeed $ROBspeed + #sls_detector_put readoutspeed full_speed + + sls_detector_put gainmode dynamic + + #CLI=/afs/psi.ch/project/sls_det_software/serial_control_software/minidelay/minidelay + + HOST=EX-6111-02 + # prepare the AGILENT 33250A + #echo $CLI" OUTP OFF " | nc pc10773 5555 + (echo OUTP OFF ) | nc -t $HOST 5000 + sleep 0.2 + + #remember to put High-Z load! + #Change load to Infinity + (echo OUTP:LOAD INF ) | nc -t $HOST 5000 + sleep 0.2 + + # Polarity normal + #echo $CLI" OUTP:POL NORM" | nc pc10773 5555 + (echo OUTP:POL NORM) | nc -t $HOST 5000 + sleep 0.2 + + # pulse + #echo $CLI" FUNC PULS" | nc pc10773 5555 + (echo FUNC PULS) | nc -t $HOST 5000 + sleep 0.2 + + # frequency 1kHz + #echo $CLI" FREQ 1000" | nc pc10773 5555 + (echo FREQ 1000) | nc -t $HOST 5000 + sleep 0.2 + + # width 40 us + #echo $CLI" PULS:WIDT 0.000040" | nc pc10773 5555 + (echo PULS:WIDT $PulseWidth) | nc -t $HOST 5000 + sleep 0.2 + + # amplitude 0.1 V" | nc pc10773 5555 + #echo $CLI" VOLT 0.1" | nc pc10773 5555 + (echo VOLT 0.1) | nc -t $HOST 5000 + sleep 0.2 + + # offset 0 V echo $CLI" VOLT:OFFS 0" | nc pc8830 5555 + # sleep 0.2 + + # VLOW 0 V + #echo $CLI" VOLT:LOW 0" | nc pc10773 5555 + (echo VOLT:LOW 0) | nc -t $HOST 5000 + sleep 0.2 + + # edge 50 ns + #echo $CLI" PULS:TRAN 0.000000050" | nc pc10773 5555 + (echo PULS:TRAN 0.000000050) | nc -t $HOST 5000 + sleep 0.2 + + # triggered burst + #echo $CLI" BURS:MODE TRIG" | nc pc10773 5555 + (echo BURS:MODE TRIG) | nc -t $HOST 5000 + sleep 0.2 + + # cycles 1 + #echo $CLI" BURS:NCYC 1" | nc pc10773 5555 + (echo BURS:NCYC 1) | nc -t $HOST 5000 + sleep 0.2 + + # external trigger source + #echo $CLI" TRIG:SOUR EXT" | nc pc10773 5555 + (echo TRIG:SOUR EXT) | nc -t $HOST 5000 + sleep 0.2 + + # delay 1 us + #echo $CLI" TRIG:DEL 0.000001" | nc pc10773 5555 + (echo TRIG:DEL $PulseDelay) | nc -t $HOST 5000 + sleep 0.2 + # delay 40 us + #echo $CLI" TRIG:DEL 0.000040" | nc pc10773 5555 + #sleep 0.2 + + # slope positive + #echo $CLI" TRIG:SLOP POS" | nc pc10773 5555 + (echo TRIG:SLOP POS) | nc -t $HOST 5000 + sleep 0.2 + + # turn on burst mode + #echo $CLI" BURS:STAT ON" | nc pc10773 5555 + (echo BURS:STAT ON) | nc -t $HOST 5000 + sleep 0.2 + + (echo VOLT:HIGH 0.02) | nc -t $HOST 5000 + sleep 0.2 + + if [ "$1" == 'Y' ]; then + echo "started with Y argument, skipping manual checks" + else + echo "It is now safe to connect the cable between the amplifier board and the readout board" + echo "Please do so and press any key to continue, or press q to exit this script" + read -n 1 -s input + + if [[ $input = "q" ]]; then + echo "Exiting script" + exit 1 + fi + fi + + # high voltage + # sls_detector_put highvoltage 200 #because it seemed more stable, we are using external HV 230V + # output on + #echo $CLI" OUTP ON" | nc pc10773 5555 + (echo OUTP ON) | nc -t $HOST 5000 + sleep 0.2 + + if [ "$1" == 'Y' ]; then + echo "started with Y argument, skipping manual checks" + else + echo "The current on the amplifier board should be ~0.035 A" + echo "Please check and press any key to continue, or press q to exit this script" + read -n 1 -s input + if [[ $input = "q" ]]; then + echo "Exiting script" + exit 1 + fi + fi + + sls_detector_put frames 20000 + sls_detector_put start + sleep 110 + + sls_detector_put stop + + sls_detector_put triggers 1 + sls_detector_put frames 100 -sls_detector_put delay 0 -sls_detector_put triggers 1 -sls_detector_put frames 100 -sls_detector_put period 0.005 -sls_detector_put exptime 0.00004 -sls_detector_put highvoltage 0 + $TKBPG0 & + sleep 1 -# configure for receiver on pc-jungfrau-01/pc-jungfrau-test/pc-jungfrau-02 -# source pccalib.sh with pc (pc-jungfrau-01/pc-jungfrau-test/pc-jungfrau-02) - -sls_detector_put udp_dstport 32410 -sls_detector_put udp_dstip $DSTIP #10.1.4.105 -sls_detector_put udp_dstmac $DSTMAC #3C:FD:FE:A2:14:D8 -sls_detector_put udp_srcip $SRCIP #10.1.4.9 -sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 - -#sls_detector_put configuremac 0 -sls_detector_put readoutspeed half_speed -#sls_detector_put readoutspeed full_speed - -sls_detector_put gainmode dynamic - -CLI=/afs/psi.ch/project/sls_det_software/serial_control_software/minidelay/minidelay - -# prepare the AGILENT 33250A -echo $CLI" OUTP OFF " | nc pc10773 5555 - -sleep 0.2 - -#remember to put High-Z load! -#Change load to Infinity -echo $CLI" OUTP:LOAD INF " | nc pc10773 5555 - -# Polarity normal -echo $CLI" OUTP:POL NORM" | nc pc10773 5555 - -# pulse -echo $CLI" FUNC PULS" | nc pc10773 5555 -sleep 0.2 -# frequency 1kHz -echo $CLI" FREQ 1000" | nc pc10773 5555 -sleep 0.2 -# width 40 us -echo $CLI" PULS:WIDT 0.000040" | nc pc10773 5555 -sleep 0.2 -# amplitude 0.1 V" | nc pc10773 5555 -echo $CLI" VOLT 0.1" | nc pc10773 5555 -# offset 0 V echo $CLI" VOLT:OFFS 0" | nc pc8830 5555 -sleep 0.2 -# VLOW 0 V -echo $CLI" VOLT:LOW 0" | nc pc10773 5555 -sleep 0.2 -# edge 50 ns -echo $CLI" PULS:TRAN 0.000000050" | nc pc10773 5555 -sleep 0.2 -# triggered burst -echo $CLI" BURS:MODE TRIG" | nc pc10773 5555 -sleep 0.2 -# cycles 1 -echo $CLI" BURS:NCYC 1" | nc pc10773 5555 -sleep 0.2 -# external trigger source -echo $CLI" TRIG:SOUR EXT" | nc pc10773 5555 -sleep 0.2 -# delay 1 us -echo $CLI" TRIG:DEL 0.000001" | nc pc10773 5555 -# delay 40 us -#echo $CLI" TRIG:DEL 0.000040" | nc pc10773 5555 -sleep 0.2 -# slope positive -echo $CLI" TRIG:SLOP POS" | nc pc10773 5555 -sleep 0.2 -# turn on burst mode -echo $CLI" BURS:STAT ON" | nc pc10773 5555 -sleep 0.2 + # the scan + for ivpulse in {10..1000..10} + do + vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) + (echo VOLT:HIGH $vpulse) | nc -t $HOST 5000 + sleep 1 + sls_detector_put start + sleep 1 + done -if [ "$1" == 'Y' ]; then -echo "started with Y argument, skipping manual checks" + + for ivpulse in {1050..6000..50} + do + vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) + (echo VOLT:HIGH $vpulse) | nc -t $HOST 5000 + sleep 1 + sls_detector_put start + sleep 1 + done + + # Kill receiver + sls_detector_put stop + (echo VOLT:HIGH 0.010) | nc -t $HOST 5000 + (echo OUTP OFF) | nc -t $HOST 5000 + sleep 20 + $KILLRCV + + echo "Finished scan, please wait for capacitor to discharge" + sls_detector_put readoutspeed half_speed + sleep 20 + echo "It is now safe to disconnect the cable between the amplifier board and the readout board" + echo "Script finished" + else -echo "It is now safe to connect the cable between the amplifier board and the readout board" -echo "Please do so and press any key to continue, or press q to exit this script" -read -n 1 -s input -if [[ $input = "q" ]]; then - echo "Exiting script" - exit 1 -fi + echo "Specify module number as a first argument" + echo "Specify readout_speed as a second argument:half_speed,full_speed" + echo "Script finished" fi - -# high voltage -# sls_detector_put highvoltage 200 #because it seemed more stable, we are using external HV 230V -# output on -echo $CLI" OUTP ON" | nc pc10773 5555 -sleep 0.2 - - -if [ "$1" == 'Y' ]; then -echo "started with Y argument, skipping manual checks" -else - -echo "The current on the amplifier board should be ~0.035 A" -echo "Please check and press any key to continue, or press q to exit this script" -read -n 1 -s input -if [[ $input = "q" ]]; then - echo "Exiting script" - exit 1 -fi -fi - -$TKBPG0 & - - -# the scan -for ivpulse in {10..1000..10} -do - -vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) -echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 -sleep 1 -sls_detector_put start -sleep 1 -done - -for ivpulse in {1050..6000..50} -do -vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) -echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 -sleep 1 -sls_detector_put start -sleep 1 -done - - -# high voltage -# sls_detector_put highvoltage 0 -# output off -echo $CLI" OUTP OFF " | nc pc10773 5555 - -$KILLRCV - -echo "Finished scan, please wait for capacitor to discharge" -sleep 20 -echo "It is now safe to disconnect the cable between the amplifier board and the readout board" -echo "Script finished" diff --git a/BP_scan_both_speeds.sh b/BP_scan_both_speeds.sh index f55eeb2..46540f9 100644 --- a/BP_scan_both_speeds.sh +++ b/BP_scan_both_speeds.sh @@ -11,7 +11,8 @@ # - amplifier board is powered and unconnected. # - last file should be 2097184000 bytes big. # connect to pc10773 (RH7 machine connected to the pulser and, after klog, run the command -# nc -k -n -v -l -p 5555 -e /bin/bash +# Old (with serial cable to USB) nc -k -n -v -l -p 5555 -e /bin/bash +# Using the new serial to ethernet EX-6111-02 or EX-6111-01 # last data file (000002.dat) should be 2097184000 bytes @@ -35,8 +36,8 @@ if [ ! -v $1 ]; then sls_detector_put powerchip 1 sls_detector_put delay 0 - sls_detector_put triggers 1 - sls_detector_put frames 100 + #sls_detector_put triggers 1 + #sls_detector_put frames 100 sls_detector_put period 0.005 sls_detector_put exptime 0.00004 sls_detector_put highvoltage 0 @@ -52,75 +53,95 @@ if [ ! -v $1 ]; then sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 #sls_detector_put configuremac 0 - sls_detector_put readoutspeed half_speed + sls_detector_put readoutspeed half_speed #sls_detector_put readoutspeed full_speed sls_detector_put gainmode dynamic - - CLI=/afs/psi.ch/project/sls_det_software/serial_control_software/minidelay/minidelay - + sls_detector_put dac vb_comp 1100 + #CLI=/afs/psi.ch/project/sls_det_software/serial_control_software/minidelay/minidelay + HOST=EX-6111-02 # prepare the AGILENT 33250A - echo $CLI" OUTP OFF " | nc pc10773 5555 + #echo $CLI" OUTP OFF " | nc pc10773 5555 + (echo OUTP OFF ) | nc -t $HOST 5000 sleep 0.2 #remember to put High-Z load! #Change load to Infinity - echo $CLI" OUTP:LOAD INF " | nc pc10773 5555 - + (echo OUTP:LOAD INF ) | nc -t $HOST 5000 + sleep 0.2 + # Polarity normal - echo $CLI" OUTP:POL NORM" | nc pc10773 5555 + #echo $CLI" OUTP:POL NORM" | nc pc10773 5555 + (echo OUTP:POL NORM) | nc -t $HOST 5000 + sleep 0.2 # pulse - echo $CLI" FUNC PULS" | nc pc10773 5555 + #echo $CLI" FUNC PULS" | nc pc10773 5555 + (echo FUNC PULS) | nc -t $HOST 5000 sleep 0.2 # frequency 1kHz - echo $CLI" FREQ 1000" | nc pc10773 5555 + #echo $CLI" FREQ 1000" | nc pc10773 5555 + (echo FREQ 1000) | nc -t $HOST 5000 sleep 0.2 # width 40 us - echo $CLI" PULS:WIDT 0.000040" | nc pc10773 5555 + #echo $CLI" PULS:WIDT 0.000040" | nc pc10773 5555 + (echo PULS:WIDT 0.000040) | nc -t $HOST 5000 sleep 0.2 # amplitude 0.1 V" | nc pc10773 5555 - echo $CLI" VOLT 0.1" | nc pc10773 5555 - - # offset 0 V echo $CLI" VOLT:OFFS 0" | nc pc8830 5555 + #echo $CLI" VOLT 0.1" | nc pc10773 5555 + (echo VOLT 0.1) | nc -t $HOST 5000 sleep 0.2 + + # offset 0 V echo $CLI" VOLT:OFFS 0" | nc pc8830 5555 + # sleep 0.2 # VLOW 0 V - echo $CLI" VOLT:LOW 0" | nc pc10773 5555 + #echo $CLI" VOLT:LOW 0" | nc pc10773 5555 + (echo VOLT:LOW 0) | nc -t $HOST 5000 sleep 0.2 # edge 50 ns - echo $CLI" PULS:TRAN 0.000000050" | nc pc10773 5555 + #echo $CLI" PULS:TRAN 0.000000050" | nc pc10773 5555 + (echo PULS:TRAN 0.000000050) | nc -t $HOST 5000 sleep 0.2 # triggered burst - echo $CLI" BURS:MODE TRIG" | nc pc10773 5555 + #echo $CLI" BURS:MODE TRIG" | nc pc10773 5555 + (echo BURS:MODE TRIG) | nc -t $HOST 5000 sleep 0.2 # cycles 1 - echo $CLI" BURS:NCYC 1" | nc pc10773 5555 + #echo $CLI" BURS:NCYC 1" | nc pc10773 5555 + (echo BURS:NCYC 1) | nc -t $HOST 5000 sleep 0.2 # external trigger source - echo $CLI" TRIG:SOUR EXT" | nc pc10773 5555 + #echo $CLI" TRIG:SOUR EXT" | nc pc10773 5555 + (echo TRIG:SOUR EXT) | nc -t $HOST 5000 sleep 0.2 # delay 1 us - echo $CLI" TRIG:DEL 0.000001" | nc pc10773 5555 - + #echo $CLI" TRIG:DEL 0.000001" | nc pc10773 5555 + (echo TRIG:DEL 0.000001) | nc -t $HOST 5000 + sleep 0.2 # delay 40 us #echo $CLI" TRIG:DEL 0.000040" | nc pc10773 5555 - sleep 0.2 + #sleep 0.2 # slope positive - echo $CLI" TRIG:SLOP POS" | nc pc10773 5555 + #echo $CLI" TRIG:SLOP POS" | nc pc10773 5555 + (echo TRIG:SLOP POS) | nc -t $HOST 5000 sleep 0.2 # turn on burst mode - echo $CLI" BURS:STAT ON" | nc pc10773 5555 + #echo $CLI" BURS:STAT ON" | nc pc10773 5555 + (echo BURS:STAT ON) | nc -t $HOST 5000 + sleep 0.2 + + (echo VOLT:HIGH 0.02) | nc -t $HOST 5000 sleep 0.2 if [ "$1" == 'Y' ]; then @@ -140,7 +161,8 @@ if [ ! -v $1 ]; then # high voltage # sls_detector_put highvoltage 200 #because it seemed more stable, we are using external HV 230V # output on - echo $CLI" OUTP ON" | nc pc10773 5555 + #echo $CLI" OUTP ON" | nc pc10773 5555 + (echo OUTP ON) | nc -t $HOST 5000 sleep 0.2 if [ "$1" == 'Y' ]; then @@ -155,6 +177,15 @@ if [ ! -v $1 ]; then fi fi + sls_detector_put frames 20000 + sls_detector_put start + sleep 110 + + sls_detector_put stop + + sls_detector_put triggers 1 + sls_detector_put frames 100 + $TKBPG0 & sleep 1 @@ -162,7 +193,8 @@ if [ ! -v $1 ]; then for ivpulse in {10..1000..10} do vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) - echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + #echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + (echo VOLT:HIGH $vpulse) | nc -t $HOST 5000 sleep 1 sls_detector_put start sleep 1 @@ -172,7 +204,8 @@ if [ ! -v $1 ]; then for ivpulse in {1050..6000..50} do vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) - echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + #echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + (echo VOLT:HIGH $vpulse) | nc -t $HOST 5000 sleep 1 sls_detector_put start sleep 1 @@ -180,7 +213,8 @@ if [ ! -v $1 ]; then # Kill receiver sls_detector_put stop - echo $CLI" VOLT:HIGH 0.010" | nc pc10773 5555 + #echo $CLI" VOLT:HIGH 0.010" | nc pc10773 5555 + (echo VOLT:HIGH 0.010) | nc -t $HOST 5000 sleep 20 $KILLRCV @@ -201,7 +235,8 @@ if [ ! -v $1 ]; then do vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) - echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + #echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + (echo VOLT:HIGH $vpulse) | nc -t $HOST 5000 sleep 1 sls_detector_put start sleep 1 @@ -210,7 +245,8 @@ if [ ! -v $1 ]; then for ivpulse in {1050..6000..50} do vpulse=$(printf %.3f $(echo "$ivpulse/1000" | bc -l)) - echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + #echo $CLI" VOLT:HIGH "$vpulse | nc pc10773 5555 + (echo VOLT:HIGH $vpulse) | nc -t $HOST 5000 sleep 1 sls_detector_put start sleep 1 @@ -221,11 +257,12 @@ if [ ! -v $1 ]; then # high voltage # sls_detector_put highvoltage 0 # output off - echo $CLI" OUTP OFF " | nc pc10773 5555 - + #echo $CLI" OUTP OFF " | nc pc10773 5555 + (echo OUTP OFF) | nc -t $HOST 5000 $KILLRCV echo "Finished scan, please wait for capacitor to discharge" + sls_detector_put dac vb_comp 1220 sleep 20 echo "It is now safe to disconnect the cable between the amplifier board and the readout board" echo "Script finished" diff --git a/CS_analysis.cpp b/CS_analysis.cpp index ffed718..8e04d24 100644 --- a/CS_analysis.cpp +++ b/CS_analysis.cpp @@ -688,7 +688,115 @@ cout << " G0->G1->G2 sequence - dynamicG0" <G1->G2 sequence - dynamicG0" <>>>>>> refs/remotes/origin/master scan_v6.push_back("578"); //jfcalib-0 scan_v6.push_back("578_fullspeed"); //jfcalib-0 scan_v6.push_back("588"); //jfcalib-2 @@ -677,10 +674,7 @@ int main(int argc, char* argv[]) { scan_v6.push_back("589"); //jfcalib-5 scan_v6.push_back("589_fullspeed"); //jfcalib-5 -<<<<<<< HEAD -======= ->>>>>>> refs/remotes/origin/master scan_v6.push_back("586"); //jfcalib-0 scan_v6.push_back("586_fullspeed"); //jfcalib-0 scan_v6.push_back("607"); //jfcalib-1 @@ -689,7 +683,6 @@ int main(int argc, char* argv[]) { scan_v6.push_back("609_fullspeed"); //jfcalib-2 scan_v6.push_back("625"); //jfcalib-3 scan_v6.push_back("625_fullspeed"); //jfcalib-3 -<<<<<<< HEAD scan_v6.push_back("626"); //jfcalib-4 scan_v6.push_back("626_fullspeed"); //jfcalib-4 @@ -720,11 +713,109 @@ int main(int argc, char* argv[]) { scan_v6.push_back("604"); //jfcalib-4 scan_v6.push_back("604_fullspeed"); //jfcalib-4 scan_v6.push_back("701_Vadym"); -======= scan_v6.push_back("526"); //jfcalib-4 scan_v6.push_back("526_fullspeed"); //jfcalib-4 ->>>>>>> refs/remotes/origin/master + + scan_v6.push_back("643"); //jfcalib-0 + scan_v6.push_back("643_fullspeed"); //jfcalib-0 + scan_v6.push_back("644"); //jfcalib-1 + scan_v6.push_back("644_fullspeed"); //jfcalib-1 + scan_v6.push_back("645"); //jfcalib-2 + scan_v6.push_back("645_fullspeed"); //jfcalib-2 + scan_v6.push_back("646"); //jfcalib-3 + scan_v6.push_back("646_fullspeed"); //jfcalib-3 + scan_v6.push_back("665"); //jfcalib-4 + scan_v6.push_back("665_fullspeed"); //jfcalib-4 + scan_v6.push_back("570"); //jfcalib-5 + scan_v6.push_back("570_fullspeed"); //jfcalib-5 + + + scan_v6.push_back("666"); //jfcalib-0 + scan_v6.push_back("666_fullspeed"); //jfcalib-0 + scan_v6.push_back("667"); //jfcalib-1 + scan_v6.push_back("667_fullspeed"); //jfcalib-1 + scan_v6.push_back("668"); //jfcalib-2 + scan_v6.push_back("668_fullspeed"); //jfcalib-2 + scan_v6.push_back("669"); //jfcalib-3 + scan_v6.push_back("669_fullspeed"); //jfcalib-3 + scan_v6.push_back("670"); //jfcalib-4 + scan_v6.push_back("670_fullspeed"); //jfcalib-4 + + scan_v6.push_back("412"); //jfcalib-2 + scan_v6.push_back("412_fullspeed"); //jfcalib-2 + scan_v6.push_back("424"); //jfcalib-3 + scan_v6.push_back("424_fullspeed"); //jfcalib-3 + scan_v6.push_back("475"); //jfcalib-4 + scan_v6.push_back("475_fullspeed"); //jfcalib-4 + scan_v6.push_back("413"); //jfcalib-5 + scan_v6.push_back("413_fullspeed"); //jfcalib-5 + + scan_v6.push_back("636"); //jfcalib-0 + scan_v6.push_back("636_fullspeed"); //jfcalib-0 + scan_v6.push_back("637"); //jfcalib-1 + scan_v6.push_back("637_fullspeed"); //jfcalib-1 + scan_v6.push_back("638"); //jfcalib-2 + scan_v6.push_back("638_fullspeed"); //jfcalib-2 + scan_v6.push_back("639"); //jfcalib-3 + scan_v6.push_back("639_fullspeed"); //jfcalib-3 + scan_v6.push_back("640"); //jfcalib-4 + scan_v6.push_back("640_fullspeed"); //jfcalib-4 + scan_v6.push_back("641"); //jfcalib-5 + scan_v6.push_back("641_fullspeed"); //jfcalib-5 + + scan_v6.push_back("649"); //jfcalib-0 + scan_v6.push_back("649_fullspeed"); //jfcalib-0 + scan_v6.push_back("650"); //jfcalib-1 + scan_v6.push_back("650_fullspeed"); //jfcalib-1 + scan_v6.push_back("651"); //jfcalib-2 + scan_v6.push_back("651_fullspeed"); //jfcalib-2 + scan_v6.push_back("652"); //jfcalib-3 + scan_v6.push_back("652_fullspeed"); //jfcalib-3 + scan_v6.push_back("653"); //jfcalib-4 + scan_v6.push_back("653_fullspeed"); //jfcalib-4 + scan_v6.push_back("686"); //jfcalib-5 + scan_v6.push_back("686_fullspeed"); //jfcalib-5 + + scan_v6.push_back("687"); //jfcalib-0 + scan_v6.push_back("687_fullspeed"); //jfcalib-0 + scan_v6.push_back("693"); //jfcalib-1 + scan_v6.push_back("693_fullspeed"); //jfcalib-1 + scan_v6.push_back("695"); //jfcalib-2 + scan_v6.push_back("695_fullspeed"); //jfcalib-2 + scan_v6.push_back("696"); //jfcalib-3 + scan_v6.push_back("696_fullspeed"); //jfcalib-3 + scan_v6.push_back("697"); //jfcalib-4 + scan_v6.push_back("697_fullspeed"); //jfcalib-4 + scan_v6.push_back("699"); //jfcalib-5 + scan_v6.push_back("699_fullspeed"); //jfcalib-5 + + scan_v6.push_back("698"); //jfcalib-0 + scan_v6.push_back("698_fullspeed"); //jfcalib-0 + scan_v6.push_back("703"); //jfcalib-1 + scan_v6.push_back("703_fullspeed"); //jfcalib-1 + scan_v6.push_back("704"); //jfcalib-2 + scan_v6.push_back("704_fullspeed"); //jfcalib-2 + scan_v6.push_back("708"); //jfcalib-3 + scan_v6.push_back("708_fullspeed"); //jfcalib-3 + scan_v6.push_back("709"); //jfcalib-4 + scan_v6.push_back("709_fullspeed"); //jfcalib-4 + scan_v6.push_back("744"); //jfcalib-5 + scan_v6.push_back("744_fullspeed"); //jfcalib-5 + + scan_v6.push_back("735"); //jfcalib-0 + scan_v6.push_back("741"); //jfcalib-1 + scan_v6.push_back("742"); //jfcalib-2 + scan_v6.push_back("743"); //jfcalib-3 + scan_v6.push_back("745"); //jfcalib-4 + scan_v6.push_back("746"); //jfcalib-5 + + scan_v6.push_back("748"); //jfcalib-0 + scan_v6.push_back("750"); //jfcalib-1 + scan_v6.push_back("751"); //jfcalib-2 + scan_v6.push_back("752"); //jfcalib-3 + scan_v6.push_back("753"); //jfcalib-4 + scan_v6.push_back("784"); //jfcalib-5 diff --git a/CS_scan.sh b/CS_scan.sh index ef2d032..09987f9 100644 --- a/CS_scan.sh +++ b/CS_scan.sh @@ -15,172 +15,186 @@ KILLRCV="killall ju_udp_receiver_3threads_2_0" $KILLRCV -sls_detector_put stop #just in case -sls_detector_put powerchip 1 +if [[ "$0" == *"CS_scan.sh"* ]]; then + echo "script changes env. variables: should be invoked with source, not sh " + exit +fi + +if [ ! -v $1 & ! -v $2 ]; then + echo $0 + echo "Readout speed is" $2 + echo "printing filenames for module" $1 + ROBspeed=$2 + if [[ "$2" == "full_speed" ]]; then + source filename_creator.sh $1"_fullspeed" N + + elif [[ "$2" == "half_speed" ]]; then + source filename_creator.sh $1 N + else + echo "Readout speed has to be specified as half_speed or full_speed" + exit + fi + + sls_detector_put stop #just in case + sls_detector_put powerchip 1 -sls_detector_put frames 640 -sls_detector_put period 0.005 -sls_detector_put exptime 0.000010 -sls_detector_put highvoltage 200 #200 + sls_detector_put frames 640 + sls_detector_put period 0.005 + sls_detector_put exptime 0.000010 + sls_detector_put highvoltage 200 #200 -# configure for receiver on pc-jungfrau-01/pc-jungfrau-02/pc-jungfrau-test -# source pccalib.sh [pc] (pc-jungfrau-01/pc-jungfrau-02/pc-jungfrau-test) -sls_detector_put udp_dstport 32410 -sls_detector_put udp_dstip $DSTIP #10.1.4.105 -sls_detector_put udp_dstmac $DSTMAC #3C:FD:FE:A2:14:D8 -sls_detector_put udp_srcip $SRCIP #10.1.4.9 -sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 + # configure for receiver on pc-jungfrau-01/pc-jungfrau-02/pc-jungfrau-test + # source pccalib.sh [pc] (pc-jungfrau-01/pc-jungfrau-02/pc-jungfrau-test) -sls_detector_put readoutspeed half_speed -#sls_detector_put readoutspeed full_speed -#sls_detector_put dbitphase 125 + sls_detector_put udp_dstport 32410 + sls_detector_put udp_dstip $DSTIP #10.1.4.105 + sls_detector_put udp_dstmac $DSTMAC #3C:FD:FE:A2:14:D8 + sls_detector_put udp_srcip $SRCIP #10.1.4.9 + sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 -sleep 3 + sls_detector_put readoutspeed $ROBspeed + #sls_detector_put readoutspeed full_speed + #sls_detector_put dbitphase 125 + + sleep 3 -sls_detector_put frames 10000 -sls_detector_put start -sleep 70 -sls_detector_put stop -sls_detector_put frames 640 + sls_detector_put frames 10000 + sls_detector_put start + sleep 70 + sls_detector_put stop + sls_detector_put frames 640 -$TKCSG0 & -sleep 3 + $TKCSG0 & + sleep 3 -echo "recording G0 pede" -sls_detector_put start -sleep 4 + echo "recording G0 pede" + sls_detector_put start + sleep 4 + echo "recording G1 pede" + sls_detector_put gainmode forceswitchg1 + sls_detector_put start + sleep 4 -echo "recording G1 pede" -sls_detector_put gainmode forceswitchg1 -sls_detector_put start -sleep 4 + echo "recording G2 pede" + sls_detector_put gainmode forceswitchg2 + sls_detector_put start + sleep 4 + sls_detector_put gainmode dynamic -echo "recording G2 pede" -sls_detector_put gainmode forceswitchg2 -sls_detector_put start -sleep 4 + # turn on current source + # bit 16 high bit 17 low = automatic cal col sweep + # bit 16 high bit 17 high = cal col selected with bits 26-20 + sls_detector_put currentsource 1 nofix 0 + sleep 1 -sls_detector_put gainmode dynamic + # loop 1 + for tint in {50..450..50} # 25 is too small here, 50 min + do + tint_sec=$(printf %.9f $(echo "$tint/1000000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done + # loop 2a + for tint in {50..100..5} + do + tint_sec=$(printf %.8f $(echo "$tint/100000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done -# turn on current source -# bit 16 high bit 17 low = automatic cal col sweep -# bit 16 high bit 17 high = cal col selected with bits 26-20 -sls_detector_put currentsource 1 nofix 0 + # loop 2b + for tint in {110..200..10} + do + tint_sec=$(printf %.8f $(echo "$tint/100000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done -sleep 1 + # loop 2c + for tint in {225..450..25} + do + tint_sec=$(printf %.8f $(echo "$tint/100000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done + # loop 3a + for tint in {50..100..5} + do + tint_sec=$(printf %.7f $(echo "$tint/10000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done -# loop 1 -for tint in {50..450..50} # 25 is too small here, 50 min -do -tint_sec=$(printf %.9f $(echo "$tint/1000000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done + # loop 3b + for tint in {110..200..10} + do + tint_sec=$(printf %.7f $(echo "$tint/10000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done + # loop 3c + for tint in {225..450..25} + do + tint_sec=$(printf %.7f $(echo "$tint/10000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done -# loop 2a -for tint in {50..100..5} -do -tint_sec=$(printf %.8f $(echo "$tint/100000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done + # loop 4a + for tint in {50..100..5} + do + tint_sec=$(printf %.7f $(echo "$tint/1000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done + # loop 4b + for tint in {110..250..10} + do + tint_sec=$(printf %.7f $(echo "$tint/1000000" | bc -l)) + echo "setting integration time to (s) " $tint_sec + sls_detector_put exptime $tint_sec + sls_detector_put start + sleep 4 + done -# loop 2b -for tint in {110..200..10} -do -tint_sec=$(printf %.8f $(echo "$tint/100000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done - - -# loop 2c -for tint in {225..450..25} -do -tint_sec=$(printf %.8f $(echo "$tint/100000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done - - -# loop 3a -for tint in {50..100..5} -do -tint_sec=$(printf %.7f $(echo "$tint/10000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done - - -# loop 3b -for tint in {110..200..10} -do -tint_sec=$(printf %.7f $(echo "$tint/10000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done - - -# loop 3c -for tint in {225..450..25} -do -tint_sec=$(printf %.7f $(echo "$tint/10000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done - - -# loop 4a -for tint in {50..100..5} -do -tint_sec=$(printf %.7f $(echo "$tint/1000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done - - -# loop 4b -for tint in {110..250..10} -do -tint_sec=$(printf %.7f $(echo "$tint/1000000" | bc -l)) -echo "setting integration time to (s) " $tint_sec -sls_detector_put exptime $tint_sec -sls_detector_put start -sleep 4 -done - - -echo "Finished scan" -sls_detector_put exptime 0.000010 -sls_detector_put period 0.002 -sls_detector_put frames 1000000 -sls_detector_put currentsource 0 -sls_detector_put highvoltage 0 -echo "Script finished" -sleep 4 -$KILLRCV + echo "Finished scan" + sls_detector_put exptime 0.000010 + sls_detector_put period 0.002 + sls_detector_put frames 1000000 + sls_detector_put currentsource 0 + sls_detector_put highvoltage 0 + sls_detector_put readoutspeed half_speed + echo "Script finished" + sleep 4 + $KILLRCV + +else + echo "Specify module number as a first argument" + echo "Specify readout_speed as a second argument:half_speed or full_speed" + echo "Script finished" +fi diff --git a/CS_scan_both_speeds.sh b/CS_scan_both_speeds.sh index e26c9d7..1a845c3 100644 --- a/CS_scan_both_speeds.sh +++ b/CS_scan_both_speeds.sh @@ -48,6 +48,7 @@ if [ ! -v $1 ]; then sls_detector_put readoutspeed half_speed #sls_detector_put readoutspeed full_speed #sls_detector_put dbitphase 125 + sls_detector_put dac vb_comp 1100 sleep 3 @@ -337,6 +338,7 @@ if [ ! -v $1 ]; then sls_detector_put frames 1000000 sls_detector_put currentsource 0 sls_detector_put highvoltage 0 + sls_detector_put dac vb_comp 1220 echo "Script finished" sleep 4 $KILLRCV diff --git a/CuFluo_exposure.sh b/CuFluo_exposure.sh index a7d209a..db7b19c 100644 --- a/CuFluo_exposure.sh +++ b/CuFluo_exposure.sh @@ -11,129 +11,158 @@ # - source pccalib.sh [pc] (mpc2012/pc-jungfrau-test) # - xray tube is on and ramped for 40 kV, 60 mA, set to Cu -shutter=1 +shutter=1 # for big X-ray box +# shutter=3 # for small X-ray box -sls_detector_put stop #just in case - -sls_detector_put powerchip 1 - - -sls_detector_put period 0.002 -sls_detector_put exptime 0.000010 -sls_detector_put highvoltage 200 #200 - -# configure for receiver on mpc2012/pc-jungfrau-test/mpc2198/mpc3282 -# source pccalib.sh [pc] (mpc2012/pc-jungfrau-test/mpc2198/mpc3282) - -sls_detector_put udp_dstport 32410 -sls_detector_put udp_dstip $DSTIP #10.1.4.105 -sls_detector_put udp_dstmac $DSTMAC #3C:FD:FE:A2:14:D8 -sls_detector_put udp_srcip $SRCIP #10.1.4.9 -sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 - - -#sls_detector_put readoutspeed half_speed -sls_detector_put readoutspeed full_speed -#sls_detector_put reg 0x59 0x1310 #0001 0011 0001 0000 - -#sls_detector_put readoutspeed 0 -#sls_detector_put reg 0x59 0x0100 #0000 0001 0000 0000 - KILLRCV="killall ju_udp_receiver_3threads_2_0" $KILLRCV -#CLI=/afs/psi.ch/project/sls_det_software/bin/sl7_binaries_to_be_removed_soon/xrayClient_sl7 -CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl8 #/vacuumClient_sl7 -$CLI setv 40 -$CLI setc 60 -$CLI HV on +if [[ "$0" == *"BP_scan.sh"* ]]; then + echo "script changes env. variables: should be invoked with source, not sh " + exit +fi -sls_detector_put clearbit 0x5d 0 +if [ ! -v $1 & ! -v $2 ]; then + echo $0 + echo "Readout speed is" $2 + echo "printing filenames for module" $1 + ROBspeed=$2 + + if [[ "$2" == "full_speed" ]]; then + source filename_creator.sh $1"_fullspeed" Y + elif [[ "$2" == "half_speed" ]]; then + source filename_creator.sh $1 Y + else + echo "Readout speed has to be specified as half_speed or full_speed" + exit + fi -$CLI shutter $shutter off #$CLI shutter 1 off -echo "warmin up the board" -sls_detector_put frames 40000 -sls_detector_put start -sleep 81 -sls_detector_put stop + sls_detector_put stop #just in case -echo "end of board warm up" + sls_detector_put powerchip 1 -sls_detector_put frames 1000 -$KILLRCV -sleep 1 -$TKPG0 & -sleep 2 -echo "recording G0 pede" -sls_detector_put start -sleep 3 -# 1000 frames at 500 frames per second takes 2s + # JF1.2 to fix saturation issue in HG0 + # sls_detector_put defaultdac vref_comp 420 highgain0 + # sls_detector_put setbit 0x58 18 + # End JF1.2 -echo "recording G1 pede" -sls_detector_put gainmode forceswitchg1 -sls_detector_put start -sleep 3 + sls_detector_put period 0.002 + sls_detector_put exptime 0.000010 + sls_detector_put highvoltage 200 #200 -echo "recording G2 pede" -sls_detector_put gainmode forceswitchg2 -sls_detector_put start -sleep 3 + # configure for receiver on mpc2012/pc-jungfrau-test/mpc2198/mpc3282 + # source pccalib.sh [pc] (mpc2012/pc-jungfrau-test/mpc2198/mpc3282) -sls_detector_put gainmode dynamic + sls_detector_put udp_dstport 32410 + sls_detector_put udp_dstip $DSTIP #10.1.4.105 + sls_detector_put udp_dstmac $DSTMAC #3C:FD:FE:A2:14:D8 + sls_detector_put udp_srcip $SRCIP #10.1.4.9 + sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 -$KILLRCV -echo "closed G0 pede file and open the G0 CuFluo file" -sleep 1 -$TKFG0 & -sleep 3 + sls_detector_put readoutspeed $ROBspeed -sls_detector_put frames 230000 -$CLI shutter $shutter on #$CLI shutter 1 on -sleep 1 -sls_detector_put start -sleep 470 -# 200k frames at 500 frames per second takes 400s -$CLI shutter $shutter off #$CLI shutter 1 off + #sls_detector_put readoutspeed full_speed + #sls_detector_put reg 0x59 0x1310 #0001 0011 0001 0000 -$KILLRCV -echo "closed G0 CuFluo file and open HG0 pede file" -sleep 1 -$TKPHG0 & -sleep 3 + #sls_detector_put readoutspeed 0 + #sls_detector_put reg 0x59 0x0100 #0000 0001 0000 0000 -sls_detector_put settings highgain0 + #CLI=/afs/psi.ch/project/sls_det_software/bin/sl7_binaries_to_be_removed_soon/xrayClient_sl7 + CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl8 #/vacuumClient_sl7 + # CLI=/afs/psi.ch/project/sls_det_software/bin/vacuumClient_sl8 # for small X-ray box -sls_detector_put frames 1000 + $CLI setv 60 + $CLI setc 40 # for big X-ray box -echo "recording HG0 pede" + # $CLI setc 55 # for small X-ray box + $CLI HV on -sls_detector_put start -sleep 3 -# 1000 frames at 500 frames per second takes 2s + sls_detector_put clearbit 0x5d 0 -$KILLRCV -echo "closed HG0 pede file and open the HG0 CuFluo file" -sleep 1 + $CLI shutter $shutter off #$CLI shutter 1 off + echo "warmin up the board" + sls_detector_put frames 40000 + sls_detector_put start + sleep 81 + sls_detector_put stop -$TKFHG0 & -sleep 3 + echo "end of board warm up" + # : ' # Uncomment to skip a G0 part + sls_detector_put frames 1000 + $KILLRCV + sleep 1 + $TKPG0 & + sleep 2 + echo "recording G0 pede" + sls_detector_put start + sleep 3 + # 1000 frames at 500 frames per second takes 2s -sls_detector_put frames 230000 + echo "recording G1 pede" + sls_detector_put gainmode forceswitchg1 + sls_detector_put start + sleep 3 -$CLI shutter $shutter on #$CLI shutter 1 on -sleep 1 + echo "recording G2 pede" + sls_detector_put gainmode forceswitchg2 + sls_detector_put start + sleep 3 -sls_detector_put start -sleep 470 -# 200k frames at 500 frames per second takes 400s + sls_detector_put gainmode dynamic + $KILLRCV + echo "closed G0 pede file and open the G0 CuFluo file" + sleep 1 + $TKFG0 & + sleep 3 + sls_detector_put frames 220000 + $CLI shutter $shutter on #$CLI shutter 1 on + sleep 1 + sls_detector_put start + sleep 450 -$CLI shutter $shutter off #$CLI shutter 1 off + # 200k frames at 500 frames per second takes 400s + $CLI shutter $shutter off #$CLI shutter 1 off + # ' # Uncomment to skip a G0 part + $KILLRCV + echo "closed G0 CuFluo file and open HG0 pede file" + sleep 1 + $TKPHG0 & + sleep 3 -$KILLRCV + sls_detector_put settings highgain0 + sls_detector_put frames 1000 -sls_detector_put highvoltage 0 + echo "recording HG0 pede" + sls_detector_put start + sleep 3 + # 1000 frames at 500 frames per second takes 2s + $KILLRCV + echo "closed HG0 pede file and open the HG0 CuFluo file" + sleep 1 -echo "Script finished" + $TKFHG0 & + sleep 3 + + sls_detector_put frames 220000 + $CLI shutter $shutter on #$CLI shutter 1 on + sleep 1 + + sls_detector_put start + sleep 450 + + # 200k frames at 500 frames per second takes 400s + $CLI shutter $shutter off #$CLI shutter 1 off + $KILLRCV + + sls_detector_put highvoltage 0 + sls_detector_put readoutspeed half_speed + echo "Script finished" + +else + echo "Specify module number as a first argument" + echo "Specify readout_speed as a second argument:half_speed,full_speed" + echo "Script finished" +fi diff --git a/CuFluo_exposure_JF11.sh b/CuFluo_exposure_JF11.sh index facca4c..2d35fa8 100644 --- a/CuFluo_exposure_JF11.sh +++ b/CuFluo_exposure_JF11.sh @@ -54,9 +54,9 @@ sls_detector_put reg 0x7f 0xff1f -CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl7 -$CLI setv 40 -$CLI setc 60 +CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl8 +$CLI setv 60 +$CLI setc 40 $CLI HV on diff --git a/CuFluo_exposure_both_speeds.sh b/CuFluo_exposure_both_speeds.sh index 7a58a34..7ff0a32 100644 --- a/CuFluo_exposure_both_speeds.sh +++ b/CuFluo_exposure_both_speeds.sh @@ -55,16 +55,17 @@ if [ ! -v $1 ]; then #CLI=/afs/psi.ch/project/sls_det_software/bin/sl7_binaries_to_be_removed_soon/xrayClient_sl7 #/vacuumClient_sl7 CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl8 #/vacuumClient_sl7 - $CLI setv 40 - $CLI setc 60 + $CLI setv 60 + $CLI setc 40 $CLI HV on sls_detector_put clearbit 0x5d 0 #sls_detector_put vref_prech 1000 #sls_detector_put vref_ds 1100 - + sls_detector_put dac vb_comp 1100 $CLI shutter $shutter off #$CLI shutter 1 off + $CLI shutter $shutter on #$CLI shutter 1 on echo "warmin up the board" sls_detector_put frames 40000 sls_detector_put start @@ -72,6 +73,7 @@ if [ ! -v $1 ]; then sls_detector_put stop echo "end of board warm up" + $CLI shutter $shutter off #$CLI shutter 1 off sls_detector_put frames 1000 $KILLRCV @@ -101,9 +103,10 @@ if [ ! -v $1 ]; then $TKFG0 & sleep 5 - sls_detector_put frames 230000 - $CLI shutter $shutter on #$CLI shutter 1 on - sleep 1 + sls_detector_put frames 220000 + + $CLI shutter $shutter on #$CLI shutter 1 off + sleep 2 sls_detector_put start sleep 470 # 200k frames at 500 frames per second takes 400s @@ -116,6 +119,7 @@ if [ ! -v $1 ]; then $TKPHG0 & sleep 3 sls_detector_put settings highgain0 + sls_detector_put dac vb_comp 1100 #sls_detector_put vref_prech 1000 #sls_detector_put vref_ds 1100 sls_detector_put frames 1000 @@ -132,7 +136,7 @@ if [ ! -v $1 ]; then $TKFHG0 & sleep 5 - sls_detector_put frames 230000 + sls_detector_put frames 220000 $CLI shutter $shutter on #$CLI shutter 1 on sleep 1 sls_detector_put start @@ -155,7 +159,8 @@ if [ ! -v $1 ]; then sls_detector_put clearbit 0x5d 0 #sls_detector_put vref_prech 1000 #sls_detector_put vref_ds 1100 - + sls_detector_put dac vb_comp 1100 + sls_detector_put frames 1000 $TKPG0 & sleep 5 @@ -182,7 +187,7 @@ if [ ! -v $1 ]; then $TKFG0 & sleep 5 - sls_detector_put frames 230000 + sls_detector_put frames 220000 $CLI shutter $shutter on #$CLI shutter 1 on sleep 1 sls_detector_put start @@ -197,6 +202,7 @@ if [ ! -v $1 ]; then $TKPHG0 & sleep 5 sls_detector_put settings highgain0 + sls_detector_put dac vb_comp 1100 #sls_detector_put vref_prech 1000 #sls_detector_put vref_ds 1100 @@ -214,7 +220,7 @@ if [ ! -v $1 ]; then $TKFHG0 & sleep 5 - sls_detector_put frames 230000 + sls_detector_put frames 220000 $CLI shutter $shutter on #$CLI shutter 1 on sleep 1 sls_detector_put start @@ -228,7 +234,7 @@ if [ ! -v $1 ]; then sls_detector_put highvoltage 0 sls_detector_put clearbit 0x5d 0 - + sls_detector_put dac vb_comp 1220 echo "Script finished" diff --git a/CuFluo_exposure_sc.sh b/CuFluo_exposure_sc.sh index 7c48707..e894d84 100644 --- a/CuFluo_exposure_sc.sh +++ b/CuFluo_exposure_sc.sh @@ -9,6 +9,28 @@ # - detector is on # - xray tube is on and ramped for 40 kV, 60 mA, set to Cu +KILLRCV="killall ju_udp_receiver_3threads_2_0" +$KILLRCV + +if [[ "$0" == *"CuFluo_exposure_sc.sh"* ]]; then + echo "script changes env. variables: should be invoked with source, not sh " + exit + +fi + + +if [ ! -v $1 ]; then + echo $0 + echo "printing filenames for module " $1 + + source filename_creator.sh $1 N + +else + echo "Make sure you source filename_creator.sh file name" +fi + +shutter=1 + sls_detector_put stop #just in case sls_detector_put powerchip 1 @@ -16,7 +38,7 @@ sls_detector_put powerchip 1 #Effective SC period = sc_delay + exptime + 2.1us (reset preamp and CDS) #Frame period = effective SC period *16 + 840 us * 16 = 14 ms (for readout) -sls_detector_put period 0.1 #0.03 #0.002 +sls_detector_put period 0.03 #0.017 #0.1 #0.03 #0.002 sls_detector_put exptime 0.000010 #0.000010 sls_detector_put extrastoragecells 15 sls_detector_put storagecell_start 0 @@ -36,47 +58,48 @@ sls_detector_put readoutspeed half_speed #sls_detector_put readoutspeed 0 #sls_detector_put reg 0x59 0x0100 #0000 0001 0000 0000 -KILLRCV="killall ju_udp_receiver_3threads_2_0" -$KILLRCV -CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl7 -$CLI setv 40 -$CLI setc 60 +CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl8 #/vacuumClient_sl7 +$CLI setv 60 +$CLI setc 40 $CLI HV on sls_detector_put clearbit 0x5d 0 -$CLI shutter 1 off +$CLI shutter $shutter off #$CLI shutter 1 off +$CLI shutter $shutter on #$CLI shutter 1 on + echo "warmin up the board" -sls_detector_put frames 2500 #40000 +sls_detector_put frames 3500 #40000 sls_detector_put start -sleep 260 #81 # 2500 * 100ms = 250s # 2500 * 30ms = 75s # 2500 * 20 ms = 50s +sleep 110 #80 #81 # 2500 * 100ms = 250s # 2500 * 30ms = 75s # 2500 * 20 ms = 50s sls_detector_put stop echo "end of board warm up" +$CLI shutter $shutter off #$CLI shutter 1 off sls_detector_put frames 1000 $KILLRCV -sleep 10 #1 +sleep 10 #10 #1 $TKPG0 & - +sleep 5 echo "recording G0 pede" sls_detector_put start -sleep 105 #35 +sleep 32 #25 #105 #35 # 1000 frames (per sc) at 10 frames per second (period 100ms) takes 100s # 1000 frames (per sc) at 34 frames per second (period 30ms) takes 35s echo "recording G0 pede" #sls_detector_put gainmode forceswitchg1 #consumes too much power sls_detector_put start -sleep 105 #35 +sleep 32 #25 #105 #35 echo "recording G0 pede" #sls_detector_put gainmode forceswitchg2 #consumes too much power sls_detector_put start -sleep 105 #35 +sleep 32 #25 #105 #35 sls_detector_put gainmode dynamic @@ -91,18 +114,20 @@ sls_detector_put frames 220000 $CLI shutter 1 on sleep 10 #1 sls_detector_put start -sleep 22010 #6800 +sleep 6800 #3900 #22010 #6800 # 220k frames (per sc) at 10 frames per second (period 10ms) takes 22000s (6h 7min) # 220k frames (per sc) at 34 frames per second (period 30ms) takes 6600s (1h 50min) -$CLI shutter 1 off +$CLI shutter $shutter off #$CLI shutter 1 off #We are not interested in HG0 - #$KILLRCV #echo "closed G0 CuFluo file and open HG0 pede file" #sleep 1 #$TKPHG0 & +#sleep 5 +#sls_detector_put clearbit 0x5d 0 +#sls_detector_put period 0.002 #sls_detector_put settings highgain0 @@ -118,21 +143,24 @@ $CLI shutter 1 off #echo "closed HG0 pede file and open the HG0 CuFluo file" #sleep 1 #$TKFHG0 & - +#sleep 5 #sls_detector_put frames 220000 -#$CLI shutter 1 on +#$CLI shutter $shutter on #$CLI shutter 1 on #sleep 1 #sls_detector_put start #sleep 450 # 200k frames at 500 frames per second takes 400s -#$CLI shutter 1 off +#$CLI shutter $shutter off #$CLI shutter 1 off +sleep 2 +$KILLRCV $CLI HV off -$KILLRCV - sls_detector_put highvoltage 0 +sls_detector_put clearbit 0x5d 0 +sls_detector_put powerchip 0 +sls_detector_put free echo "Script finished" diff --git a/CuFluo_fit_sc.cpp b/CuFluo_fit_sc.cpp new file mode 100644 index 0000000..5f7181f --- /dev/null +++ b/CuFluo_fit_sc.cpp @@ -0,0 +1,322 @@ +// to analyse the backplane pulsing data per module +// changes by VH 210906: to eliminate hardcoded absolute paths, uses location of the analysis root files as additional input argument (accordingly changed in filename_creator.sh) + +#include "TApplication.h" +#include "sls_detector_calibration/jungfrauCommonHeader.h" +#include "sls_detector_calibration/jungfrauCommonFunctions.h" + +#include "sls_detector_calibration/jungfrauFile.C" +#include "sls_detector_calibration/jungfrauPixelMask.C" +#include "sls_detector_calibration/jungfrauPedestal.C" + +#include "sls_detector_calibration/energyCalibration.h" +#include "sls_detector_calibration/energyCalibration.cpp" + +#include "TGraph.h" +#include "TGraphErrors.h" +#include "TF1.h" +#include "TFile.h" +#include "TPaveStats.h" +#include "TLegend.h" +#include "TPaveText.h" + +#include +//#include + +//#define NB_ENABLE 1 +//void nonblock(int state); +//#define NB_DISABLE 0 + +//TApplication* rootapp; +//TCanvas *A2; +//TCanvas *A3; +//TCanvas *A4; +//TCanvas *A5; +//TCanvas *A6; + + +//TPaveStats *st0; + + +//void PlotCanvas(void); + +double checkRangeMaxForAmplifierPlateau(double range_max) { + + // check that the range maximum is no more than 6.4 V + // to avoid non-linearity coming from amplifier plateau + if (range_max > 6400) { + return 6400; + } else { + return range_max; + } +} + + + + +bool isHGX=false; +int main(int argc, char* argv[]) { + + //nonblock(NB_ENABLE); + cout <<"opening the rootapp" <SetBatch(1); + gStyle->SetOptFit(11); + + /* + if (argc != 3) { + cout << "Correct usage:" << endl; + cout << "arg 1: specify module number" << endl; + cout << "arg 2: specify data location" << endl; + cout << "arg 3: specify column (x)" << endl; + cout << "arg 4: specify row (y)" << endl; + exit(1); + } + */ //uncomment for SR + + if (argc != 6) { + cout << "Correct usage:" << endl; + cout << "arg 1: specify module number" << endl; + cout << "arg 2: gain settings" << endl; + cout << "arg 3: specify storage cell" << endl; + cout << "arg 4: specify pixel x position" << endl; + cout << "arg 5: specify pixel y position" << endl; + exit(1); + } //uncomment for VH 210906 + string module_str = argv[1]; + string gain_str = argv[2]; + int sc_int = atoi(argv[3]); + string str2 =("HG0G1G2"); + string str3 =("HGOG1G2"); //filename creator had this bug + + int column = atoi(argv[4]); + int row = atoi(argv[5]); + + + int pixel = column+row*1024; + + char data_loc[256]; + sprintf(data_loc,"/mnt/sls_det_storage/jungfrau_calib/jungfrau_ana_sophie/M%s_CalibAna/", module_str.c_str()); + cout << data_loc << endl; + + std::string folder_path(data_loc); + if (folder_path.find(str2) != string::npos) isHGX=true; + if (folder_path.find(str3) != string::npos) isHGX=true; + + bool isJF11=false; + if (gain_str == "HG0JF11") { + gain_str = "HG0"; + isJF11=true; + } + + // cout << data_loc.find(str2)<<" " << string::npos << " " << str2 << " " << data_loc <HG1->HG2 sequence - dynamicHG0" <G1->G2 sequence - dynamicG0" <SetLeftMargin(0.1); + A2->SetRightMargin(0.13); + A2->SetTopMargin(0.08); + A2->SetBottomMargin(0.15); + + A3->SetLeftMargin(0.1); + A3->SetRightMargin(0.13); + A3->SetTopMargin(0.08); + A3->SetBottomMargin(0.15); + + //file name + sprintf(filename,"%sCuFluo_%s_sc%i_file0to351.root",folder_path.c_str(), gain_str.c_str(),sc_int); //storage cells in burst mode + cout << "Loading file " << filename << endl; + TFile* f = new TFile((const char *)(filename),"READ"); + + int chip; + int CH = row*1024+column; + + if (CH < (65536*1)) { + chip = 1; + } else if (CH < (65536*2)) { + chip = 2; + } else if (CH < (65536*3)) { + chip = 3; + } else if (CH < (65536*4)) { + chip = 4; + } else if (CH < (65536*5)) { + chip = 5; + } else if (CH < (65536*6)) { + chip = 6; + } else if (CH < (65536*7)) { + chip = 7; + } else if (CH < (65536*8)){ + chip = 8; + } + cout<< "Chip "<< chip << " Channel number " << CH << endl; + + TH2I* hist0=(TH2I*)f->Get(Form("adc2d_%d_sc%i",chip, sc_int)); // Storage cell 1 in burst mode + cout << "Creating histogram for " << Form("adc2d_%d_sc%i",chip, sc_int) << endl; + TH1D* proj = hist0->ProjectionX("bin1",CH-(65536*(chip-1))+1,CH-(65536*(chip-1))+1); + cout << "Data for pixel "<< pixel << " is loaded" << endl; + + +if (proj->Integral(low_bin_noise,high_bin_noise)!=0 && proj->Integral(low_bin_peak,high_bin_peak)!=0) { + + A2->cd(); + cout << "Canvas Noise" << endl; + // noise + TH1D *proj_noise = dynamic_cast(proj->Rebin(4,"proj_noise")); + proj_noise->SetStats(kTRUE); + proj_noise->GetXaxis()->SetRangeUser(proj->GetBinLowEdge(low_bin_noise),proj->GetBinLowEdge(high_bin_noise+1)); + proj_noise->Fit("gaus","Q"); + TF1 *fit = proj_noise->GetFunction("gaus"); + + proj_noise->Draw(); + A2->Update(); + proj_noise->GetXaxis()->SetTitle("Pedestal corrected ADC [ADU]"); + proj_noise->GetXaxis()->SetRangeUser(-100,150); + fit->SetParNames("N_{#gamma}", "Peak pos", "Noise RMS"); + TPaveStats *st0 = (TPaveStats*)proj_noise->FindObject("stats"); + st0->SetX1NDC(0.53); + st0->SetX2NDC(0.94); + st0->SetY1NDC(0.75); + st0->SetY2NDC(0.94); + st0->SetBorderSize(0); + st0->SetTextSize(0.04); + A2->Modified(); + A2->Update(); + + A3->cd(); + + // peak + TH1D *proj_peak = dynamic_cast(proj->Rebin(4,"proj_peak")); + proj_peak->SetStats(kTRUE); + proj_peak->GetXaxis()->SetRangeUser(proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + + + Double_t mypar[8]; + mypar[0] = 0.0; + mypar[1] = 0.0; + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + mypar[6] = 1.12; + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + Double_t emypar[8]; + energyCalibration *thiscalibration = new energyCalibration(); + thiscalibration->setScanSign(1); + thiscalibration->setStartParametersKb(mypar); + thiscalibration->fixParameter(0,0.); // no background + thiscalibration->fixParameter(1,0.); + TF1* fittedfun = thiscalibration->fitSpectrumKb(proj_peak,mypar,emypar); + + TF1 *gaus_Ka = new TF1("gaus_Ka","gaus",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + gaus_Ka->SetParameters(mypar[4],mypar[2],mypar[3]); + gaus_Ka->SetLineColor(kBlue); + + TF1 *erfc_Ka = new TF1("erfc_Ka","[0]/2.*(TMath::Erfc(([1]*(x-[2])/[3])/(TMath::Sqrt(2.))))",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + erfc_Ka->SetParameters(mypar[4]*mypar[5], 1, mypar[2], mypar[3]); + erfc_Ka->SetLineColor(kOrange); + + TF1 *gaus_Kb = new TF1("gaus_Kb","gaus",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + gaus_Kb->SetParameters(mypar[4]*mypar[7],mypar[6]*mypar[2],mypar[3]); + gaus_Kb->SetLineColor(kGreen+2); + + TF1 *erfc_Kb = new TF1("erfc_Kb","[0]/2.*(TMath::Erfc(([1]*(x-[2])/[3])/(TMath::Sqrt(2.))))",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + erfc_Kb->SetParameters(mypar[4]*mypar[7]*mypar[5], 1, mypar[6]*mypar[2], mypar[3]); + erfc_Kb->SetLineColor(kOrange+7); + + proj_peak->Draw(); + A3->Update(); + erfc_Kb->Draw("same"); + erfc_Ka->Draw("same"); + gaus_Kb->Draw("same"); + gaus_Ka->Draw("same"); + fittedfun->Draw("same"); + A3->Update(); + proj_peak->GetXaxis()->SetTitle("Pedestal corrected ADC [ADU]"); + fittedfun->SetParNames("Bkg height", "Bkg grad", "K_{#alpha} pos", "Noise RMS", "K_{#alpha} height", "CS", "K_{#beta}/K_{#alpha} pos", "K_{#beta} frac"); + TPaveStats *st = (TPaveStats*)proj_peak->FindObject("stats"); + st->SetX1NDC(0.15); + st->SetX2NDC(0.55); + st->SetY1NDC(0.7); + st->SetY2NDC(0.94); + st->SetBorderSize(0); + st->SetTextSize(0.04); + A3->Modified(); + A3->Update(); +} else { + std::cout << "Masked pixel"; + } + + +rootapp.Run(); +return 0; + +} + diff --git a/Default_pixels_arrays.cpp b/Default_pixels_arrays.cpp index e6f7c7a..20c8587 100644 --- a/Default_pixels_arrays.cpp +++ b/Default_pixels_arrays.cpp @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) { std::vector this_g2_default_pixels(NCH,0); std::vector this_hg0_default_pixels(NCH,0); - // // CuFluo HG0 dataset + // // CuFluo HG0 dataset sprintf(savename,"data/M%s/CuFluo_gain_HG0_M%s.root", this_module.c_str(), this_module.c_str()); TFile* FL_HG0_file = new TFile((char*)savename,"READ"); TH2F* FL_HG0_gain_map = 0; @@ -129,8 +129,10 @@ int main(int argc, char* argv[]) { double this_g0 = 0; double this_g0overg1 = 0; double this_g1 = 0; + double this_g1_2 = 0; double this_g1overg2 = 0; double this_g2 = 0; + double this_g2_2 =0; // HG0 if (FL_HG0_gain_map) { @@ -149,7 +151,7 @@ int main(int argc, char* argv[]) { // G0 if (FL_G0_gain_map) { this_g0 = FL_G0_gain_map->GetBinContent((i%NC)+1,(i/NC)+1); - this_g0_default_pixels[i] = 0; + //this_g0_default_pixels[i] = 0; if (this_g0 == 0) { this_g0_default_pixels[i] = 1; } else if (this_g0 < 30 || this_g0 > 56) { @@ -163,12 +165,15 @@ int main(int argc, char* argv[]) { if (DB_ratio_map) { this_g0overg1 = DB_ratio_map->GetBinContent((i%NC)+1,(i/NC)+1); this_g1 = this_g0 / this_g0overg1; + this_g1_2 = this_g0_default_pixels[i]; this_g1_default_pixels[i] = 0; if (this_g0overg1 == 0) { this_g1_default_pixels[i] = 1; } else if (this_g0 != 0 && (this_g1 < -2.5 || this_g1 > -0.4)) { this_g1_default_pixels[i] = 1; - } + } else if (this_g1_2 == 1) { + this_g1_default_pixels[i] =1; + } } else { this_g1_default_pixels[i] = 1; } @@ -176,12 +181,16 @@ int main(int argc, char* argv[]) { if (CS_ratio_map) { this_g1overg2 = CS_ratio_map->GetBinContent((i%NC)+1,(i/NC)+1); this_g2 = this_g1 / this_g1overg2; + this_g2_2 = this_g1_default_pixels[i]; this_g2_default_pixels[i] = 0; + if (this_g1overg2 == 0) { this_g2_default_pixels[i] = 1; } else if (this_g0 != 0 && this_g1 != 0 && (this_g2 < -0.3 || this_g2 > -0.015)) { this_g2_default_pixels[i] = 1; - } + } else if (this_g2_2 == 1) { + this_g2_default_pixels[i] =1; + } } else { this_g2_default_pixels[i] = 1; } @@ -189,17 +198,17 @@ int main(int argc, char* argv[]) { if (this_module == "586") { if ( (i/NC) > 0 && (i/NC)<256 && (i%NC)> 768 && (i%NC)<1024 ) { - this_g2_default_pixels[i]=1; - this_g1_default_pixels[i]=1; - - } + this_g2_default_pixels[i]=1; + this_g1_default_pixels[i]=1; + + } } if (this_module == "454") { if ( (i/NC) > 0 && (i/NC)<256 && (i%NC)> 768 && (i%NC)<1024 ) { - this_g2_default_pixels[i]=1; - } + this_g2_default_pixels[i]=1; + } } diff --git a/Fluo_analysis_Ti_In.cpp b/Fluo_analysis_Ti_In.cpp new file mode 100644 index 0000000..6ef3dfe --- /dev/null +++ b/Fluo_analysis_Ti_In.cpp @@ -0,0 +1,1357 @@ +// file to calculate pedestal correction of fluo data +// make correction and save spectrum per pixel +// then fit fluo spectrum per pixel +// and save peak position and uncertainty +// changes by VH 210906: to eliminate hardcoded absolute paths, uses location of the analysis root files as additional input argument (accordingly changed in filename_creator.sh) + +#include "sls_detector_calibration/jungfrauCommonHeader.h" +#include "sls_detector_calibration/jungfrauCommonFunctions.h" + +#include "sls_detector_calibration/jungfrauFileSLSReceiver.C" +#include "sls_detector_calibration/jungfrauPixelMask.C" +#include "sls_detector_calibration/jungfrauPedestal.C" + +#include "sls_detector_calibration/energyCalibration.h" +#include "sls_detector_calibration/energyCalibration.cpp" + +#include "TGraph.h" +#include "TGraphErrors.h" +#include "TF1.h" +#include "TFile.h" +#include "TPaveStats.h" +#include "TLegend.h" +#include "TPaveText.h" + +#include + +int main(int argc, char* argv[]) { + + jungfrauStyle(); + gStyle->SetOptFit(11); + + /* + if (argc != 6) { + cout << "Correct usage:" << endl; + cout << "arg 1: specify module number" << endl; + cout << "arg 2: specify HG0 or G0" << endl; + cout << "arg 3: specify data location" << endl; + cout << "arg 4: specify pede file" << endl; + cout << "arg 5: specify data file" << endl; + cout << " " << endl; + exit(1); + } + */ //uncomment for SR + + if (argc != 9) { + cout << "Correct usage:" << endl; + cout << "arg 1: specify module number" << endl; + cout << "arg 2: specify HG0 or G0" << endl; + cout << "arg 3: pede starting index" << endl; + cout << "arg 4: target" << endl; + cout << "arg 5: specify data location folder" << endl; + cout << "arg 6: specify pede file prefix" << endl; + cout << "arg 7: specify data file prefix" << endl; + cout << "arg 8: specify location of analysis root files" << endl; + cout << " " << endl; + exit(1); + } //uncomment for VH 210906 + + string module_str = argv[1]; + cout << "The module number is" << module_str << endl; + string gain_str = argv[2]; + cout << "The gain is" << gain_str << endl; + + bool isJF11=false; + + string findex = argv[3]; + int index1 = atoi(argv[3]); + cout << "I'm after atoi" << endl; + cout << "Index1 value is" << findex << endl; + int indexfl = 0; + string target = argv[4]; + string data_loc = argv[5]; + string pede_file = argv[6]; + string data_file = argv[7]; + string anadata_loc = argv[8]; //uncomment for VH 210906 + cout << "I'm after declaration of strings" << endl; + int createHistoFile = 0; + + //char histoname[128]; + //char savename[128]; + char histoname[256]; // VH 210902 + char savename[256]; // VH 210902 + int filen = 22; + int gain_val[3]; + gain_val[0]=0; + gain_val[1]=1; + gain_val[2]=3; + + + + cout << "gain0=" << gain_val[0]<< endl; + cout << "gain1=" << gain_val[1]<< endl; +cout << "gain2=" << gain_val[2]<< endl; + + // create necessary directories with permissions drwxrwxr-x + // data/Mxxx + sprintf(savename,"data/M%s_%s", module_str.c_str(),target.c_str()); + mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + // plots/Mxxx + sprintf(savename,"plots/M%s_%s", module_str.c_str(),target.c_str()); + mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + // plots/Mxxx/CuFluo + sprintf(savename,"plots/M%s_%s/CuFluo", module_str.c_str(),target.c_str()); + mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + // plots/Mxxx/CuFluo/G0 + sprintf(savename,"plots/M%s_%s/CuFluo/G0", module_str.c_str(),target.c_str()); + mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + // plots/Mxxx/CuFluo/HG0 + sprintf(savename,"plots/M%s_%s/CuFluo/HG0", module_str.c_str(),target.c_str()); + mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + // /mnt/pcmoench_jungfrau_data/jungfrau_ana_sophie/Mxxx_CalibAna + //sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna", module_str.c_str()); //uncomment for SR + sprintf(savename,"%s", anadata_loc.c_str()); //uncomment for VH 210906 + mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + + cout << "I'm after creation directories" << endl; + + jungfrauPixelMask *pixelMaskObject = new jungfrauPixelMask(); + bool pixel_mask [NCH]; + + cout << "I'm after creation pixel mask" << endl; + + TCanvas *mapcanvas = new TCanvas("mapcanvas","",150,10,800,400); + mapcanvas->SetLeftMargin(0.1); + mapcanvas->SetRightMargin(0.13); + mapcanvas->SetTopMargin(0.08); + mapcanvas->SetBottomMargin(0.15); + + TCanvas* c1 = new TCanvas("c1",""); + + if (createHistoFile == 1) { + + jungfrauFileSLS *thisfile = new jungfrauFileSLS(); + + jungfrauPedestal *pedestalObject = new jungfrauPedestal(); + pedestalObject->pedestalSetNFrames(100); + static uint16_t pedestals16_G0_start[NCH]; + static double pedeRMS16_G0[NCH]; + + TH2F* pedestalsG0 = new TH2F("pedestalsG0","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* pedestalsG1 = new TH2F("pedestalsG1","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* pedestalsG2 = new TH2F("pedestalsG2","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + TH2F* pedeRMSG0 = new TH2F("pedeRMSG0","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + if (gain_str == "G0") { + cout<< "I'm in G0" << endl; + + indexfl=index1+3; + cout << "Index fluorescence" << indexfl << endl; + // calculate pixel mask + pixelMaskObject->initialisePixelMask(pixel_mask); + + for (int j=index1; jopen((char*)savename, 0); + + int nevents = 0; + while (thisfile->readNextFrame()) { + nevents++; + } + thisfile->rewind(); + cout << "read " << nevents << " events" << endl; + cout << "Loop index " << j << endl; + + if (nevents == 999 || nevents == 1000) { + for (int i = 0; i < 1000; i++) { + //cout << " number" << i << endl; + thisfile->readNextFrame(); + pixelMaskObject->maskIfGainNot(gain_val[j-index1], thisfile->getFrameDataHandle(), pixel_mask); + }thisfile->close(); + + } else { + cout << "Number of frames less than 999" << endl; + thisfile->close(); + exit(1); + } + } + } else { // HG0 case + indexfl=index1+1; + cout << "I'm in HG0" << endl; + cout << "Index fluorescence" << indexfl << endl; + sprintf(savename,"%s/%s_%s__d0_f0_%i.raw", data_loc.c_str(), pede_file.c_str(),target.c_str(),index1); //VH: note, this adds a double slash in the filepath + thisfile->open((char*)savename, 0); + + // calculate pixel mask + pixelMaskObject->initialisePixelMask(pixel_mask); + + int nevents = 0; + while (thisfile->readNextFrame()) { + nevents++; + } + thisfile->rewind(); + cout << "read " << nevents << " events" << endl; + + + if (nevents == 999 || nevents == 1000) { + for (int i = 0; i < 1000; i++) { + thisfile->readNextFrame(); + pixelMaskObject->maskIfGainNot(0, thisfile->getFrameDataHandle(), pixel_mask); + }thisfile->close(); + } else { + cout << "Number of frames less than 999" << endl; + thisfile->close(); + exit(1); + } + } + + thisfile->rewind(); + + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pixelmask_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + pixelMaskObject->plotPixelMask(pixel_mask,savename); + cout << "after chip mask, n masked pixels is " << pixelMaskObject->getNMasked(pixel_mask) << endl; + + // calculate pedestals + if (gain_str == "G0") { + sprintf(savename,"%s/%s_%s__d0_f0_%i.raw", data_loc.c_str(), pede_file.c_str(),target.c_str(),index1); //VH: note, this adds a double slash in the filepath + thisfile->open((char*)savename, 0); + + for (int i = 0; i < 1000; i++) { + thisfile->readNextFrame(); + pedestalObject->addFrameToPedestalCalculation(thisfile->getFrameDataHandle()); + } + + for (int i = 0; i < NCH; i++) { + if (pixel_mask[i] == true) { + pedestalsG0->Fill(i%NC,i/NC,pedestalObject->pedestalOfChannel(i)); + pedeRMSG0->Fill(i%NC,i/NC,pedestalObject->rmsOfChannel(i)); + } + } + + pedestalObject->pedestalClear(); + thisfile->close(); + + sprintf(savename,"%s/%s_%s__d0_f0_%i.raw", data_loc.c_str(), pede_file.c_str(),target.c_str(),index1+1); //VH: note, this adds a double slash in the filepath + thisfile->open((char*)savename, 0); + + for (int i = 0; i < 1000; i++) { + thisfile->readNextFrame(); + pedestalObject->addFrameToPedestalCalculation(thisfile->getFrameDataHandle()); + } + for (int i = 0; i < NCH; i++) { + if (pixel_mask[i] == true) { + pedestalsG1->Fill(i%NC,i/NC,pedestalObject->pedestalOfChannel(i)); + } + } + pedestalObject->pedestalClear(); + thisfile->close(); + + sprintf(savename,"%s/%s_%s__d0_f0_%i.raw", data_loc.c_str(), pede_file.c_str(),target.c_str(),index1+2); //VH: note, this adds a double slash in the filepath + thisfile->open((char*)savename, 0); + + for (int i = 0; i < 1000; i++) { + thisfile->readNextFrame(); + pedestalObject->addFrameToPedestalCalculation(thisfile->getFrameDataHandle()); + } + for (int i = 0; i < NCH; i++) { + if (pixel_mask[i] == true) { + pedestalsG2->Fill(i%NC,i/NC,pedestalObject->pedestalOfChannel(i)); + } + } + pedestalObject->pedestalClear(); + thisfile->close(); + } else { + + sprintf(savename,"%s/%s_%s__d0_f0_%i.raw", data_loc.c_str(), pede_file.c_str(),target.c_str(),index1); //VH: note, this adds a double slash in the filepath + thisfile->open((char*)savename, 0); + + for (int i = 0; i < 1000; i++) { + thisfile->readNextFrame(); + pedestalObject->addFrameToPedestalCalculation(thisfile->getFrameDataHandle()); + + } + + for (int i = 0; i < NCH; i++) { + if (pixel_mask[i] == true) { + pedestalsG0->Fill(i%NC,i/NC,pedestalObject->pedestalOfChannel(i)); + pedeRMSG0->Fill(i%NC,i/NC,pedestalObject->rmsOfChannel(i)); + } + } + pedestalObject->pedestalClear(); + thisfile->close(); + } + + // G0 calculation for pede tracking + + sprintf(savename,"%s/%s_%s__d0_f0_%i.raw", data_loc.c_str(), pede_file.c_str(),target.c_str(),index1); //VH: note, this adds a double slash in the filepath + thisfile->open((char*)savename, 0); + + while (thisfile->readNextFrame()) { + pedestalObject->addFrameToPedestalCalculation(thisfile->getFrameDataHandle()); + } + for (int i = 0; i < NCH; i++) { + if (pixel_mask[i] == true) { + pedestalsG0->Fill(i%NC,i/NC,pedestalObject->pedestalOfChannel(i)); + pedeRMSG0->Fill(i%NC,i/NC,pedestalObject->rmsOfChannel(i)); + } + } + pedestalObject->pedestalData((uint16_t*)(&pedestals16_G0_start)); + pedestalObject->pedestalRMSData(pedeRMS16_G0); + pedestalObject->pedestalResetUpdates(); + + thisfile->close(); + + + mapcanvas->cd(); + + pedestalsG0->GetXaxis()->SetTitle("Column"); + pedestalsG0->GetYaxis()->SetTitle("Row"); + pedestalsG0->GetYaxis()->SetTitleOffset(0.7); + pedestalsG0->Draw("colz"); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pedeG0_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + pedestalsG1->GetXaxis()->SetTitle("Column"); + pedestalsG1->GetYaxis()->SetTitle("Row"); + pedestalsG1->GetYaxis()->SetTitleOffset(0.7); + pedestalsG1->Draw("colz"); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pedeG1_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + pedestalsG2->GetXaxis()->SetTitle("Column"); + pedestalsG2->GetYaxis()->SetTitle("Row"); + pedestalsG2->GetYaxis()->SetTitleOffset(0.7); + pedestalsG2->Draw("colz"); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pedeG2_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + pedeRMSG0->GetXaxis()->SetTitle("Column"); + pedeRMSG0->GetYaxis()->SetTitle("Row"); + pedeRMSG0->GetYaxis()->SetTitleOffset(0.7); + pedeRMSG0->GetZaxis()->SetRangeUser(0,30); + pedeRMSG0->Draw("colz"); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pedeRMSG0_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + int adc2d_nbin= 1700; + int adc2d_maxbin=3400; + if (isJF11) adc2d_nbin= 1600; + + + TH2I* adc2d_1 = new TH2I("adc2d_1","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*0-0.5),(65536*1-0.5)); + TH2I* adc2d_2 = new TH2I("adc2d_2","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*1-0.5),(65536*2-0.5)); + TH2I* adc2d_3 = new TH2I("adc2d_3","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*2-0.5),(65536*3-0.5)); + TH2I* adc2d_4 = new TH2I("adc2d_4","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*3-0.5),(65536*4-0.5)); + TH2I* adc2d_5 = new TH2I("adc2d_5","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*4-0.5),(65536*5-0.5)); + TH2I* adc2d_6 = new TH2I("adc2d_6","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*5-0.5),(65536*6-0.5)); + TH2I* adc2d_7 = new TH2I("adc2d_7","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*6-0.5),(65536*7-0.5)); + TH2I* adc2d_8 = new TH2I("adc2d_8","",adc2d_nbin,-200-0.5,adc2d_maxbin-200-0.5,65536,(65536*7-0.5),(65536*8-0.5)); + + TH1D* adcpc_spec = new TH1D("adcpc_spec","",300,0,3000); + + TH2F* pede_updates = new TH2F("pede_updates","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* pede_diff = new TH2F("pede_diff","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + for (int filei = 0; filei < filen; filei++) { + + // open data file //file name must include d0_f + sprintf(savename,"%s/%s%i_%i.raw", data_loc.c_str(), data_file.c_str(), filei, indexfl); //VH: note, this adds a double slash in the filepath + thisfile->open((char*)savename, filei); + + while (thisfile->readNextFrame()) { + + uint16_t* imagedptr = thisfile->getFrameDataHandle(); + + pedestalObject->addG0FrameToPedestalCalculationWThreshold(imagedptr, pedestalObject, pedeRMS16_G0); + + for (int i = 0; i < NCH; i++) { + + uint16_t gain = (imagedptr[i]&0xc000) >> 14; + + if (gain == 0) { + + int adcpc = (imagedptr[i]&0x3fff) - pedestalObject->pedestalOfChannel(i); + adcpc_spec->Fill(adcpc); + + if (i < (65536*1)) { + adc2d_1->Fill(adcpc,i); + } else if (i < (65536*2)) { + adc2d_2->Fill(adcpc,i); + } else if (i < (65536*3)) { + adc2d_3->Fill(adcpc,i); + } else if (i < (65536*4)) { + adc2d_4->Fill(adcpc,i); + } else if (i < (65536*5)) { + adc2d_5->Fill(adcpc,i); + } else if (i < (65536*6)) { + adc2d_6->Fill(adcpc,i); + } else if (i < (65536*7)) { + adc2d_7->Fill(adcpc,i); + } else if (i < (65536*8)) { + adc2d_8->Fill(adcpc,i); + } + } + } + } + + thisfile->close(); + + adcpc_spec->GetXaxis()->SetTitle("Pedestal corrected ADC [ADU]"); + adcpc_spec->Draw(); + mapcanvas->SetLogy(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/adcpc_spec_file%d_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), filei, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + mapcanvas->SetLogy(0); + adcpc_spec->Reset(); + + pede_updates->Reset(); + pede_diff->Reset(); + + for (int i = 0; i < NCH; i++) { + pede_updates->Fill(i%NC,i/NC,pedestalObject->pedestalUpdates(i)); + pede_diff->Fill(i%NC,i/NC,pedestalObject->pedestalOfChannel(i) - pedestals16_G0_start[i]); + pedestals16_G0_start[i] = pedestalObject->pedestalOfChannel(i); + } + + pede_updates->GetXaxis()->SetTitle("Column"); + pede_updates->GetYaxis()->SetTitle("Row"); + pede_updates->GetYaxis()->SetTitleOffset(0.7); + pede_updates->GetZaxis()->SetRangeUser(0,10000); + pede_updates->Draw("colz"); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pede_updates_file%d_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), filei, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + pede_diff->GetXaxis()->SetTitle("Column"); + pede_diff->GetYaxis()->SetTitle("Row"); + pede_diff->GetYaxis()->SetTitleOffset(0.7); + pede_diff->GetZaxis()->SetRangeUser(-40,40); + pede_diff->Draw("colz"); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pede_diff_file%d_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), filei, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + pedestalObject->pedestalResetUpdates(); + + } // end of file loop + + //sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna/CuFluo_%s_file0to%d.root", module_str.c_str(), gain_str.c_str(), filen-1); + sprintf(savename,"%s/CuFluo_%s_file0to%d.root", anadata_loc.c_str(), gain_str.c_str(), filen-1); //uncomment for VH 210906 + TFile* saved_file = new TFile((const char *)(savename),"RECREATE"); + adc2d_1->Write(); + adc2d_2->Write(); + adc2d_3->Write(); + adc2d_4->Write(); + adc2d_5->Write(); + adc2d_6->Write(); + adc2d_7->Write(); + adc2d_8->Write(); + saved_file->Close(); + + } + + c1->cd(); + + //sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna/CuFluo_%s_file0to%d.root", module_str.c_str(), gain_str.c_str(), filen-1); + sprintf(savename,"%s/CuFluo_%s_file0to%d.root", anadata_loc.c_str(), gain_str.c_str(), filen-1); //uncomment for VH 210906 + TFile* comb_file = new TFile((const char *)(savename),"READ"); + + pixelMaskObject->initialisePixelMask(pixel_mask); + + int low_ADU_peak = 0; + int high_ADU_peak = 0; + + if (target=="Ti") { + + if (gain_str == "HG0") { + low_ADU_peak = 350; + high_ADU_peak = 600; + } else if (gain_str == "G0") { + low_ADU_peak = 180; + high_ADU_peak = 350; + } + + } + + if (target=="Fe") { + + if (gain_str == "HG0") { + low_ADU_peak = 500; + high_ADU_peak = 800; + } else if (gain_str == "G0") { + low_ADU_peak = 250; + high_ADU_peak = 400; + } + } + + if (target=="Cu") { + + if (gain_str == "HG0") { + low_ADU_peak = 700; + high_ADU_peak = 1000; + } else if (gain_str == "G0") { + low_ADU_peak = 250; + high_ADU_peak = 400; + } + + } + + if (target=="Se") { + + if (gain_str == "HG0") { + low_ADU_peak = 1050; + high_ADU_peak = 1350; + } else if (gain_str == "G0") { + low_ADU_peak = 250; + high_ADU_peak = 400; + } + } + + + if (target=="Mo") { + if (gain_str == "HG0") { + low_ADU_peak = 1650; + high_ADU_peak = 2150; + } else if (gain_str == "G0") { + low_ADU_peak = 250; + high_ADU_peak = 400; + } + } + + + + if (target=="Ag") { + if (gain_str == "HG0") { + low_ADU_peak = 2100; + high_ADU_peak = 2650; + } else if (gain_str == "G0") { + low_ADU_peak = 250; + high_ADU_peak = 400; + } + } + + if ((target=="In") || (target=="in")) { + if (gain_str == "HG0") { + low_ADU_peak = 2300; + high_ADU_peak = 2800; + } else if (gain_str == "G0") { + low_ADU_peak = 250; + high_ADU_peak = 400; + } + } + + + TH1F* fit_par3 = new TH1F("fit_par3","",100,0,50); + TH1F* fit_par4 = new TH1F("fit_par4","",100,0,500); + TH1F* fit_par5 = new TH1F("fit_par5","",100,0,0.5); + TH1F* fit_par6 = new TH1F("fit_par6","",100,1.05,1.25); + TH1F* fit_par7 = new TH1F("fit_par7","",100,0,0.4); + + TH2F* fit_par3_2d = new TH2F("fit_par3_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* fit_par4_2d = new TH2F("fit_par4_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* fit_par5_2d = new TH2F("fit_par5_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* fit_par6_2d = new TH2F("fit_par6_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* fit_par7_2d = new TH2F("fit_par7_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + TH1F* peak_fit_pos = new TH1F("peak_fit_pos","",100,low_ADU_peak,high_ADU_peak); + TH1F* peak_fit_poserr = new TH1F("peak_fit_poserr","",100,0,2); + TH2F* peak_fit_pos_2d = new TH2F("peak_fit_pos_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* peak_fit_poserr_2d = new TH2F("peak_fit_poserr_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + TH1F* noise_fit_pos = new TH1F("noise_fit_pos","",100,-10,10); + TH1F* noise_fit_poserr = new TH1F("noise_fit_poserr","",100,0,0.1); + TH2F* noise_fit_pos_2d = new TH2F("noise_fit_pos_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* noise_fit_poserr_2d = new TH2F("noise_fit_poserr_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + TH1F* gain_fit = new TH1F("gain_fit","",100,low_ADU_peak,high_ADU_peak); + TH1F* gain_fiterr = new TH1F("gain_fiterr","",100,0,2); + TH2F* gain_fit_2d = new TH2F("gain_fit_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* gain_fiterr_2d = new TH2F("gain_fiterr_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + TH1F* gain_fit_isEdge = new TH1F("gain_fit_isEdge","",100,low_ADU_peak,high_ADU_peak); + TH1F* gain_fit_isInnerEdge = new TH1F("gain_fit_isInnerEdge","",100,low_ADU_peak,high_ADU_peak); + TH1F* gain_fit_isDouble = new TH1F("gain_fit_isDouble","",100,low_ADU_peak,high_ADU_peak); + TH1F* gain_fit_isNextToDouble = new TH1F("gain_fit_isNextToDouble","",100,low_ADU_peak,high_ADU_peak); + TH1F* gain_fit_isQuad = new TH1F("gain_fit_isQuad","",100,low_ADU_peak,high_ADU_peak); + TH1F* gain_fit_isBulk = new TH1F("gain_fit_isBulk","",100,low_ADU_peak,high_ADU_peak); + + TH2F* gain_ADUper1keV_2d = new TH2F("gain_ADUper1keV_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + TH2F* gainerr_ADUper1keV_2d = new TH2F("gainerr_ADUper1keV_2d","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + + int low_bin_noise = 100; + int high_bin_noise = 350; + int low_bin_peak = 0; + int high_bin_peak = 0; + int nrebin = 4; + + // Do the conditionals for all targets + + if (target=="Ti") { + + if (gain_str == "HG0") { + low_bin_peak = 450; + high_bin_peak = 750; + nrebin = 15; + } else if (gain_str == "G0") { + low_bin_peak = 250; + high_bin_peak = 400; + } + + } + + if (target=="Fe") { + + if (gain_str == "HG0") { + low_bin_peak = 558; + high_bin_peak = 955; + nrebin = 4; + } else if (gain_str == "G0") { + low_bin_peak = 250; + high_bin_peak = 400; + } + + } + + if (target=="Cu") { + + if (gain_str == "HG0") { + low_bin_peak = 701; + high_bin_peak = 1200; + nrebin = 4; + } else if (gain_str == "G0") { + low_bin_peak = 250; + high_bin_peak = 400; + } + + } + + if (target=="Se") { + + if (gain_str == "HG0") { + low_bin_peak = 900; + high_bin_peak = 1500; + nrebin = 4; + } else if (gain_str == "G0") { + low_bin_peak = 250; + high_bin_peak = 400; + } + + } + +if (target=="Mo") { + + if (gain_str == "HG0") { + low_bin_peak = 1400; + high_bin_peak = 2400; + nrebin = 8; + } else if (gain_str == "G0") { + low_bin_peak = 250; + high_bin_peak = 400; + } + + } + +if (target=="Ag") { + + if (gain_str == "HG0") { + low_bin_peak = 1900; + high_bin_peak = 2900; + nrebin = 15; + } else if (gain_str == "G0") { + low_bin_peak = 250; + high_bin_peak = 400; + } + + } + +if ((target=="In") || (target=="in")) { + + if (gain_str == "HG0") { + low_bin_peak = 2000; + high_bin_peak = 3000; + nrebin = 15; + } else if (gain_str == "G0") { + low_bin_peak = 250; + high_bin_peak = 400; + } + + } + + + for (int j=1; j<9; j++) { + cout << "slice " << j << endl; + sprintf(histoname,"adc2d_%i",j); + TH2I* adc2d_j = (TH2I*)(comb_file->Get((const char *)(histoname))); + cout << adc2d_j->GetEntries() << endl; + adc2d_j->Draw("colz"); + c1->Update(); + + for (int i=(65536*(j-1)); i<(65536*(j)); i++) { + + if (i%10000==0){cout << "another 10k" << endl;} + + TH1D* proj = adc2d_j->ProjectionX("bin1",i-(65536*(j-1))+1,i-(65536*(j-1))+1); + + if (proj->Integral(low_bin_noise,high_bin_noise)!=0 && proj->Integral(low_bin_peak,high_bin_peak)!=0) { + // noise + TH1D *proj_noise = dynamic_cast(proj->Rebin(nrebin,"proj_noise")); + proj_noise->SetStats(kTRUE); + proj_noise->GetXaxis()->SetRangeUser(proj->GetBinLowEdge(low_bin_noise),proj->GetBinLowEdge(high_bin_noise+1)); + proj_noise->Fit("gaus","Q"); + TF1 *fit = proj_noise->GetFunction("gaus"); + + noise_fit_pos->Fill(fit->GetParameter(1)); + noise_fit_pos_2d->Fill(i%NC,i/NC,fit->GetParameter(1)); + noise_fit_poserr->Fill(fit->GetParError(1)); + noise_fit_poserr_2d->Fill(i%NC,i/NC,fit->GetParError(1)); + + // peak + TH1D *proj_peak = dynamic_cast(proj->Rebin(nrebin,"proj_peak")); + proj_peak->SetStats(kTRUE); + proj_peak->GetXaxis()->SetRangeUser(proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + + Double_t mypar[8]; + mypar[0] = 0.0; + mypar[1] = 0.0; + + + if (target=="Ti") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 24.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.12; + } + + // Kb/Ka position ratio + mypar[6] = 1.0; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.2; + } + + } + + + if (target=="Fe") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 27.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.2; + } + + // Kb/Ka position ratio + mypar[6] = 1.11; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.12; + } + + } + + if (target=="Cu") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.11; // mypar[6] = 1.12; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + + if (target=="Se") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.11; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + if (target=="Mo") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.12; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + if (target=="Ag") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.10; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + if ((target=="In") || (target=="in")) { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.13; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + Double_t emypar[8]; + energyCalibration *thiscalibration = new energyCalibration(); + thiscalibration->setScanSign(1); + thiscalibration->setStartParametersKb(mypar); + thiscalibration->fixParameter(0,0.); // no background + thiscalibration->fixParameter(1,0.); + TF1* fittedfun = thiscalibration->fitSpectrumKb(proj_peak,mypar,emypar); + + fit_par3->Fill(mypar[3]); + fit_par4->Fill(mypar[4]); + fit_par5->Fill(mypar[5]); + fit_par6->Fill(mypar[6]); + fit_par7->Fill(mypar[7]); + + fit_par3_2d->Fill(i%NC,i/NC,mypar[3]); + fit_par4_2d->Fill(i%NC,i/NC,mypar[4]); + fit_par5_2d->Fill(i%NC,i/NC,mypar[5]); + fit_par6_2d->Fill(i%NC,i/NC,mypar[6]); + fit_par7_2d->Fill(i%NC,i/NC,mypar[7]); + + peak_fit_pos->Fill(mypar[2]); + peak_fit_poserr->Fill(emypar[2]); + peak_fit_pos_2d->Fill(i%NC,i/NC,mypar[2]); + peak_fit_poserr_2d->Fill(i%NC,i/NC,emypar[2]); + + if ((i >= 58000 && i < 58000+10) || // bulk + (i >= 10 && i < 10+10) || // edge + (i >= 1024+10 && i < 1024+10+10) || // inner edge + (i >= (256*1024)+10 && i < (256*1024)+10+10) || // double + (i >= (257*1024)+10 && i < (257*1024)+10+10) || // next to double + (i == (255*1024)+255) // quad + ) { + + string pixel_type = "x"; + if (i >= 58000 && i < 58000+10) { + pixel_type = "b"; + } else if (i >= 10 && i < 10+10) { + pixel_type = "e"; + } else if (i >= 1024+10 && i < 1024+10+10) { + pixel_type = "ie"; + } else if (i >= (256*1024)+10 && i < (256*1024)+10+10) { + pixel_type = "d"; + } else if (i >= (257*1024)+10 && i < (257*1024)+10+10) { + pixel_type = "ntd"; + } else if (i == (255*1024)+255) { + pixel_type = "q"; + } + + proj_noise->Draw(); + c1->Update(); + proj_noise->GetXaxis()->SetTitle("Pedestal corrected ADC [ADU]"); + proj_noise->GetXaxis()->SetRangeUser(-100,150); + fit->SetParNames("N_{#gamma}", "Peak pos", "Noise RMS"); + TPaveStats *st0 = (TPaveStats*)proj_noise->FindObject("stats"); + st0->SetX1NDC(0.53); + st0->SetX2NDC(0.94); + st0->SetY1NDC(0.75); + st0->SetY2NDC(0.94); + st0->SetBorderSize(0); + st0->SetTextSize(0.04); + sprintf(savename,"plots/M%s/CuFluo/%s/noise_%s_%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), pixel_type.c_str(), i, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + TF1 *gaus_Ka = new TF1("gaus_Ka","gaus",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + gaus_Ka->SetParameters(mypar[4],mypar[2],mypar[3]); + gaus_Ka->SetLineColor(kBlue); + + TF1 *erfc_Ka = new TF1("erfc_Ka","[0]/2.*(TMath::Erfc(([1]*(x-[2])/[3])/(TMath::Sqrt(2.))))",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + erfc_Ka->SetParameters(mypar[4]*mypar[5], 1, mypar[2], mypar[3]); + erfc_Ka->SetLineColor(kOrange); + + TF1 *gaus_Kb = new TF1("gaus_Kb","gaus",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + gaus_Kb->SetParameters(mypar[4]*mypar[7],mypar[6]*mypar[2],mypar[3]); + gaus_Kb->SetLineColor(kGreen+2); + + TF1 *erfc_Kb = new TF1("erfc_Kb","[0]/2.*(TMath::Erfc(([1]*(x-[2])/[3])/(TMath::Sqrt(2.))))",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + erfc_Kb->SetParameters(mypar[4]*mypar[7]*mypar[5], 1, mypar[6]*mypar[2], mypar[3]); + erfc_Kb->SetLineColor(kOrange+7); + + proj_peak->Draw(); + erfc_Kb->Draw("same"); + erfc_Ka->Draw("same"); + gaus_Kb->Draw("same"); + gaus_Ka->Draw("same"); + fittedfun->Draw("same"); + c1->Update(); + proj_peak->GetXaxis()->SetTitle("Pedestal corrected ADC [ADU]"); + fittedfun->SetParNames("Bkg height", "Bkg grad", "K_{#alpha} pos", "Noise RMS", "K_{#alpha} height", "CS", "K_{#beta}/K_{#alpha} pos", "K_{#beta} frac"); + TPaveStats *st = (TPaveStats*)proj_peak->FindObject("stats"); + st->SetX1NDC(0.22); + st->SetX2NDC(0.62); + st->SetY1NDC(0.7); + st->SetY2NDC(0.94); + st->SetBorderSize(0); + st->SetTextSize(0.04); + sprintf(savename,"plots/M%s/CuFluo/%s/peak_%s_%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), pixel_type.c_str(), i, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + } + + // gain + gain_fit->Fill(mypar[2] - fit->GetParameter(1)); + gain_fiterr->Fill(sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2))); + gain_fit_2d->Fill(i%NC,i/NC,mypar[2] - fit->GetParameter(1)); + gain_fiterr_2d->Fill(i%NC,i/NC,sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2))); + gain_ADUper1keV_2d->Fill(i%NC,i/NC,(mypar[2] - fit->GetParameter(1))); /// 8.0); + gainerr_ADUper1keV_2d->Fill(i%NC,i/NC,sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2))); /// 8.0); + + if (isEdge(i)) { + gain_fit_isEdge->Fill(mypar[2] - fit->GetParameter(1)); + } + if (isInnerEdge(i)) { + gain_fit_isInnerEdge->Fill(mypar[2] - fit->GetParameter(1)); + } + if (isDouble(i)) { + gain_fit_isDouble->Fill(mypar[2] - fit->GetParameter(1)); + } + if (isNextToDouble(i)) { + gain_fit_isNextToDouble->Fill(mypar[2] - fit->GetParameter(1)); + } + if (isQuad(i)) { + gain_fit_isQuad->Fill(mypar[2] - fit->GetParameter(1)); + } + if (isBulk(i)) { + gain_fit_isBulk->Fill(mypar[2] - fit->GetParameter(1)); + } + + delete thiscalibration; + delete proj_noise; + delete proj_peak; + delete proj; + + } else { + pixel_mask[i] = false; + } + } // close loop pixel + } // close loop slices + + sprintf(savename,"plots/M%s_%s/CuFluo/%s/pixelmask_afterfit_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + pixelMaskObject->plotPixelMask(pixel_mask,savename); + + TPaveText *pave = new TPaveText(0.86,0.95,0.91,0.98,"blNDC"); + pave->SetBorderSize(0); + pave->SetFillStyle(0); + pave->SetTextSize(0.06); + pave->SetTextAlign(32); + + mapcanvas->cd(); + + fit_par3_2d->GetXaxis()->SetTitle("Column"); + fit_par3_2d->GetYaxis()->SetTitle("Row"); + fit_par3_2d->GetYaxis()->SetTitleOffset(0.7); + fit_par3_2d->Draw("colz"); + fit_par3_2d->GetZaxis()->SetRangeUser(0,50); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par3_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par4_2d->GetXaxis()->SetTitle("Column"); + fit_par4_2d->GetYaxis()->SetTitle("Row"); + fit_par4_2d->GetYaxis()->SetTitleOffset(0.7); + fit_par4_2d->Draw("colz"); + fit_par4_2d->GetZaxis()->SetRangeUser(0,500); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par4_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par5_2d->GetXaxis()->SetTitle("Column"); + fit_par5_2d->GetYaxis()->SetTitle("Row"); + fit_par5_2d->GetYaxis()->SetTitleOffset(0.7); + fit_par5_2d->Draw("colz"); + fit_par5_2d->GetZaxis()->SetRangeUser(0,0.5); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par5_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par6_2d->GetXaxis()->SetTitle("Column"); + fit_par6_2d->GetYaxis()->SetTitle("Row"); + fit_par6_2d->GetYaxis()->SetTitleOffset(0.7); + fit_par6_2d->Draw("colz"); + fit_par6_2d->GetZaxis()->SetRangeUser(1.0,1.25); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par6_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par7_2d->GetXaxis()->SetTitle("Column"); + fit_par7_2d->GetYaxis()->SetTitle("Row"); + fit_par7_2d->GetYaxis()->SetTitleOffset(0.7); + fit_par7_2d->Draw("colz"); + fit_par7_2d->GetZaxis()->SetRangeUser(0.,0.4); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par7_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + peak_fit_pos_2d->GetXaxis()->SetTitle("Column"); + peak_fit_pos_2d->GetYaxis()->SetTitle("Row"); + peak_fit_pos_2d->GetYaxis()->SetTitleOffset(0.7); + peak_fit_pos_2d->Draw("colz"); + peak_fit_pos_2d->GetZaxis()->SetRangeUser(low_ADU_peak,high_ADU_peak); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/peak_fit_pos_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + peak_fit_poserr_2d->GetXaxis()->SetTitle("Column"); + peak_fit_poserr_2d->GetYaxis()->SetTitle("Row"); + peak_fit_poserr_2d->GetYaxis()->SetTitleOffset(0.7); + peak_fit_poserr_2d->Draw("colz"); + peak_fit_poserr_2d->GetZaxis()->SetRangeUser(0,2); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/peak_fit_poserr_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + noise_fit_pos_2d->GetXaxis()->SetTitle("Column"); + noise_fit_pos_2d->GetYaxis()->SetTitle("Row"); + noise_fit_pos_2d->GetYaxis()->SetTitleOffset(0.7); + noise_fit_pos_2d->Draw("colz"); + noise_fit_pos_2d->GetZaxis()->SetRangeUser(-5,5); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/noise_fit_pos_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + noise_fit_poserr_2d->GetXaxis()->SetTitle("Column"); + noise_fit_poserr_2d->GetYaxis()->SetTitle("Row"); + noise_fit_poserr_2d->GetYaxis()->SetTitleOffset(0.7); + noise_fit_poserr_2d->Draw("colz"); + if (gain_str == "HG0") { + noise_fit_poserr_2d->GetZaxis()->SetRangeUser(0,0.1); + } else if (gain_str == "G0") { + noise_fit_poserr_2d->GetZaxis()->SetRangeUser(0,0.05); + } + sprintf(savename,"plots/M%s_%s/CuFluo/%s/noise_fit_poserr_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + gain_fit_2d->GetXaxis()->SetTitle("Column"); + gain_fit_2d->GetYaxis()->SetTitle("Row"); + gain_fit_2d->GetYaxis()->SetTitleOffset(0.7); + gain_fit_2d->Draw("colz"); + sprintf(savename,"%s [ADU/8 keV]", gain_str.c_str()); + pave->AddText((const char *)(savename)); + pave->Draw(); + gain_fit_2d->GetZaxis()->SetRangeUser(low_ADU_peak,high_ADU_peak); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gain_fit_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + gain_fiterr_2d->GetXaxis()->SetTitle("Column"); + gain_fiterr_2d->GetYaxis()->SetTitle("Row"); + gain_fiterr_2d->GetYaxis()->SetTitleOffset(0.7); + gain_fiterr_2d->Draw("colz"); + gain_fiterr_2d->GetZaxis()->SetRangeUser(0,2); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gain_fiterr_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + gain_ADUper1keV_2d->GetXaxis()->SetTitle("Column"); + gain_ADUper1keV_2d->GetYaxis()->SetTitle("Row"); + gain_ADUper1keV_2d->GetYaxis()->SetTitleOffset(0.7); + gain_ADUper1keV_2d->Draw("colz"); + if (gain_str == "HG0") { + gain_ADUper1keV_2d->GetZaxis()->SetRangeUser(80,120); + } else if (gain_str == "G0") { + gain_ADUper1keV_2d->GetZaxis()->SetRangeUser(35,50); + } + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gain_ADUper1keV_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + gainerr_ADUper1keV_2d->GetXaxis()->SetTitle("Column"); + gainerr_ADUper1keV_2d->GetYaxis()->SetTitle("Row"); + gainerr_ADUper1keV_2d->GetYaxis()->SetTitleOffset(0.7); + gainerr_ADUper1keV_2d->Draw("colz"); + if (gain_str == "HG0") { + gainerr_ADUper1keV_2d->GetZaxis()->SetRangeUser(0,0.5); + } else if (gain_str == "G0") { + gainerr_ADUper1keV_2d->GetZaxis()->SetRangeUser(0,0.25); + } + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gainerr_ADUper1keV_2d_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + c1->cd(); + + fit_par3->GetXaxis()->SetTitle("Fit par 3"); + fit_par3->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par3_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + fit_par4->GetXaxis()->SetTitle("Fit par 4"); + fit_par4->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par4_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + fit_par5->GetXaxis()->SetTitle("Fit par 5"); + fit_par5->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par5_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + fit_par6->GetXaxis()->SetTitle("Fit par 6"); + fit_par6->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par6_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + fit_par7->GetXaxis()->SetTitle("Fit par 7"); + fit_par7->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/fit_par7_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + peak_fit_pos->GetXaxis()->SetTitle("Peak position [ADU]"); + peak_fit_pos->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/peak_fit_pos_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + peak_fit_poserr->GetXaxis()->SetTitle("Peak position uncert [ADU]"); + peak_fit_poserr->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/peak_fit_poserr_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + noise_fit_pos->GetXaxis()->SetTitle("Noise position [ADU]"); + noise_fit_pos->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/noise_fit_pos_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + noise_fit_poserr->GetXaxis()->SetTitle("Noise position uncert [ADU]"); + noise_fit_poserr->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/noise_fit_poserr_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + sprintf(savename,"Gain %s [ADU / 8 keV]", gain_str.c_str()); + gain_fit->GetXaxis()->SetTitle((const char *)(savename)); + gain_fit->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gain_fit_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + gain_fit->GetXaxis()->SetRangeUser(low_ADU_peak+30, high_ADU_peak); + gain_fit->Fit("gaus"); + gain_fit->Draw(); + c1->Update(); + TPaveText *pave2 = new TPaveText(0.6,0.8,0.94,0.94,"blNDC"); + pave2->SetBorderSize(0); + pave2->SetFillStyle(0); + pave2->SetTextSize(0.04); + pave2->SetTextAlign(32); + TF1* gain_fit_gaus = gain_fit->GetFunction("gaus"); + sprintf(savename,"Mean %0.2f #pm %0.2f", gain_fit_gaus->GetParameter(1), gain_fit_gaus->GetParError(1)); + pave2->AddText((const char *)(savename)); + sprintf(savename,"Sigma %0.2f #pm %0.2f", gain_fit_gaus->GetParameter(2), gain_fit_gaus->GetParError(2)); + pave2->AddText((const char *)(savename)); + pave2->Draw(); + gain_fit->SetStats(kFALSE); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gain_fit_fit_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + gain_fiterr->GetXaxis()->SetTitle("Gain uncert [ADU / 8 keV]"); + gain_fiterr->Draw(); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gain_fiterr_%s_M%s.png",module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + gain_fit_isEdge->SetLineColor(kBlue); + gain_fit_isInnerEdge->SetLineColor(kCyan); + gain_fit_isDouble->SetLineColor(kGreen+2); + gain_fit_isNextToDouble->SetLineColor(kRed); + gain_fit_isQuad->SetLineColor(kOrange); + + gain_fit_isEdge->Scale(1./gain_fit_isEdge->GetEntries()); + gain_fit_isInnerEdge->Scale(1./gain_fit_isInnerEdge->GetEntries()); + gain_fit_isDouble->Scale(1./gain_fit_isDouble->GetEntries()); + gain_fit_isNextToDouble->Scale(1./gain_fit_isNextToDouble->GetEntries()); + gain_fit_isQuad->Scale(1./gain_fit_isQuad->GetEntries()); + gain_fit_isBulk->Scale(1./gain_fit_isBulk->GetEntries()); + + TLegend *leg = new TLegend(0.62,0.6,0.93,0.93); + leg->AddEntry(gain_fit_isBulk, "Normal", "l"); + leg->AddEntry(gain_fit_isDouble, "Double", "l"); + leg->AddEntry(gain_fit_isNextToDouble, "Next to D", "l"); + leg->AddEntry(gain_fit_isEdge, "Edge", "l"); + leg->AddEntry(gain_fit_isInnerEdge, "Inner E", "l"); + + sprintf(savename,"Gain %s [ADU / 8 keV]", gain_str.c_str()); + gain_fit_isDouble->GetXaxis()->SetTitle((const char *)(savename)); + gain_fit_isDouble->GetYaxis()->SetTitle("Normalised"); + gain_fit_isDouble->GetYaxis()->SetTitleOffset(1.3); + gain_fit_isDouble->SetMinimum(0.0); + gain_fit_isDouble->SetMaximum(0.16); + gain_fit_isDouble->Draw(); + gain_fit_isEdge->Draw("same"); + gain_fit_isInnerEdge->Draw("same"); + gain_fit_isNextToDouble->Draw("same"); + gain_fit_isBulk->Draw("same"); + leg->Draw("same"); + sprintf(savename,"plots/M%s_%s/CuFluo/%s/gain_fit_perType_%s_M%s.png", module_str.c_str(), target.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); + + sprintf(savename,"data/M%s_%s/CuFluo_gain_%s_M%s.root", module_str.c_str(), target.c_str(), gain_str.c_str(), module_str.c_str()); + TFile* saved_file = new TFile((const char *)(savename),"RECREATE"); + gain_ADUper1keV_2d->Write(); + gainerr_ADUper1keV_2d->Write(); + saved_file->Close(); + +} diff --git a/Fluo_exposure_Ti_In.sh b/Fluo_exposure_Ti_In.sh new file mode 100644 index 0000000..3059996 --- /dev/null +++ b/Fluo_exposure_Ti_In.sh @@ -0,0 +1,166 @@ +#!/bin/bash + +# to run do: bash CuFluo_exposure.sh + +# prerequisites: +# - the hostname is set +# - export PATH=/afs/psi.ch/project/sls_det_software/latest_slsDetectorPackage/build/bin:$PATH +# - export LD_LIBRARY_PATH=/afs/psi.ch/project/sls_det_software/latest_slsDetectorPackage/build/bin:$LD_LIBRARY_PATH +# - detector is on +# - source filename_creator.sh # +# - source pccalib.sh [pc] (mpc2012/pc-jungfrau-test) +# - xray tube is on and ramped for 40 kV, 60 mA, set to Cu + +shutter=1 # for big X-ray box +# shutter=3 # for small X-ray box + + +sls_detector_put stop #just in case + +sls_detector_put powerchip 1 + +# JF1.2 to fix saturation issue in HG0 +# sls_detector_put defaultdac vref_comp 420 highgain0 +# sls_detector_put setbit 0x58 18 +# End JF1.2 + +sls_detector_put period 0.002 +sls_detector_put exptime 0.000010 +sls_detector_put highvoltage 200 #200 + +# configure for receiver on mpc2012/pc-jungfrau-test/mpc2198/mpc3282 +# source pccalib.sh [pc] (mpc2012/pc-jungfrau-test/mpc2198/mpc3282) + +sls_detector_put udp_dstport 32410 +sls_detector_put udp_dstip $DSTIP #10.1.4.105 +sls_detector_put udp_dstmac $DSTMAC #3C:FD:FE:A2:14:D8 +sls_detector_put udp_srcip $SRCIP #10.1.4.9 +sls_detector_put udp_srcmac 00:ab:be:cc:dd:e2 +sls_detector_put rx_tcpport 1975 +sls_detector_put rx_hostname pc-jungfrau-02 + +sls_detector_put readoutspeed half_speed +#sls_detector_put readoutspeed full_speed +#sls_detector_put reg 0x59 0x1310 #0001 0011 0001 0000 + +#sls_detector_put readoutspeed 0 +#sls_detector_put reg 0x59 0x0100 #0000 0001 0000 0000 + +#CLI=/afs/psi.ch/project/sls_det_software/bin/sl7_binaries_to_be_removed_soon/xrayClient_sl7 + +CLI=/afs/psi.ch/project/sls_det_software/bin/xrayClient_sl8 #/vacuumClient_sl7 +# CLI=/afs/psi.ch/project/sls_det_software/bin/vacuumClient_sl8 # for small X-ray box + +$CLI setv 40 +$CLI setc 60 # for big X-ray box +# $CLI setc 55 # for small X-ray box +$CLI HV on + +sls_detector_put clearbit 0x5d 0 +sls_detector_put fwrite 0 + +echo "warmin up the board" +sls_detector_put frames 40000 +sls_detector_acquire +sleep 1 +echo "end of board warm up" + +declare -a arr=("Ti" "Fe" "Cu" "Se" "Mo" "Ag" "in") + +for i in "${arr[@]}" +do + + $CLI setfl Fluorescence $i + echo "Target moved" + sleep 1 + + +$CLI shutter $shutter off #$CLI shutter 1 off + + +# : ' # Uncomment to skip a G0 part + +sls_detector_put frames 1000 +sleep 1 +sls_detector_put fwrite 1 +sls_detector_put fpath /mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/ +sls_detector_put fname pedeG0_target_${i}_ +echo "Saving file /mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/pedeG0_target_${i}_" +sleep 2 +echo "recording G0 pede" +sls_detector_acquire +sleep 1 +# 1000 frames at 500 frames per second takes 2s + +echo "recording G1 pede" +sls_detector_put gainmode forceswitchg1 +sls_detector_acquire +sleep 1 + +echo "recording G2 pede" +sls_detector_put gainmode forceswitchg2 +sls_detector_acquire +sleep 1 + +sls_detector_put gainmode dynamic + +echo "closed G0 pede file and open the G0 CuFluo file" +sleep 1 + +sls_detector_put frames 220000 +$CLI shutter $shutter on #$CLI shutter 1 on +sleep 1 +sls_detector_put fpath "/mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/" +sls_detector_put fname "FluoG0_target_${i}_" +echo "Saving file /mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/FluoG0_target_${i}_" +sleep 1 +sls_detector_acquire +sleep 1 + +# 200k frames at 500 frames per second takes 400s +$CLI shutter $shutter off #$CLI shutter 1 off +# ' # Uncomment to skip a G0 part + +echo "closed G0 CuFluo file and open HG0 pede file" +sleep 1 + +sls_detector_put settings highgain0 + +sls_detector_put frames 1000 +echo "recording HG0 pede" +sls_detector_put fpath "/mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/" +sls_detector_put fname "pedeHG0_target_${i}_" +echo "Saving file /mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/pedeHG0_target_${i}_" +sleep 1 +sls_detector_acquire +sleep 1 + +# 1000 frames at 500 frames per second takes 2s +echo "closed HG0 pede file and open the HG0 CuFluo file" + +sls_detector_put frames 220000 +sleep 1 +$CLI shutter $shutter on #$CLI shutter 1 on +sleep 1 + +sls_detector_put fpath "/mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/" +sls_detector_put fname "FluoHG0_target_${i}_" +echo "Saving file /mnt/sls_det_storage/jungfrau_calib/data/Module_748_Calib/FluoHG0_target_${i}_" +sleep 1 + +sls_detector_acquire +sleep 1 + +# 200k frames at 500 frames per second takes 400s + +$CLI shutter $shutter off #$CLI shutter 1 off + +sls_detector_put clearbit 0x5d 0 + +done + +$CLI setfl Fluorescence Ti + +sls_detector_put highvoltage 0 + +echo "Script finished" diff --git a/Fluo_fit.cpp b/Fluo_fit.cpp new file mode 100644 index 0000000..b73deda --- /dev/null +++ b/Fluo_fit.cpp @@ -0,0 +1,721 @@ +// to analyse the backplane pulsing data per module +// changes by VH 210906: to eliminate hardcoded absolute paths, uses location of the analysis root files as additional input argument (accordingly changed in filename_creator.sh) + +#include "TApplication.h" +#include "sls_detector_calibration/jungfrauCommonHeader.h" +#include "sls_detector_calibration/jungfrauCommonFunctions.h" + +#include "sls_detector_calibration/jungfrauFile.C" +#include "sls_detector_calibration/jungfrauPixelMask.C" +#include "sls_detector_calibration/jungfrauPedestal.C" + +#include "sls_detector_calibration/energyCalibration.h" +#include "sls_detector_calibration/energyCalibration.cpp" + +#include "TGraph.h" +#include "TGraphErrors.h" +#include "TF1.h" +#include "TFile.h" +#include "TPaveStats.h" +#include "TLegend.h" +#include "TPaveText.h" + +#include +//#include + +//#define NB_ENABLE 1 +//void nonblock(int state); +//#define NB_DISABLE 0 + +//TApplication* rootapp; +//TCanvas *A2; +//TCanvas *A3; +//TCanvas *A4; +//TCanvas *A5; +//TCanvas *A6; + + +//TPaveStats *st0; + + +//void PlotCanvas(void); + +double checkRangeMaxForAmplifierPlateau(double range_max) { + + // check that the range maximum is no more than 6.4 V + // to avoid non-linearity coming from amplifier plateau + if (range_max > 6400) { + return 6400; + } else { + return range_max; + } +} + + + + +bool isHGX=false; +int main(int argc, char* argv[]) { + + //nonblock(NB_ENABLE); + cout <<"opening the rootapp" <SetBatch(1); + gStyle->SetOptFit(11); + + /* + if (argc != 3) { + cout << "Correct usage:" << endl; + cout << "arg 1: specify module number" << endl; + cout << "arg 2: specify data location" << endl; + cout << "arg 3: specify column (x)" << endl; + cout << "arg 4: specify row (y)" << endl; + exit(1); + } + */ //uncomment for SR + + if (argc != 6) { + cout << "Correct usage:" << endl; + cout << "arg 1: specify module number" << endl; + cout << "arg 2: specify fluorescence target" << endl; + cout << "arg 3: gain settings" << endl; + cout << "arg 4: specify pixel x position" << endl; + cout << "arg 5: specify pixel y position" << endl; + exit(1); + } //uncomment for VH 210906 + string module_str = argv[1]; + string gain_str = argv[3]; + string target= argv[2]; + + string str2 =("HG0G1G2"); + string str3 =("HGOG1G2"); //filename creator had this bug + + + int column = atoi(argv[4]); + int row = atoi(argv[5]); + + + int pixel = column+row*1024; + + char data_loc[256]; + sprintf(data_loc,"/mnt/sls_det_storage/jungfrau_calib/jungfrau_ana_sophie/M%s_%s_CalibAna/", module_str.c_str(),target.c_str()); + cout << data_loc << endl; + + std::string folder_path(data_loc); + if (folder_path.find(str2) != string::npos) isHGX=true; + if (folder_path.find(str3) != string::npos) isHGX=true; + + bool isJF11=false; + if (gain_str == "HG0JF11") { + gain_str = "HG0"; + isJF11=true; + } + + // cout << data_loc.find(str2)<<" " << string::npos << " " << str2 << " " << data_loc <HG1->HG2 sequence - dynamicHG0" <G1->G2 sequence - dynamicG0" <SetLeftMargin(0.1); + A2->SetRightMargin(0.13); + A2->SetTopMargin(0.08); + A2->SetBottomMargin(0.15); + + A3->SetLeftMargin(0.1); + A3->SetRightMargin(0.13); + A3->SetTopMargin(0.08); + A3->SetBottomMargin(0.15); + + //file name + sprintf(filename,"%sCuFluo_%s_file0to21.root",folder_path.c_str(), gain_str.c_str()); + cout << "Loading file " << filename << endl; + TFile* f = new TFile((const char *)(filename),"READ"); + + int chip; + int CH = row*1024+column; + + if (CH < (65536*1)) { + chip = 1; + } else if (CH < (65536*2)) { + chip = 2; + } else if (CH < (65536*3)) { + chip = 3; + } else if (CH < (65536*4)) { + chip = 4; + } else if (CH < (65536*5)) { + chip = 5; + } else if (CH < (65536*6)) { + chip = 6; + } else if (CH < (65536*7)) { + chip = 7; + } else if (CH < (65536*8)){ + chip = 8; + } + cout<< "Chip "<< chip << " Channel number " << CH << endl; + + TH2I* hist0=(TH2I*)f->Get(Form("adc2d_%d",chip)); + cout << "Creating histogram for " << Form("adc2d_%d",chip) << endl; + TH1D* proj = hist0->ProjectionX("bin1",CH-(65536*(chip-1))+1,CH-(65536*(chip-1))+1); + cout << "Data for pixel "<< pixel << " is loaded" << endl; + + +if (proj->Integral(low_bin_noise,high_bin_noise)!=0 && proj->Integral(low_bin_peak,high_bin_peak)!=0) { + + A2->cd(); + cout << "Canvas Noise" << endl; + // noise + TH1D *proj_noise = dynamic_cast(proj->Rebin(nrebin,"proj_noise")); + proj_noise->SetStats(kTRUE); + proj_noise->GetXaxis()->SetRangeUser(proj->GetBinLowEdge(low_bin_noise),proj->GetBinLowEdge(high_bin_noise+1)); + proj_noise->Fit("gaus","Q"); + TF1 *fit = proj_noise->GetFunction("gaus"); + + proj_noise->Draw(); + A2->Update(); + proj_noise->GetXaxis()->SetTitle("Noise RMS [ADU]"); + proj_noise->GetXaxis()->SetRangeUser(-200,200); + fit->SetParNames("N_{#gamma}", "Peak pos", "Noise RMS"); + TPaveStats *st0 = (TPaveStats*)proj_noise->FindObject("stats"); + st0->SetX1NDC(0.53); + st0->SetX2NDC(0.94); + st0->SetY1NDC(0.75); + st0->SetY2NDC(0.94); + st0->SetBorderSize(0); + st0->SetTextSize(0.04); + A2->Modified(); + A2->Update(); + + A3->cd(); + + // peak + TH1D *proj_peak = dynamic_cast(proj->Rebin(nrebin,"proj_peak")); + proj_peak->SetStats(kTRUE); + proj_peak->GetXaxis()->SetRangeUser(proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + + + Double_t mypar[8]; + + + mypar[0] = 0.0; + mypar[1] = 0.0; + + + + if (target=="Ti") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 24.; + } + + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.12; + } + + + // Kb/Ka position ratio + mypar[6] = 1.0; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.2; + } + + } + + + + + if (target=="Fe") { + + + // Peak position + + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 27.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.2; + } + + + // Kb/Ka position ratio + mypar[6] = 1.11; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.12; + } + + } + + + + + + if (target=="Cu") { + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + + + // Peak hight + + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + + mypar[6] = 1.11; // mypar[6] = 1.12; + + // Kb fraction + + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + if (target=="Se") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.11; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + if (target=="Mo") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.12; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + if (target=="Ag") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.10; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + + if (target=="In") { + + + // Peak position + mypar[2] = proj_peak->GetBinCenter(proj_peak->GetMaximumBin()); + + // Noise RMS + if (gain_str == "G0") { + mypar[3] = 16.; + } else if (gain_str == "HG0") { + mypar[3] = 29.; + } + + // Peak hight + mypar[4] = proj_peak->GetBinContent(proj_peak->GetMaximumBin()); + + // Charge sharing + if (gain_str == "G0") { + mypar[5] = 0.17; + } else if (gain_str == "HG0") { + mypar[5] = 0.14; + } + + // Kb/Ka position ratio + mypar[6] = 1.13; + + // Kb fraction + if (gain_str == "G0") { + mypar[7] = 0.12; + } else if (gain_str == "HG0") { + mypar[7] = 0.14; + } + + } + + + Double_t emypar[8]; + energyCalibration *thiscalibration = new energyCalibration(); + thiscalibration->setScanSign(1); + thiscalibration->setStartParametersKb(mypar); + thiscalibration->fixParameter(0,0.); // no background + thiscalibration->fixParameter(1,0.); + TF1* fittedfun = thiscalibration->fitSpectrumKb(proj_peak,mypar,emypar); + + TF1 *gaus_Ka = new TF1("gaus_Ka","gaus",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + gaus_Ka->SetParameters(mypar[4],mypar[2],mypar[3]); + gaus_Ka->SetLineColor(kBlue); + + TF1 *erfc_Ka = new TF1("erfc_Ka","[0]/2.*(TMath::Erfc(([1]*(x-[2])/[3])/(TMath::Sqrt(2.))))",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + erfc_Ka->SetParameters(mypar[4]*mypar[5], 1, mypar[2], mypar[3]); + erfc_Ka->SetLineColor(kOrange); + + TF1 *gaus_Kb = new TF1("gaus_Kb","gaus",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + gaus_Kb->SetParameters(mypar[4]*mypar[7],mypar[6]*mypar[2],mypar[3]); + gaus_Kb->SetLineColor(kGreen+2); + + TF1 *erfc_Kb = new TF1("erfc_Kb","[0]/2.*(TMath::Erfc(([1]*(x-[2])/[3])/(TMath::Sqrt(2.))))",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); + erfc_Kb->SetParameters(mypar[4]*mypar[7]*mypar[5], 1, mypar[6]*mypar[2], mypar[3]); + erfc_Kb->SetLineColor(kOrange+7); + + proj_peak->Draw(); + A3->Update(); + erfc_Kb->Draw("same"); + erfc_Ka->Draw("same"); + gaus_Kb->Draw("same"); + gaus_Ka->Draw("same"); + fittedfun->Draw("same"); + A3->Update(); + proj_peak->GetXaxis()->SetTitle("Pedestal corrected ADC [ADU]"); + fittedfun->SetParNames("Bkg height", "Bkg grad", "K_{#alpha} pos", "Noise RMS", "K_{#alpha} height", "CS", "K_{#beta}/K_{#alpha} pos", "K_{#beta} frac"); + TPaveStats *st = (TPaveStats*)proj_peak->FindObject("stats"); + st->SetX1NDC(0.15); + st->SetX2NDC(0.55); + st->SetY1NDC(0.7); + st->SetY2NDC(0.94); + st->SetBorderSize(0); + st->SetTextSize(0.04); + A3->Modified(); + A3->Update(); +} else { + std::cout << "Masked pixel"; + } + + +rootapp.Run(); +return 0; + +} + diff --git a/JFMC_CalibWriter_wBP_sc.cpp b/JFMC_CalibWriter_wBP_sc.cpp index 23f6903..72edf7c 100644 --- a/JFMC_CalibWriter_wBP_sc.cpp +++ b/JFMC_CalibWriter_wBP_sc.cpp @@ -66,7 +66,8 @@ int main(int argc, char* argv[]) { for (int sci = 0; sci < NSC; ++sci) { // CuFluo HG0 dataset - sprintf( savename, "data/M%s/CuFluo_gain_sc%d_HG0_M%s.root", module_str.c_str(), sci, module_str.c_str() ); + //sprintf( savename, "data/M%s/CuFluo_gain_sc%d_HG0_M%s.root", module_str.c_str(), sci, module_str.c_str() ); + sprintf( savename, "/mnt/sls_det_storage/jungfrau_calib/ana/M%s_CalibAna/data/CuFluo_gain_sc%d_HG0_M%s.root", module_str.c_str(), sci, module_str.c_str() ); TFile* FL_HG0_file = new TFile((char*)savename,"READ"); TH2F* FL_HG0_gain_map = 0; TH2F* FL_HG0_gainer_map = 0; @@ -80,7 +81,8 @@ int main(int argc, char* argv[]) { } // CuFluo G0 dataset - sprintf( savename, "data/M%s/CuFluo_gain_sc%d_G0_M%s.root", module_str.c_str(), sci, module_str.c_str() ); + //sprintf( savename, "data/M%s/CuFluo_gain_sc%d_G0_M%s.root", module_str.c_str(), sci, module_str.c_str() ); + sprintf( savename, "/mnt/sls_det_storage/jungfrau_calib/ana/M%s_CalibAna/data/CuFluo_gain_sc%d_G0_M%s.root", module_str.c_str(), sci, module_str.c_str() ); TFile* FL_G0_file = new TFile((char*)savename,"READ"); TH2F* FL_G0_gain_map = 0; TH2F* FL_G0_gainer_map = 0; diff --git a/Multi_filename_creator.sh b/Multi_filename_creator.sh new file mode 100644 index 0000000..37efa6f --- /dev/null +++ b/Multi_filename_creator.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +if [[ "$0" == *"Multi_filename_creator.sh"* ]]; then + echo "script changes env. variables: should be invoked with source, not sh " + exit + +fi + +if [ ! -v $6 ]; then + echo $0 + echo "Run pccalib.sh [pc_name] to set the DST ip address before running the filename creator" + echo "printing filenames for jfcalib0 " $1 + echo "printing filenames for jfcalib1 " $2 + echo "printing filenames for jfcalib2 " $3 + echo "printing filenames for jfcalib3 " $4 + echo "printing filenames for jfcalib4 " $5 + echo "printing filenames for jfcalib5 " $6 + + #define folder structure + parentdir="/mnt/sls_det_storage/jungfrau_calib/" #"/home/l_msdetect/test/" #"/mnt/sls_det_storage/jungfrau_calib/" + calib0_relativedir="data/Module_"$1"_Calib/" + calib1_relativedir="data/Module_"$2"_Calib/" + calib2_relativedir="data/Module_"$3"_Calib/" + calib3_relativedir="data/Module_"$4"_Calib/" + calib4_relativedir="data/Module_"$5"_Calib/" + calib5_relativedir="data/Module_"$6"_Calib/" + ana0_relativedir="ana/M"$1"_CalibAna/" + ana1_relativedir="ana/M"$2"_CalibAna/" + ana2_relativedir="ana/M"$3"_CalibAna/" + ana3_relativedir="ana/M"$4"_CalibAna/" + ana4_relativedir="ana/M"$5"_CalibAna/" + ana5_relativedir="ana/M"$6"_CalibAna/" + calibdatafolder0=$parentdir$calib0_relativedir + calibdatafolder1=$parentdir$calib1_relativedir + calibdatafolder2=$parentdir$calib2_relativedir + calibdatafolder3=$parentdir$calib3_relativedir + calibdatafolder4=$parentdir$calib4_relativedir + calibdatafolder5=$parentdir$calib5_relativedir + anadatafolder0=$parentdir$ana0_relativedir + anadatafolder1=$parentdir$ana1_relativedir + anadatafolder2=$parentdir$ana2_relativedir + anadatafolder3=$parentdir$ana3_relativedir + anadatafolder4=$parentdir$ana4_relativedir + anadatafolder5=$parentdir$ana5_relativedir + + datestring=$(date +%F) + echo "Relative calib directory is "$calib0_relativedir + echo "Relative calib directory is "$calib1_relativedir + echo "Relative calib directory is "$calib2_relativedir + echo "Relative calib directory is "$calib3_relativedir + echo "Relative calib directory is "$calib4_relativedir + echo "Relative calib directory is "$calib5_relativedir + echo "Relative analysis results directory is "$ana0_relativedir + echo "Relative analysis results directory is "$ana1_relativedir + echo "Relative analysis results directory is "$ana2_relativedir + echo "Relative analysis results directory is "$ana3_relativedir + echo "Relative analysis results directory is "$ana4_relativedir + echo "Relative analysis results directory is "$ana5_relativedir + echo "mkdir "$calibdatafolder0 "if not already existing." + echo "mkdir "$calibdatafolder1 "if not already existing." + echo "mkdir "$calibdatafolder2 "if not already existing." + echo "mkdir "$calibdatafolder3 "if not already existing." + echo "mkdir "$calibdatafolder4 "if not already existing." + echo "mkdir "$calibdatafolder5 "if not already existing." + + mkdir -p $calibdatafolder0 + mkdir -p $calibdatafolder1 + mkdir -p $calibdatafolder2 + mkdir -p $calibdatafolder3 + mkdir -p $calibdatafolder4 + mkdir -p $calibdatafolder5 + + Rcv0="./slsDetector_bin/ju_udp_receiver_3threads_2_0_jfcalib0 S " #pc-jungfrau-02 RHEL8 + Rcv1="./slsDetector_bin/ju_udp_receiver_3threads_2_0_jfcalib1 S " #pc-jungfrau-02 RHEL8 + Rcv2="./slsDetector_bin/ju_udp_receiver_3threads_2_0_jfcalib2 S " #pc-jungfrau-02 RHEL8 + Rcv3="./slsDetector_bin/ju_udp_receiver_3threads_2_0_jfcalib3 S " #pc-jungfrau-02 RHEL8 + Rcv4="./slsDetector_bin/ju_udp_receiver_3threads_2_0_jfcalib4 S " #pc-jungfrau-02 RHEL8 + Rcv5="./slsDetector_bin/ju_udp_receiver_3threads_2_0_jfcalib5 S " #pc-jungfrau-02 RHEL8 + + export TKBPG0_0=$Rcv0$calibdatafolder0"BP_M"$1"_"$datestring"_ "$DSTIP + export TKBPG0_1=$Rcv1$calibdatafolder1"BP_M"$2"_"$datestring"_ "$DSTIP + export TKBPG0_2=$Rcv2$calibdatafolder2"BP_M"$3"_"$datestring"_ "$DSTIP + export TKBPG0_3=$Rcv3$calibdatafolder3"BP_M"$4"_"$datestring"_ "$DSTIP + export TKBPG0_4=$Rcv4$calibdatafolder4"BP_M"$5"_"$datestring"_ "$DSTIP + export TKBPG0_5=$Rcv5$calibdatafolder5"BP_M"$6"_"$datestring"_ "$DSTIP + + export TKBPHG0_0=$Rcv0$calibdatafolder0"BP_M"$1"_"$datestring"_HGOG1G2_ "$DSTIP + export TKBPHG0_1=$Rcv1$calibdatafolder1"BP_M"$2"_"$datestring"_HGOG1G2_ "$DSTIP + export TKBPHG0_2=$Rcv2$calibdatafolder2"BP_M"$3"_"$datestring"_HGOG1G2_ "$DSTIP + export TKBPHG0_3=$Rcv3$calibdatafolder3"BP_M"$4"_"$datestring"_HGOG1G2_ "$DSTIP + export TKBPHG0_4=$Rcv4$calibdatafolder4"BP_M"$5"_"$datestring"_HGOG1G2_ "$DSTIP + export TKBPHG0_5=$Rcv5$calibdatafolder5"BP_M"$6"_"$datestring"_HGOG1G2_ "$DSTIP + + export TKCSHG0_0=$Rcv0$calibdatafolder0"CS_M"$1"_"$datestring"_HGOG1G2_ "$DSTIP + export TKCSHG0_1=$Rcv1$calibdatafolder1"CS_M"$2"_"$datestring"_HGOG1G2_ "$DSTIP + export TKCSHG0_2=$Rcv2$calibdatafolder2"CS_M"$3"_"$datestring"_HGOG1G2_ "$DSTIP + export TKCSHG0_3=$Rcv3$calibdatafolder3"CS_M"$4"_"$datestring"_HGOG1G2_ "$DSTIP + export TKCSHG0_4=$Rcv4$calibdatafolder4"CS_M"$5"_"$datestring"_HGOG1G2_ "$DSTIP + export TKCSHG0_5=$Rcv5$calibdatafolder5"CS_M"$6"_"$datestring"_HGOG1G2_ "$DSTIP + + export TKCSG0_0=$Rcv0$calibdatafolder0"CS_M"$1"_"$datestring"_ $DSTIP" + export TKCSG0_1=$Rcv1$calibdatafolder1"CS_M"$2"_"$datestring"_ $DSTIP" + export TKCSG0_2=$Rcv2$calibdatafolder2"CS_M"$3"_"$datestring"_ $DSTIP" + export TKCSG0_3=$Rcv3$calibdatafolder3"CS_M"$4"_"$datestring"_ $DSTIP" + export TKCSG0_4=$Rcv4$calibdatafolder4"CS_M"$5"_"$datestring"_ $DSTIP" + export TKCSG0_5=$Rcv5$calibdatafolder5"CS_M"$6"_"$datestring"_ $DSTIP" + + echo "exporting the fluorescence receiver commands " + + export TKFG0_0=$Rcv0$calibdatafolder0"CuFluoG0_M"$1"_"$datestring"_ "$DSTIP + export TKFG0_1=$Rcv1$calibdatafolder1"CuFluoG0_M"$2"_"$datestring"_ "$DSTIP + export TKFG0_2=$Rcv2$calibdatafolder2"CuFluoG0_M"$3"_"$datestring"_ "$DSTIP + export TKFG0_3=$Rcv3$calibdatafolder3"CuFluoG0_M"$4"_"$datestring"_ "$DSTIP + export TKFG0_4=$Rcv4$calibdatafolder4"CuFluoG0_M"$5"_"$datestring"_ "$DSTIP + export TKFG0_5=$Rcv5$calibdatafolder5"CuFluoG0_M"$6"_"$datestring"_ "$DSTIP + + export TKFHG0_0=$Rcv0$calibdatafolder0"CuFluoHG0_M"$1"_"$datestring"_ "$DSTIP + export TKFHG0_1=$Rcv1$calibdatafolder1"CuFluoHG0_M"$2"_"$datestring"_ "$DSTIP + export TKFHG0_2=$Rcv2$calibdatafolder2"CuFluoHG0_M"$3"_"$datestring"_ "$DSTIP + export TKFHG0_3=$Rcv3$calibdatafolder3"CuFluoHG0_M"$4"_"$datestring"_ "$DSTIP + export TKFHG0_4=$Rcv4$calibdatafolder4"CuFluoHG0_M"$5"_"$datestring"_ "$DSTIP + export TKFHG0_5=$Rcv5$calibdatafolder5"CuFluoHG0_M"$6"_"$datestring"_ "$DSTIP + + export TKPG0_0=$Rcv0$calibdatafolder0"pedeG0_M"$1"_"$datestring"_ "$DSTIP + export TKPG0_1=$Rcv1$calibdatafolder1"pedeG0_M"$2"_"$datestring"_ "$DSTIP + export TKPG0_2=$Rcv2$calibdatafolder2"pedeG0_M"$3"_"$datestring"_ "$DSTIP + export TKPG0_3=$Rcv3$calibdatafolder3"pedeG0_M"$4"_"$datestring"_ "$DSTIP + export TKPG0_4=$Rcv4$calibdatafolder4"pedeG0_M"$5"_"$datestring"_ "$DSTIP + export TKPG0_5=$Rcv5$calibdatafolder5"pedeG0_M"$6"_"$datestring"_ "$DSTIP + + export TKPHG0_0=$Rcv0$calibdatafolder0"pedeHG0_M"$1"_"$datestring"_ "$DSTIP + export TKPHG0_1=$Rcv1$calibdatafolder1"pedeHG0_M"$2"_"$datestring"_ "$DSTIP + export TKPHG0_2=$Rcv2$calibdatafolder2"pedeHG0_M"$3"_"$datestring"_ "$DSTIP + export TKPHG0_3=$Rcv3$calibdatafolder3"pedeHG0_M"$4"_"$datestring"_ "$DSTIP + export TKPHG0_4=$Rcv4$calibdatafolder4"pedeHG0_M"$5"_"$datestring"_ "$DSTIP + export TKPHG0_5=$Rcv5$calibdatafolder5"pedeHG0_M"$6"_"$datestring"_ "$DSTIP + +else + echo "Specify module number for each jfcalib board after firt argument" + echo "Script finished" +fi + + + diff --git a/filename_creator.sh b/filename_creator.sh index ba97106..45851f7 100644 --- a/filename_creator.sh +++ b/filename_creator.sh @@ -13,7 +13,7 @@ echo "printing filenames for module " $1 #define folder structure -parentdir="/mnt/sls_det_storage/jungfrau_calib/" +parentdir="/mnt/sls_det_storage/jungfrau_calib/" #"/home/l_msdetect/test/" #"/mnt/sls_det_storage/jungfrau_calib/" calib_relativedir="data/Module_"$1"_Calib/" ana_relativedir="ana/M"$1"_CalibAna/" calibdatafolder=$parentdir$calib_relativedir diff --git a/makefile b/makefile index d02138b..a073b89 100644 --- a/makefile +++ b/makefile @@ -104,3 +104,13 @@ CS_analysis_M439: CS_analysis_M439.cpp Default_pixels_arrays: Default_pixels_arrays.cpp g++ -Wall -O3 -m64 -I$(ROOTSYS)/include -L$(ROOTSYS)/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic Default_pixels_arrays.cpp -o Default_pixels_arrays + +Fluo_analysis_Ti_In: Fluo_analysis_Ti_In.cpp + g++ -Wall -O3 -m64 -I$(ROOTSYS)/include -L$(ROOTSYS)/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic Fluo_analysis_Ti_In.cpp -o Fluo_analysis_Ti_In + + +Fluo_fit: Fluo_fit.cpp + g++ -Wall -ggdb -fopenmp -O3 -m64 -I$(ROOTSYS)/include -L$(ROOTSYS)/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lrt -o Fluo_fit Fluo_fit.cpp +CuFluo_fit_sc: CuFluo_fit_sc.cpp + g++ -Wall -ggdb -fopenmp -O3 -m64 -I$(ROOTSYS)/include -L$(ROOTSYS)/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lrt -o CuFluo_fit_sc CuFluo_fit_sc.cpp +