Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-14 02:23:00

0001 /** \class EcalTrigPrimFunctionalAlgo
0002  *
0003  * EcalTrigPrimFunctionalAlgo is the main algorithm class for TPG
0004  * It coordinates all the other algorithms
0005  * Structure is very close to electronics
0006  *
0007  *
0008  * \author Ursula Berthon, Stephanie Baffioni, LLR Palaiseau
0009  *
0010  * \version   1st Version may 2006
0011  * \version   2nd Version jul 2006
0012 
0013  *
0014  ************************************************************/
0015 #include <algorithm>
0016 #include <functional>
0017 #include <numeric>
0018 #include <string>
0019 
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 
0022 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0023 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0024 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0025 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0026 
0027 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixLinearizer.h"
0028 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStrip.h"
0029 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcp.h"
0030 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h"
0031 
0032 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0033 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
0034 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
0035 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
0036 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
0037 
0038 #include "CondFormats/DataRecord/interface/EcalTPGPedestalsRcd.h"
0039 #include "CondFormats/EcalObjects/interface/EcalTPGPedestals.h"
0040 
0041 #include <string>
0042 
0043 const unsigned int EcalTrigPrimFunctionalAlgo::nrSamples_ = 5;  // to be written
0044 const unsigned int EcalTrigPrimFunctionalAlgo::maxNrSamplesOut_ = 10;
0045 const unsigned int EcalTrigPrimFunctionalAlgo::maxNrTowers_ = 2448;
0046 const unsigned int EcalTrigPrimFunctionalAlgo::maxNrTPs_ = 2448;  // FIXME??
0047 
0048 //----------------------------------------------------------------------
0049 
0050 EcalTrigPrimFunctionalAlgo::EcalTrigPrimFunctionalAlgo(const EcalTrigTowerConstituentsMap *eTTmap,
0051                                                        const CaloSubdetectorGeometry *endcapGeometry,
0052                                                        const EcalElectronicsMapping *theMapping,
0053                                                        int binofmax,
0054                                                        bool tcpFormat,
0055                                                        bool debug,
0056                                                        bool famos,
0057                                                        bool tpInfoPrintout)
0058     : eTTmap_(eTTmap),
0059       theEndcapGeometry_(endcapGeometry),
0060       theMapping_(theMapping),
0061       binOfMaximum_(binofmax),
0062       tcpFormat_(tcpFormat),
0063       barrelOnly_(true),
0064       debug_(debug),
0065       famos_(famos),
0066       tpInfoPrintout_(tpInfoPrintout)
0067 
0068 {
0069   if (famos_)
0070     maxNrSamples_ = 1;  // get from input??
0071   else
0072     maxNrSamples_ = 10;
0073   this->init();
0074 }
0075 
0076 EcalTrigPrimFunctionalAlgo::EcalTrigPrimFunctionalAlgo(
0077     const EcalElectronicsMapping *theMapping, int binofmax, bool tcpFormat, bool debug, bool famos, bool tpInfoPrintout)
0078     : theMapping_(theMapping),
0079       binOfMaximum_(binofmax),
0080       tcpFormat_(tcpFormat),
0081       barrelOnly_(true),
0082       debug_(debug),
0083       famos_(famos),
0084       tpInfoPrintout_(tpInfoPrintout)
0085 
0086 {
0087   if (famos_)
0088     maxNrSamples_ = 1;  // get from input??
0089   else
0090     maxNrSamples_ = 10;
0091   this->init();
0092 }
0093 
0094 //----------------------------------------------------------------------
0095 void EcalTrigPrimFunctionalAlgo::init() {
0096   // create main sub algos
0097   estrip_ = std::make_unique<EcalFenixStrip>(theMapping_, debug_, famos_, maxNrSamples_, nbMaxXtals_, tpInfoPrintout_);
0098   etcp_ = std::make_unique<EcalFenixTcp>(
0099       tcpFormat_, debug_, famos_, binOfMaximum_, maxNrSamples_, nbMaxStrips_, tpInfoPrintout_);
0100 
0101   // initialise data structures
0102   initStructures(towerMapEB_);
0103   initStructures(towerMapEE_);
0104 
0105   hitTowers_.resize(maxNrTowers_);
0106   towtp_.resize(maxNrSamplesOut_);
0107   towtp2_.resize(maxNrSamplesOut_);
0108 }
0109 //----------------------------------------------------------------------
0110 
0111 EcalTrigPrimFunctionalAlgo::~EcalTrigPrimFunctionalAlgo() {}
0112 //----------------------------------------------------------------------
0113 void EcalTrigPrimFunctionalAlgo::run(EBDigiCollection const *col,
0114                                      EcalTrigPrimDigiCollection &result,
0115                                      EcalTrigPrimDigiCollection &resultTcp) {
0116   run_part1_EB(col);
0117   run_part2(col, towerMapEB_, result, resultTcp);
0118 }
0119 
0120 //----------------------------------------------------------------------
0121 void EcalTrigPrimFunctionalAlgo::run(EEDigiCollection const *col,
0122                                      EcalTrigPrimDigiCollection &result,
0123                                      EcalTrigPrimDigiCollection &resultTcp) {
0124   run_part1_EE(col);
0125   run_part2(col, towerMapEE_, result, resultTcp);
0126 }
0127 //----------------------------------------------------------------------
0128 int EcalTrigPrimFunctionalAlgo::findStripNr(const EBDetId &id) {
0129   int stripnr;
0130   int n = ((id.ic() - 1) % 100) / 20;  // 20 corresponds to 4 * ecal_barrel_crystals_per_strip FIXME!!
0131   if (id.ieta() < 0)
0132     stripnr = n + 1;
0133   else
0134     stripnr = nbMaxStrips_ - n;
0135   return stripnr;
0136 }
0137 //----------------------------------------------------------------------
0138 int EcalTrigPrimFunctionalAlgo::findStripNr(const EEDetId &id) {
0139   int stripnr;
0140   const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(id);
0141   stripnr = elId.pseudoStripId();
0142   return stripnr;
0143 }
0144 //----------------------------------------------------------------------
0145 
0146 void EcalTrigPrimFunctionalAlgo::run_part1_EB(EBDigiCollection const *col) {
0147   clean(towerMapEB_);
0148   // loop over dataframes and fill map
0149   fillMap(col, towerMapEB_);
0150 }
0151 //----------------------------------------------------------------------
0152 void EcalTrigPrimFunctionalAlgo::run_part1_EE(EEDigiCollection const *col) {
0153   clean(towerMapEE_);
0154   // loop over dataframes and fill map
0155   fillMap(col, towerMapEE_);
0156 }