====== Decomp Calibrations ====== == detmap files == The calibration procedure starts with a detmap file. Such a file exists for each quad. Each file is a plain text list of the offset and gain of each channel of the quad respectively. The channels are separated by new lines. The order of the channels is in the the daq order (i.e the order they arrive at the digitizer, remember Q1 is different). The naming scheme of the files is important for the rest of the scripts to work; current convention is **detmap_Q1.txt**, where the 1 could be replaced by any quad number. A truncated example of a detmap file: 0.282147 0.293645 -0.455952 0.292579 -0.281072 0.294927 -0.579122 0.293367 -0.391375 0.314109 0.106291 0.295857 -0.20183 0.295819 -0.294165 0.286083 -0.323898 0.300403 0.101371 0.308178 Above are the first ten channels of the one detmap file. The first column is the offset, the second column is the gain. The channel is indicted by the row number. detmap files live in gretina account as ~/DecompParam/detmap_YYMMDD == Splitting the detmap files == After the creation of the detmap files, they must be split into the corresponding cores and segments. Assuming the above formatted file and standard file convention; this can be done with the script run in same directory where the detmap files live. This is script is run by passing it the detmap file to be split: ~analysis/packages/Calibrations/split_cal.py detmap_Q1.txt which will create files **detmap_Q1CC.txt** and **detmap_Q1Seg.txt**. == Shaofei's mapping scripts == Once all detmap files are split into their CC and Seg components, we can than use Shaofei's mapping scripts to create the rest of the need decomp files. **The order these scripts are run in is very important.** In order with example arguments: ~analysis/packages/benderCal/merge_detmap . detmap This script creates **detmap_Q1pos[1-4]_CC[9-39]Cal.txt** and **detmap_Q1Seg.txt** file for each quad ~analysis/packages/benderCal/get_detmap ~gretina/DecompParam/detmaps_170209/ detmap . detmap This script gets the header file need to map daq ordered channels to decomp mode2 order channels. The file **detmap_Q1pos[1-4]_CC[9-39].txt** will be created. These files should now look like: 0x3 0 0 0 0.282147 0.293645 0x3 1 0 1 -0.455952 0.292579 0x3 2 0 2 -0.281072 0.294927 0x3 3 0 3 -0.579122 0.293367 0x3 4 0 4 -0.391375 0.314109 0x3 5 0 5 0.106291 0.295857 0x3 6 0 6 -0.20183 0.295819 0x3 7 0 7 -0.294165 0.286083 0x3 8 0 8 -0.323898 0.300403 0x3 9 0 36 0.101371 0.308178 0x4 0 0 9 -0.0101913 0.324076 0x4 1 0 10 0.404754 0.300472 0x4 2 0 11 -0.346688 0.295173 0x4 3 0 12 0.397739 0.326801 0x4 4 0 13 -0.0799647 0.231865 0x4 5 0 14 -0.53801 0.319978 0x4 6 0 15 -0.485629 0.305327 0x4 7 0 16 -0.346114 0.295598 0x4 8 0 17 -0.385398 0.295361 0x5 0 0 18 -0.354487 0.322502 0x5 1 0 19 -0.253475 0.298176 0x5 2 0 20 -0.403024 0.314914 0x5 3 0 21 -0.441589 0.318274 0x5 4 0 22 -0.235985 0.287324 0x5 5 0 23 -0.0343097 0.306376 0x5 6 0 24 -0.533586 0.293114 0x5 7 0 25 0.509689 0.297238 0x5 8 0 26 -0.179804 0.303876 0x6 0 0 27 -0.0729594 0.217916 0x6 1 0 28 -0.516658 0.298321 0x6 2 0 29 -0.771099 0.290957 0x6 3 0 30 -0.375356 0.297646 0x6 4 0 31 0.175389 0.298985 0x6 5 0 32 -0.354584 0.308682 0x6 6 0 33 -0.792392 0.314499 0x6 7 0 34 -0.365302 0.289866 0x6 8 0 35 -0.942629 0.294357 These are the calibrations files actually loaded by the GRETINA Decomp process. == Trace gain files == After the calibration files have been made using the above steps, we must make the trace gain files. This is a two step procedure and we assume here we are still using the standard naming procedure. The first step requires running a root script: > root -lb root [0] .L ~analysis/packages/benderCal/GT2Cal_Bender.cpp root [1] get_tr_gain(".","detmap") This script will output the trace gains to the screen as they are calculated. One must hit enter after each Q for the script to continue or simply hold enter down, the script only takes a few seconds to run. Once this is done we need to quit root. root [2] .q This script will have created files **detmap_Q[1-10]CC_tr_gain.txt** and files **detmap_Q[1-10]Seg_tr_gain.txt** for each quad. After creating these files they must be merged into their trace gain files for their respective gain ranges: ~analysis/packages/benderCal/merge_detmap_tr . detmap which will produce files ** tr_gain_Q[1-10]pos[1-4]_CC[9-39].txt**. These are the trace gains actually loaded by the GRETINA Decomp process. At this point bad channels must be edited to a large value for the gain range which will be loaded by the DAQ. For example, the **Q4P2** has a bad segment and we plan to use the 10 MeV range (first digitizer) - so file **tr_gain_Q4pos2_CC9.txt** must be edited from something which looks like: 0.83885843 0.82833356 0.79647750 0.86153644 0.82199061 0.85602087 0.82397383 0.88007176 0.95295018 0.83846498 0.83268768 0.81359202 0.84887129 0.84606075 0.82328838 0.92762762 0.90537167 0.84306300 0.84145373 0.83354926 0.84602684 0.82818270 0.84309858 0.84301353 0.35928223 0.83807576 0.84559876 0.83149475 0.82677245 0.84563261 0.84975672 0.85358042 0.85946518 0.84654522 0.92021245 0.85450613 0.88523686 to: 0.83885843 0.82833356 0.79647750 0.86153644 0.82199061 0.85602087 0.82397383 0.88007176 0.95295018 0.83846498 0.83268768 0.81359202 0.84887129 0.84606075 0.82328838 0.92762762 0.90537167 0.84306300 0.84145373 0.83354926 0.84602684 0.82818270 0.84309858 0.84301353 100000.000 0.83807576 0.84559876 0.83149475 0.82677245 0.84563261 0.84975672 0.85358042 0.85946518 0.84654522 0.92021245 0.85450613 0.88523686 Notice the change in line 25, which is the bad segment, to the a large number. This effectively turns of the segment when computing the decomp position. == Loading the Decomp File == Once all the above files have been created, we can load them into the GRETINA DAQ. To do this, we must be logged into the **gretina** account preferably on the computer currently hosting the gretina daq (currently this is **a2.gam**) On gretina: cd ~/DecompParam mkdir detmaps_yymmdd where yymmdd in the above is replaced with the year, month and date respectively. After this directory is created copy all the above created files into the newly created directory. Now we must copy/edit the setfile. The setfiles are located in **~gretina/DecompParam/** Copy the last setfile to the current date: cp setFile.2017-02-09 setFile.YYYY-MM-DD Now the newly created setfile must be edited. Assuming we keep the standard naming convention mentioned here; all one needs to do is a mass search and replace for the old date with the new date. Using 2017-02-09 as the old example and YYYY-MM-DD as the new example 170209 -> YYMMDD Once the new setfile is edited to point to the newly created Decomp files, we must tell the gretina daq to load use this new setfile. This is done by editing the file **~gretina/grdecomp.sh** In the file, the parameter FILECONF should be edited to point to the newly created setfile. This parameter is at the top of the file in the first uncommented line. The convention is to copy the line, comment out the old definition, and change the setfile name in the new line. == Loading new Decomp Parameters == Once all the above is done, we must tell the daq to load the new decomp values. This can be done either using the buttons, **GRETINA Stand Alone** of **GRETINA + S800**, or by running the script **~gretina/grdecomp.sh** directly. After the above load - the daq should be started and left to run for a few minutes. If there is some mistake in the loading of the above files, this will cause the buffers for the bad channels to fill up and the daq will stall.