diff --git a/Detectors/TRD/CMakeLists.txt b/Detectors/TRD/CMakeLists.txt index 97f3ae0f4f3f7..6adbc1c43d277 100644 --- a/Detectors/TRD/CMakeLists.txt +++ b/Detectors/TRD/CMakeLists.txt @@ -9,6 +9,7 @@ # submit itself to any jurisdiction. add_subdirectory(base) +add_subdirectory(calibration) add_subdirectory(simulation) add_subdirectory(reconstruction) add_subdirectory(macros) diff --git a/Detectors/TRD/calibration/CMakeLists.txt b/Detectors/TRD/calibration/CMakeLists.txt new file mode 100644 index 0000000000000..140fc15b6b96e --- /dev/null +++ b/Detectors/TRD/calibration/CMakeLists.txt @@ -0,0 +1,18 @@ +#Copyright CERN and copyright holders of ALICE O2.This software is distributed +#under the terms of the GNU General Public License v3(GPL Version 3), copied +#verbatim in the file "COPYING". +# +#See http: //alice-o2.web.cern.ch/license for full licensing information. +# +#In applying this license CERN does not waive the privileges and immunities +#granted to it by virtue of its status as an Intergovernmental Organization or +#submit itself to any jurisdiction. + +o2_add_library(TRDCalibration + SOURCES src/CalibVDrift.cxx + PUBLIC_LINK_LIBRARIES O2::TRDBase + O2::DataFormatsTRD + O2::GPUTracking) + + o2_target_root_dictionary(TRDCalibration + HEADERS include/TRDCalibration/CalibVDrift.h) diff --git a/Detectors/TRD/calibration/include/TRDCalibration/CalibVDrift.h b/Detectors/TRD/calibration/include/TRDCalibration/CalibVDrift.h new file mode 100644 index 0000000000000..7b107fa6a3e7e --- /dev/null +++ b/Detectors/TRD/calibration/include/TRDCalibration/CalibVDrift.h @@ -0,0 +1,55 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef ALICEO2_TRD_CALIBVDRIFT_H_ +#define ALICEO2_TRD_CALIBVDRIFT_H_ + +/// \file CalibVDrift.h +/// \author Ole Schmidt, ole.schmidt@cern.ch + +#include "GPUO2Interface.h" +#include "GPUTRDSpacePointInternal.h" // FIXME: replace with actual data type + +namespace o2 +{ +namespace trd +{ + +/// \brief VDrift calibration class +/// +/// This class is used to determine chamber-wise vDrift values +/// +/// origin: TRD +/// \author Ole Schmidt, ole.schmidt@cern.ch + +class CalibVDrift +{ + public: + /// default constructor + CalibVDrift() = default; + + /// default destructor + ~CalibVDrift() = default; + + /// set input angular deviations + void setAngDevInp(const std::vector input) { mAngulerDeviationProf = input; } + + /// main processing function + void process(); + + private: + //FIXME: replace GPUTRDSpacePointInternal with the type Sven creates for collecting the angular deviations + std::vector mAngulerDeviationProf; ///< input TRD track to tracklet angular deviations +}; + +} // namespace trd + +} // namespace o2 +#endif diff --git a/Detectors/TRD/calibration/src/CalibVDrift.cxx b/Detectors/TRD/calibration/src/CalibVDrift.cxx new file mode 100644 index 0000000000000..0c691c2b190a2 --- /dev/null +++ b/Detectors/TRD/calibration/src/CalibVDrift.cxx @@ -0,0 +1,37 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file CalibVDrift.cxx +/// \author Ole Schmidt, ole.schmidt@cern.ch + +#include "TFile.h" +#include "TH2F.h" + +#include + +#include "TRDCalibration/CalibVDrift.h" + +using namespace o2::trd; + +void CalibVDrift::process() +{ + LOG(info) << "Started processing for vDrift calibration"; + + // as an example I loop over the input, create a histogram and write it to a file + auto fOut = TFile::Open("trdcalibdummy.root", "recreate"); + auto hXY = std::make_unique("histDummy", "foo", 100, -60, 60, 100, 250, 400); // xy distribution of TRD space points + for (int i = 0; i < mAngulerDeviationProf.size(); ++i) { + hXY->Fill(mAngulerDeviationProf[i].mX[0], mAngulerDeviationProf[i].mR); + } + fOut->cd(); + hXY->Write(); + hXY.reset(); // delete the histogram before closing the output file + fOut->Close(); +} diff --git a/Detectors/TRD/calibration/src/TRDCalibrationLinkDef.h b/Detectors/TRD/calibration/src/TRDCalibrationLinkDef.h new file mode 100644 index 0000000000000..6f10a82a50b64 --- /dev/null +++ b/Detectors/TRD/calibration/src/TRDCalibrationLinkDef.h @@ -0,0 +1,19 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::trd::CalibVDrift + ; + +#endif diff --git a/Detectors/TRD/workflow/CMakeLists.txt b/Detectors/TRD/workflow/CMakeLists.txt index 589932309585b..402102d857b2e 100644 --- a/Detectors/TRD/workflow/CMakeLists.txt +++ b/Detectors/TRD/workflow/CMakeLists.txt @@ -25,8 +25,8 @@ o2_add_library(TRDWorkflow src/TRDTrackWriterSpec.cxx src/TRDTrackingWorkflow.cxx src/EntropyDecoderSpec.cxx - src/EntropyEncoderSpec.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DPLUtils O2::Steer O2::Algorithm O2::DataFormatsTRD O2::TRDSimulation O2::TRDReconstruction O2::DetectorsBase O2::SimulationDataFormat O2::TRDBase O2::GPUTracking O2::GlobalTrackingWorkflow) + src/EntropyEncoderSpec.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DPLUtils O2::Steer O2::Algorithm O2::DataFormatsTRD O2::TRDSimulation O2::TRDReconstruction O2::DetectorsBase O2::SimulationDataFormat O2::TRDBase O2::TRDCalibration O2::GPUTracking O2::GlobalTrackingWorkflow) #o2_target_root_dictionary(TRDWorkflow # HEADERS include/TRDWorkflow/TRDTrapSimulatorSpec.h) diff --git a/Detectors/TRD/workflow/include/TRDWorkflow/TRDGlobalTrackingSpec.h b/Detectors/TRD/workflow/include/TRDWorkflow/TRDGlobalTrackingSpec.h index 3613cf620ca15..ec7bb972b8bec 100644 --- a/Detectors/TRD/workflow/include/TRDWorkflow/TRDGlobalTrackingSpec.h +++ b/Detectors/TRD/workflow/include/TRDWorkflow/TRDGlobalTrackingSpec.h @@ -17,6 +17,7 @@ #include "Framework/Task.h" #include "TStopwatch.h" #include "TRDBase/GeometryFlat.h" +#include "TRDCalibration/CalibVDrift.h" #include "GPUO2Interface.h" #include "GPUTRDTracker.h" @@ -41,6 +42,7 @@ class TRDGlobalTracking : public o2::framework::Task std::unique_ptr mFlatGeo{nullptr}; ///< flat TRD geometry bool mUseMC{false}; ///< MC flag bool mUseTrackletTransform{false}; ///< if true, output from TrackletTransformer is used instead of uncalibrated Tracklet64 directly + CalibVDrift mCalibVDrift{}; ///< steers the vDrift calibration TStopwatch mTimer; }; diff --git a/Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx b/Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx index 57a79011f8bb8..6f4b551e548b9 100644 --- a/Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx +++ b/Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx @@ -68,6 +68,7 @@ void TRDGlobalTracking::init(InitContext& ic) mTracker->SetProcessPerTimeFrame(); mTracker->SetNMaxCollisions(mRec->GetProcessingSettings().trdNMaxCollisions); mTracker->SetTrkltTransformNeeded(!mUseTrackletTransform); + mTracker->SetDoImpactAngleHistograms(true); mRec->RegisterGPUProcessor(mTracker, false); mChainTracking->SetTRDGeometry(std::move(mFlatGeo)); @@ -171,11 +172,19 @@ void TRDGlobalTracking::run(ProcessingContext& pc) mTracker->SetTriggerRecordIndices(&(trdTriggerIndices[0])); mTracker->SetNCollisions(nCollisions); //mTracker->DumpTracks(); + mTracker->ResetImpactAngleHistograms(); mTracker->DoTracking(mChainTracking); //mTracker->DumpTracks(); std::vector tracksOut(mTracker->NTracks()); std::copy(mTracker->Tracks(), mTracker->Tracks() + mTracker->NTracks(), tracksOut.begin()); + + // FIXME instead of the space points we need to get the profile 'histograms' here + std::vector spacePointsOut(mTracker->NTracklets()); + std::copy(mTracker->SpacePoints(), mTracker->SpacePoints() + mTracker->NTracklets(), spacePointsOut.begin()); + mCalibVDrift.setAngDevInp(spacePointsOut); + mCalibVDrift.process(); + pc.outputs().snapshot(Output{o2::header::gDataOriginTRD, "MATCHTRD", 0, Lifetime::Timeframe}, tracksOut); mTimer.Stop(); diff --git a/GPU/GPUTracking/CMakeLists.txt b/GPU/GPUTracking/CMakeLists.txt index 2d50bac291cb1..66772b5d0d437 100644 --- a/GPU/GPUTracking/CMakeLists.txt +++ b/GPU/GPUTracking/CMakeLists.txt @@ -110,7 +110,7 @@ set(HDRS_INSTALL TRDTracking/GPUTRDTrackPoint.h TRDTracking/GPUTRDTrack.h TRDTracking/GPUTRDTrackData.h - TRDTracking/GPUTRDTrackPoint.h + TRDTracking/GPUTRDSpacePointInternal.h TRDTracking/GPUTRDTrackletLabels.h Base/GPUReconstructionIncludes.h SliceTracker/GPUTPCDef.h diff --git a/GPU/GPUTracking/TRDTracking/GPUTRDAngularResiduals.h b/GPU/GPUTracking/TRDTracking/GPUTRDAngularResiduals.h new file mode 100644 index 0000000000000..06a1f9b5dc957 --- /dev/null +++ b/GPU/GPUTracking/TRDTracking/GPUTRDAngularResiduals.h @@ -0,0 +1,36 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GPUTRDAngularResiduals.h +/// \brief This data structure stores the angular residuals between the TRD tracks and their tracklets + +/// \author Sven Hoppner +// \E-Mail sven.hoppner@cern.ch + +#include "GPUCommonDef.h" + +namespace GPUCA_NAMESPACE +{ +namespace gpu +{ + +struct AngularResiduals { + //float mImpactAngle; // Impact Angle of track + unsigned short mTrackletCounter; //counter of the tracklets + float mAngleDiffSum; //Sum of Angle Difference of tracklet to track for each bin + //short mDetectorId; // Detector index + + GPUd() AngularResiduals() : mTrackletCounter(0), mAngleDiffSum(0) + { + } +}; + +} // namespace gpu +} // namespace GPUCA_NAMESPACE diff --git a/GPU/GPUTracking/TRDTracking/GPUTRDInterfaces.h b/GPU/GPUTracking/TRDTracking/GPUTRDInterfaces.h index f6d71d93c60f6..e5a234d6b6eca 100644 --- a/GPU/GPUTracking/TRDTracking/GPUTRDInterfaces.h +++ b/GPU/GPUTracking/TRDTracking/GPUTRDInterfaces.h @@ -301,7 +301,7 @@ class trackInterface : public GPUTPCGMTrackParam GPUd() const float* getPar() const { return GetPar(); } GPUd() const float* getCov() const { return GetCov(); } GPUd() float getTime() const { return -1.f; } - + GPUd() void resetCovariance(float s) { ResetCovariance(); } GPUd() void setAlpha(float alpha) { mAlpha = alpha; } GPUd() void set(float x, float alpha, const float param[5], const float cov[15]) { diff --git a/GPU/GPUTracking/TRDTracking/GPUTRDSpacePointInternal.h b/GPU/GPUTracking/TRDTracking/GPUTRDSpacePointInternal.h new file mode 100644 index 0000000000000..51a16e6ef5697 --- /dev/null +++ b/GPU/GPUTracking/TRDTracking/GPUTRDSpacePointInternal.h @@ -0,0 +1,47 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GPUTRDSpacePointInternal.h +/// \brief This data structure stores the TRD space point used internally by the tracking code + +/// \author Ole Schmidt + +#ifndef GPUTRDSPACEPOINTINTERNAL_H +#define GPUTRDSPACEPOINTINTERNAL_H + +#include "GPUCommonDef.h" + +namespace GPUCA_NAMESPACE +{ +namespace gpu +{ + +// struct to hold the information on the space points +struct GPUTRDSpacePointInternal { + float mR; // x position (3.5 mm above anode wires) - radial offset due to t0 mis-calibration, measured -1 mm for run 245353 + float mX[2]; // y and z position (sector coordinates) + float mDy; // deflection over drift length + unsigned short mVolumeId; // basically derived from TRD chamber number + GPUd() GPUTRDSpacePointInternal(float x, float y, float z, float dy) : mR(x), mDy(dy), mVolumeId(0) + { + mX[0] = y; + mX[1] = z; + } + GPUd() GPUTRDSpacePointInternal() : mR(0), mDy(0), mVolumeId(0) + { + mX[0] = 0; + mX[1] = 0; + } +}; + +} // namespace gpu +} // namespace GPUCA_NAMESPACE + +#endif // GPUTRDSPACEPOINTINTERNAL_H diff --git a/GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx b/GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx index 3471036b8e6d3..266d11d4b99f8 100644 --- a/GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx +++ b/GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx @@ -75,6 +75,8 @@ void* GPUTRDTracker_t::SetPointersBase(void* base) computePointerWithAlignment(base, mTrackletIndexArray, (kNChambers + 1) * mNMaxCollisions); computePointerWithAlignment(base, mHypothesis, mNCandidates * mMaxThreads); computePointerWithAlignment(base, mCandidates, mNCandidates * 2 * mMaxThreads); + computePointerWithAlignment(base, mAngleDiffvsImpactAngleGlobal, kNChambers * (mNAngleHistogramBins + 1)); + return base; } @@ -103,7 +105,7 @@ void* GPUTRDTracker_t::SetPointersTracks(void* base) } template -GPUTRDTracker_t::GPUTRDTracker_t() : mR(nullptr), mIsInitialized(false), mTrkltTransfNeeded(true), mProcessPerTimeFrame(false), mMemoryPermanent(-1), mMemoryTracklets(-1), mMemoryTracks(-1), mNMaxCollisions(1), mNMaxTracks(0), mNMaxSpacePoints(0), mTracks(nullptr), mNCandidates(1), mNCollisions(1), mNTracks(0), mNEvents(0), mTriggerRecordIndices(nullptr), mTriggerRecordTimes(nullptr), mTracklets(nullptr), mTrackletIndices(nullptr), mMaxThreads(100), mNTracklets(0), mTrackletIndexArray(nullptr), mHypothesis(nullptr), mCandidates(nullptr), mSpacePoints(nullptr), mTrackletLabels(nullptr), mGeo(nullptr), mRPhiA2(0), mRPhiB(0), mRPhiC2(0), mDyA2(0), mDyB(0), mDyC2(0), mAngleToDyA(0), mAngleToDyB(0), mAngleToDyC(0), mDebugOutput(false), mTimeWindow(.1f), mRadialOffset(-0.1), mMaxEta(0.84f), mExtraRoadY(2.f), mRoadZ(18.f), mZCorrCoefNRC(1.4f), mMCEvent(nullptr), mDebug(new GPUTRDTrackerDebug()) +GPUTRDTracker_t::GPUTRDTracker_t() : mR(nullptr), mIsInitialized(false), mTrkltTransfNeeded(true), mDoImpactAngleHistograms(false), mProcessPerTimeFrame(false), mMemoryPermanent(-1), mMemoryTracklets(-1), mMemoryTracks(-1), mNMaxCollisions(1), mNMaxTracks(0), mNMaxSpacePoints(0), mTracks(nullptr), mNCandidates(1), mNCollisions(1), mNTracks(0), mNEvents(0), mTriggerRecordIndices(nullptr), mTriggerRecordTimes(nullptr), mTracklets(nullptr), mTrackletIndices(nullptr), mMaxThreads(100), mNTracklets(0), mTrackletIndexArray(nullptr), mHypothesis(nullptr), mNAngleHistogramBins(25), mAngleHistogramRange(50), mCandidates(nullptr), mSpacePoints(nullptr), mTrackletLabels(nullptr), mGeo(nullptr), mRPhiA2(0), mRPhiB(0), mRPhiC2(0), mDyA2(0), mDyB(0), mDyC2(0), mAngleToDyA(0), mAngleToDyB(0), mAngleToDyC(0), mDebugOutput(false), mTimeWindow(.1f), mRadialOffset(-0.1), mMaxEta(0.84f), mExtraRoadY(2.f), mRoadZ(18.f), mZCorrCoefNRC(1.4f), mMCEvent(nullptr), mDebug(new GPUTRDTrackerDebug()) { //-------------------------------------------------------------------- // Default constructor @@ -250,7 +252,7 @@ void GPUTRDTracker_t::DoTracking(GPUChainTracking* chainTracking) } auto timeStart = std::chrono::high_resolution_clock::now(); - + printf("NumberOfTracks:%d\n", mNTracks); if (mRec->GetRecoStepsGPU() & GPUDataTypes::RecoStep::TRDTracking) { chainTracking->DoTRDGPUTracking(); } else { @@ -271,7 +273,18 @@ void GPUTRDTracker_t::DoTracking(GPUChainTracking* chainTracking) } #endif } + printf("================================\nNOWdoTRACKINGfor%dTracks\n", mNTracks); + if (mDoImpactAngleHistograms) { + for (int iTrk = 0; iTrk < mNTracks; ++iTrk) { + if (mTracks[iTrk].GetNtracklets() > 3) { + PROP prop(&Param().polynomialField); + auto trkCopy = mTracks[iTrk]; + //if(mDoImpactAngleHistograms && trkCopy->GetNtracklets()>3 ){ + DoImpactAngleHistograms(&prop, &trkCopy); + } + } + } auto duration = std::chrono::high_resolution_clock::now() - timeStart; (void)duration; // suppress warning about unused variable /* @@ -605,6 +618,119 @@ GPUd() bool GPUTRDTracker_t::CalculateSpacePoints(int iCollision) } return result; } +template +GPUd() void GPUTRDTracker_t::ResetImpactAngleHistograms() +{ + for (int i = 0; i < kNChambers * (mNAngleHistogramBins + 1); i++) { + mAngleDiffvsImpactAngleGlobal[i].mAngleDiffSum = 0; + mAngleDiffvsImpactAngleGlobal[i].mTrackletCounter = 0; + } +} + +template +GPUd() void GPUTRDTracker_t::DoImpactAngleHistograms(PROP* prop, TRDTRK* t) +{ + //mDebug->Reset(); + int iTrack = t->GetTPCtrackId(); + float HistoWidth = 50.f; + short NHistoBins = 25; + float invBinWidth = NHistoBins / HistoWidth; + t->SetChi2(0.f); + t->resetCovariance(100); + + //mSpacePoints[t->GetTracklet(iLy)].mLabel[il] + printf("===========================================================\n"); + + printf("Print Radius of Tracklets for track %d with %d tracklets:\n", iTrack, t->GetNtracklets()); + for (int iLayer = kNLayers - 1; iLayer >= 0; --iLayer) { + if (t->GetTracklet(iLayer) == -1) + continue; + printf("%d:%f, ", iLayer, mSpacePoints[t->GetTracklet(iLayer)].mR); + } + printf("\n"); + for (int iLayer = kNLayers - 1; iLayer >= 0; --iLayer) { + if (t->GetTracklet(iLayer) == -1) + continue; + if (PropagateAndUpdateLayer(prop, t, iLayer)) + return; + } + printf("\n===========================================================\n"); + for (int iLayer = 1; iLayer < kNLayers; ++iLayer) { + if (t->GetTracklet(iLayer) == -1) + continue; + if (PropagateAndUpdateLayer(prop, t, iLayer)) + return; + } + printf("\n===========================================================\n"); + for (int iLayer = kNLayers - 1; iLayer >= 0; --iLayer) { + if (t->GetTracklet(iLayer) == -1) + continue; + if (PropagateAndUpdateLayer(prop, t, iLayer)) + return; + + float impactAngle = CAMath::ASin(t->getSnp()) * 180.f / M_PI; + float trackletAngle = CAMath::ATan(mSpacePoints[t->GetTracklet(iLayer)].mDy / 3) * 180.f / M_PI; + float anglediff = trackletAngle - impactAngle; + + short detIndexOffset = mTracklets[t->GetTracklet(iLayer)].GetDetector() * (mNAngleHistogramBins + 1); + short index = (short)((impactAngle + 0.5 * mAngleHistogramRange) * invBinWidth); + + if (impactAngle <= -0.5 * mAngleHistogramRange || impactAngle >= 0.5 * mAngleHistogramRange) { + index = mNAngleHistogramBins; + } + mAngleDiffvsImpactAngleGlobal[index + detIndexOffset].mAngleDiffSum += anglediff; + mAngleDiffvsImpactAngleGlobal[index + detIndexOffset].mTrackletCounter++; + + printf("Anglediffindex %d,impact %f, tracklet %f, counter %d,angular sum%f\n", detIndexOffset, impactAngle, trackletAngle, mAngleDiffvsImpactAngleGlobal[index + detIndexOffset].mTrackletCounter, mAngleDiffvsImpactAngleGlobal[index + detIndexOffset].mAngleDiffSum); + } + printf("\n===========================================================\n"); +} + +template +GPUd() bool GPUTRDTracker_t::PropagateAndUpdateLayer(PROP* prop, TRDTRK* trkWork, int iLayer) +{ + int trackletID = trkWork->GetTracklet(iLayer); + int iTrack = trkWork->GetTPCtrackId(); + const GPUTRDpadPlane* pad = nullptr; + + pad = mGeo->GetPadPlane(iLayer, 0); + float tilt = CAMath::Tan(M_PI / 180.f * pad->GetTiltingAngle()); // tilt is signed! + + prop->setTrack(trkWork); + + if (mTracklets[trkWork->GetTracklet(iLayer)].GetDetector() / 30 != GetSector(prop->getAlpha())) { + if (!prop->rotate(GetAlphaOfSector(mTracklets[trkWork->GetTracklet(iLayer)].GetDetector() / 30))) { + if (ENABLE_WARNING) { + Warning("PropagateAndUpdateLayer", "Track could not be rotated in tracklet coordinate system"); + } + return true; + } + } + + if (!prop->propagateToX(mSpacePoints[trackletID].mR, .8f, 2.f)) { + GPUInfo("Track propagation failed for track %i candidate %i in layer %i (pt=%f, x=%f, mR[layer]=%f)", iTrack, trkWork->GetTracklet(iLayer), iLayer, trkWork->getPt(), trkWork->getX(), mR[2 * kNLayers + iLayer]); + return true; + } + + float tiltCorrUp = tilt * (mSpacePoints[trackletID].mX[1] - trkWork->getZ()); + float zPosCorrUp = mSpacePoints[trackletID].mX[1] + mZCorrCoefNRC * trkWork->getTgl(); + float l_padTrklt = pad->GetRowSize(mTracklets[trackletID].GetZbin()); + if (!((trkWork->getSigmaZ2() < (l_padTrklt * l_padTrklt / 12.f)) && (CAMath::Abs(mSpacePoints[trackletID].mX[1] - trkWork->getZ()) < l_padTrklt))) { + tiltCorrUp = 0.f; + } + + My_Float trkltPosUp[2] = {mSpacePoints[trackletID].mX[0] - tiltCorrUp, zPosCorrUp}; + My_Float trkltCovUp[3] = {0.f}; + RecalcTrkltCov(tilt, trkWork->getSnp(), pad->GetRowSize(mTracklets[trackletID].GetZbin()), trkltCovUp); + + if (!prop->update(trkltPosUp, trkltCovUp)) { + Warning("PropagateAndUpdateLayer", "Failed to update track %i with space point in layer %i", iTrack, iLayer); + return true; + } + printf("x%d:%f, ", iLayer, trkWork->getX()); + //printf("%d:%f, ",iLayer,mSpacePoints[t->GetTracklet(iLayer)].mR); + return false; +} template GPUd() bool GPUTRDTracker_t::FollowProlongation(PROP* prop, TRDTRK* t, int threadId, int collisionId) diff --git a/GPU/GPUTracking/TRDTracking/GPUTRDTracker.h b/GPU/GPUTracking/TRDTracking/GPUTRDTracker.h index ea3bbbc9cd060..62d7670540453 100644 --- a/GPU/GPUTracking/TRDTracking/GPUTRDTracker.h +++ b/GPU/GPUTracking/TRDTracking/GPUTRDTracker.h @@ -22,6 +22,8 @@ #include "GPUDef.h" #include "GPUTRDTrack.h" #include "GPULogging.h" +#include "GPUTRDSpacePointInternal.h" +#include "GPUTRDAngularResiduals.h" #ifndef GPUCA_GPUCODE_DEVICE #include @@ -77,20 +79,6 @@ class GPUTRDTracker_t : public GPUProcessor kNStacks = 5, kNSectors = 18, kNChambers = 540 }; - - // struct to hold the information on the space points - struct GPUTRDSpacePointInternal { - float mR; // x position (3.5 mm above anode wires) - radial offset due to t0 mis-calibration, measured -1 mm for run 245353 - float mX[2]; // y and z position (sector coordinates) - float mDy; // deflection over drift length - unsigned short mVolumeId; // basically derived from TRD chamber number - GPUd() GPUTRDSpacePointInternal(float x, float y, float z, float dy) : mR(x), mDy(dy), mVolumeId(0) - { - mX[0] = y; - mX[1] = z; - } - }; - struct Hypothesis { int mLayers; // number of layers with TRD space point int mCandidateId; // to which track candidate the hypothesis belongs @@ -122,6 +110,9 @@ class GPUTRDTracker_t : public GPUProcessor GPUd() void DoTrackingThread(int iTrk, int threadId = 0); GPUd() bool CalculateSpacePoints(int iCollision = 0); GPUd() bool FollowProlongation(PROP* prop, TRDTRK* t, int threadId, int collisionId); + GPUd() void DoImpactAngleHistograms(PROP* prop, TRDTRK* t); + GPUd() void ResetImpactAngleHistograms(); + GPUd() bool PropagateAndUpdateLayer(PROP* prop, TRDTRK* trkWork, int iLayer); GPUd() int GetDetectorNumber(const float zPos, const float alpha, const int layer) const; GPUd() bool AdjustSector(PROP* prop, TRDTRK* t) const; GPUd() int GetSector(float alpha) const; @@ -146,6 +137,7 @@ class GPUTRDTracker_t : public GPUProcessor // settings GPUd() void SetTrkltTransformNeeded(bool flag) { mTrkltTransfNeeded = flag; } GPUd() void SetProcessPerTimeFrame() { mProcessPerTimeFrame = true; } + GPUd() void SetDoImpactAngleHistograms(bool flag) { mDoImpactAngleHistograms = flag; } GPUd() void SetMCEvent(AliMCEvent* mc) { mMCEvent = mc; } GPUd() void EnableDebugOutput() { mDebugOutput = true; } GPUd() void SetMaxEta(float maxEta) { mMaxEta = maxEta; } @@ -164,6 +156,7 @@ class GPUTRDTracker_t : public GPUProcessor GPUd() TRDTRK* Tracks() const { return mTracks; } GPUd() int NTracklets() const { return mNTracklets; } GPUd() GPUTRDSpacePointInternal* SpacePoints() const { return mSpacePoints; } + GPUd() AngularResiduals* AngleDiffvsImpactAngleGlobal() const { return mAngleDiffvsImpactAngleGlobal; } GPUd() GPUTRDTrackletWord* Tracklets() const { return mTracklets; } GPUd() void DumpTracks(); @@ -172,6 +165,9 @@ class GPUTRDTracker_t : public GPUProcessor bool mIsInitialized; // flag is set upon initialization bool mTrkltTransfNeeded; // if the output of the TRDTrackletTransformer is used we don't need to do the coordinate transformation for the tracklets bool mProcessPerTimeFrame; // if true, tracking is done per time frame instead of on a single events basis + bool mDoImpactAngleHistograms; // if true, impact angle vs angle difference histograms are filled + short mNAngleHistogramBins; // number of bins per angle histogram (25) + float mAngleHistogramRange; // range of impact angles covered by each histogram short mMemoryPermanent; // size of permanent memory for the tracker short mMemoryTracklets; // size of memory for TRD tracklets short mMemoryTracks; // size of memory for tracks (used for i/o) @@ -196,6 +192,7 @@ class GPUTRDTracker_t : public GPUProcessor Hypothesis* mHypothesis; // array with multiple track hypothesis TRDTRK* mCandidates; // array of tracks for multiple hypothesis tracking GPUTRDSpacePointInternal* mSpacePoints; // array with tracklet coordinates in global tracking frame + AngularResiduals* mAngleDiffvsImpactAngleGlobal; // array with histogram information of angle diff vs impact angle in global tracking frame int* mTrackletLabels; // array with MC tracklet labels TRD_GEOMETRY_CONST GPUTRDGeometry* mGeo; // TRD geometry /// ---- error parametrization depending on magnetic field ---- diff --git a/GPU/GPUTracking/TRDTracking/GPUTRDTrackerComponent.cxx b/GPU/GPUTracking/TRDTracking/GPUTRDTrackerComponent.cxx index 7b0deb9ca597a..bb30eb827bb55 100644 --- a/GPU/GPUTracking/TRDTracking/GPUTRDTrackerComponent.cxx +++ b/GPU/GPUTracking/TRDTracking/GPUTRDTrackerComponent.cxx @@ -30,6 +30,7 @@ #include "AliHLTTRDDefinitions.h" #include "AliHLTTPCDefinitions.h" #include "GPUTRDTrackPoint.h" +#include "GPUTRDSpacePointInternal.h" #include "AliHLTGlobalBarrelTrack.h" #include "AliExternalTrackParam.h" #include "AliHLTExternalTrackParam.h" @@ -386,7 +387,7 @@ int GPUTRDTrackerComponent::DoEvent(const AliHLTComponentEventData& evtData, con GPUTRDTrackGPU* trackArray = fTracker->Tracks(); int nTracks = fTracker->NTracks(); - GPUTRDTrackerGPU::GPUTRDSpacePointInternal* spacePoints = fTracker->SpacePoints(); + GPUTRDSpacePointInternal* spacePoints = fTracker->SpacePoints(); // TODO delete fTrackList since it only works for TObjects (or use compiler flag after tests with GPU track type) // for (int iTrack=0; iTrackfPoints[i]; currOutPoint->fX[0] = sp.mR; // x in sector coordinates currOutPoint->fX[1] = sp.mX[0]; // y in sector coordinates