00001
00015 #include <string>
00016 #include <algorithm>
00017 #include <numeric>
00018 #include <functional>
00019
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021
00022 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00023 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00024 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
00025 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
00026
00027 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h"
00028 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixLinearizer.h"
00029 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStrip.h"
00030 #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcp.h"
00031
00032 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00033 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00034 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
00035 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00036 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
00037
00038 #include "CondFormats/EcalObjects/interface/EcalTPGPedestals.h"
00039 #include "CondFormats/DataRecord/interface/EcalTPGPedestalsRcd.h"
00040
00041 #include <TTree.h>
00042 #include <TMath.h>
00043
00044 const unsigned int EcalTrigPrimFunctionalAlgo::nrSamples_=5;
00045 const unsigned int EcalTrigPrimFunctionalAlgo::maxNrSamplesOut_=10;
00046 const unsigned int EcalTrigPrimFunctionalAlgo::maxNrTowers_=2448;
00047 const unsigned int EcalTrigPrimFunctionalAlgo::maxNrTPs_=2448;
00048
00049
00050
00051 EcalTrigPrimFunctionalAlgo::EcalTrigPrimFunctionalAlgo(const edm::EventSetup & setup,int binofmax,bool tcpFormat, bool barrelOnly,bool debug,bool famos): binOfMaximum_(binofmax),
00052 tcpFormat_(tcpFormat), barrelOnly_(barrelOnly), debug_(debug), famos_(famos)
00053
00054 {
00055 if (famos_) maxNrSamples_=1;
00056 else maxNrSamples_=10;
00057 this->init(setup);
00058 }
00059
00060
00061 void EcalTrigPrimFunctionalAlgo::init(const edm::EventSetup & setup) {
00062 if (!barrelOnly_) {
00063 edm::ESHandle<CaloGeometry> theGeometry;
00064 edm::ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle;
00065 setup.get<CaloGeometryRecord>().get( theGeometry );
00066 setup.get<EcalEndcapGeometryRecord>().get("EcalEndcap",theEndcapGeometry_handle);
00067 theEndcapGeometry = &(*theEndcapGeometry_handle);
00068 setup.get<IdealGeometryRecord>().get(eTTmap_);
00069 }
00070
00071 edm::ESHandle< EcalElectronicsMapping > ecalmapping;
00072 setup.get< EcalMappingRcd >().get(ecalmapping);
00073 theMapping_ = ecalmapping.product();
00074
00075
00076 estrip_= new EcalFenixStrip(setup,theMapping_,debug_,famos_,maxNrSamples_,nbMaxXtals_);
00077 etcp_ = new EcalFenixTcp(setup,tcpFormat_,debug_,famos_,binOfMaximum_,maxNrSamples_,nbMaxStrips_) ;
00078
00079
00080 initStructures(towerMapEB_);
00081 initStructures(towerMapEE_);
00082
00083 hitTowers_.resize(maxNrTowers_);
00084 towtp_.resize(maxNrSamplesOut_);
00085 towtp2_.resize(maxNrSamplesOut_);
00086
00087 }
00088
00089
00090 EcalTrigPrimFunctionalAlgo::~EcalTrigPrimFunctionalAlgo()
00091 {
00092 delete estrip_;
00093 delete etcp_;
00094 }
00095
00096 void EcalTrigPrimFunctionalAlgo::run(const edm::EventSetup & setup, EBDigiCollection const * col,
00097 EcalTrigPrimDigiCollection & result,
00098 EcalTrigPrimDigiCollection & resultTcp)
00099 {
00100 run_part1_EB(col);
00101 run_part2(setup,col,towerMapEB_,result,resultTcp);
00102 }
00103
00104
00105 void EcalTrigPrimFunctionalAlgo::run(const edm::EventSetup & setup, EEDigiCollection const * col,
00106 EcalTrigPrimDigiCollection & result,
00107 EcalTrigPrimDigiCollection & resultTcp)
00108 {
00109
00110 run_part1_EE(col);
00111 run_part2(setup, col,towerMapEE_,result,resultTcp);
00112 }
00113
00114 int EcalTrigPrimFunctionalAlgo::findStripNr(const EBDetId &id){
00115 int stripnr;
00116 int n=((id.ic()-1)%100)/20;
00117 if (id.ieta()<0) stripnr = n+1;
00118 else stripnr =nbMaxStrips_ - n;
00119 return stripnr;
00120 }
00121
00122 int EcalTrigPrimFunctionalAlgo::findStripNr(const EEDetId &id){
00123 int stripnr;
00124 const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(id);
00125 stripnr=elId.pseudoStripId();
00126 return stripnr;
00127 }
00128
00129
00130 void EcalTrigPrimFunctionalAlgo::run_part1_EB(EBDigiCollection const * col){
00131 clean(towerMapEB_);
00132
00133 fillMap(col,towerMapEB_);
00134 }
00135
00136 void EcalTrigPrimFunctionalAlgo::run_part1_EE(EEDigiCollection const * col){
00137 clean(towerMapEE_);
00138
00139 fillMap(col,towerMapEE_);
00140 }