Document generated by Hector Alvarez Pol @ USC (hector.alvarez@usc.es), 26/09/2014 Last update by Hector Alvarez Pol @ USC (hector.alvarez@usc.es), 30/09/2014 ---------------------------------------------------------------------------------- EXPERIMENT s438 Description of the procedure for the calibration of the s438 data: Hardware: - 2 petals: petal 1 (top, old petal) and 2 (bottom, new) - 128 crystals (from 0 to 63 in the petal 1, 64 to 127 in petal 2) - 4 preamplifiers (32 channels each): 0 for crystals 0 to 31 1 for crystals 32 to 63 2 for crystals 64 to 95 3 for crystals 96 to 127 - FEBEX numbers from 0 to 7 0 for crystals 0 to 15 1 for crystals 16 to 31 ... - mapping table as in ???.txt (NOTE: not a correspondence between FEBEX channels and preamp channels) Unpacking: (example with 10 files of run 140925, from 0100 to 0110, 22Na calib. run) In a working session of r3broot, directory r3broot/macros/r3b/califa/s438: $ root -l root [0] .L califaUnpack.C root [1] run("na22_", 100, 110) [INFO ] 0 events, multiplicity: 1 ... [INFO ] 25281800 events, multiplicity: 1 Macro finished succesfully. Output file is ./data/na22__raw.root Parameter file is ./data/params_na22__raw.root Real time 122.739 s, CPU time 120.81s root [2] .q Then, a new file r3broot/macros/r3b/califa/s438/data/na22__raw.root contains the R3BCaloRawHit (rawHits for short) [An alternative is califaUnpack_batch.C, where you simply do root -l -b -q 'califaUnpack_batch.C("1000mv_30mev_",362,364)'; which allows you to run a list of events in a bash script] Calibration:(example with run 140925, as before) The R3BCaloRawHit datamembers storing are channels. The task R3BCaloCal convert them to R3BCaloCrystalHit where energies are in keV. The macro r3broot/macros/r3b/califa/s438/califaCal.C does this work, once a ROOT parameters file is given for the run to analyze. An ascii file can be also given just modifying the FairParRootFileIo for a FairParAsciiFileIo inside the macro. In a working session of r3broot, directory r3broot/macros/r3b/califa/s438: $ root -l root [0] .L califaCal.C root [1] califaCal("./data1/140925/na22__raw.root","./data1/140925/na22__calTest.root", "../../db/califa/califa_cal_par.root") (all in the same line!) (califa_allPars.root in the s438 file) the output with R3BCaloCrystalHits will be in na22__calTest.root It is recommended to use a symbolic link to outside of the r3broot dir $ ln -s /path/to/your/data data Initial calibration parameters are available in r3broot/macros/r3b/califa/s438/califa_cal_par.root (with runid=0) Calibration parameters: There are the following calibration parameters: Double_t fGammaCal_offset; offset in linear gamma calibration Double_t fGammaCal_gain; gain in linear gamma calibration Double_t ftotCal_par0 Double_t ftotCal_par1 Double_t ftotCal_par2; ToT energy cal parameters for fit E=par0*exp(TOT/par1)+par2 Double_t fRangeCal_offset; offset in the linear 30 to 300 MeV range calibration Double_t fRangeCal_gain; gain in the linear 30 to 300 MeV range calibration Double_t fQuenchingFactor; quenching factor for protons (tentative) calculated from proton and pulser measurements fGammaCal (Gamma calibration parameters) are obtained from a calibrated source: 22Na has been used in the example below (macros calibrate.C and extractParams.C). fToTCal (ToT calibration parameters) are obtained from a non-linear fit of several pulser amplitudes taken by ToT method and the 300MeV range (macros calToT_part1.C and calToT_part2.C). fRangeCal (30 to 300MeV range calibration parameters) are obtained by using the same pulser amplitudes in the two ranges (macros calPulser_part1.C and calPulser_part2.C). fQuenchingFactor is our guess about the quenching factor of protons, obtained from the relation between 30 to 300MeV range measured with pulser and with protons (Krakow data). Once all parameters are found (see below for each individual case) the macro r3broot/macros/r3b/califa/s438/mergePars.C creates the container in an ascii file. The macro r3broot/macros/r3b/califa/s438/convertPars.C moves the container to a root contained to load it during calibration NOTE: the runID is set to 0!!!! Modify if neccesary. Getting Gamma calibration parameters: (example with run 140925, as before) Use the macro r3broot/macros/r3b/califa/s438/calibrate.C. A few parameters should be checked before, from the rawHits tree. In our case peaks are around channels 560 (for 511keV peak) and 1370 (for 1274kev peak). Then, with windows (510,610) and (1320,1420): $ root -l root [0] .L calibrate.C root [2] calibrate("./data/na22__raw.root",0,510,610,1320,1420) Event:0 Event:100000 ... The macro is not perfect (check the fits!). In this case 5 out of 256 fits failed (this number could change as a function of the window opened around each peak). To correct those cases, check the parameters in fitPars_final.txt and modify manually the lines corresponding to the fits, with your estimates; the file format is: line 1, crystal 0, first peak: gaus heigth, gaus mean, gaus sigma, baseline line 2, cyrstal 0, second peak: gaus heigth, gaus mean, gaus sigma, baseline line 3, cyrstal 1, first peak: ... after modifying the 5 cases wrong with your estimates from the plots, convert the fitPars_final.txt into a fitPars_init.txt and run again in mode 1: mv fitPars_final.txt fitPars_init.txt $ root -l root [0] .L calibrate.C root [2] calibrate("./data/na22__raw.root",1,510,610,1320,1420) Event:0 Event:100000 ... Check again all the fits! Save your results! (in this case to fitPars_140925.txt). To produce the gains and offsets from the fits results, as well as some additional information, run the macro extractParams.C. $ root -l root [0] .L extractParams.C root [1] extractParams("fitPars_140925.txt","calPars_140925.txt", "crystalInfo_140925.txt",510.998910,1274.53) (all in the same line!) The parameters will be at calPars_140925.txt and more information in the file crystalInfo_140925.txt (resolution). Getting Range calibration parameters: (example with run 140926) Use the macros r3broot/macros/r3b/califa/s438/calPulser_part1.C and r3broot/macros/r3b/califa/s438/calPulser_part2.C $ root -l root [0] .L calPulser_part1.C root [2] cal("data1/140926/pul_30mev.root","data1/140926/pul_300mev.root", 4) Event:0 Event:100000 ... The macro finds the location and fits the four peaks expected in the pulser run. The output of the macro, fitPars_pulser.txt, contains the parameters of the fit. Save the file (fitPars_pulser.txt will be overwritten everytime you run the macro). Use the second macro r3broot/macros/r3b/califa/s438/calPulser_part2.C to plot and linearly fit the function of the two gains (30 vs. 300MeV). $ root -l root [0] .L calPulser_part2.C root [2] cal("fitPars_pulser_140926.txt","gainPars_pulser_140926.txt") The output is the gainPars_pulser_140926.txt with the gain and offsets. PLEASE, check all the points in the final fits. A bad fit is easy to localize and solve, but a single point out of place will destroy the calibration for this channel! Getting ToT calibration parameters: (example with run 140927) // needs new E=par0*exp(TOT/par1)+par2 function.. NOT DONE Use the macros r3broot/macros/r3b/califa/s438/calToT_part1.C and r3broot/macros/r3b/califa/s438/calToT_part2.C $ root -l root [0] .L calToT_part1.C root [2] cal("data1/14092","data1/140927/?????", 5) Event:0 Event:100000 ... The macro finds the location and fits the five peaks expected in the pulser run. The output of the macro, fitPars_ToT.txt, contains the parameters of the fit. Save the file (fitPars_ToT.txt will be overwritten everytime you run the macro). Use the second macro r3broot/macros/r3b/califa/s438/calToT_part2.C to plot and linearly fit the function of the two modes (ToT vs. 300MeV). $ root -l root [0] .L calToT_part2.C root [2] cal("fitPars_ToT_140927.txt","gainPars_ToT_140927.txt") The output is the gainPars_ToT_140926.txt with the gain and offsets. PLEASE, check all the points in the final fits. A bad fit is easy to localize and solve, but a single point out of place will destroy the calibration for this channel! Adding the parameters to r3broot: (example from the outcome of the previous points) This step allows to enter the parameters in the adequate parameter container in R3BRoot for moving from RawHits to CrystalHits (R3BCaloCrystalHit). Assuming you have text files with the parameters obtained following the previous macros: calPars_140925.txt, gainPars_pulser_140926.txt, gainPars_ToT_140927.txt (the fQuenchingFactor calibration parameter is for the moment fixed to 0.9 in the macro!) The macro r3broot/macros/r3b/califa/s438/mergerPars.C merge all and create a valid ascii file parameters file for R3BRoot: $ root -l root [0] .L mergerPars.C root [1] mergerPars("calPars_140925.txt","ToT_Pars_140929.txt","gainPars_pulser_140926.txt","califa_allPars.par") The output can be directly used in a calibration macro with the code: // ----- Runtime database --------------------------------------------- FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParAsciiFileIo* parAsciiIn = new FairParAsciiFileIo(); parAsciiIn->open("name_of_the_file.par"); rtdb->setFirstInput(parAsciiIn); rtdb->print(); or, it can be used to create a parameters root file using the macro r3broot/macros/r3b/califa/s438/convertPars.C $ root -l root [0] .L convertPars.C root [1] convert("califa_allPars.par","califa_allPars.root") In this case, the root file should enter in the calibration macro as: FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parRootIn = new FairParRootFileIo(); parRootIn->open(parRootFile); rtdb->setFirstInput("name_of_the_file.root"); rtdb->print(); ------------------------------------------------------------------------------------------------- ADDITIONAL INFO FOR THE INITIALIZATION OF THE CALIBRATION PARAMETER CONTAINERS (OLD INFO): For the initial (only first time) creation of the calibration parameters container, a macro r3broot/macros/r3b/db/califa/califa_test.C creates a root file from the parameters introduced by hand in the ducals.par file. $ root -l califa_test.C root [0] Processing califa_test.C... Warning in : duplicate entry for level 0; ignored -I-R3BCaloContFact::createContainer CaloCalPar ************************************************************* initialisation for run id 1411817945 ************************************************************* -I- FairRunTimeDB::InitContainer() CaloCalPar s: NrOfDUnits: Int_t 128 n: 10 s: 0: Double_t \ n: 1 ... [INFO ] *** CaloCalPar written to ROOT file version: 1 -------------------------------------------------------------------------------- -------------- actual containers in runtime database ------------------------- CaloCalPar Califa Calib Parameters -------------- runs, versions ------------------------------------------------ run id container 1st-inp 2nd-inp output run: 1411817945 CaloCalPar 1 -1 1 -------------- input/output -------------------------------------------------- first Input: Ascii I/O ducals.par is open detector I/Os: FairGenericParIo second input: none output: OBJ: FairParRootFile califa_cal_par.root : 0 at: 0x7fb789d8d6c0 Root file I/O califa_cal_par.root is open detector I/Os: FairGenericParIo (Int_t)0 The created califa_cal_par.root can be used for the calibration.