CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixTcpFormat.cc

Go to the documentation of this file.
00001 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcpFormat.h>
00002 #include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h"
00003 #include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
00004 #include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include <iostream>
00007 
00008 using  namespace std;
00009 
00010 EcalFenixTcpFormat::EcalFenixTcpFormat(bool tcpFormat, bool debug, bool famos,int binOfMax)
00011   : tcpFormat_(tcpFormat),debug_(debug),famos_(famos),binOfMax_(binOfMax)
00012 {
00013   status_=0;
00014   badTTStatus_=&status_;
00015 }
00016  
00017 EcalFenixTcpFormat::~EcalFenixTcpFormat() {
00018 }
00019 
00020  
00021 void EcalFenixTcpFormat::process(std::vector<int> &Et, std::vector<int> &fgvb, int eTTotShift,
00022                                  std::vector<EcalTriggerPrimitiveSample> & out,
00023                                  std::vector<EcalTriggerPrimitiveSample> & out2, bool isInInnerRings){
00024   // put TP-s in the output
00025   // on request also in TcpFormat    
00026   // for famos version we have to write dummies except for the middle
00027   
00028   int myEt;
00029   if (famos_) {
00030     for (unsigned int i=0; i<out.size();++i) {
00031       if (i==binOfMax_-1) {
00032         myEt=Et[0]>>eTTotShift;
00033         if (myEt>0x3ff) myEt=0x3ff ;
00034         if (isInInnerRings) myEt = myEt /2 ;
00035         
00036         // badTTStatus_ ==0 if the TT works
00037         // badTTStatus_ !=0 if there are some problems
00038         int lut_out;
00039         if (*badTTStatus_!=0){
00040           lut_out = 0;
00041         }
00042         else
00043           lut_out = (lut_)[myEt] ;
00044         
00045         int ttFlag = (lut_out & 0x700) >> 8 ;
00046         myEt = lut_out & 0xff ;
00047         out[i]=EcalTriggerPrimitiveSample( myEt,fgvb[0],ttFlag); 
00048       }
00049       else out[i]=EcalTriggerPrimitiveSample( );
00050     }
00051   }
00052   else {
00053     for (unsigned int i=0; i<Et.size();++i) {
00054       int myFgvb=fgvb[i];
00055       //myEt=Et[i]>>eTTotShift;
00056       //if (myEt>0x3ff) myEt=0x3ff ;
00057       //if (isInInnerRings) myEt = myEt /2 ;  
00058 
00059       // bug fix 091009:
00060       myEt=Et[i]; 
00061       if (myEt>0xfff) 
00062         myEt=0xfff ;
00063       if (isInInnerRings) 
00064         myEt = myEt /2 ;  
00065       myEt >>= eTTotShift ;
00066       if (myEt>0x3ff) myEt=0x3ff ;
00067 
00068         int lut_out;
00069         if (*badTTStatus_!=0){
00070           lut_out = 0;
00071         }
00072         else
00073           lut_out = (lut_)[myEt] ;
00074       
00075       int ttFlag = (lut_out & 0x700) >> 8 ;
00076       if (tcpFormat_)  {
00077         out2[i]=EcalTriggerPrimitiveSample( ((ttFlag&0x7)<<11) | ((myFgvb & 0x1)<<10) |  (myEt & 0x3ff));
00078       }
00079       myEt = lut_out & 0xff ;
00080       out[i]=EcalTriggerPrimitiveSample( myEt,myFgvb,ttFlag); 
00081     }
00082   }
00083 }
00084 
00085 void EcalFenixTcpFormat::setParameters(uint32_t towid,const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT)
00086 {
00087   const EcalTPGGroups::EcalTPGGroupsMap & groupmap = ecaltpgLutGroup -> getMap();
00088   EcalTPGGroups::EcalTPGGroupsMapItr it=groupmap.find(towid);
00089   if (it!=groupmap.end()) {
00090     uint32_t lutid=(*it).second;
00091     const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut-> getMap();
00092     EcalTPGLutIdMap::EcalTPGLutMapItr itl=lutmap.find(lutid);
00093     if (itl!=lutmap.end()) {
00094       lut_=(*itl).second.getLut();
00095     }  else edm::LogWarning("EcalTPG")<<" could not find EcalTPGLutMap for "<<lutid;
00096 
00097   }
00098   else edm::LogWarning("EcalTPG")<<" could not find EcalTPGFineGrainTowerEEMap for "<<towid;
00099   
00100   const EcalTPGTowerStatusMap & badTTMap = ecaltpgbadTT -> getMap();
00101   EcalTPGTowerStatusMapIterator itbadTT = badTTMap.find(towid);
00102   if (itbadTT!=badTTMap.end()) {
00103     badTTStatus_=&(*itbadTT).second;
00104   }
00105 }
00106