Skip to content

Commit fc97fd7

Browse files
matthias-kleinerdavidrohr
authored andcommitted
implementing IDC workflow
- adding device for integration of IDCs (simulation only) - adding device for grouping and averaging of IDCs - adding device for aggregation of grouped IDCs and factorization+fourier transform of aggregated IDCs
1 parent f54802c commit fc97fd7

34 files changed

Lines changed: 4415 additions & 25 deletions

Detectors/TPC/base/include/TPCBase/Mapper.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ class Mapper
5757
return mMapPadOffsetPerRow[globalPadPosition.getRow()] + globalPadPosition.getPad();
5858
}
5959

60+
/// \return returns the global pad number for given local pad row and pad
61+
/// \param lrow ungrouped local row in a region
62+
/// \param pad ungrouped pad in row
63+
GlobalPadNumber static getGlobalPadNumber(const unsigned int lrow, const unsigned int pad, const unsigned int region) { return GLOBALPADOFFSET[region] + OFFSETCRULOCAL[region][lrow] + pad; }
64+
65+
/// \param row global pad row
66+
/// \param pad pad in row
67+
/// \return returns local pad number in region
68+
static unsigned int getLocalPadNumber(const unsigned int row, const unsigned int pad) { return OFFSETCRUGLOBAL[row] + pad; }
69+
70+
/// \param row global pad row
71+
static unsigned int getLocalRowFromGlobalRow(const unsigned int row) { return row - ROWOFFSET[REGION[row]]; }
72+
6073
/// return the cru number from sector and global pad number
6174
/// \param sec sector
6275
/// \param globalPad global pad number in sector
@@ -486,6 +499,70 @@ class Mapper
486499
float(double(pos.X()) * sn + double(pos.Y() * cs)));
487500
}
488501

502+
static constexpr unsigned int NSECTORS{36}; ///< total number of sectors in the TPC
503+
static constexpr unsigned int NREGIONS{10}; ///< total number of regions in one sector
504+
static constexpr unsigned int PADROWS{152}; ///< total number of pad rows
505+
static constexpr unsigned int PADSPERREGION[NREGIONS]{1200, 1200, 1440, 1440, 1440, 1440, 1600, 1600, 1600, 1600}; ///< number of pads per CRU
506+
static constexpr unsigned int GLOBALPADOFFSET[NREGIONS]{0, 1200, 2400, 3840, 5280, 6720, 8160, 9760, 11360, 12960}; ///< offset of number of pads for region
507+
static constexpr unsigned int ROWSPERREGION[NREGIONS]{17, 15, 16, 15, 18, 16, 16, 14, 13, 12}; ///< number of pad rows for region
508+
static constexpr unsigned int ROWOFFSET[NREGIONS]{0, 17, 32, 48, 63, 81, 97, 113, 127, 140}; ///< offset to calculate local row from global row
509+
static constexpr float REGIONAREA[NREGIONS]{374.4f, 378.f, 453.6f, 470.88f, 864.f, 864.f, 1167.36f, 1128.96f, 1449.6f, 1456.8f}; ///< volume of each region in cm^2
510+
static constexpr float PADAREA[NREGIONS]{1 / 0.312f, 1 / 0.315f, 1 / 0.315f, 1 / 0.327f, 1 / 0.6f, 1 / 0.6f, 1 / 0.7296f, 1 / 0.7056f, 1 / 0.906f, 1 / 0.9105f}; ///< inverse size of the pad area padwidth*padLength
511+
static constexpr unsigned REGION[PADROWS] = {
512+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
513+
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
514+
3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
515+
5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
516+
7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}; ///< region for global pad row
517+
const inline static std::vector<unsigned int> ADDITIONALPADSPERROW[NREGIONS]{
518+
{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5}, // region 0
519+
{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}, // region 1
520+
{0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4}, // region 2
521+
{0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}, // region 3
522+
{0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4}, // region 4
523+
{0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4}, // region 5
524+
{0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6}, // region 6
525+
{0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}, // region 7
526+
{0, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5}, // region 8
527+
{0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5} // region 9
528+
}; ///< additional pads per row compared to first row
529+
const inline static std::vector<unsigned int> OFFSETCRULOCAL[NREGIONS]{
530+
{0, 66, 132, 198, 266, 334, 402, 472, 542, 612, 684, 756, 828, 902, 976, 1050, 1124}, // region 0
531+
{0, 76, 152, 228, 306, 384, 462, 542, 622, 702, 784, 866, 948, 1032, 1116}, // region 1
532+
{0, 86, 172, 258, 346, 434, 522, 612, 702, 792, 882, 974, 1066, 1158, 1252, 1346}, // region 2
533+
{0, 92, 184, 276, 370, 464, 558, 654, 750, 846, 944, 1042, 1140, 1240, 1340}, // region 3
534+
{0, 76, 152, 228, 304, 382, 460, 538, 618, 698, 778, 858, 940, 1022, 1104, 1188, 1272, 1356}, // region 4
535+
{0, 86, 172, 258, 346, 434, 522, 612, 702, 792, 882, 974, 1066, 1158, 1252, 1346}, // region 5
536+
{0, 94, 190, 286, 382, 480, 578, 676, 776, 876, 978, 1080, 1182, 1286, 1390, 1494}, // region 6
537+
{0, 110, 220, 332, 444, 556, 670, 784, 898, 1014, 1130, 1246, 1364, 1482}, // region 7
538+
{0, 118, 236, 356, 476, 598, 720, 844, 968, 1092, 1218, 1344, 1472}, // region 8
539+
{0, 128, 258, 388, 520, 652, 784, 918, 1052, 1188, 1324, 1462} // region 9
540+
}; ///< row offset in cru for given local pad row
541+
const inline static std::vector<unsigned int> PADSPERROW[NREGIONS]{
542+
{66, 66, 66, 68, 68, 68, 70, 70, 70, 72, 72, 72, 74, 74, 74, 74, 76}, // region 0
543+
{76, 76, 76, 78, 78, 78, 80, 80, 80, 82, 82, 82, 84, 84, 84}, // region 1
544+
{86, 86, 86, 88, 88, 88, 90, 90, 90, 90, 92, 92, 92, 94, 94, 94}, // region 2
545+
{92, 92, 92, 94, 94, 94, 96, 96, 96, 98, 98, 98, 100, 100, 100}, // region 3
546+
{76, 76, 76, 76, 78, 78, 78, 80, 80, 80, 80, 82, 82, 82, 84, 84, 84, 84}, // region 4
547+
{86, 86, 86, 88, 88, 88, 90, 90, 90, 90, 92, 92, 92, 94, 94, 94}, // region 5
548+
{94, 96, 96, 96, 98, 98, 98, 100, 100, 102, 102, 102, 104, 104, 104, 106}, // region 6
549+
{110, 110, 112, 112, 112, 114, 114, 114, 116, 116, 116, 118, 118, 118}, // region 7
550+
{118, 118, 120, 120, 122, 122, 124, 124, 124, 126, 126, 128, 128}, // region 8
551+
{128, 130, 130, 132, 132, 132, 134, 134, 136, 136, 138, 138} // region 9
552+
}; ///< number of pads per row in region
553+
static constexpr unsigned int OFFSETCRUGLOBAL[PADROWS]{
554+
0, 66, 132, 198, 266, 334, 402, 472, 542, 612, 684, 756, 828, 902, 976, 1050, 1124, // region 0
555+
0, 76, 152, 228, 306, 384, 462, 542, 622, 702, 784, 866, 948, 1032, 1116, // region 1
556+
0, 86, 172, 258, 346, 434, 522, 612, 702, 792, 882, 974, 1066, 1158, 1252, 1346, // region 2
557+
0, 92, 184, 276, 370, 464, 558, 654, 750, 846, 944, 1042, 1140, 1240, 1340, // region 3
558+
0, 76, 152, 228, 304, 382, 460, 538, 618, 698, 778, 858, 940, 1022, 1104, 1188, 1272, 1356, // region 4
559+
0, 86, 172, 258, 346, 434, 522, 612, 702, 792, 882, 974, 1066, 1158, 1252, 1346, // region 5
560+
0, 94, 190, 286, 382, 480, 578, 676, 776, 876, 978, 1080, 1182, 1286, 1390, 1494, // region 6
561+
0, 110, 220, 332, 444, 556, 670, 784, 898, 1014, 1130, 1246, 1364, 1482, // region 7
562+
0, 118, 236, 356, 476, 598, 720, 844, 968, 1092, 1218, 1344, 1472, // region 8
563+
0, 128, 258, 388, 520, 652, 784, 918, 1052, 1188, 1324, 1462 // region 9
564+
}; ///< row offset in cru for given global pad row
565+
489566
private:
490567
Mapper(const std::string& mappingDir);
491568
// use old c++03 due to root

Detectors/TPC/calibration/CMakeLists.txt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
add_subdirectory(SpacePoints)
1212

1313
o2_add_library(TPCCalibration
14+
TARGETVARNAME targetName
1415
SOURCES src/CalibRawBase.cxx
1516
src/CalibPedestal.cxx
1617
src/CalibPulser.cxx
@@ -20,6 +21,14 @@ o2_add_library(TPCCalibration
2021
src/DigitDump.cxx
2122
src/DigitDumpParam.cxx
2223
src/CalibPadGainTracks.cxx
24+
src/IDCAverageGroup.cxx
25+
src/IDCGroup.cxx
26+
src/IDCGroupHelperRegion.cxx
27+
src/IDCGroupingParameter.cxx
28+
src/IDCFactorization.cxx
29+
src/IDCFourierTransform.cxx
30+
src/RobustAverage.cxx
31+
src/IDCCCDBHelper.cxx
2332
PUBLIC_LINK_LIBRARIES O2::DataFormatsTPC O2::TPCBase
2433
O2::TPCReconstruction ROOT::Minuit
2534
Microsoft.GSL::GSL)
@@ -34,7 +43,17 @@ o2_target_root_dictionary(TPCCalibration
3443
include/TPCCalibration/DigitDump.h
3544
include/TPCCalibration/DigitDumpParam.h
3645
include/TPCCalibration/CalibPadGainTracks.h
37-
include/TPCCalibration/FastHisto.h)
46+
include/TPCCalibration/FastHisto.h
47+
include/TPCCalibration/IDCAverageGroup.h
48+
include/TPCCalibration/IDCGroup.h
49+
include/TPCCalibration/IDCGroupHelperRegion.h
50+
include/TPCCalibration/IDCGroupHelperSector.h
51+
include/TPCCalibration/IDCFactorization.h
52+
include/TPCCalibration/IDCGroupingParameter.h
53+
include/TPCCalibration/IDCContainer.h
54+
include/TPCCalibration/RobustAverage.h
55+
include/TPCCalibration/IDCFourierTransform.h
56+
include/TPCCalibration/IDCCCDBHelper.h)
3857

3958
o2_add_test_root_macro(macro/comparePedestalsAndNoise.C
4059
PUBLIC_LINK_LIBRARIES O2::TPCBase
@@ -67,3 +86,16 @@ o2_add_test_root_macro(macro/extractGainMap.C
6786
o2_add_test_root_macro(macro/preparePedestalFiles.C
6887
PUBLIC_LINK_LIBRARIES O2::TPCCalibration
6988
LABELS tpc)
89+
90+
o2_add_test(IDCFourierTransform
91+
COMPONENT_NAME calibration
92+
PUBLIC_LINK_LIBRARIES O2::TPCCalibration
93+
SOURCES test/testO2TPCIDCFourierTransform.cxx
94+
ENVIRONMENT O2_ROOT=${CMAKE_BINARY_DIR}/stage
95+
LABELS tpc
96+
CONFIGURATIONS RelWithDebInfo Release MinRelSize)
97+
98+
if (OpenMP_CXX_FOUND)
99+
target_compile_definitions(${targetName} PRIVATE WITH_OPENMP)
100+
target_link_libraries(${targetName} PRIVATE OpenMP::OpenMP_CXX)
101+
endif()
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file IDCAverageGroup.h
12+
/// \brief class for averaging and grouping of IDCs
13+
/// \author Matthias Kleiner <mkleiner@ikf.uni-frankfurt.de>
14+
15+
#ifndef ALICEO2_IDCAVERAGEGROUP_H_
16+
#define ALICEO2_IDCAVERAGEGROUP_H_
17+
18+
#include <vector>
19+
#include "TPCCalibration/IDCGroup.h"
20+
#include "TPCBase/Mapper.h"
21+
#include "Rtypes.h"
22+
23+
namespace o2::utils
24+
{
25+
class TreeStreamRedirector;
26+
}
27+
28+
namespace o2::tpc
29+
{
30+
31+
/// class for averaging and grouping IDCs
32+
/// usage:
33+
/// 1. Define grouping parameters
34+
/// const int region = 3;
35+
/// IDCAverageGroup idcaverage(6, 4, 3, 2, region);
36+
/// 2. set the ungrouped IDCs for one CRU
37+
/// const int nIntegrationIntervals = 3;
38+
/// std::vector<float> idcsungrouped(nIntegrationIntervals*Mapper::PADSPERREGION[region], 11.11); // vector containing IDCs for one region
39+
/// idcaverage.setIDCs(idcsungrouped)
40+
/// 3. perform the averaging and grouping
41+
/// idcaverage.processIDCs();
42+
/// 4. draw IDCs
43+
/// idcaverage.drawUngroupedIDCs(0)
44+
/// idcaverage.drawGroupedIDCs(0)
45+
46+
class IDCAverageGroup
47+
{
48+
public:
49+
/// constructor
50+
/// \param groupPads number of pads in pad direction which will be grouped
51+
/// \param groupRows number of pads in row direction which will be grouped
52+
/// \param groupLastRowsThreshold minimum number of pads in row direction for the last group in row direction
53+
/// \param groupLastPadsThreshold minimum number of pads in pad direction for the last group in pad direction
54+
/// \param region region of the TPC
55+
IDCAverageGroup(const unsigned char groupPads = 4, const unsigned char groupRows = 4, const unsigned char groupLastRowsThreshold = 2, const unsigned char groupLastPadsThreshold = 2, const unsigned int region = 0, const Sector sector = Sector{0})
56+
: mIDCsGrouped{groupPads, groupRows, groupLastRowsThreshold, groupLastPadsThreshold, region}, mSector{sector} {}
57+
58+
/// set the IDCs which will be averaged and grouped
59+
/// \param idcs vector containing the IDCs
60+
void setIDCs(const std::vector<float>& idcs);
61+
62+
/// set the IDCs which will be averaged and grouped using move operator
63+
/// \param IDCs vector containing the IDCs
64+
void setIDCs(std::vector<float>&& idcs);
65+
66+
/// \return returns number of integration intervalls stored in this object
67+
unsigned int getNIntegrationIntervals() const { return mIDCsUngrouped.size() / Mapper::PADSPERREGION[mIDCsGrouped.getRegion()]; }
68+
69+
/// grouping and averaging of IDCs
70+
void processIDCs();
71+
72+
/// \return returns grouped IDC object
73+
const auto& getIDCGroup() const { return mIDCsGrouped; }
74+
75+
/// dump object to disc
76+
/// \param outFileName name of the output file
77+
/// \param outName name of the object in the output file
78+
void dumpToFile(const char* outFileName = "IDCAverageGroup.root", const char* outName = "IDCAverageGroup") const;
79+
80+
/// draw ungrouped IDCs
81+
/// \param integrationInterval integration interval for which the IDCs will be drawn
82+
/// \param filename name of the output file. If empty the canvas is drawn.
83+
void drawUngroupedIDCs(const unsigned int integrationInterval = 0, const std::string filename = "IDCsUngrouped.pdf") const;
84+
85+
/// draw grouped IDCs
86+
/// \param integrationInterval integration interval for which the IDCs will be drawn
87+
/// \param filename name of the output file. If empty the canvas is drawn.
88+
void drawGroupedIDCs(const unsigned int integrationInterval = 0, const std::string filename = "IDCsGrouped.pdf") const { mIDCsGrouped.draw(integrationInterval, filename); }
89+
90+
/// \return returns the stored ungrouped IDC value for local ungrouped pad row and ungrouped pad
91+
/// \param ulrow ungrouped local row in region
92+
/// \param upad ungrouped pad in pad direction
93+
/// \param integrationInterval integration interval for which the IDCs will be returned
94+
float getUngroupedIDCValLocal(const unsigned int ulrow, const unsigned int upad, const unsigned int integrationInterval) const { return mIDCsUngrouped[getUngroupedIndex(ulrow, upad, integrationInterval)]; }
95+
96+
/// \return returns the stored ungrouped IDC value for global ungrouped pad row and ungrouped pad
97+
/// \param ugrow ungrouped global row
98+
/// \param upad ungrouped pad in pad direction
99+
/// \param integrationInterval integration interval for which the IDCs will be returned
100+
float getUngroupedIDCValGlobal(const unsigned int ugrow, const unsigned int upad, const unsigned int integrationInterval) const { return mIDCsUngrouped[getUngroupedIndexGlobal(ugrow, upad, integrationInterval)]; }
101+
102+
/// \return returns the stored ungrouped IDC value for local pad number
103+
/// \param localPadNumber local pad number for region
104+
/// \param integrationInterval integration interval for which the IDCs will be returned
105+
float getUngroupedIDCVal(const unsigned int localPadNumber, const unsigned int integrationInterval) const { return mIDCsUngrouped[localPadNumber + integrationInterval * Mapper::PADSPERREGION[mIDCsGrouped.getRegion()]]; }
106+
107+
/// \return returns the stored grouped IDC value for local ungrouped pad row and ungrouped pad
108+
/// \param ulrow local row in region of the ungrouped IDCs
109+
/// \param upad pad number of the ungrouped IDCs
110+
/// \param integrationInterval integration interval
111+
float getGroupedIDCValLocal(unsigned int ulrow, unsigned int upad, unsigned int integrationInterval) const { return mIDCsGrouped.getValUngrouped(ulrow, upad, integrationInterval); }
112+
113+
/// \return returns the stored grouped IDC value for local ungrouped pad row and ungrouped pad
114+
/// \param ugrow global ungrouped row
115+
/// \param upad pad number of the ungrouped IDCs
116+
/// \param integrationInterval integration interval
117+
float getGroupedIDCValGlobal(unsigned int ugrow, unsigned int upad, unsigned int integrationInterval) const { return mIDCsGrouped.getValUngroupedGlobal(ugrow, upad, integrationInterval); }
118+
119+
/// get the number of threads used for some of the calculations
120+
static int getNThreads() { return sNThreads; }
121+
122+
/// \return returns sector of which the IDCs are averaged and grouped
123+
Sector getSector() const { return mSector; }
124+
125+
/// \return returns ungrouped IDCs
126+
const auto& getIDCsUngrouped() const { return mIDCsGrouped; }
127+
128+
/// \return returns region
129+
unsigned int getRegion() const { return mIDCsGrouped.getRegion(); }
130+
131+
/// set the number of threads used for some of the calculations
132+
static void setNThreads(const int nThreads) { sNThreads = nThreads; }
133+
134+
/// for debugging: creating debug tree
135+
/// \param nameTree name of the output file
136+
void createDebugTree(const char* nameTree) const;
137+
138+
/// for debugging: creating debug tree for integrated IDCs for all objects which are in the same file
139+
/// \param nameTree name of the output file
140+
/// \param filename name of the input file containing all objects
141+
static void createDebugTreeForAllCRUs(const char* nameTree, const char* filename);
142+
143+
private:
144+
inline static int sNThreads{1}; ///< number of threads which are used during the calculations
145+
std::vector<float> mIDCsUngrouped{}; ///< integrated ungrouped IDC values per pad
146+
IDCGroup mIDCsGrouped{}; ///< grouped and averaged IDC values
147+
const Sector mSector{}; ///< sector of averaged and grouped IDCs (used for debugging)
148+
149+
/// \return returns index to data from ungrouped pad and row
150+
/// \param ulrow ungrouped local row in region
151+
/// \param upad ungrouped pad in pad direction
152+
unsigned int getUngroupedIndex(const unsigned int ulrow, const unsigned int upad, const unsigned int integrationInterval) const { return integrationInterval * Mapper::PADSPERREGION[mIDCsGrouped.getRegion()] + Mapper::OFFSETCRULOCAL[mIDCsGrouped.getRegion()][ulrow] + upad; }
153+
154+
/// \return returns index to data from ungrouped pad and row
155+
/// \param ugrow ungrouped global row
156+
/// \param upad ungrouped pad in pad direction
157+
unsigned int getUngroupedIndexGlobal(const unsigned int ugrow, const unsigned int upad, const unsigned int integrationInterval) const { return integrationInterval * Mapper::PADSPERREGION[mIDCsGrouped.getRegion()] + Mapper::OFFSETCRUGLOBAL[ugrow] + upad; }
158+
159+
/// called from createDebugTreeForAllCRUs()
160+
static void createDebugTree(const IDCAverageGroup& idcavg, o2::utils::TreeStreamRedirector& pcstream);
161+
162+
ClassDefNV(IDCAverageGroup, 1)
163+
};
164+
165+
} // namespace o2::tpc
166+
167+
#endif

0 commit comments

Comments
 (0)