diff --git a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py index aa6e8143f3f3ec00b56131004af2123f1e42a5b9..f0fa35b4aaa071c3a0e699e74f8a949a8f7765c9 100755 --- a/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py +++ b/Control/CalypsoExample/Reconstruction/scripts/faser_reco.py @@ -7,9 +7,11 @@ # filepath - fully qualified path, including url if needed, to the input raw data file # example: "root://hepatl30//atlas/local/torrence/faser/commissioning/TestBeamData/Run-004150/Faser-Physics-004150-00000.raw" # -# runtype - optional flag to specify the data type (TI12Data or TestBeamData). +# runtype - optionally specify the data type (TI12Data, TI12Data02, or TestBeamData). # In a normal file system location, this will be extracted from the directory name, # but runtype will override this assignment. +# TI12Data02 is needed for the IFT geometry. Script will auto-detect this if read +# from normal file system location. # import sys import argparse @@ -26,6 +28,8 @@ parser.add_argument("-n", "--nevents", type=int, default=-1, help="Specify number of events to process (default: all)") parser.add_argument("-v", "--verbose", action='store_true', help="Turn on DEBUG output") +parser.add_argument("--clusterFit", action='store_true', + help="Use ClusterFit (old) track finder - default: SegmentFit(new)") args = parser.parse_args() @@ -47,6 +51,23 @@ else: runtype = filepath.parts[-3] + # Fix TI12 geometry versions as well (needed in production) + # Probably better to do this from configuration in upstream production scripts, + # so lets call this a hack for now + if runtype == "TI12Data": + + runname = filepath.parts[-2] + try: + runnumber = int(runname.split('-')[1]) + except Exception as e: + print(f"Failed to find run number in {filepath}") + print(f"Couldn't parse {runname}") + print(f"Leave runtype as {runtype}!") + else: + if runnumber > 5302: # Last TI12 run on Nov. 23, 2021 without IFT + print(f"Found run number {runnumber}, using TI12 configuration with IFT") + runtype = "TI12Data02" + print(f"Starting reconstruction of {filepath.name} with type {runtype}") if args.nevents > 0: print(f"Reconstructing {args.nevents} events by command-line option") @@ -140,9 +161,18 @@ acc.merge(FaserSCT_ClusterizationCfg(ConfigFlags)) from TrackerSpacePointFormation.TrackerSpacePointFormationConfig import TrackerSpacePointFinderCfg acc.merge(TrackerSpacePointFinderCfg(ConfigFlags)) -# Try Dave's fitter -from TrackerClusterFit.TrackerClusterFitConfig import ClusterFitAlgCfg -acc.merge(ClusterFitAlgCfg(ConfigFlags)) +# Can't use both in the same job, as they write to the same output histograms +if args.clusterFit: + print("Configuring TrackerClusterFit (old)") + # Try Dave's fitter + from TrackerClusterFit.TrackerClusterFitConfig import ClusterFitAlgCfg + acc.merge(ClusterFitAlgCfg(ConfigFlags)) + +else: + print("Configuring TrackerSegmentFit (new)") + # Try Dave's new fitter + from TrackerSegmentFit.TrackerSegmentFitConfig import SegmentFitAlgCfg + acc.merge(SegmentFitAlgCfg(ConfigFlags)) # # Configure output diff --git a/Waveform/WaveEventCnv/WaveByteStream/python/WaveByteStreamConfig.py b/Waveform/WaveEventCnv/WaveByteStream/python/WaveByteStreamConfig.py index cc13137d8e59eef7801d0ffa8fa60230721b372f..840a4d0f091a7e195f4e40f818c2b0b99c0b346b 100644 --- a/Waveform/WaveEventCnv/WaveByteStream/python/WaveByteStreamConfig.py +++ b/Waveform/WaveEventCnv/WaveByteStream/python/WaveByteStreamConfig.py @@ -37,6 +37,17 @@ def WaveByteStreamCfg(configFlags, **kwargs): waveform_tool.PreshowerChannels = [12, 13] acc.addPublicTool(waveform_tool) + elif configFlags.GeoModel.FaserVersion == "FASER-02": + print(" - setting up TI12 with IFT detector") + + # Need to fix this! + waveform_tool = CompFactory.RawWaveformDecoderTool("RawWaveformDecoderTool") + waveform_tool.CaloChannels = [1, 0, 3, 2] + waveform_tool.VetoChannels = [4, 5, 6, 7] + waveform_tool.TriggerChannels = [9, 8, 11, 10] + waveform_tool.PreshowerChannels = [12, 13] + acc.addPublicTool(waveform_tool) + else: print(" - unknown version: user must set up Waveform channel mapping by hand!") diff --git a/Waveform/WaveRecTools/src/ClockReconstructionTool.cxx b/Waveform/WaveRecTools/src/ClockReconstructionTool.cxx index aaae0861b6fab59b7144afedb72797ad9da91f86..c45ea51007362eecd0ab7827f50123c05ddebab7 100644 --- a/Waveform/WaveRecTools/src/ClockReconstructionTool.cxx +++ b/Waveform/WaveRecTools/src/ClockReconstructionTool.cxx @@ -79,8 +79,8 @@ ClockReconstructionTool::reconstruct(const RawWaveform& raw_wave, // Get the coefficients std::vector<double> re_full(N); std::vector<double> im_full(N); - std::vector<double> magnitude(N/2); - fftr2c->GetPointsComplex(&re_full[0],&im_full[0]); + std::vector<double> magnitude(N/2+1); // From fftw manual, output array is N/2+1 long + fftr2c->GetPointsComplex(&re_full[0], &im_full[0]); // Normalize the magnitude (just using the positive complex frequencies) unsigned int i=0; @@ -106,7 +106,7 @@ ClockReconstructionTool::reconstruct(const RawWaveform& raw_wave, clockdata->set_dc_offset(magnitude[0]); clockdata->set_frequency(imax * freqmult); clockdata->set_amplitude(magnitude[imax]); - clockdata->set_phase(atan2(im_full[imax], re_full[imax])); + clockdata->set_phase(atan2(im_full[imax], re_full[imax])); // Not a bug, atan2(y,x)! ATH_MSG_DEBUG("Before correcting for finite resolution:"); ATH_MSG_DEBUG(*clockdata); @@ -125,10 +125,11 @@ ClockReconstructionTool::reconstruct(const RawWaveform& raw_wave, // Improved values + // Not a bug, atan2(y,x)! double phase = atan2(im_full[imax], re_full[imax]) - dm * M_PI; - // Fix any overflows - if (phase < M_PI) phase += (2*M_PI); - if (phase > M_PI) phase -= (2*M_PI); + // Fix any overflows caused by adding dm + if (phase < -M_PI) phase += (2*M_PI); + if (phase > +M_PI) phase -= (2*M_PI); clockdata->set_frequency( (imax+dm) * freqmult ); clockdata->set_phase (phase);