00001 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcpFormat.h>
00002 #include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h"
00003 #include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include <iostream>
00006
00007 using namespace std;
00008
00009 EcalFenixTcpFormat::EcalFenixTcpFormat(bool tcpFormat, bool debug, bool famos,int binOfMax)
00010 : tcpFormat_(tcpFormat),debug_(debug),famos_(famos),binOfMax_(binOfMax)
00011 {
00012 }
00013
00014 EcalFenixTcpFormat::~EcalFenixTcpFormat() {
00015 }
00016
00017
00018 void EcalFenixTcpFormat::process(std::vector<int> &Et, std::vector<int> &fgvb, int eTTotShift,
00019 std::vector<EcalTriggerPrimitiveSample> & out,
00020 std::vector<EcalTriggerPrimitiveSample> & out2, bool isInInnerRings){
00021
00022
00023
00024
00025 int myEt;
00026 if (famos_) {
00027 for (unsigned int i=0; i<out.size();++i) {
00028 if (i==binOfMax_-1) {
00029 myEt=Et[0]>>eTTotShift;
00030 if (myEt>0x3ff) myEt=0x3ff ;
00031 if (isInInnerRings) myEt = myEt /2 ;
00032 int lut_out = (lut_)[myEt] ;
00033 int ttFlag = (lut_out & 0x700) >> 8 ;
00034 myEt = lut_out & 0xff ;
00035 out[i]=EcalTriggerPrimitiveSample( myEt,fgvb[0],ttFlag);
00036 }
00037 else out[i]=EcalTriggerPrimitiveSample( );
00038 }
00039 }
00040 else {
00041 for (unsigned int i=0; i<Et.size();++i) {
00042 int myFgvb=fgvb[i];
00043 myEt=Et[i]>>eTTotShift;
00044 if (myEt>0x3ff) myEt=0x3ff ;
00045 if (isInInnerRings) myEt = myEt /2 ;
00046
00047 int lut_out = (lut_)[myEt] ;
00048 int ttFlag = (lut_out & 0x700) >> 8 ;
00049 if (tcpFormat_) {
00050 out2[i]=EcalTriggerPrimitiveSample( ((ttFlag&0x7)<<11) | ((myFgvb & 0x1)<<10) | (myEt & 0x3ff));
00051 }
00052 myEt = lut_out & 0xff ;
00053 out[i]=EcalTriggerPrimitiveSample( myEt,myFgvb,ttFlag);
00054 }
00055 }
00056 }
00057
00058 void EcalFenixTcpFormat::setParameters(uint32_t towid,const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut)
00059 {
00060 const EcalTPGGroups::EcalTPGGroupsMap & groupmap = ecaltpgLutGroup -> getMap();
00061 EcalTPGGroups::EcalTPGGroupsMapItr it=groupmap.find(towid);
00062 if (it!=groupmap.end()) {
00063 uint32_t lutid=(*it).second;
00064 const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut-> getMap();
00065 EcalTPGLutIdMap::EcalTPGLutMapItr itl=lutmap.find(lutid);
00066 if (itl!=lutmap.end()) {
00067 lut_=(*itl).second.getLut();
00068 } else edm::LogWarning("EcalTPG")<<" could not find EcalTPGLutMap for "<<lutid;
00069
00070 }
00071 else edm::LogWarning("EcalTPG")<<" could not find EcalTPGFineGrainTowerEEMap for "<<towid;
00072 }
00073