12#include <fmt/format.h>
40 for (
auto& [
name, calDet] : calibs) {
42 mCalDetObjects.emplace_back(&calDet);
49 for (
auto calPad : calPads) {
58 std::unique_ptr<TFile>
file(TFile::Open(
filename.c_str(),
"recreate"));
59 auto tree =
new TTree(
"calibTree",
"Calibration data object tree");
62 addDefaultMapping(
tree);
70 addCalDetObjects(
tree);
73 setDefaultAliases(
tree);
79void CalibTreeDump::addDefaultMapping(TTree*
tree)
90 std::vector<float> gx;
91 std::vector<float> gy;
92 std::vector<float> lx;
93 std::vector<float> ly;
95 std::vector<unsigned char>
row;
96 std::vector<unsigned char> pad;
97 std::vector<short> cpad;
100 tree->Branch(
"roc", &rocNumber);
101 tree->Branch(
"gx", &gx);
102 tree->Branch(
"gy", &gy);
103 tree->Branch(
"lx", &lx);
104 tree->Branch(
"ly", &ly);
106 tree->Branch(
"pad", &pad);
107 tree->Branch(
"cpad", &cpad);
123 const int numberOfRows = mapper.getNumberOfRowsROC(
roc);
124 for (
int irow = 0; irow < numberOfRows; ++irow) {
127 const int numberOfPadsInRow = mapper.getNumberOfPadsInRowROC(
roc, irow);
128 for (
int ipad = 0; ipad < numberOfPadsInRow; ++ipad) {
129 const PadROCPos padROCPos(rocNumber, irow, ipad);
130 const PadPos padPos = mapper.getGlobalPadPos(padROCPos);
131 const PadCentre& localPadXY = mapper.getPadCentre(padPos);
134 gx.emplace_back(globalPadXY.X());
135 gy.emplace_back(globalPadXY.Y());
136 lx.emplace_back(localPadXY.X());
137 ly.emplace_back(localPadXY.Y());
139 row.emplace_back(irow);
140 pad.emplace_back(ipad);
141 cpad.emplace_back(ipad - numberOfPadsInRow / 2);
150void CalibTreeDump::addFEEMapping(TTree*
tree)
158 mTraceLengthIROC = mapper.getTraceLengthsIROC();
159 mTraceLengthOROC = mapper.getTraceLengthsOROC();
163 std::vector<unsigned char> fecInSector;
164 std::vector<unsigned char> sampaOnFEC;
165 std::vector<unsigned char> channelOnSampa;
167 std::vector<float>* traceLength =
nullptr;
170 auto brFecInSector =
tree->Branch(
"fecInSector", &fecInSector);
171 auto brSampaOnFEC =
tree->Branch(
"sampaOnFEC", &sampaOnFEC);
172 auto brChannelOnSampa =
tree->Branch(
"channelOnSampa", &channelOnSampa);
173 auto brTraceLength =
tree->Branch(
"traceLength", &traceLength);
179 traceLength = ((
roc.rocType() ==
RocType::IROC) ? &mTraceLengthIROC : &mTraceLengthOROC);
184 channelOnSampa.clear();
186 const int rowOffset = (
roc.rocType() ==
RocType::OROC) ? mapper.getPadsInIROC() : 0;
188 const int numberOfRows = mapper.getNumberOfRowsROC(
roc);
189 for (
int irow = 0; irow < numberOfRows; ++irow) {
192 const int numberOfPadsInRow = mapper.getNumberOfPadsInRowROC(
roc, irow);
193 for (
int ipad = 0; ipad < numberOfPadsInRow; ++ipad) {
194 const PadROCPos padROCPos(rocNumber, irow, ipad);
195 const auto& fecInfo = mapper.getFECInfo(padROCPos);
196 const auto globalPadNumber = mapper.globalPadNumber(fecInfo);
198 const CRU cru(mapper.getCRU(
roc.getSector(), globalPadNumber));
200 fecInSector.emplace_back(fecInfo.getIndex());
201 sampaOnFEC.emplace_back(fecInfo.getSampaChip());
202 channelOnSampa.emplace_back(fecInfo.getSampaChannel());
205 brFecInSector->Fill();
206 brSampaOnFEC->Fill();
207 brChannelOnSampa->Fill();
208 brTraceLength->Fill();
213void CalibTreeDump::addCalDetObjects(TTree*
tree)
217 for (
auto pcalDet : mCalDetObjects) {
222 auto& calDet = *pcalDet;
223 std::string
name = calDet.getName();
225 if (
name ==
"PadCalibrationObject" ||
name.size() == 0) {
226 name = fmt::format(fmt::runtime(
"calDet_{%02d}"), iter);
229 std::string meanName = fmt::format(
"{}_mean",
name);
230 std::string stdDevName = fmt::format(
"{}_stdDev",
name);
231 std::string medianName = fmt::format(
"{}_median",
name);
232 std::string median1Name = fmt::format(
"{}_median1",
name);
233 std::string median2Name = fmt::format(
"{}_median2",
name);
234 std::string median3Name = fmt::format(
"{}_median3",
name);
237 std::vector<float>*
data =
nullptr;
243 TBranch* brMean =
tree->Branch(meanName.data(), &mean);
244 TBranch* brStdDev =
tree->Branch(stdDevName.data(), &stdDev);
245 TBranch* brMedian =
tree->Branch(medianName.data(), &median[0]);
246 TBranch* brMedian1 =
tree->Branch(median1Name.data(), &median[1]);
247 TBranch* brMedian2 =
tree->Branch(median2Name.data(), &median[2]);
248 TBranch* brMedian3 =
tree->Branch(median3Name.data(), &median[3]);
253 for (
auto& calArray : calDet.
getData()) {
255 data = &calArray.getData();
259 stdDev = TMath::StdDev(
data->begin(),
data->end());
281void CalibTreeDump::setDefaultAliases(TTree*
tree)
283 tree->SetAlias(
"sector",
"roc%36");
284 tree->SetAlias(
"padsPerRow",
"2*(pad-cpad)");
285 tree->SetAlias(
"isEdgePad",
"(pad==0) || (pad==padsPerRow-1)");
286 tree->SetAlias(
"rowInSector",
"row + (roc>35)*63");
287 tree->SetAlias(
"padWidth",
"0.4 + (roc > 35) * 0.2");
288 tree->SetAlias(
"padHeight",
"0.75 + (rowInSector > 62) * 0.25 + (rowInSector > 96) * 0.2 + (rowInSector > 126) * 0.3");
289 tree->SetAlias(
"padArea",
"padWidth * padHeight");
291 tree->SetAlias(
"cruInSector",
"(rowInSector >= 17) + (rowInSector >= 32) + (rowInSector >= 48) + (rowInSector >= 63) + (rowInSector >= 81) + (rowInSector >= 97) + (rowInSector >= 113) + (rowInSector >= 127) + (rowInSector >= 140)");
292 tree->SetAlias(
"cruID",
"cruInSector + sector*10");
293 tree->SetAlias(
"region",
"cruInSector");
294 tree->SetAlias(
"partition",
"int(cruInSector / 2)");
296 tree->SetAlias(
"padWidth",
"(region == 0) * 0.416 + (region == 1) * 0.42 + (region == 2) * 0.42 + (region == 3) * 0.436 + (region == 4) * 0.6 + (region == 5) * 0.6 + (region == 6) * 0.608 + (region == 7) * 0.588 + (region == 8) * 0.604 + (region == 9) * 0.607");
297 tree->SetAlias(
"padHeight",
"0.75 + (region>3)*0.25 + (region>5)*0.2 + (region>7)*0.3");
298 tree->SetAlias(
"padArea",
"padHeight * padWidth");
300 tree->SetAlias(
"IROC",
"roc < 36");
301 tree->SetAlias(
"OROC",
"roc >= 36");
302 tree->SetAlias(
"OROC1",
"partition == 2");
303 tree->SetAlias(
"OROC2",
"partition == 3");
304 tree->SetAlias(
"OROC3",
"partition == 4");
306 tree->SetAlias(
"A_Side",
"sector < 18");
307 tree->SetAlias(
"C_Side",
"sector >= 18");
310 tree->SetAlias(
"fecID",
"fecInSector + sector * 91");
311 tree->SetAlias(
"sampaInSector",
"sampaOnFEC + 5 * fecInSector");
312 tree->SetAlias(
"channelOnFEC",
"channelOnSampa + 32 * sampaOnFEC");
313 tree->SetAlias(
"channelInSector",
"channelOnFEC + 160 * fecInSector");
unsigned short int uint16_t
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
void addCalPads(const std::string_view file, const std::string_view calPadNames)
Add CalPad objects from a file.
std::unordered_map< std::string, DataTypes > CalPadMapType
void dumpToFile(const std::string filename="CalibTree.root")
Dump the registered calibration data to file.
void add(CalDet< T > *calDet)
Add CalDet object.
static constexpr unsigned short getPadsInOROC3()
static constexpr unsigned short getPadsInOROC1()
static Mapper & instance(const std::string mappingDir="")
static constexpr unsigned short getPadsInOROC2()
Pad and row inside a ROC.
GLuint const GLchar * name
double mean(std::vector< double >::const_iterator first, std::vector< double >::const_iterator last)
R median(std::vector< T > v)
std::vector< CalPad * > readCalPads(const std::string_view fileName, const std::vector< std::string > &calPadNames)
Global TPC definitions and constants.
math_utils::Point2D< float > LocalPosition2D
math_utils::Point2D< float > PadCentre
Pad centres as 2D float.
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))