#!/usr/bin/python2.6 """ Script to generate the configuration files for the replay of AGATA data using the multi-process distributed system Narval or the single-process emulator femul. The script is divided in a few sections, some of which are specific to the actual analysis (and therefore are likely to be changed by the user) while some others are normally not to be touched: 0) Type of analysis and replacement macros (in the style of the shell) used to parametrize the commands listed in 2). 1) The structure of the actual analysis is defined by the variables PROGTYPE and CONFTYPE and by the dictionaries Topology and Actors. The dictionary ExtraFiles contains a list of files, which are needed by the analysis but are not generated by this script (e.g. calibrations, mappings, ...); these files can be copied from a previous analysis if the script is started WITH the option -o or --old (python gen_conf.py -h to get the list of accepted options) 2) The command lines to be written in the conf files of the actors defined in Actors{}. Uncomment/comment/modify the command lines and their parameters 3) A small database defining the position and the PSA signal basis of the germanium crystals. This part should not need to be changed. To get a list of command line arguments, launch it as "gen_conf.py -h" This script is (tentativelly) updated to follow the new naming of crystals """ import os #With the information reported in 1) and 2) it should be rather strightforward to produce the #topology file xxxxx.xml for narval (or xxxx.conf for femul) and the xxxx script for narval. ############################################################################################### ################### 0 Type of analysis and replacement symbols ############################# ############################################################################################### PROGTYPE='femul' # NARVAL or femul (to choose between os.getcwd() and '' for CWD) CONFTYPE='OFFLINE' # ONLINE or OFFLINE (used just to exclude the ReadDataDir line in the Producers) MACROS={ # various replacements for symbols defined in 2). '$CONFDIR' : 'Conf', # this will be prefixed by CWD/ '$READDIR' : 'Data', # this will be prefixed by CWD/; if ONLINE this will not be written '$SAVEDIR' : 'Out', # this will be prefixed by CWD/; if ONLINE this will be replaced by $READDIR '$BUILDER' : 'Builder', # this will be prefixed by CWD/ '$MERGER' : 'Merger', # this will be prefixed by CWD/ '$VAMOS' : 'vamos', # this will be prefixed by CWD/ '$GLOBAL' : 'Global', # this will be prefixed by CWD/ '$PSABASE' : '/opt/data/GANIL/SourceRuns2016/Replay/bases_ADL', # standard place at AGATA '$CRYSTAL_ID' : "", # the actual value is defined in GeDataBase '$SIGNAL_BASIS' : "", # the actual value is defined in GeDataBase '$CRYSTAL' : "", # the actual value taken from Topology['CRYSTAL'] } ############################################################################################### ################### 1 Structure of analysis ################################################ ############################################################################################### Topology={ # The directories to be generated in Conf, Data and Out 'CRYSTAL' : "00A 00B 00C 01A 01B 01C 02A 02B 02C 03A 03B 03C 04A 04B 04C 05A 05B 05C 09B 09C 10A 10B 10C 11A 11B 11C 12A 12B 14A 14B 14C", 'BUILDER' : "Builder", 'MERGER' : "Merger", 'GLOBAL' : "Global", 'VAMOS' : "vamos", } # The name of the used actors must correspond to one of the tuples defined in the following section. # This requirement creates a problem for BasicAFP and BasicAFC when they are used in chains of different type # (e.g. after PSA and after Tracking) and one wants to define chain-specific names for their input/output files. # The solution is to suffix the name of the chain-type (e.g. _CRYSTAL or _GLOBAL or any other), to the defining tuple. # This suffix will be silently removed from the actual name of the generated configuration files. Actors={ # These are the xxxx.conf files to be generated 'CRYSTAL' : "CrystalProducer PreprocessingFilter PSAFilter BasicAFC BasicAFP_CRYSTAL PostPSAFilter PostPSAFilter", 'VAMOS' : "BasicAFC_VAMOS BasicAFP_VAMOS", 'BUILDER' : "EventBuilder BasicAFC_BUILDER TrackingFilter", 'MERGER' : "EventMerger_MERGER BasicAFC_MERGER TrackingFilter", 'GLOBAL' : "EventBuilder BasicAFC_GLOBAL TrackingFilter", } ExtraFiles={ # If not already present, these files can be copied from a directory specified in the command line. CrystalPos LUT is placed at 3 places in order to have eventually tracking at different places offline 'CRYSTAL' : "CrystalProducerATCA.conf PreprocessingFilterPSA.conf xinv_1325-1340.cal xdir_1325-1340.cal Trapping_$CRYSTAL.cal", #Trapping_$CRYSTAL.cal recal2.dat <== files for n damage correction, not used at the moment 'GLOBAL' : "CrystalPositionLookUpTable", 'MERGER' : "CrystalPositionLookUpTable", } ############################################################################################### ################### 2 Tuples specifying the content of the configuration files ############# ############################################################################################### ######################### CrystalProducer=( "ActualClass CrystalProducerATCA", # name of the used daugther class "CrystalID $CRYSTAL_ID", # position of the crystal in the AGATA frame "ReadDataDir $READDIR/$CRYSTAL", # should not be present in the ONLINE producer, automatically done when flag "online is active" "SaveDataDir $SAVEDIR/$CRYSTAL", # Out/04C... for the OFFLINE; Data/04C... for the online "TraceLength 100", # length of traces (samples) "WriteDataMask 0", # 0=none 1=input_mezzdata 2=event_mezzdata 4=event_mezzhead 8=event_energy 16=event_core 32=tstampdiff; 10=8+2 #"WriteTraces 100", # number of traces written to "Prod__1000-42-100-S__Traces.samp" at the beginning of the run # to be uncommented for offline starting from traces !!! "InputDataFile event_mezzdata.cdat", # modify definitions in the online version of CrystalProducerATCA.conf to read from a single raw-data file #"InputDataFile arg__4120-UA__.dat", # modify definitions in the online version of CrystalProducerATCA.conf to read from a single raw-data file "AllInputFiles", # filename.ext --> filename.ext.0000 and increment the string after last . #"WriteBaseLines 10", # distribution of preamplifier baselines; events decimated by 10 #"DecimateMezzdata 4", # write one out of 4 (if WriteDataMask enables) #"DecimateMezzener 2", # write one out of 2 (if WriteDataMask enables) #"TimeStep 50", # not needed since the online has now a dedicated watchdog #"TstampCorrection 0", # used in the offline to correct for rare cases of bad setup #"MaxTstampSeconds 3200", # #"WriteDataSplit 1000000", # Size of event_mezzdata.cdat.xxxx is ~4GB (.cdat as data is compressed) #"WriteCompressed", # WriteCompressed is the default #"WriteUnCompressed", # to get uncompressed raw data #Co60 mainly... #"WriteDataRange 1500 25000", # range of CC amplitude (in channels) to write the data, not given means write all #"StopErrorCode 100", # < 100 to avoid stopping everything at the first input error #"ValidationRate 2000", # readout event-rate. Used to reduce the buffer size in the online ACQ so as to gent ~1 read/second #"NoMultiHist", # exclude local spectra and matrices "ProjeM1 10 2", # threshold (rescaled) and scaling factor for segment multiplicity=1 projections, calibration pourpose mainly... #"Verbose", # more verbose terminal-output #### command lines to be produced only for the specified crystals { #'1B' : "WriteDataRange 5500 20000", #'11C': "TstampCorrection -112", #'20A': "TstampCorrection 60", #'20B': "TstampCorrection 60", } ) ######################### PreprocessingFilter=( "ActualClass PreprocessingFilterPSA", # name of the used daugther class "SaveDataDir $SAVEDIR/$CRYSTAL", # normally Out/1R... "EnergyGain 2", # channels/keV of the calibrated energy spectra "XtalkFile xinv_1325-1340.cal", # cross talk correction coefficients for the energies "WriteTraces 100" , # number of traces written to "Prep__1000-42-100-S__Traces.samp" at the beginning of the run #"SegmentFoldGate 1 3", # selection of events based on the number of hit segments #"SegmentEnergyThreshold f32", # minimum energy on the segments to decide if fired, 10 keV is the default, look to Pre*PSA.conf file "PileUpCheck 0 0", # Slope Delta (no check if <= 0; default is to check) #"CFDparamsCC i32 i32 i32 f32 f32", # Int Diff Delay Fraction Threshold #"TriggerWithCoreAlone bool", # don't use net_charge_segments to find local trigger #"CoreEnergyGate 500 10000", # possibility to restrict the energy range #"RisetimeMatrix bool", #produce risetime matrix for segments and core #"NoMultiHist", # exclude local spectra and matrices #"Verbose", # more verbose terminal-output #### command lines to be produced only for the specified crystals { #'03A' : ("DeadSegment 12 0.9318 0.03083"), #'11B' : ("DeadSegment 13 0.93468 0.0"), } ) ######################### PSAFilter=( "ActualClass PSAFilterGridSearch", # name of the used daugther class "BasisFile $SIGNAL_BASIS", # this is generated from the GeDataBase structure (see at line ~230 of this file) "SaveDataDir $SAVEDIR/$CRYSTAL", # normally Out/Data(online) "EnergyGain 2", # channels/keV of the calibrated energy spectra "XtalkFile xdir_1325-1340.cal", # cross talk correction coefficients for traces (applied to the signal basis) "Threads 5 300", # number of threads, number of events/thread (if PSA threads enabled at compile time) "GridSearchType Adaptive", # SegCenter, Adaptive, CoarseOnly or Full; default is Adaptive #"GridSearchType SegCenter", # SegCenter, Adaptive, CoarseOnly or Full; default is Adaptive #"WriteTraces 500", # number of traces+fit written to "Prep__1000-42-100-S__Traces.samp" at the beginning of the run #"GridSearchType SegCenter", # SegCenter, Adaptive, CoarseOnly or Full; default is Adaptive #"TauSlice 35 35 35 35 35 35 35", # preamp response of the 6 slices and the CC #"TZeroCycles 10", # max number of PSA+FitTZero cycles #"TauSegment i32 f32", # segment number, its timing response (can be given multiple times, 36==CC) #"TauDecay f32", # fall time in ns of the preamplifiers (default is not to correct basis for this) #"Smooth f32", # final gaussian smoothing of the signal basis (0==no, default is 0.1) #"WritePsaHits", # writes the hits in binary to calibrate neutron damage #"NoMultiHist", # exclude local spectra and matrices #"Verbose", # more verbose terminal-output #### command lines to be produced only for the specified crystals { #'03A' : ("DeadSegment 12"), #'11B' : ("DeadSegment 13"), } ) PostPSAFilter=( "ActualClass PostPSAFilter", # name of the used daugther class, uncomment for offline "SaveDataDir $SAVEDIR/$CRYSTAL", # normally Out "EnergyGain 2", # channels/keV of the calibrated energy spectra #"SmearPos 4", # to randomize points on a 2mm3 volume #"ForceSegmentsToCore", # sum of segments forced to energy of the core. Use it EITHER in the PSA OR in the Tracking #"CoreEnergyGate 500 520 ", # possibility to restrict the energy range #"RecalCC 1", # recalibration of CC Energy #"RecalSG 1", # recalibration fired Segments #"TimeShiftCC f32", # time shift of core (ns) #"Verbose", # more verbose terminal-output #"TrappingFile Trapping_$CRYSTAL.cal", # file with the trapping-correction coefficients #"NoMultiHist", # exclude local spectra and matrices #### command lines to be produced only for the specified crystals { #'00A' : ("TimeShiftCC 23.960","RecalCC 1.207 0.999258","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'00B' : ("TimeShiftCC 17.960","RecalCC 2.148 0.998259","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'00C' : ("TimeShiftCC 16.658","RecalCC -0.290 1.000380","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'01A' : ("TimeShiftCC -34.714","RecalCC 2.670 0.998000","ForceSegmentsToCore"), #'01B' : ("TimeShiftCC -26.656","RecalCC -1.379 1.001095","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'01C' : ("TimeShiftCC -39.285","RecalCC 1.141 0.999405","ForceSegmentsToCore"), #'02A' : ("TimeShiftCC 20.939","RecalCC -2.158 1.002066","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'02B' : ("TimeShiftCC 16.433","RecalCC -1.365 1.001210","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'02C' : ("TimeShiftCC 21.195","RecalCC -0.412 1.000573","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'03A' : ("TimeShiftCC 22.403","RecalCC -1.419 1.001034","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'03B' : ("TimeShiftCC 6.125","RecalCC -0.381 1.000064","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'03C' : ("TimeShiftCC 25.621","RecalCC -1.618 1.001135","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'04A' : ("TimeShiftCC 26.451","RecalCC -1.892 1.001504","ForceSegmentsToCore"), #'04B' : ("TimeShiftCC 17.773","RecalCC -0.964 1.000878","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'04C' : ("TimeShiftCC 27.264","RecalCC -1.728 1.001414","ForceSegmentsToCore"), #'05A' : ("TimeShiftCC 14.770","RecalCC 0.261 0.999921","ForceSegmentsToCore"), #'05B' : ("TimeShiftCC 11.712","RecalCC 0.717 0.999554","ForceSegmentsToCore"), #'05C' : ("TimeShiftCC -59.500","RecalCC -2.401 1.002014","ForceSegmentsToCore"), #'09B' : ("TimeShiftCC 18.117","RecalCC 0.632 0.999547","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'09C' : ("TimeShiftCC -63.220","RecalCC -1.069 1.000923","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'10A' : ("TimeShiftCC 16.545","RecalCC -1.450 1.000920","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'10B' : ("TimeShiftCC 20.331","RecalCC 1.010 0.998986","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'10C' : ("TimeShiftCC 21.236","RecalCC -1.265 1.000923","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'11A' : ("TimeShiftCC -29.366","RecalCC 1.406 0.998909","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'11B' : ("TimeShiftCC -64.560","RecalCC -0.939 1.000828","ForceSegmentsToCore"), #'11C' : ("TimeShiftCC -62.609","RecalCC 0.130 0.999807","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), #'12A' : ("TimeShiftCC 14.224","RecalCC -1.905 1.001611","ForceSegmentsToCore"), #'12B' : ("TimeShiftCC 19.398","RecalCC -0.441 1.000604","TrappingFile Trapping_$CRYSTAL.cal"), #'14A' : ("TimeShiftCC 16.478","RecalCC 23.460 0.981851","ForceSegmentsToCore"), #'14B' : ("TimeShiftCC 21.888","RecalCC 1.497 0.998908","ForceSegmentsToCore"), #'14C' : ("TimeShiftCC -37.571","RecalCC -0.118 1.000246","ForceSegmentsToCore"), '00A' : ("TimeShiftCC -0.373","RecalCC 1.207 0.999258","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '00B' : ("TimeShiftCC 1.105","RecalCC 2.148 0.998259","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '00C' : ("TimeShiftCC 0.071","RecalCC -0.290 1.000380","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '01A' : ("TimeShiftCC 0.160","RecalCC 2.670 0.998000","ForceSegmentsToCore"), '01B' : ("TimeShiftCC 0.924","RecalCC -1.379 1.001095","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '01C' : ("TimeShiftCC -0.080","RecalCC 1.141 0.999405","ForceSegmentsToCore"), '02A' : ("TimeShiftCC 0.729","RecalCC -2.158 1.002066","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '02B' : ("TimeShiftCC 0.502","RecalCC -1.365 1.001210","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '02C' : ("TimeShiftCC 1.154","RecalCC -0.412 1.000573","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '03A' : ("TimeShiftCC -0.210","RecalCC -1.419 1.001034","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '03B' : ("TimeShiftCC -0.489","RecalCC -0.381 1.000064","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '03C' : ("TimeShiftCC -0.170","RecalCC -1.618 1.001135","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '04A' : ("TimeShiftCC -0.697","RecalCC -1.892 1.001504","ForceSegmentsToCore"), '04B' : ("TimeShiftCC -0.623","RecalCC -0.964 1.000878","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '04C' : ("TimeShiftCC 0.218","RecalCC -1.728 1.001414","ForceSegmentsToCore"), '05A' : ("TimeShiftCC 0.113","RecalCC 0.261 0.999921","ForceSegmentsToCore"), '05B' : ("TimeShiftCC 0.633","RecalCC 0.717 0.999554","ForceSegmentsToCore"), '05C' : ("TimeShiftCC -1.334","RecalCC -2.401 1.002014","ForceSegmentsToCore"), '09B' : ("TimeShiftCC 1.178","RecalCC 0.632 0.999547","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '09C' : ("TimeShiftCC -1.987","RecalCC -1.069 1.000923","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '10A' : ("TimeShiftCC -0.272","RecalCC -1.450 1.000920","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '10B' : ("TimeShiftCC -0.915","RecalCC 1.010 0.998986","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '10C' : ("TimeShiftCC -0.302","RecalCC -1.265 1.000923","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '11A' : ("TimeShiftCC -1.829","RecalCC 1.406 0.998909","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '11B' : ("TimeShiftCC 4.156","RecalCC -0.939 1.000828","ForceSegmentsToCore"), '11C' : ("TimeShiftCC 0.145","RecalCC 0.130 0.999807","ForceSegmentsToCore","TrappingFile Trapping_$CRYSTAL.cal"), '12A' : ("TimeShiftCC -0.149","RecalCC -1.905 1.001611","ForceSegmentsToCore"), '12B' : ("TimeShiftCC 0.329","RecalCC -0.441 1.000604","TrappingFile Trapping_$CRYSTAL.cal"), '14A' : ("TimeShiftCC -0.287","RecalCC 23.460 0.981851","ForceSegmentsToCore"), '14B' : ("TimeShiftCC -1.816","RecalCC 1.497 0.998908","ForceSegmentsToCore"), '14C' : ("TimeShiftCC 0.114","RecalCC -0.118 1.000246","ForceSegmentsToCore"), } ) ######################### TrackingFilter=( "ActualClass TrackingFilterOFT", # name of the used daugther class (TrackingFilterOFT or TrackingFilterMGT) "SaveDataDir $SAVEDIR/$GLOBAL", # Out/Global "EnergyGain 4", # channels/keV of the calibrated energy spectra #"ExcludeTracking", # skip the tracking part of the actor; remains only the data processing "OftParams 0.05 0.02 0.8", # minprobtrack minprobsing sigma_thet (0==default) #"MgtParams 0 # max value of Chi2 to accept a tracked gamma (0==default) "SourcePosition 0 0 0", # position of source with respect to the center of AGATA Position of source #"RecoilDirection 0 0 1", # fixed recoil direction for Doppler correction (if not using info from Ancillary) #"RecoilBeta 0.05", # and beta of recoil #"CoreEnergyGate 20 20000", # possibility to restrict the energy range in the individual detectors (better in PreprocessingFilter) #"NumDetsGate i32 i32", # event selection based on number of fired detectors #"NumHitsGate i32 i32", # event selection based on total number of hits #"WriteRootTree", # enable writing the root tree #"WriteRootTree InputHits", # enable writing the root tree with the input hits #"WriteMgtData", # enable writing Mgt_Hits.txt (same as: WriteInputHits WriteMgtHits WriteOftHits) #"WriteTracked", # write file of input hits for analysis with OFT #"RotoTranslations CrystalPositionLookUpTable", # this is the default #"Matrixgg1 4096 1", # size and gain of g-g matrix for CC before tracking (default size is 0 ==> no matrix) #"Matrixgg2 4096 1", # size and gain of g-g matrix for tracked and Doppler corrected gammas ( "" ) #"MatrixZYX f32 f32 i32 f32", # hits and intercepts: zOffset and zScale for hits; range and scale of z-planes #"OutputModel kSafe", # kStrict (default) kSafe kGrowing, behaviour for ADF #"Verbose", # more verbose terminal-output "NumGeDets 31", # Overrides the default number of Ge Crystals [20], just for printing of TkT spectra "SpecMap 0 0", # detID --> specID "SpecMap 1 1", # detID --> specID "SpecMap 2 2", "SpecMap 3 3", # detID --> specID "SpecMap 4 4", # detID --> specID "SpecMap 5 5", # detID --> specID "SpecMap 6 6", "SpecMap 7 7", "SpecMap 8 8", "SpecMap 9 9", "SpecMap 10 10", "SpecMap 11 11", "SpecMap 12 12", "SpecMap 13 13", "SpecMap 14 14", "SpecMap 15 15", "SpecMap 16 16", "SpecMap 17 17", "SpecMap 28 18", "SpecMap 29 19", "SpecMap 30 20", "SpecMap 31 21", "SpecMap 32 22", "SpecMap 33 23", "SpecMap 34 24", "SpecMap 35 25", "SpecMap 36 26", "SpecMap 37 27", "SpecMap 42 28", "SpecMap 43 29", "SpecMap 44 30", #When active with ancillary ######################33 #"KeepEmpty", # send to the adf output also events without gammas #"DiscardEmpty", # remove from the adf output events without gammas #"AncillaryRawFrame 0", # 0 (GSI) 0 (GANIL) 1 (LNL) default is 1 #"Ancillary", # to perform tracking only if ancillary data is present #"Recoiling", # Doppler shift correction to be done using event-by-event recoil direction from Ancillary #"TimeWindowGeAnc 650 670", # values should be taken from Oft__**__TA.spec #"TimeWindowGeAncillary 1110 1130", # variant of the previous #"WriteMgtData Ancillary Timing Extended", # enable writing Mgt_Hits.txt with ancillary,... data ) TrackingFilter_MERGER=( "ActualClass TrackingFilterOFT", # name of the used daugther class (TrackingFilterOFT or TrackingFilterMGT) "SaveDataDir $SAVEDIR/$MERGER", # Out/Global "ExcludeTracking", # skip the tracking part of the actor; remains only the data processing "WriteMgtData", # enable writing Mgt_Hits.txt (same as: WriteInputHits WriteMgtHits WriteOftHits) "NumGeDets 31", # Overrides the default number of Ge Crystals [20], just for printing of TkT spectra "SpecMap 0 0", # detID --> specID "SpecMap 1 1", # detID --> specID "SpecMap 2 2", "SpecMap 3 3", # detID --> specID "SpecMap 4 4", # detID --> specID "SpecMap 5 5", # detID --> specID "SpecMap 6 6", "SpecMap 7 7", "SpecMap 8 8", "SpecMap 9 9", "SpecMap 10 10", "SpecMap 11 11", "SpecMap 12 12", "SpecMap 13 13", "SpecMap 14 14", "SpecMap 15 15", "SpecMap 16 16", "SpecMap 17 17", "SpecMap 28 18", "SpecMap 29 19", "SpecMap 30 20", "SpecMap 31 21", "SpecMap 32 22", "SpecMap 33 23", "SpecMap 34 24", "SpecMap 35 25", "SpecMap 36 26", "SpecMap 37 27", "SpecMap 42 28", "SpecMap 43 29", "SpecMap 44 30", #"GroupNumDetsGate 1 1 1", #"GroupSumEnergyGate 1 1329 1336", #"GroupRemove 1", ) ######################### EventBuilder=( "ActualClass EventBuilder", # name of the used daugther class "SaveDataDir $SAVEDIR/$BUILDER", # Out/Builder "Window 30", # EventNumber also possible but not working well #"TstampWindow ui64 ui64", # coincidence window 'width' or 'from to' (timestamp units) "keyIn data:psa", # key of 1st queue. "keyIn data:psa", # key of 2nd queue. 'None' to not have the surrounding frame "keyOut event:data:psa", # key of the output frame default is event:data. 'None' to not have the surrounding frame "MinFold 1", # 2 if you want to force the coincidence between 2 AGATA #"TimestampCorrect 0 -128", # indexed by the input queue number !! #"TstampLimits ui32 ui32", # discard events outside this data-timestamp interval (seconds) #"TstampRegions ui64 ui64 str", # tStampMin, tStampStep, TxtFile with 0/1 for each timestamp step #"RateProfile ui64 ui64 i32", # tStampMin, tStampStep, Length of rate-profile spectrum #"Details 15 ", # bit1=tstamp_snapshot bit2=tstamp_diff for all input queues, bit3=TAC for all pairs "Verbose", # more verbose terminal-output ) ######################### ######################### EventMerger_MERGER=( "ActualClass EventMerger", # name of the used daugther class "SaveDataDir $SAVEDIR/$MERGER ", # Out/Merger "Window 30", # EventNumber also possible but not working well #"TstampWindow ui64 ui64", # coincidence window 'width' or 'from to' (timestamp units) "keyIn event:data:psa", # key of 1st queue. "keyIn data:ranc0", # key of 2nd queue. "keyOut event:data", # key of the output frame default is event:data. 'None' to not have the surrounding frame #"keyIn data:psa", # key of 1st queue. #"keyIn data:psa", # key of 2nd queue. 'None' to not have the surrounding frame #"keyOut event:data:psa", # key of the output frame default is event:data. 'None' to not have the surrounding frame "MinFold 1", # 2 if you want to force the coincidence between AGATA and the Ancillary #"TimestampCorrect 0 -128", # indexed by the input queue number !! #"TstampLimits ui32 ui32", # discard events outside this data-timestamp interval (seconds) #"TstampRegions ui64 ui64 str", # tStampMin, tStampStep, TxtFile with 0/1 for each timestamp step #"RateProfile ui64 ui64 i32", # tStampMin, tStampStep, Length of rate-profile spectrum #"Details i32 ", # bit1=tstamp_snapshot bit2=tstamp_diff for all input queues, bit3=TAC for all pairs "Verbose", # more verbose terminal-output ) ######################### BasicAFC_VAMOS=( "$SAVEDIR/$VAMOS vamos_ 0", # name of the final adf file "vamos_0000.adf" ) BasicAFP_VAMOS=( "$READDIR/$VAMOS vamos_ 0", # it reads adf file "vamos_0000.adf" ) BasicAFC_BUILDER=( # _BUILDER will be removed when building the name of the file "$SAVEDIR/$BUILDER Builder_ 0", # name of the final adf file "Builder_0000.adf" ) BasicAFC_MERGER=( # _MERGER will be removed when building the name of the file "$SAVEDIR/$MERGER Tracked_ 0", # name of the final adf file "Merger_0000.adf" ) BasicAFC_GLOBAL=( # _GLOBAL will be removed when building the name of the file "$SAVEDIR/$GLOBAL Tracked_ 0", # name of the final adf file "Tracked_0000.adf" ) BasicAFC=( "$SAVEDIR/$CRYSTAL psa_ 0", # name of the final adf file "Tracked_0000.adf" ) BasicAFP_CRYSTAL=( "$READDIR/$CRYSTAL psa_ 0", ) ################## ####### ############################################################################################### ################### 3 Database of AGATA germanium detectors ################################ ############################################################################################### # These values should be checked carefully against the detector configuration used to take the data GeDataBase2012_perf_com={ '00A': ['00', '$PSABASE/LibTrap_A001.dat'], '00B': ['01', '$PSABASE/LibTrap_B012.dat'], '00C': ['02', '$PSABASE/LibTrap_C010.dat'], '01A': ['03', '$PSABASE/LibTrap_A001.dat'], '01B': ['04', '$PSABASE/LibTrap_B012.dat'], '01C': ['05', '$PSABASE/LibTrap_C010.dat'], '04A': ['12', '$PSABASE/LibTrap_A001.dat'], '04B': ['13', '$PSABASE/LibTrap_B008.dat'], '04C': ['14', '$PSABASE/LibTrap_C006.dat'], '06A': ['18', '$PSABASE/LibTrap_A001.dat'], '06B': ['19', '$PSABASE/LibTrap_B012.dat'], '06C': ['20', '$PSABASE/LibTrap_C001.dat'], '12A': ['36', '$PSABASE/LibTrap_A008.dat'], '12B': ['37', '$PSABASE/LibTrap_B001.dat'], '12C': ['38', '$PSABASE/LibTrap_C003.dat'], '13A': ['39', '$PSABASE/LibTrap_A002.dat'], '13B': ['40', '$PSABASE/LibTrap_B010.dat'], '13C': ['41', '$PSABASE/LibTrap_C001.dat'], '14A': ['42', '$PSABASE/LibTrap_A002.dat'], '14B': ['43', '$PSABASE/LibTrap_B010.dat'], '14C': ['44', '$PSABASE/LibTrap_C001.dat'], } #This are the correct ones for the configuration of sep-oct 2012 in GSI, done the 21092012 GeDataBase2012_Oct={ '00A': ['00', '$PSABASE/LibTrap_A001.dat'], '00B': ['01', '$PSABASE/LibTrap_B011.dat'], '00C': ['02', '$PSABASE/LibTrap_C008.dat'], '01A': ['03', '$PSABASE/LibTrap_A001.dat'], '01B': ['04', '$PSABASE/LibTrap_B012.dat'], '01C': ['05', '$PSABASE/LibTrap_C010.dat'], '04A': ['12', '$PSABASE/LibTrap_A001.dat'], '04B': ['13', '$PSABASE/LibTrap_B008.dat'], '04C': ['14', '$PSABASE/LibTrap_C006.dat'], '06A': ['18', '$PSABASE/LibTrap_A001.dat'], '06B': ['19', '$PSABASE/LibTrap_B004.dat'], '06C': ['20', '$PSABASE/LibTrap_C001.dat'], '07A': ['21', '$PSABASE/LibTrap_A003.dat'], '07B': ['22', '$PSABASE/LibTrap_B003.dat'], '07C': ['23', '$PSABASE/LibTrap_C005.dat'], '12A': ['36', '$PSABASE/LibTrap_A008.dat'], '12B': ['37', '$PSABASE/LibTrap_B001.dat'], '12C': ['38', '$PSABASE/LibTrap_C003.dat'], '13A': ['39', '$PSABASE/LibTrap_A002.dat'], '13B': ['40', '$PSABASE/LibTrap_B010.dat'], '13C': ['41', '$PSABASE/LibTrap_C001.dat'], '14A': ['42', '$PSABASE/LibTrap_A004.dat'], '14B': ['43', '$PSABASE/LibTrap_B002.dat'], '14C': ['44', '$PSABASE/LibTrap_C004.dat'], '99A': ['33', '$PSABASE/LibTrap_A004.dat'], '99B': ['33', '$PSABASE/LibTrap_B002.dat'], '99C': ['33', '$PSABASE/LibTrap_C004.dat'], } #This are the configuration planned for the 2014 GSI runs GeDataBase2014={ '00A': ['00', '$PSABASE/LibTrap_A001.dat'], '00B': ['01', '$PSABASE/LibTrap_B011.dat'], '00C': ['02', '$PSABASE/LibTrap_C008.dat'], '01A': ['03', '$PSABASE/LibTrap_A001.dat'], '01B': ['04', '$PSABASE/LibTrap_B012.dat'], '01C': ['05', '$PSABASE/LibTrap_C010.dat'], '04A': ['12', '$PSABASE/LibTrap_A001.dat'], '04B': ['13', '$PSABASE/LibTrap_B008.dat'], '04C': ['14', '$PSABASE/LibTrap_C006.dat'], '05A': ['15', '$PSABASE/LibTrap_A004.dat'], '05B': ['16', '$PSABASE/LibTrap_B002.dat'], '05C': ['17', '$PSABASE/LibTrap_C004.dat'], '07A': ['21', '$PSABASE/LibTrap_A003.dat'], '07B': ['22', '$PSABASE/LibTrap_B003.dat'], '07C': ['23', '$PSABASE/LibTrap_C005.dat'], '12A': ['36', '$PSABASE/LibTrap_A001.dat'], '12B': ['37', '$PSABASE/LibTrap_B004.dat'], '12C': ['38', '$PSABASE/LibTrap_C099.dat'], '13A': ['39', '$PSABASE/LibTrap_A002.dat'], '13B': ['40', '$PSABASE/LibTrap_B010.dat'], '13C': ['41', '$PSABASE/LibTrap_C001.dat'], '14A': ['42', '$PSABASE/LibTrap_A007.dat'], '14B': ['43', '$PSABASE/LibTrap_B007.dat'], '14C': ['44', '$PSABASE/LibTrap_C007.dat'], '99A': ['33', '$PSABASE/LibTrap_A004.dat'], '99B': ['33', '$PSABASE/LibTrap_B002.dat'], '99C': ['33', '$PSABASE/LibTrap_C004.dat'], } #This are the configuration GANIL: DO NOT MODIFY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GeDataBaseGANIL={ '00A': ['00', '$PSABASE/LibTrap_A001.dat'], '00B': ['01', '$PSABASE/LibTrap_B004.dat'], '00C': ['02', '$PSABASE/LibTrap_C010.dat'], '02A': ['06', '$PSABASE/LibTrap_A009.dat'], '02B': ['07', '$PSABASE/LibTrap_B005.dat'], '02C': ['08', '$PSABASE/LibTrap_C008.dat'], '03A': ['09', '$PSABASE/LibTrap_A005.dat'], '03B': ['10', '$PSABASE/LibTrap_B002.dat'], '03C': ['11', '$PSABASE/LibTrap_C009.dat'], '04A': ['12', '$PSABASE/LibTrap_A008.dat'], '04B': ['13', '$PSABASE/LibTrap_B001.dat'], '04C': ['14', '$PSABASE/LibTrap_C003.dat'], '10A': ['30', '$PSABASE/LibTrap_A003.dat'], '10B': ['31', '$PSABASE/LibTrap_B003.dat'], '10C': ['32', '$PSABASE/LibTrap_C005.dat'], '11A': ['33', '$PSABASE/LibTrap_A006.dat'], '11B': ['34', '$PSABASE/LibTrap_B013.dat'], '11C': ['35', '$PSABASE/LibTrap_C006.dat'], '12A': ['36', '$PSABASE/LibTrap_A002.dat'], '12B': ['37', '$PSABASE/LibTrap_B010.dat'], '12C': ['38', '$PSABASE/LibTrap_C001.dat'], '13A': ['39', '$PSABASE/LibTrap_A007.dat'], '13B': ['40', '$PSABASE/LibTrap_B007.dat'], '13C': ['41', '$PSABASE/LibTrap_C007.dat'], '20A': ['02', '$PSABASE/LibTrap_C010.dat'], '20B': ['08', '$PSABASE/LibTrap_C008.dat'], } GeDataBaseGANIL2016={ #CM : C012 for 04C has to be changed with C013.... '00A': ['00', '$PSABASE/LibTrap_A001.dat'], '00B': ['01', '$PSABASE/LibTrap_B004.dat'], '00C': ['02', '$PSABASE/LibTrap_C010.dat'], '01A': ['03', '$PSABASE/LibTrap_A010.dat'], '01B': ['04', '$PSABASE/LibTrap_B012.dat'], '01C': ['05', '$PSABASE/LibTrap_C014.dat'], '02A': ['06', '$PSABASE/LibTrap_A009.dat'], '02B': ['07', '$PSABASE/LibTrap_B005.dat'], '02C': ['08', '$PSABASE/LibTrap_C008.dat'], '03A': ['09', '$PSABASE/LibTrap_A005.dat'], '03B': ['10', '$PSABASE/LibTrap_B002.dat'], '03C': ['11', '$PSABASE/LibTrap_C009.dat'], '04A': ['12', '$PSABASE/LibTrap_A004.dat'], '04B': ['13', '$PSABASE/LibTrap_B008.dat'], '04C': ['14', '$PSABASE/LibTrap_C012.dat'], '05A': ['15', '$PSABASE/LibTrap_A011.dat'], '05B': ['16', '$PSABASE/LibTrap_B006.dat'], '05C': ['17', '$PSABASE/LibTrap_C012.dat'], '09B': ['28', '$PSABASE/LibTrap_B011.dat'], '09C': ['29', '$PSABASE/LibTrap_C011.dat'], '10A': ['30', '$PSABASE/LibTrap_A003.dat'], '10B': ['31', '$PSABASE/LibTrap_B003.dat'], '10C': ['32', '$PSABASE/LibTrap_C005.dat'], '11A': ['33', '$PSABASE/LibTrap_A006.dat'], '11B': ['34', '$PSABASE/LibTrap_B013.dat'], '11C': ['35', '$PSABASE/LibTrap_C006.dat'], '12A': ['36', '$PSABASE/LibTrap_A002.dat'], '12B': ['37', '$PSABASE/LibTrap_B010.dat'], '12C': ['38', '$PSABASE/LibTrap_C001.dat'], '13A': ['39', '$PSABASE/LibTrap_A007.dat'], '13B': ['40', '$PSABASE/LibTrap_B007.dat'], '13C': ['41', '$PSABASE/LibTrap_C007.dat'], '14A': ['42', '$PSABASE/LibTrap_A012.dat'], '14B': ['43', '$PSABASE/LibTrap_B009.dat'], '14C': ['44', '$PSABASE/LibTrap_C004.dat'], } GeDataBaseGANIL2017={ '00A': ['00', '$PSABASE/LibTrap_A001.dat'], '00B': ['01', '$PSABASE/LibTrap_B004.dat'], '00C': ['02', '$PSABASE/LibTrap_C010.dat'], '01A': ['03', '$PSABASE/LibTrap_A012.dat'], '01B': ['04', '$PSABASE/LibTrap_B009.dat'], '01C': ['05', '$PSABASE/LibTrap_C004.dat'], '02A': ['06', '$PSABASE/LibTrap_A009.dat'], '02B': ['07', '$PSABASE/LibTrap_B005.dat'], '02C': ['08', '$PSABASE/LibTrap_C008.dat'], '03A': ['09', '$PSABASE/LibTrap_A005.dat'], '03B': ['10', '$PSABASE/LibTrap_B002.dat'], '03C': ['11', '$PSABASE/LibTrap_C009.dat'], '04A': ['12', '$PSABASE/LibTrap_A004.dat'], '04B': ['13', '$PSABASE/LibTrap_B008.dat'], '04C': ['14', '$PSABASE/LibTrap_C002.dat'], '05A': ['15', '$PSABASE/LibTrap_A011.dat'], '05B': ['16', '$PSABASE/LibTrap_B006.dat'], '05C': ['17', '$PSABASE/LibTrap_C012.dat'], '09B': ['28', '$PSABASE/LibTrap_B011.dat'], '09C': ['29', '$PSABASE/LibTrap_C011.dat'], '10A': ['30', '$PSABASE/LibTrap_A003.dat'], '10B': ['31', '$PSABASE/LibTrap_B003.dat'], '10C': ['32', '$PSABASE/LibTrap_C005.dat'], '11A': ['33', '$PSABASE/LibTrap_A006.dat'], '11B': ['34', '$PSABASE/LibTrap_B013.dat'], '11C': ['35', '$PSABASE/LibTrap_C006.dat'], '12A': ['36', '$PSABASE/LibTrap_A010.dat'], '12B': ['37', '$PSABASE/LibTrap_B012.dat'], '12C': ['38', '$PSABASE/LibTrap_C014.dat'], '13A': ['39', '$PSABASE/LibTrap_A007.dat'], '13B': ['40', '$PSABASE/LibTrap_B007.dat'], '13C': ['41', '$PSABASE/LibTrap_C007.dat'], '14A': ['42', '$PSABASE/LibTrap_A014.dat'], '14B': ['43', '$PSABASE/LibTrap_B016.dat'], '14C': ['44', '$PSABASE/LibTrap_C016.dat'], } GeDataBase = GeDataBaseGANIL2017 ############################################################################################### ###### Code to generate directories and files. You should not need to modify this part. ##### ############################################################################################### import os.path import shutil import sys import optparse verbose = False verbstr = "" def getGeData(cr): """ get data of crystal cr from GeDataBase """ if cr in GeDataBase: if GeDataBase[cr] != ['','']: return GeDataBase[cr] else: print 'GeDataBase for',cr,'is empty' sys.exit(-1) else: print cr, ' is not in GeDataBase' sys.exit(-1) def replaceMacros(ss, cr): """ replace macros (as defined in MACROS) in string ss. If cr is a Ge crystal (e.g. 1R), its data ($CRYSTAL_ID and $SIGNAL_BASIS are extracted from GeDataBase and replaced before checking MACRO """ if (len(cr) == 2 or len(cr)==3): # 2 characters for the ge crystals dd = getGeData(cr) ll = ss.replace("$CRYSTAL_ID", dd[0]) ll = ll.replace("$SIGNAL_BASIS", dd[1]) ll = ll.replace("$CRYSTAL", cr) else: ll = ss for mm in MACROS: ll = ll.replace(mm, MACROS[mm]) return ll def printItem(vv, cc, ff): """ item vv relative to the chain cc is printed to file ff, after macro replacement. If vv is a tuple or a list, its components are printed in separate lines """ if isinstance(vv, list) or isinstance(vv, tuple): # multi line: recursively call printItem for the elements for vi in vv: printItem(vi, cc, ff) else: # single line: replace macros and print it ll = replaceMacros(vv, cc) if CONFTYPE != 'ONLINE' or ll.find('ReadDataDir')!=0: ff.write(ll+os.linesep) #print ll+os.linesep def printActor(vv, cc, ff): """ print the command lines in vv to file ff of analysis chain cc """ global verbstr #import pdb; pdb.set_trace() if len(ff) < 1: return if os.path.exists(ff): if verbose: print " Replaced ", ff else: verbstr += "." else: print " Created ", ff with open(ff, "w") as fi: for vi in vv: if isinstance(vi, dict): if cc in vi: # dictionary refers to the present detector printItem(vi[cc], cc, fi) else: # common item printItem(vi, cc, fi) def checkMakeDirs(dd): """ created sub-directory dd in $CONFDIR, $READDIR and $SAVEDIR """ for cc in ['$CONFDIR', '$READDIR', '$SAVEDIR']: if cc in MACROS: ff = os.path.join(MACROS[cc], dd) if os.path.exists(ff) == False: print 'Creating ', ff os.makedirs(ff) def makeFileName(pre, cc, aa, topo): """ generate the actual name of the configuration file pre/cc/aa if the generated filename contains "_topo" this part is removed """ #import pdb; pdb.set_trace() if PROGTYPE == "NARVAL" : if aa == "EventBuilder" or aa == "EventMerger" : print (" "+aa+".conf").ljust(18), "not generated when using NARVAL" return "" ff = os.path.join(pre, cc, aa+'.conf') ff = ff.replace('_'+topo, '') return ff def checkExtraFiles(new, old, dd, files): """ check existence of the files defined in ExtraFiles. Try to copy it from oldDir if file not present and the script is launched with "-o oldDir" """ global verbstr newDir = os.path.join(new, dd) oldDir = os.path.join(old, dd) for f in files.split(): fff = os.path.join(newDir, f) ff = replaceMacros(fff, dd) if os.path.exists(ff): if verbose: print " Existing ", ff else: verbstr += "." else: if old != "": gg = os.path.join(oldDir, f) if os.path.exists(gg): if os.path.isdir(gg): shutil.copytree(gg, ff) else: shutil.copy(gg, ff) print " Copied ", gg if not os.path.exists(ff): print " Missing ", ff def checkArgsAndMacros(): """ decode command line arguments and perform some consistency checks on PROGTYPE and CONFTYPE """ parser = optparse.OptionParser() parser.add_option("-o", "--old", dest="confold", help="old Conf where to look for missing auxiliary files", metavar="DIR") parser.add_option("-d", "--dir", dest="workdir", help="the directory where to generate the analysis structure", metavar="DIR") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbosity of printouts") (options, args) = parser.parse_args() #print 'confold = ', options.confold #print 'workdir = ', options.workdir #print 'verbose = ', options.verbose global verbose verbose = options.verbose if options.workdir is None: CWD = os.getcwd() else: CWD = options.workdir global PROGTYPE, CONFTYPE if PROGTYPE != 'NARVAL': CONFTYPE = 'OFFLINE' if CONFTYPE == 'ONLINE': CWD = os.getcwd() for cc in ['$CONFDIR', '$READDIR', '$SAVEDIR']: if cc in MACROS: MACROS[cc] = os.path.join(CWD, MACROS[cc]) if CONFTYPE == 'ONLINE': MACROS['$SAVEDIR'] = MACROS['$READDIR'] del MACROS['$READDIR'] print print 'CWD '.ljust(10), " --> ", CWD print 'PROGTYPE'.ljust(10), " --> ", PROGTYPE print 'CONFTYPE'.ljust(10), " --> ", CONFTYPE for a in MACROS: if MACROS[a] != '': print a.ljust(10), " --> ", MACROS[a] print newPrefix = MACROS['$CONFDIR'] if options.confold is None: oldPrefix = '' else: oldPrefix = options.confold return newPrefix, oldPrefix def main(): """ """ (newConf, oldConf) = checkArgsAndMacros() print "newConf = ", newConf print "oldConf = ", oldConf print global verbstr myGlobals = globals() for topo in Topology: block = Topology[topo] if isinstance(block, dict): dire = block.split() else: dire = block; for dd in dire.split(): checkMakeDirs(dd) if topo in Actors: print dd+'/' verbstr = "" actor = Actors[topo].split() for aa in actor: ff = makeFileName(newConf, dd, aa, topo) printActor(myGlobals[aa], dd, ff) if topo in ExtraFiles: checkExtraFiles(newConf, oldConf, dd, ExtraFiles[topo]) if verbstr: print " " + verbstr ############################################################################################### ############################################################################################### if __name__ == "__main__": main()