Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:10

0001 #include "CondFormats/EcalObjects/interface/EcalSRSettings.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 
0004 #include <sstream>
0005 #include <iostream>
0006 #include <cstdlib>
0007 #include <cassert>
0008 #include <algorithm>
0009 
0010 using namespace std;
0011 
0012 EcalSRSettings::EcalSRSettings()
0013     : ebDccAdcToGeV_(0.), eeDccAdcToGeV_(0.), bxGlobalOffset_(0), automaticMasks_(0), automaticSrpSelect_(0) {}
0014 
0015 #define SR_PRINT(a) o << #a ": " << val.a##_ << "\n";
0016 #define SR_VPRINT(a)                              \
0017   o << #a;                                        \
0018   if (val.a##_.empty())                           \
0019     o << "[0.." << (val.a##_.size() - 1) << "]:"; \
0020   else                                            \
0021     o << "[]: <empty>";                           \
0022   for (size_t i = 0; i < val.a##_.size(); ++i)    \
0023     o << "\t" << val.a##_[i];                     \
0024   o << "\n";
0025 #define SR_VVPRINT(a)                                  \
0026   if (val.a##_.empty())                                \
0027     o << #a "[][]: <empty>\n";                         \
0028   for (size_t i = 0; i < val.a##_.size(); ++i) {       \
0029     o << #a "[" << i << "]";                           \
0030     if (val.a##_.empty())                              \
0031       o << "[0.." << (val.a##_[i].size() - 1) << "]:"; \
0032     else                                               \
0033       o << "[]: <empty>";                              \
0034     for (size_t j = 0; j < val.a##_[i].size(); ++j)    \
0035       o << "\t" << val.a##_[i][j];                     \
0036     o << "\n";                                         \
0037   }
0038 
0039 std::ostream& operator<<(std::ostream& o, const EcalSRSettings& val) {
0040   o << "# Neighbour eta range, neighborhood: (2*deltaEta+1)*(2*deltaPhi+1)\n"
0041        "# In the vector contains:\n"
0042        "#   - 1 element, then value applies to whole ECAL\n"
0043        "#   - 2 elements, then element 0 applies to EB, element 1 to EE\n"
0044        "#   - 12 elements, then element i applied to SRP (i+1)\n"
0045        "# SRP emulation (see SimCalorimetry/EcalSelectiveReadoutProcuders) supports\n"
0046        "# only 1 element mode.\n";
0047   SR_VPRINT(deltaEta);
0048 
0049   o << "\n# Neighbouring eta range, neighborhood: (2*deltaEta+1)*(2*deltaPhi+1)\n"
0050        "# If the vector contains...\n"
0051        "#   ... 1 element, then value applies to whole ECAL\n"
0052        "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0053        "#   ... 12 elements, then element i applied to SRP (i+1)\n"
0054        "# If the vector contains...\n"
0055        "#   ... 1 element, then value applies to whole ECAL\n"
0056        "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0057        "#   ... 12 elements, then element i applied to SRP (i+1)\n"
0058        "# SRP emulation (see SimCalorimetry/EcalSelectiveReadoutProcuders) supports\n"
0059        "# only the single-element mode.\n";
0060   SR_VPRINT(deltaPhi);
0061 
0062   o << "\n# Index of time sample (staring from 1) the first DCC weights is implied\n"
0063        "# If the vector contains:\n"
0064        "#   ... 1 element, then value applies to whole ECAL\n"
0065        "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0066        "#   ... 54 elements, then element i applied to DCC (i+1) (FED ID 651+i)\n"
0067        "# SRP emulation (see SimCalorimetry/EcalSelectiveReadoutProcuders) supports\n"
0068        "# only the single-element mode.\n";
0069   SR_VPRINT(ecalDccZs1stSample);
0070 
0071   o << "\n# ADC to GeV conversion factor used in ZS filter for EB\n";
0072   SR_PRINT(ebDccAdcToGeV);
0073 
0074   o << "\n# ADC to GeV conversion factor used in ZS filter for EE\n";
0075   SR_PRINT(eeDccAdcToGeV);
0076 
0077   o << "\n# DCC ZS FIR weights: weights are rounded in such way that in Hw\n"
0078        "# representation (weigth*1024 rounded to nearest integer) the sum is null:\n"
0079        "# Each element is a vector of 6 values, the 6 weights\n"
0080        "# If the vector contains...\n"
0081        "#   ... 1 element, then the weight set applies to whole ECAL\n"
0082        "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0083        "#   ... 54 elements, then element i applied to DCC (i+1) (FED ID 651+i)\n";
0084   SR_VVPRINT(dccNormalizedWeights);
0085 
0086   o << "\n# Switch to use a symetric zero suppression (cut on absolute value). For\n"
0087        "# studies only, for time being it is not supported by the hardware.\n"
0088        "# having troubles for vector<bool> with coral (3.8.0pre1), using vector<int> instead,\n"
0089        "# 0 means false, a value different than 0 means true.\n"
0090        "# If the vector contains...\n"
0091        "#   ... 1 element, then the weight set applies to whole ECAL\n"
0092        "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0093        "#   ... 54 elements, then element i applied to DCC (i+1) (FED ID 651+i)\n"
0094        "#   ... 75848 elements, then:\n"
0095        "#          for i < 61200, element i applies to EB crystal with denseIndex i\n"
0096        "#                         (see EBDetId::denseIndex())\n"
0097        "#          for i >= 61200, element i applies to EE crystal with denseIndex (i+61200)\n"
0098        "#                         (see EBDetId::denseIndex())\n"
0099        "# SRP emulation supports only 1 element mode. Hardware does not support\n"
0100        "# the symetric ZS, so symetricZS = 0 for real data.\n";
0101   SR_VPRINT(symetricZS);
0102 
0103   o << "\n# ZS energy threshold in GeV to apply to low interest channels of barrel\n"
0104        "# If the vector contains...\n"
0105        "#   ... 1 element, then the weight set applies to whole ECAL\n"
0106        "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0107        "#   ... 54 elements, then element i applied to DCC (i+1) (FED ID 651+i)\n"
0108        "# SRP emulation supports only the 2-element mode.\n"
0109        "# Corresponds to srpBarrelLowInterestChannelZS and srpEndcapLowInterestChannelZS\n"
0110        "# of python configuration file parameters\n";
0111   SR_VPRINT(srpLowInterestChannelZS);
0112 
0113   o << "\n# ZS energy threshold in GeV to apply to high interest channels of endcap\n"
0114        "# If the vector contains...\n"
0115        "#   ... 1 element, then the weight set applies to whole ECAL\n"
0116        "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0117        "#   ... 54 elements, then element i applied to DCC (i+1) (FED ID 651+i)\n"
0118        "# SRP emulation supports only the 2-element mode.\n"
0119        "# Corresponds to srpBarrelLowInterestChannelZS and srpEndcapLowInterestChannelZS\n"
0120        "# of python configuration file parameters\n";
0121   SR_VPRINT(srpHighInterestChannelZS);
0122 
0123   //  o << "\n# Switch to run w/o trigger primitive. For debug use only\n"
0124   //  "# having troubles for vector<bool> with coral (3.8.0pre1), using vector<int> instead\n"
0125   //  "# Parameter only relevant for emulation. For real data, must be contains 1 element with\n"
0126   //  "# value 0.\n"
0127   //  "#   ... 1 element, then the weight set applies to whole ECAL\n"
0128   //  "#   ... 2 elements, then element 0 applies to EB, element 1 to EE\n"
0129   //  "#   ... 54 elements, then element i applied to DCC (i+1) (FED ID 651+i)\n"
0130   //  "# SRP emulation supports only the single-element mode.\n";
0131   //  SR_VPRINT(trigPrimBypass);\n"
0132   //
0133   //  o << "\n# Mode selection for "# Trig bypass" mode\n"
0134   //  "# 0: TT thresholds applied on sum of crystal Et's\n"
0135   //  "# 1: TT thresholds applies on compressed Et from Trigger primitive\n"
0136   //  "# @see trigPrimByPass switch\n"
0137   //  "# Parameter only relevant for \n";
0138   //  SR_VPRINT(trigPrimBypassMode);
0139   //
0140   //  o << "\n# for debug mode only:\n";
0141   //  SR_VPRINT( trigPrimBypassLTH);
0142   //
0143   //  o << "\n# for debug mode only:\n";
0144   //  SR_VPRINT(trigPrimBypassHTH);
0145   //
0146   //  o << "\n# for debug mode only\n"
0147   //  "# having troubles for vector<bool> with coral (3.8.0pre1), using vector<int> instead\n";
0148   //  SR_VPRINT( trigPrimBypassWithPeakFinder);
0149   //
0150   //  o << "\n# Trigger Tower Flag to use when a flag is not found from the input\n"
0151   //  "# Trigger Primitive collection. Must be one of the following values:\n"
0152   //  "# 0: low interest, 1: mid interest, 3: high interest\n"
0153   //  "# 4: forced low interest, 5: forced mid interest, 7: forced high interest\n";
0154   //  SR_VPRINT(defaultTtf);\n"
0155 
0156   o << "\n# SR->action flag map. 4 elements\n"
0157        "# action_[i]: action for flag value i\n";
0158   SR_VPRINT(actions);
0159 
0160   o << "\n# Masks for TTC inputs of SRP cards\n"
0161        "# One element per TCC, that is 108 elements: element i applies to TCC (i+1)\n";
0162   SR_VPRINT(tccMasksFromConfig);
0163 
0164   o << "\n# Masks for SRP-SRP inputs of SRP cards\n"
0165        "# One element per SRP, that is 12 elements: element i applies to SRP (i+1)\n"
0166        "# indices: [iSrp][iCh]\n";
0167   SR_VVPRINT(srpMasksFromConfig);
0168 
0169   o << "\n# Masks for DCC output of SRP cards\n"
0170        "# One element per DCC, that is 54 elements: element i applies to DCC (i+1)\n";
0171   SR_VPRINT(dccMasks);
0172 
0173   o << "\n# Mask to enable pattern test. Typical value: 0.\n"
0174        "# One element per SRP, that is 12 elements: element i applies to SRP (i+1)\n";
0175   SR_VPRINT(srfMasks);
0176 
0177   o << "\n# Substitution flags used in patterm mode\n"
0178        "# indices: [iSrp][iFlag]\n";
0179   SR_VVPRINT(substitutionSrfs);
0180 
0181   o << "\n# Tester mode configuration\n";
0182   SR_VPRINT(testerTccEmuSrpIds);
0183   SR_VPRINT(testerSrpEmuSrpIds);
0184   SR_VPRINT(testerDccTestSrpIds);
0185   SR_VPRINT(testerSrpTestSrpIds);
0186   //@}
0187 
0188   o << "\n# Per SRP card bunch crossing counter offset.\n"
0189        "# This offset is added to the bxGlobalOffset\n";
0190   SR_VPRINT(bxOffsets);
0191 
0192   o << "\n# SRP system bunch crossing counter offset.\n"
0193        "# For each card the bxOffset[i]\n"
0194        "# is added to this one.\n";
0195   SR_PRINT(bxGlobalOffset);
0196 
0197   o << "\n# Switch for automatic channel masking. 0: disabled; 1: enabled. Standard  configuration: 1.\n"
0198        "# When enabled, if a FED is excluded from the run, the corresponding TCC inputs is automatically\n"
0199        "# masked (overwrites the tccInputMasks).\n";
0200   SR_PRINT(automaticMasks);
0201 
0202   o << "\n# Switch for automatic SRP card selection. 0: disabled; 1 : enabled..\n"
0203        "# When enabled, if all the FEDs corresponding to a given SRP is excluded from the run,\n"
0204        "# Then the corresponding SRP card is automatically excluded.\n";
0205   SR_PRINT(automaticSrpSelect);
0206 
0207   return o;
0208 }