@@ -42,17 +42,17 @@ namespace o2::ft0
4242template <typename Float>
4343Float signalForm_i (Float x)
4444{
45- float p0, p1, p2, p3, p4, p5, p6, p7;
46- p0 = 1.30853 ;
47- p1 = 0.516807 ;
48- p2 = 3.36714 ;
49- p3 = -1.01206 ;
50- p4 = 1.42832 ;
51- p5 = 1.1589 ;
52- p6 = 1.22019 ;
53- p7 = 0.426818 ;
54-
55- Double_t val = 0 ;
45+ float p0, p1, p2, p3, p4, p5, p6, p7;
46+ p0 = 1.30853 ;
47+ p1 = 0.516807 ;
48+ p2 = 3.36714 ;
49+ p3 = -1.01206 ;
50+ p4 = 1.42832 ;
51+ p5 = 1.1589 ;
52+ p6 = 1.22019 ;
53+ p7 = 0.426818 ;
54+
55+ Double_t val = 0 ;
5656
5757 if (x > p3) {
5858 Double_t x1 = x - p3;
@@ -72,52 +72,52 @@ p7 = 0.426818;
7272// integrated signal shape function
7373inline float signalForm_integral (float x)
7474{
75- float p0, p1, p2, p3, p4, p5, p6, p7;
76- p0 = 1.30853 ;
77- p1 = 0.516807 ;
78- p2 = 3.36714 ;
79- p3 = -1.01206 ;
80- p4 = 1.42832 ;
81- p5 = 1.1589 ;
82- p6 = 1.22019 ;
83- p7 = 0.426818 ;
75+ float p0, p1, p2, p3, p4, p5, p6, p7;
76+ p0 = 1.30853 ;
77+ p1 = 0.516807 ;
78+ p2 = 3.36714 ;
79+ p3 = -1.01206 ;
80+ p4 = 1.42832 ;
81+ p5 = 1.1589 ;
82+ p6 = 1.22019 ;
83+ p7 = 0.426818 ;
8484 Double_t val = 0 ;
8585
8686 if (x > p3) {
8787 Double_t x1 = x - p3;
8888 Double_t z1 = (log (x1) - p0) / (sqrt (2 ) * p1);
89- val += p2 * 0.5 * (1 + TMath::Erf (z1)); // norm1 * CDF1
89+ val += p2 * 0.5 * (1 + TMath::Erf (z1)); // norm1 * CDF1
9090 }
9191
9292 if (x > p7) {
9393 Double_t x2 = x - p7;
9494 Double_t z2 = (log (x2) - p4) / (sqrt (2 ) * p5);
95- val += p6 * 0.5 * (1 + TMath::Erf (z2)); // norm2 * CDF2
95+ val += p6 * 0.5 * (1 + TMath::Erf (z2)); // norm2 * CDF2
9696 }
9797
9898 return val;
9999};
100- /*
100+ /*
101101// signal shape function
102102template <typename Float>
103103Float signalForm_i(Float x)
104104{
105- using namespace std;
106- Float const a = -0.45458;
107- Float const b = -0.83344945;
108- return x > Float(0) ? -(exp(b * x) - exp(a * x)) / Float(7.8446501) : Float(0);
105+ using namespace std;
106+ Float const a = -0.45458;
107+ Float const b = -0.83344945;
108+ return x > Float(0) ? -(exp(b * x) - exp(a * x)) / Float(7.8446501) : Float(0);
109109};
110110
111111// integrated signal shape function
112112inline float signalForm_integral(float x)
113113{
114- using namespace std;
115- double const a = -0.45458;
116- double const b = -0.83344945;
117- if (x < 0) {
118- x = 0;
119- }
120- return -(exp(b * x) / b - exp(a * x) / a) / 7.8446501;
114+ using namespace std;
115+ double const a = -0.45458;
116+ double const b = -0.83344945;
117+ if (x < 0) {
118+ x = 0;
119+ }
120+ return -(exp(b * x) / b - exp(a * x) / a) / 7.8446501;
121121};
122122*/
123123// SIMD version of the integrated signal shape function
@@ -316,63 +316,63 @@ void Digitizer::storeBC(BCCache& bc,
316316 if (bc.hits .empty ()) {
317317 return ;
318318 }
319- // Initialize mapping channelID -> PM hash and PM side (A/C) using FT0 LUT
320- static bool pmLutInitialized = false ;
321- static std::array<uint8_t , o2::ft0::Constants::sNCHANNELS_PM > mChID2PMhash {};
322- static std::map<uint8_t , bool > mMapPMhash2isAside ; // hashed PM -> is A side
323-
324- if (!pmLutInitialized) {
325- std::map<std::string, uint8_t > mapFEE2hash; // module name -> hashed PM id
326- uint8_t tcmHash = 0 ;
327-
328- const auto & lut = o2::ft0::SingleLUT::Instance ().getVecMetadataFEE ();
329- auto lutSorted = lut;
330- std::sort (lutSorted.begin (), lutSorted.end (),
331- [](const auto & first, const auto & second) { return first.mModuleName < second.mModuleName ; });
332-
333- uint8_t binPos = 0 ;
334- for (const auto & lutEntry : lutSorted) {
335- const auto & moduleName = lutEntry.mModuleName ;
336- const auto & moduleType = lutEntry.mModuleType ;
337- const auto & strChID = lutEntry.mChannelID ;
338-
339- auto [it, inserted] = mapFEE2hash.insert ({moduleName, binPos});
340- if (inserted) {
341- if (moduleName.find (" PMA" ) != std::string::npos) {
342- mMapPMhash2isAside .insert ({binPos, true });
343- } else if (moduleName.find (" PMC" ) != std::string::npos) {
344- mMapPMhash2isAside .insert ({binPos, false });
319+ // Initialize mapping channelID -> PM hash and PM side (A/C) using FT0 LUT
320+ static bool pmLutInitialized = false ;
321+ static std::array<uint8_t , o2::ft0::Constants::sNCHANNELS_PM > mChID2PMhash {};
322+ static std::map<uint8_t , bool > mMapPMhash2isAside ; // hashed PM -> is A side
323+
324+ if (!pmLutInitialized) {
325+ std::map<std::string, uint8_t > mapFEE2hash; // module name -> hashed PM id
326+ uint8_t tcmHash = 0 ;
327+
328+ const auto & lut = o2::ft0::SingleLUT::Instance ().getVecMetadataFEE ();
329+ auto lutSorted = lut;
330+ std::sort (lutSorted.begin (), lutSorted.end (),
331+ [](const auto & first, const auto & second) { return first.mModuleName < second.mModuleName ; });
332+
333+ uint8_t binPos = 0 ;
334+ for (const auto & lutEntry : lutSorted) {
335+ const auto & moduleName = lutEntry.mModuleName ;
336+ const auto & moduleType = lutEntry.mModuleType ;
337+ const auto & strChID = lutEntry.mChannelID ;
338+
339+ auto [it, inserted] = mapFEE2hash.insert ({moduleName, binPos});
340+ if (inserted) {
341+ if (moduleName.find (" PMA" ) != std::string::npos) {
342+ mMapPMhash2isAside .insert ({binPos, true });
343+ } else if (moduleName.find (" PMC" ) != std::string::npos) {
344+ mMapPMhash2isAside .insert ({binPos, false });
345+ }
346+ ++binPos;
345347 }
346- ++binPos;
347- }
348348
349- if (std::regex_match (strChID, std::regex (" ^[0-9]{1,3}$" ))) {
350- int chID = std::stoi (strChID);
351- if (chID < o2::ft0::Constants::sNCHANNELS_PM ) {
352- mChID2PMhash [chID] = mapFEE2hash[moduleName];
353- } else {
354- LOG (fatal) << " Incorrect LUT entry: chID " << strChID << " | " << moduleName;
349+ if (std::regex_match (strChID, std::regex (" ^[0-9]{1,3}$" ))) {
350+ int chID = std::stoi (strChID);
351+ if (chID < o2::ft0::Constants::sNCHANNELS_PM ) {
352+ mChID2PMhash [chID] = mapFEE2hash[moduleName];
353+ } else {
354+ LOG (fatal) << " Incorrect LUT entry: chID " << strChID << " | " << moduleName;
355+ }
356+ } else if (moduleType != " TCM" ) {
357+ LOG (fatal) << " Non-TCM module w/o numerical chID: chID " << strChID << " | " << moduleName;
358+ } else { // TCM
359+ tcmHash = mapFEE2hash[moduleName];
355360 }
356- } else if (moduleType != " TCM" ) {
357- LOG (fatal) << " Non-TCM module w/o numerical chID: chID " << strChID << " | " << moduleName;
358- } else { // TCM
359- tcmHash = mapFEE2hash[moduleName];
360361 }
361- }
362362
363- pmLutInitialized = true ;
364- }
363+ pmLutInitialized = true ;
364+ }
365365
366366 int n_hit_A = 0 , n_hit_C = 0 , mean_time_A = 0 , mean_time_C = 0 ;
367367 int summ_ampl_A = 0 , summ_ampl_C = 0 ;
368368 int sum_A_ampl = 0 , sum_C_ampl = 0 ;
369369 int nPMTs = mGeometry .NCellsA * 4 + mGeometry .NCellsC * 4 ;
370370 std::vector<int > sum_ampl_ipmt (nPMTs, 0 );
371- // Per-PM summed charge (like in digits2trgFT0)
372- std::map<uint8_t , int > mapPMhash2sumAmpl;
373- for (const auto & entry : mMapPMhash2isAside ) {
374- mapPMhash2sumAmpl.insert ({entry.first , 0 });
375- }
371+ // Per-PM summed charge (like in digits2trgFT0)
372+ std::map<uint8_t , int > mapPMhash2sumAmpl;
373+ for (const auto & entry : mMapPMhash2isAside ) {
374+ mapPMhash2sumAmpl.insert ({entry.first , 0 });
375+ }
376376
377377 int vertex_time;
378378 const auto & params = FT0DigParam::Instance ();
@@ -447,42 +447,41 @@ for (const auto& entry : mMapPMhash2isAside) {
447447 mean_time_C += smeared_time;
448448 }
449449 }
450-
450+
451451 for (size_t i = 0 ; i < sum_ampl_ipmt.size (); i++) {
452- sum_ampl_ipmt[i] = sum_ampl_ipmt[i] >> 3 ;
453- if (i < 4 * mGeometry .NCellsA ) {
454- sum_A_ampl += sum_ampl_ipmt[i];
455- } else {
456- sum_C_ampl += sum_ampl_ipmt[i];
457- }
452+ sum_ampl_ipmt[i] = sum_ampl_ipmt[i] >> 3 ;
453+ if (i < 4 * mGeometry .NCellsA ) {
454+ sum_A_ampl += sum_ampl_ipmt[i];
455+ } else {
456+ sum_C_ampl += sum_ampl_ipmt[i];
457+ }
458458 }
459-
459+
460460 // Sum over PMs (using per-PM map) for debug/monitoring
461461 int sum_PM_ampl_debug = 0 ;
462462 int sum_PM_ampl_A_debug = 0 ;
463463 int sum_PM_ampl_C_debug = 0 ;
464464 for (const auto & entry : mapPMhash2sumAmpl) {
465- int pmAmpl = (entry.second >> 3 );
466- sum_PM_ampl_debug += pmAmpl;
467- auto itSide = mMapPMhash2isAside .find (entry.first );
468- if (itSide != mMapPMhash2isAside .end ()) {
469- if (itSide->second ) {
470- sum_PM_ampl_A_debug += pmAmpl;
471- } else {
472- sum_PM_ampl_C_debug += pmAmpl;
473- }
474- }
465+ int pmAmpl = (entry.second >> 3 );
466+ sum_PM_ampl_debug += pmAmpl;
467+ auto itSide = mMapPMhash2isAside .find (entry.first );
468+ if (itSide != mMapPMhash2isAside .end ()) {
469+ if (itSide->second ) {
470+ sum_PM_ampl_A_debug += pmAmpl;
471+ } else {
472+ sum_PM_ampl_C_debug += pmAmpl;
473+ }
474+ }
475475 }
476- LOG (debug) << " Sum PM amplitude (LUT-based): total=" << sum_PM_ampl_debug
477- << " A-side=" << sum_PM_ampl_A_debug
478- << " C-side=" << sum_PM_ampl_C_debug;
479-
476+ LOG (debug) << " Sum PM amplitude (LUT-based): total=" << sum_PM_ampl_debug
477+ << " A-side=" << sum_PM_ampl_A_debug
478+ << " C-side=" << sum_PM_ampl_C_debug;
480479
481480 Bool_t is_A, is_C, isVertex, is_Central, is_SemiCentral = 0 ;
482481 is_A = n_hit_A > 0 ;
483482 is_C = n_hit_C > 0 ;
484- is_Central = sum_PM_ampl_A_debug + sum_PM_ampl_C_debug >= 2 * params.mtrg_central_trh ;
485- is_SemiCentral = sum_PM_ampl_A_debug + sum_PM_ampl_C_debug >= 2 * params.mtrg_semicentral_trh && !is_Central;
483+ is_Central = sum_PM_ampl_A_debug + sum_PM_ampl_C_debug >= 2 * params.mtrg_central_trh ;
484+ is_SemiCentral = sum_PM_ampl_A_debug + sum_PM_ampl_C_debug >= 2 * params.mtrg_semicentral_trh && !is_Central;
486485 uint32_t amplA = is_A ? summ_ampl_A * 0.125 : -5000 ; // sum amplitude A side / 8 (hardware)
487486 uint32_t amplC = is_C ? summ_ampl_C * 0.125 : -5000 ; // sum amplitude C side / 8 (hardware)
488487 int timeA = is_A ? mean_time_A / n_hit_A : -5000 ; // average time A side
0 commit comments