Back to home page

EIC code displayed by LXR

 
 

    


Warning, /snippets/Calorimetery/ECalCalibration/Snakefile is written in an unsupported language. File is not indexed.

0001 import os
0002 
0003 # All generated data stays below calibration/; no parent scratch directory is used.
0004 EICRECON_DIR = 'data/eicrecon'
0005 
0006 ID_RANGES = [(i, 10*i) for i in range(20)]
0007 
0008 rule all:
0009     input:
0010         'plot/theta80_100/gamma/zRes0mm/UncalibratedERecoVsETruth_CALOROCCluster_Single_energy2000_20000.png'
0011 
0012 rule sim_single_particle:
0013     output:
0014         'data/eicrecon/Single_energy2000_20000/gamma/id{id1}_{id2}/output.edm4hep.root'
0015     params:
0016         output_abs=lambda wc, output: os.path.abspath(output[0])
0017     shell:
0018         r'''
0019         mkdir -p "$(dirname "{params.output_abs}")"
0020 source /opt/detector/epic-main/bin/thisepic.sh
0021 npsim --compactFile $DETECTOR_PATH/epic_craterlake.xml --numberOfEvents 200 --outputFile {params.output_abs} --gun.particle "gamma" --gun.momentumMin 2000 --gun.momentumMax 20000 --gun.distribution uniform --gun.thetaMin 80*deg --gun.thetaMax 100*deg  --enableGun
0022         '''
0023 
0024 rule eicrecon:
0025     input:
0026         simulation='data/eicrecon/Single_energy2000_20000/gamma/id{id1}_{id2}/output.edm4hep.root',
0027     output:
0028         'data/eicrecon/Single_energy2000_20000/gamma/id{id1}_{id2}/zRes0mm/eicrecon.uncalibrated.root'
0029     params:
0030         slope='-PBEMC:EcalBarrelScFiCalibration:slope=1.0 ',
0031         # Imaging cluster arguments are irrelevant for the CALOROC-based plot this pipeline produces.
0032         input_abs=lambda wc, input: os.path.abspath(input.simulation),
0033         output_abs=lambda wc, output: os.path.abspath(output[0])
0034     shell:
0035         '''
0036 source /opt/detector/epic-main/bin/thisepic.sh
0037 #source EICrecon/bin/eicrecon-this.sh
0038 cd $( dirname {params.output_abs} )
0039 eicrecon -Pdd4hep:xml_files=epic_craterlake.xml -Ppodio:output_file=eicrecon.uncalibrated.root -Ppodio:output_collections=EventHeader,\
0040 MCParticles,\
0041 EcalBarrelScFiPAttenuatedHitContributions,\
0042 EcalBarrelScFiNAttenuatedHitContributions,\
0043 EcalBarrelScFiPNpeHits,\
0044 EcalBarrelScFiNNpeHits,\
0045 EcalBarrelScFiPNpeHitContributions,\
0046 EcalBarrelScFiPPulses,\
0047 EcalBarrelScFiNPulses,\
0048 EcalBarrelScFiProtoClusters,\
0049 EcalBarrelScFiClustersWithoutShapes,\
0050 EcalBarrelScFiRawHitLinks,\
0051 EcalBarrelScFiRawHits,\
0052 EcalBarrelScFiRecHits,\
0053 EcalBarrelScFiPCALOROCHits,\
0054 EcalBarrelScFiNCALOROCHits,\
0055 EcalBarrelScFiClusters,\
0056 EcalBarrelScFiPCALOROCHits \
0057 {params.slope} \
0058 {params.input_abs}
0059         '''
0060 
0061 rule compile_writeCALOROC:
0062     input: 'script/writeCALOROCToTxt.C'
0063     output:
0064         so='script/writeCALOROCToTxt_C.so',
0065         d='script/writeCALOROCToTxt_C.d'
0066     shell: "root -b -l -q -e '.L {input}+'"
0067 
0068 rule compile_attCor:
0069     input: 'script/AttCor.C'
0070     output:
0071         so='script/AttCor_C.so',
0072         d='script/AttCor_C.d'
0073     shell: "root -b -l -q -e '.L {input}+'"
0074 
0075 rule writeCALOROC2Txt:
0076     input:
0077         source=f'{EICRECON_DIR}/Single_energy2000_20000/gamma/id{{id1}}_{{id2}}/zRes0mm/eicrecon.uncalibrated.root',
0078         script='script/writeCALOROCToTxt.C',
0079         lib_so='script/writeCALOROCToTxt_C.so',
0080         lib_d='script/writeCALOROCToTxt_C.d'
0081     output:
0082         'tmp/VarCALOROC_UncalibratedScFi_id{id1}_{id2}.txt'
0083     shell:
0084         r'''
0085         root -b -l -q '{input.script}+("{input.source}","{output}")'
0086         '''
0087 
0088 rule attCor:
0089     input:
0090         data='tmp/VarCALOROC_UncalibratedScFi_id{id1}_{id2}.txt',
0091         script='script/AttCor.C',
0092         lib_so='script/AttCor_C.so',
0093         lib_d='script/AttCor_C.d'
0094     output:
0095         'tmp/CALOROCCluster_UncalibratedScFi_id{id1}_{id2}.txt'
0096     shell:
0097         r'''
0098         root -b -l -q '{input.script}+("P","{input.data}","{output}",80,100)'
0099         '''
0100 
0101 rule appendTxt:
0102     input:
0103         expand('tmp/CALOROCCluster_UncalibratedScFi_id{id1}_{id2}.txt',
0104                zip,
0105                id1=[r[0] for r in ID_RANGES],
0106                id2=[r[1] for r in ID_RANGES])
0107     output:
0108         'tmp/CALOROCCluster_UncalibratedScFi_summed.txt'
0109     shell: 'cat {input} > {output}'
0110 
0111 rule plot_uncalibrated_caloroc_cluster:
0112     input:
0113         data='tmp/CALOROCCluster_UncalibratedScFi_summed.txt',
0114         script='script/plotERecoVsETruth.py'
0115     output:
0116         png='plot/theta80_100/gamma/zRes0mm/UncalibratedERecoVsETruth_CALOROCCluster_Single_energy2000_20000.png',
0117         txt='plot/theta80_100/gamma/zRes0mm/UncalibratedERecoVsETruth_CALOROCCluster_Single_energy2000_20000.txt'
0118     params:
0119         pdg=22,
0120         title=r'Single 0.01 < E < 20.00 GeV $\\gamma$, 80 < $\\theta$ < 100 deg, MC cluster and CALOROC',
0121         e_truth_min=0.01,
0122         e_truth_max=20.0,
0123         e_reco_min=0.001,
0124         e_reco_max=2.1,
0125         ytitle=r'$\\sum Att. Cor. NPE$ (GeV)'
0126     shell:
0127         r'''
0128         mkdir -p "$(dirname "{output.png}")"
0129         python -m script.plotERecoVsETruth \
0130             "{output.png}" "{input.data}" {params.pdg} "{params.title}" \
0131             --eTruthMin {params.e_truth_min} --eTruthMax {params.e_truth_max} \
0132             --eRecoMin {params.e_reco_min} --eRecoMax {params.e_reco_max} \
0133             --txt "{output.txt}" --ytitle "{params.ytitle}"
0134         '''