diff --git a/Detectors/TPC/base/src/ParameterElectronics.cxx b/Detectors/TPC/base/src/ParameterElectronics.cxx index 1ccbca6bb4761..64c9897032168 100644 --- a/Detectors/TPC/base/src/ParameterElectronics.cxx +++ b/Detectors/TPC/base/src/ParameterElectronics.cxx @@ -33,6 +33,6 @@ void ParameterElectronics::setDefaultValues() mChipGain = 20.f; mADCdynamicRange = 2200.f; mADCsaturation = 1024.f; - mZbinWidth = 0.19379844961f; + mZbinWidth = 0.2f; mElectronCharge = 1.602e-19f; } diff --git a/Detectors/TPC/reconstruction/include/TPCReconstruction/TrackTPC.h b/Detectors/TPC/reconstruction/include/TPCReconstruction/TrackTPC.h index b6a43f19731e2..951a87be5490a 100644 --- a/Detectors/TPC/reconstruction/include/TPCReconstruction/TrackTPC.h +++ b/Detectors/TPC/reconstruction/include/TPCReconstruction/TrackTPC.h @@ -2,7 +2,7 @@ // 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. +// See https://alice-o2.web.cern.ch/ 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 @@ -12,10 +12,15 @@ #define ALICEO2_TPC_TRACKTPC #include "DetectorsBase/Track.h" - #include "TPCBase/Defs.h" + #include "TPCReconstruction/Cluster.h" #include "DataFormatsTPC/ClusterNative.h" +#include "TPCBase/CalDet.h" + +#include +#include +#include namespace o2 { namespace TPC { @@ -24,13 +29,26 @@ namespace TPC { /// This is the definition of the TPC Track Object -class TrackTPC :public o2::Base::Track::TrackParCov { +class TrackTPC { public: - using o2::Base::Track::TrackParCov::TrackParCov; // inherit + //using o2::Base::Track::TrackParCov::TrackParCov; // inherit /// Default constructor - TrackTPC() = default; + TrackTPC(); + + /// Constructor, initializing values for x, alpha and an array with Y, Z, sin(phi), tg(lambda) and q/pT + /// \param x X of track evaluation + /// \param alpha track frame angle + /// \param std::array par contains Y, Z, sin(phi), tg(lambda) and q/pT + TrackTPC(float x, float alpha, const std::array &par, const std::array &cov); + + /// Constructor, initializing values for x,y and z in an array, momenta px, py and pz in an array + /// \param std::array xyz contains x, y and z coordinates of the vertex of the origin + /// \param std::array pxpypz contains momenta in x, y and z direction + /// \param sign sign of the charge of the particle + /// \param sectorAlpha false: angle of pT direction, true: angle of the sector from X, Y coordinate for r>1; angle of pT direction for r==0 + TrackTPC(const std::array &xyz, const std::array &pxpypz, const std::array &cv, int sign, bool sectorAlpha=true); /// Destructor ~TrackTPC() = default; @@ -38,7 +56,8 @@ class TrackTPC :public o2::Base::Track::TrackParCov { /// Add a single cluster to the track void addCluster(const Cluster &c); - /// Add an array/vector of clusters to the track; ClusterType needs to inherit from o2::TPC::Cluster + /// Add an array/vector of clusters to the track + //void addClusterArray(TClonesArray *arr); template void addClusterArray(std::vector *arr); @@ -50,10 +69,10 @@ class TrackTPC :public o2::Base::Track::TrackParCov { /// \param low low end of truncation /// \param high high end of truncation /// \param type 0 for Qmax, 1 for Q + /// \param particleType 0 for Pions, 1 for Electrons /// \param removeRows option to remove certain rows from the dEdx calculation /// \param nclPID pass any pointer to have the number of used clusters written to it /// \return mean energy loss - float getTruncatedMean(float low=0.05, float high=0.7, int type=1, int removeRows=0, int *nclPID=nullptr) const; float getTime0() const {return mTime0;} float getLastClusterZ() const {return mLastClusterZ;} @@ -84,7 +103,49 @@ class TrackTPC :public o2::Base::Track::TrackParCov { return(getCluster(nCluster, clusters, sectorIndex, rowIndex)); } + float getTruncatedMean(int runNr, float low=0.05, float high=0.7, int type=1, bool removeRows=false, bool removeEdge=false, bool removeEnd=false, TH2D *excludeHisto=nullptr, float ChargeCorr=1, int edgeCut=1, int *nclPID=nullptr, TH1F *TruncDist=nullptr, TH1F *ChargeDist=nullptr) const; + + void setGainMap(TString GainMapFile, int setting); + + /// Get the TrackParCov object + o2::Base::Track::TrackParCov getTrack() { return mTrackParCov; } + + + + float getX() const { return mTrackParCov.getX(); } + float getAlpha() const { return mTrackParCov.getAlpha(); } + float getY() const { return mTrackParCov.getY(); } + float getZ() const { return mTrackParCov.getZ(); } + float getSnp() const { return mTrackParCov.getSnp(); } + float getTgl() const { return mTrackParCov.getTgl(); } + float getQ2Pt() const { return mTrackParCov.getQ2Pt(); } + + // derived getters + float getCurvature(float b) const { return mTrackParCov.getCurvature(float(b));} + float getSign() const { return mTrackParCov.getSign();} + float getPhi() const { return mTrackParCov.getPhi();} + float getPhiPos() const { return mTrackParCov.getPhiPos(); } + + float getP() const { return mTrackParCov.getP(); } + float getPt() const { return mTrackParCov.getPt(); } + void getXYZ(std::array &xyz) const { mTrackParCov.getXYZGlo(xyz); } + bool getPxPyPz(std::array &pxyz) const { return mTrackParCov.getPxPyPzGlo(pxyz); } + bool getPosDir(std::array &posdirp) const { return mTrackParCov.getPosDirGlo(posdirp); } + + /// \todo implement getters for covariance (missing access to full covariance in Track.h) + + + // parameters manipulation + bool rotateParam(float alpha) { return mTrackParCov.rotate(alpha); } + bool propagateParamTo(float xk, float b) { return mTrackParCov.propagateParamTo(xk, b); } + bool propagateParamTo(float xk, const std::array &b) { return mTrackParCov.propagateParamTo(xk, b); } + void invertParam() { mTrackParCov.invertParam(); } + + void PrintParam() { mTrackParCov.PrintParam(); } + + private: + o2::Base::Track::TrackParCov mTrackParCov; std::vector mClusterVector; float mTime0 = 0.f; //Reference Z of the track assumed for the vertex, scaled with pseudo VDrift and reference timeframe length. float mLastClusterZ = 0.f; //Z position of last cluster @@ -93,8 +154,31 @@ class TrackTPC :public o2::Base::Track::TrackParCov { //New structure to store cluster references int mNClusters = 0; std::vector mClusterReferences; + + //static std::unique_ptr> mGainMap; + + static o2::TPC::CalDet *mGainMap; + }; +inline +TrackTPC::TrackTPC() + : mTrackParCov() + , mClusterVector() +{} + +inline +TrackTPC::TrackTPC(float x,float alpha, const std::array &par, const std::array &cov) + : mTrackParCov(x, alpha, par, cov) + , mClusterVector() +{} + +inline +TrackTPC::TrackTPC(const std::array &xyz,const std::array &pxpypz, const std::array &cv, int sign, bool sectorAlpha) + : mTrackParCov(xyz, pxpypz, cv, sign, sectorAlpha) + , mClusterVector() +{} + inline void TrackTPC::addCluster(const Cluster &c) { @@ -102,12 +186,16 @@ void TrackTPC::addCluster(const Cluster &c) } template + inline +//void TrackTPC::addClusterArray(TClonesArray *arr) void TrackTPC::addClusterArray(std::vector *arr) { static_assert(std::is_base_of::value, "ClusterType needs to inherit from o2::TPC::Cluster"); for (auto clusterObject : *arr){ addCluster(clusterObject); + //Cluster *inputcluster = static_cast(clusterObject); + //addCluster(*inputcluster); } } diff --git a/Detectors/TPC/reconstruction/src/TrackTPC.cxx b/Detectors/TPC/reconstruction/src/TrackTPC.cxx index c6e284be56ad9..f16564f2b00c9 100644 --- a/Detectors/TPC/reconstruction/src/TrackTPC.cxx +++ b/Detectors/TPC/reconstruction/src/TrackTPC.cxx @@ -13,30 +13,1073 @@ /// \author Thomas Klemenz, TU Muenchen, thomas.klemenz@tum.de #include "TPCReconstruction/TrackTPC.h" +#include "TPCBase/ROC.h" +#include "TPCBase/Mapper.h" + +#include +#include +#include using namespace o2::TPC; +CalDet *TrackTPC::mGainMap = new CalDet(PadSubset::ROC); -float TrackTPC::getTruncatedMean(float low, float high, int type, int removeRows, int *nclPID) const +float TrackTPC::getTruncatedMean(int runNr, float low, float high, int type, bool removeRows, bool removeEdge, bool removeEnd, TH2D *excludeHisto, float ChargeCorr, int edgeCut, int *nclPID, TH1F *TruncDist, TH1F *ChargeDist) const { + ROC roc(0); + float norm = 1.; + std::vector values; + Mapper &mapper = Mapper::instance(); for (auto &clusterObject : mClusterVector) { - values.push_back((type == 0)?clusterObject.getQmax():clusterObject.getQ()); + DigitPos pos(clusterObject.getCRU(), PadPos(clusterObject.getRow(), clusterObject.getPadMean())); + float row = pos.getPadSecPos().getPadPos().getRow(); + float pad = pos.getPadSecPos().getPadPos().getPad(); + float cpad = pad - mapper.getNumberOfPadsInRowSector(row)/2; + if (removeRows) { + if (row == 31 || row == 32) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + + +// int nexthit = HitMapS0->getValue(roc, row, pad+1); +// int previoushit = HitMapS0->getValue(roc, row, pad-1); +// if (nexthit != 1 || previoushit != 1) { +// excludeHisto->Fill(row, cpad, 1); +// continue; +// } + + if (runNr > 255) { + if (row > 1 && row < 61) { + if (cpad == 0 || cpad == -1 || cpad == -2) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } +// int nexthit = HitMapS1->getValue(roc, row, pad+1); +// int previoushit = HitMapS1->getValue(roc, row, pad-1); +// if (nexthit != 1 || previoushit != 1) { +// excludeHisto->Fill(row, cpad, 1); +// continue; +// } + } + } + if (removeEdge) { + if (runNr <= 243) { + + if (row < 5) { + if (edgeCut == 1) { + if (!(cpad > 7 && cpad < 19)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 8 && cpad < 18)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 9 && cpad < 17)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 7 && cpad < 19)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 8 && cpad < 18)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 9 && cpad < 17)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 5 && row < 10) { + if (edgeCut == 1) { + if (!(cpad > 7 && cpad < 20)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 8 && cpad < 19)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 9 && cpad < 18)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 7 && cpad < 20)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 8 && cpad < 19)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 9 && cpad < 18)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 10 && row < 16) { + if (edgeCut == 1) { + if (!(cpad > 7 && cpad < 21)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 8 && cpad < 20)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 9 && cpad < 19)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 8 && cpad < 21)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 9 && cpad < 20)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 10 && cpad < 19)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 7 && cpad < 20) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (cpad > 8 && cpad < 19) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (cpad > 9 && cpad < 18) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 15 && row <= 22) { + if (edgeCut == 1) { + if (!(cpad > 8 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 9 && cpad < 21)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 10 && cpad < 20)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 22 && row <= 27) { + if (edgeCut == 1) { + if (!(cpad > 8 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 9 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 10 && cpad < 21)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 27 && row <= 30) { + if (edgeCut == 1) { + if (!(cpad > 8 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 9 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 10 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 9 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 10 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 11 && cpad < 21)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 10 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 11 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 12 && cpad < 21)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 32 && row <= 37) { + if (edgeCut == 1) { + if (!(cpad > 10 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 11 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 12 && cpad < 21)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 37 && row <= 43) { + if (edgeCut == 1) { + if (!(cpad > 10 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 11 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 12 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 10 && cpad < 25)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 11 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 12 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 11 && cpad < 25)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 12 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 13 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 11 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 12 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 13 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 10 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 11 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 12 && cpad < 22)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 10 && cpad < 25)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 11 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 12 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 52 && row <= 55) { + if (edgeCut == 1) { + if (!(cpad > 11 && cpad < 25)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 12 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 13 && cpad < 23)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 55 && row <= 60) { + if (edgeCut == 1) { + if (!(cpad > 11 && cpad < 26)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 12 && cpad < 25)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 13 && cpad < 24)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< 11 && cpad < 27)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > 12 && cpad < 26)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 13 && cpad < 25)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 255) { + if (row < 6) { + if (edgeCut == 1) { + if (!(cpad > -2 && cpad < 10)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -1 && cpad < 9)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 0 && cpad < 8)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 6 && row <=10) { + if (edgeCut == 1) { + if (!(cpad > -2 && cpad < 11)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -1 && cpad < 10)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 0 && cpad < 9)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -2 && cpad < 10)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -1 && cpad < 9)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > 0 && cpad < 8)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 12 && row <= 15) { + if (edgeCut == 1) { + if (!(cpad > -3 && cpad < 10)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -2 && cpad < 9)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -1 && cpad < 8)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -3 && cpad < 7)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -2 && cpad < 6)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -1 && cpad < 5)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 18 && row <= 29) { + if (edgeCut == 1) { + if (!(cpad > -8 && cpad < 7)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -7 && cpad < 6)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -6 && cpad < 5)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -8 && cpad < 6)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -7 && cpad < 5)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -6 && cpad < 4)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -8 && cpad < 4)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -7 && cpad < 3)) { + excludeHisto->Fill(row, cpad, 1);continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -6 && cpad < 2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -9 && cpad < 4)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -8 && cpad < 3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -7 && cpad < 2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 34 && row <= 46) { + if (edgeCut == 1) { + if (!(cpad > -10 && cpad < 4)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -9 && cpad < 3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -8 && cpad < 2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -10 && cpad < -1)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -9 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -8 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -11 && cpad < -1)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -10 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -9 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -13 && cpad < -1)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -12 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -11 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -14 && cpad < -1)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -13 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -12 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -15 && cpad < -1)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -14 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -13 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 53 && row <= 59) { + if (edgeCut == 1) { + if (!(cpad > -16 && cpad < -1)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -15 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -14 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -16 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -15 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -14 && cpad < -4)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout< -17 && cpad < -2)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 2) { + if (!(cpad > -16 && cpad < -3)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (edgeCut == 3) { + if (!(cpad > -15 && cpad < -4)) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else { + std::cout<= 57 || row < 2) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + else if (runNr > 255) { + if (row >= 61 || row < 2) { + excludeHisto->Fill(row, cpad, 1); + continue; + } + } + } + if (mGainMap) { + norm = mGainMap->getValue(roc, row, pad); + if (norm < 1e-4) { + norm = 1.; + } + values.push_back((type == 0)?clusterObject.getQmax()/(norm*ChargeCorr):clusterObject.getQ()/(norm*ChargeCorr)); + } + else { + values.push_back((type == 0)?clusterObject.getQmax()/ChargeCorr:clusterObject.getQ()/ChargeCorr); + } } + transform(values.begin(), values.end(), values.begin(), boost::lambda::_1 * cos(atan(TrackTPC::getTgl())) * cos(asin(TrackTPC::getSnp()))); + std::sort(values.begin(), values.end()); float dEdx = 0.f; int nClustersTrunc = 0; int nClustersUsed = static_cast(values.size()); + if (ChargeDist != nullptr) { + for (int icl=0; iclFill(values[icl]); + } + } + for (int icl=0; iclstd::round(high*nClustersUsed)) break; dEdx+=values[icl]; ++nClustersTrunc; + if (TruncDist != nullptr) { + TruncDist->Fill(values[icl]); + } } if (nClustersTrunc>0){ @@ -48,6 +1091,30 @@ float TrackTPC::getTruncatedMean(float low, float high, int type, int removeRows return dEdx; } +void TrackTPC::setGainMap(TString GainMapFile ,int setting) +{ + TFile f(GainMapFile); + gROOT->cd(); + + ROC roc(0); + + CalDet *gainmapS0 = nullptr, *gainmapS1 = nullptr; + f.GetObject("GainMapS0", gainmapS0); + f.GetObject("GainMapS1", gainmapS1); + + CalArray& mGainMapArr = mGainMap->getCalArray(roc); + + if (setting == 0) { + mGainMapArr = gainmapS0->getCalArray(roc); + } + else if (setting == 1) { + mGainMapArr = gainmapS1->getCalArray(roc); + } + else { + std::cout<& hits, f const DigitPos digiPadPos = mapper.findDigitPosFromGlobalPosition(posEleDiff); if(!digiPadPos.isValid()) continue; + ///Added for less computing time in my simulation in sector 0 IROC + if(digiPadPos.getCRU() > 3) continue; + const PadSecPos digiSecPos = digiPadPos.getPadSecPos(); + const Sector digiSector = digiSecPos.getSector(); + if(digiSector.getSector() != 0) continue; + const int nElectronsGEM = gemAmplification.getStackAmplification(); if ( nElectronsGEM ==0 ) continue; diff --git a/macro/run_digi_tpc.C b/macro/run_digi_tpc.C index 73e7c1fb99540..ca7f51863f5b2 100644 --- a/macro/run_digi_tpc.C +++ b/macro/run_digi_tpc.C @@ -49,7 +49,7 @@ void run_digi_tpc(Int_t nEvents = 10, TString mcEngine = "TGeant3", Int_t isCont fFileSource->SetEventMeanTime(20*1000); //is in us // TGeoManager::Import("geofile_full.root"); - o2::field::MagneticField *magField = new o2::field::MagneticField("Maps","Maps", -1., -1., o2::field::MagFieldParam::k5kG); + o2::field::MagneticField *magField = new o2::field::MagneticField("Maps","Maps", 0., -1., o2::field::MagFieldParam::k5kG); run->SetField(magField); // Setup digitizer diff --git a/macro/run_sim_tpc.C b/macro/run_sim_tpc.C index 0ed4d2eeb82d7..35106cd69586c 100644 --- a/macro/run_sim_tpc.C +++ b/macro/run_sim_tpc.C @@ -24,7 +24,7 @@ #define BOX_GENERATOR 1 -void run_sim_tpc(Int_t nEvents = 10, TString mcEngine = "TGeant3") +void run_sim_tpc(Int_t nEvents = 1, TString mcEngine = "TGeant3") { TString dir = getenv("VMCWORKDIR"); TString geom_dir = dir + "/Detectors/Geometry/"; @@ -69,7 +69,7 @@ void run_sim_tpc(Int_t nEvents = 10, TString mcEngine = "TGeant3") cave->SetGeometryFileName("cave.geo"); run->AddModule(cave); - auto magField = std::make_unique("Maps","Maps", -1., -1., o2::field::MagFieldParam::k5kG); + auto magField = std::make_unique("Maps","Maps", 0., -1., o2::field::MagFieldParam::k5kG); run->SetField(magField.get()); // ===| Add TPC |============================================================ @@ -80,8 +80,8 @@ void run_sim_tpc(Int_t nEvents = 10, TString mcEngine = "TGeant3") // Create PrimaryGenerator FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); #ifdef BOX_GENERATOR - FairBoxGenerator* boxGen = new FairBoxGenerator(211, 10); /*protons*/ - + FairBoxGenerator* boxGenPi = new FairBoxGenerator(211, 1); /*pions*/ +/* //boxGen->SetThetaRange(0.0, 90.0); boxGen->SetEtaRange(-0.9,0.9); boxGen->SetPRange(0.1, 5); @@ -89,6 +89,20 @@ void run_sim_tpc(Int_t nEvents = 10, TString mcEngine = "TGeant3") boxGen->SetDebug(kTRUE); primGen->AddGenerator(boxGen); +*/ + + boxGenPi->SetThetaRange(90.-0.24,90.+0.24); + boxGenPi->SetPRange(1.,1.); + boxGenPi->SetPhiRange(193.39-0.34,193.39+0.34); +// boxGenPi->SetBoxXYZ(127.387, 30.93, 127.387, 30.93, 245); + boxGenPi->SetBoxXYZ(127.8, 28.47, 126.8, 34.38, 247); + boxGenPi->SetDebug(kTRUE); + + primGen->SetBeam(0.,0.,0.,0.); + primGen->SetBeamAngle(0.,0.,0.,0.); + primGen->AddGenerator(boxGenPi); + + #else // reading the events from a kinematics file (produced by AliRoot) auto extGen = new o2::eventgen::GeneratorFromFile("Kinematics.root"); diff --git a/macro/run_sim_tpc.C_electrons b/macro/run_sim_tpc.C_electrons new file mode 100644 index 0000000000000..84b4d15c91559 --- /dev/null +++ b/macro/run_sim_tpc.C_electrons @@ -0,0 +1,148 @@ +#if !defined(__CLING__) || defined(__ROOTCLING__) + #include + + #include "Rtypes.h" + #include "TSystem.h" + #include "TMath.h" + #include "TString.h" + #include "TStopwatch.h" + #include "TGeoManager.h" + + #include "FairRunSim.h" + #include "FairRuntimeDb.h" + #include "FairPrimaryGenerator.h" + #include "FairBoxGenerator.h" + #include "FairParRootFileIo.h" + #include "FairSystemInfo.h" + + #include "Field/MagneticField.h" + + #include "DetectorsPassive/Cave.h" + #include "Generators/GeneratorFromFile.h" + #include "TPCSimulation/Detector.h" +#endif + +#define BOX_GENERATOR 1 + +void run_sim_tpc(Int_t nEvents = 1, TString mcEngine = "TGeant3") +{ + TString dir = getenv("VMCWORKDIR"); + TString geom_dir = dir + "/Detectors/Geometry/"; + gSystem->Setenv("GEOMPATH",geom_dir.Data()); + + + TString tut_configdir = dir + "/Detectors/gconfig"; + gSystem->Setenv("CONFIG_DIR",tut_configdir.Data()); + + // Output file name + char fileout[100]; + sprintf(fileout, "AliceO2_%s.tpc.mc_%i_event.root", mcEngine.Data(), nEvents); + TString outFile = fileout; + + // Parameter file name + char filepar[100]; + sprintf(filepar, "AliceO2_%s.tpc.params_%i.root", mcEngine.Data(), nEvents); + TString parFile = filepar; + + // In general, the following parts need not be touched + + // Debug option + gDebug = 0; + + // Timer + TStopwatch timer; + timer.Start(); + + + // Create simulation run + FairRunSim* run = new FairRunSim(); + + run->SetName(mcEngine); // Transport engine + run->SetOutputFile(outFile); // Output file + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + + // Create media + run->SetMaterials("media.geo"); // Materials + + // Create geometry + o2::Passive::Cave* cave = new o2::Passive::Cave("CAVE"); + cave->SetGeometryFileName("cave.geo"); + run->AddModule(cave); + + auto magField = std::make_unique("Maps","Maps", 0., -1., o2::field::MagFieldParam::k5kG); + run->SetField(magField.get()); + + // ===| Add TPC |============================================================ + o2::TPC::Detector* tpc = new o2::TPC::Detector(kTRUE); + tpc->SetGeoFileName("TPCGeometry.root"); + run->AddModule(tpc); + + // Create PrimaryGenerator + FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); +#ifdef BOX_GENERATOR + FairBoxGenerator* boxGenEle = new FairBoxGenerator(11, 1); /*electrons*/ +/* + //boxGen->SetThetaRange(0.0, 90.0); + boxGen->SetEtaRange(-0.9,0.9); + boxGen->SetPRange(0.1, 5); + boxGen->SetPhiRange(0., 360.); + boxGen->SetDebug(kTRUE); + + primGen->AddGenerator(boxGen); +*/ + + boxGenEle->SetThetaRange(90.-0.24,90.+0.24); + boxGenEle->SetPRange(1.,1.); + boxGenEle->SetPhiRange(193.39-0.34,193.39+0.34); +// boxGenEle->SetBoxXYZ(127.387, 30.93, 127.387, 30.93, 245); + boxGenEle->SetBoxXYZ(127.8, 28.47, 126.8, 34.38, 247); + boxGenEle->SetDebug(kTRUE); + + primGen->SetBeam(0.,0.,0.,0.); + primGen->SetBeamAngle(0.,0.,0.,0.); + primGen->AddGenerator(boxGenEle); + + +#else + // reading the events from a kinematics file (produced by AliRoot) + auto extGen = new o2::eventgen::GeneratorFromFile("Kinematics.root"); + extGen->SetStartEvent(2); + primGen->AddGenerator(extGen); +#endif + + run->SetGenerator(primGen); + + // store track trajectories + // run->SetStoreTraj(kTRUE); + + // Initialize simulation run + run->Init(); + + // Runtime database + Bool_t kParameterMerged = kTRUE; + FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); + parOut->open(parFile.Data()); + rtdb->setOutput(parOut); + rtdb->saveOutput(); + rtdb->print(); + + // Start run + run->Run(nEvents); + delete run; +// run->CreateGeometryFile("geofile_full.root"); + + // Finish + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + + // extract max memory usage + FairSystemInfo sysinfo; + + std::cout << std::endl << std::endl; + std::cout << "Macro finished succesfully." << std::endl; + std::cout << "Output file is " << outFile << std::endl; + std::cout << "Parameter file is " << parFile << std::endl; + std::cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << std::endl << std::endl; + std::cout << "Memory used " << sysinfo.GetMaxMemory() << "\n"; +}