CMS 3D CMS Logo

HcaluLUTTPGCoder Class Reference

The nominal coder uses a user-supplied table to linearize the ADC values. More...

#include <CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h>

Inheritance diagram for HcaluLUTTPGCoder:

HcalTPGCoder

List of all members.

Public Member Functions

virtual unsigned short adc2Linear (HcalQIESample sample, HcalDetId id) const
virtual void adc2Linear (const HFDataFrame &df, IntegerCaloSamples &ics) const
virtual void adc2Linear (const HBHEDataFrame &df, IntegerCaloSamples &ics) const
virtual void compress (const IntegerCaloSamples &ics, const std::vector< bool > &featureBits, HcalTriggerPrimitiveDigi &tp) const
virtual float getLUTGain (HcalDetId id) const
virtual float getLUTPedestal (HcalDetId id) const
 HcaluLUTTPGCoder (const char *ifilename, bool read_Ascii_LUTs)
void PrintTPGMap ()
void update (const char *filename)
void update (const HcalDbService &conditions)
virtual ~HcaluLUTTPGCoder ()

Private Types

typedef short unsigned int LUT
typedef std::vector< intLUTType

Private Member Functions

void AllocateLUTs ()
int GetLUTID (HcalSubdetector id, int ieta, int iphi, int depth) const
void getRecHitCalib (const char *filename)
void loadILUTs (const char *filename)

Private Attributes

float * _gain
float * _ped
LUTinputLUT [nluts]
std::vector< LUTTypeinputluts_
float Rcalib [87]

Static Private Attributes

static const int INPUT_LUT_SIZE = 128
static const int nluts = 46007
static const float nominal_gain = 0.177


Detailed Description

The nominal coder uses a user-supplied table to linearize the ADC values.

 [number of ieta slices]
 [low tower 1] [low tower 2] ...
 [high tower 1] [ high tower 2] ...
 [LUT 1(0)] [LUT 2(0)] ...
 [LUT 1(1)] [LUT 2(1)] ...
 . . .
 [LUT 1(127)] [LUT 2(127)] ...
 

Date
2008/05/01 20:43:29
Revision
1.15
Author:
M. Weinberger -- TAMU

Tulika Bose and Greg Landsberg -- Brown

Definition at line 31 of file HcaluLUTTPGCoder.h.


Member Typedef Documentation

typedef short unsigned int HcaluLUTTPGCoder::LUT [private]

Definition at line 55 of file HcaluLUTTPGCoder.h.

typedef std::vector<int> HcaluLUTTPGCoder::LUTType [private]

Definition at line 48 of file HcaluLUTTPGCoder.h.


Constructor & Destructor Documentation

HcaluLUTTPGCoder::HcaluLUTTPGCoder ( const char *  ifilename,
bool  read_Ascii_LUTs 
)

Definition at line 24 of file HcaluLUTTPGCoder.cc.

References AllocateLUTs(), getRecHitCalib(), and update().

00024                                                                              {
00025   AllocateLUTs();
00026   // std::cout << " filename:" << filename << " read_Ascii_LUTs " << read_Ascii_LUTs << std::endl;
00027   if (read_Ascii_LUTs == true) {
00028     update(filename);
00029   }
00030   else {
00031     getRecHitCalib(filename);
00032   }
00033 }

HcaluLUTTPGCoder::~HcaluLUTTPGCoder (  )  [virtual]

Definition at line 201 of file HcaluLUTTPGCoder.cc.

References _gain, _ped, i, inputLUT, and nluts.

00201                                     {
00202   for (int i = 0; i < nluts; i++) {
00203     if (inputLUT[i] != 0) delete [] inputLUT[i];
00204   }
00205   delete [] _gain;
00206   delete [] _ped;
00207 }


Member Function Documentation

unsigned short HcaluLUTTPGCoder::adc2Linear ( HcalQIESample  sample,
HcalDetId  id 
) const [virtual]

Implements HcalTPGCoder.

Definition at line 522 of file HcaluLUTTPGCoder.cc.

References HcalQIESample::adc(), GetLUTID(), and inputLUT.

00522                                                                                     {
00523   int ref = GetLUTID(id.subdet(), id.ieta(), id.iphi(), id.depth());
00524   return inputLUT[ref][sample.adc()];
00525 }

void HcaluLUTTPGCoder::adc2Linear ( const HFDataFrame df,
IntegerCaloSamples ics 
) const [virtual]

Implements HcalTPGCoder.

Definition at line 509 of file HcaluLUTTPGCoder.cc.

References ecalMGPA::adc(), HcalDetId::depth(), Exception, GetLUTID(), i, HFDataFrame::id(), HcalDetId::ieta(), INPUT_LUT_SIZE, inputLUT, HcalDetId::iphi(), HFDataFrame::size(), and HcalDetId::subdet().

00509                                                                                        {
00510    int id = GetLUTID(df.id().subdet(), df.id().ieta(), df.id().iphi(), df.id().depth());
00511    if (inputLUT[id]==0) {
00512      throw cms::Exception("Missing Data") << "No LUT for " << df.id();
00513    } else {
00514      for (int i=0; i<df.size(); i++){
00515        if (df[i].adc() >= INPUT_LUT_SIZE || df[i].adc() < 0)
00516          throw cms::Exception("ADC overflow for HF tower: ") << i << " adc= " << df[i].adc();
00517        if (inputLUT[id] !=0) ics[i]=inputLUT[id][df[i].adc()];
00518      }
00519    }
00520  }

void HcaluLUTTPGCoder::adc2Linear ( const HBHEDataFrame df,
IntegerCaloSamples ics 
) const [virtual]

Implements HcalTPGCoder.

Definition at line 496 of file HcaluLUTTPGCoder.cc.

References ecalMGPA::adc(), HcalDetId::depth(), Exception, GetLUTID(), i, HBHEDataFrame::id(), HcalDetId::ieta(), INPUT_LUT_SIZE, inputLUT, HcalDetId::iphi(), HBHEDataFrame::size(), and HcalDetId::subdet().

00496                                                                                          {
00497    int id = GetLUTID(df.id().subdet(), df.id().ieta(), df.id().iphi(), df.id().depth());
00498    if (inputLUT[id]==0) {
00499      throw cms::Exception("Missing Data") << "No LUT for " << df.id();
00500    } 
00501    else {
00502      for (int i=0; i<df.size(); i++){
00503        if (df[i].adc() >= INPUT_LUT_SIZE || df[i].adc() < 0) throw cms::Exception("ADC overflow for HBHE tower: ") << i << " adc= " << df[i].adc();
00504        if (inputLUT[id] !=0) ics[i]=inputLUT[id][df[i].adc()];
00505      }  
00506    }
00507  }

void HcaluLUTTPGCoder::AllocateLUTs (  )  [private]

Definition at line 209 of file HcaluLUTTPGCoder.cc.

References _gain, _ped, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), GetLUTID(), HcalBarrel, HcalEndcap, HcalForward, i, INPUT_LUT_SIZE, inputLUT, nluts, muonGeometry::rawid, and HcalTopology::valid().

Referenced by HcaluLUTTPGCoder().

00209                                     {
00210   HcalTopology theTopo;
00211   HcalDetId did;
00212 
00213 //  PrintTPGMap();
00214 
00215   _ped = new float[nluts];
00216   _gain = new float[nluts];
00217   for (int i = 0; i < nluts; i++) inputLUT[i] = 0;
00218   int maxid = 0, minid = 0x7FFFFFFF, rawid = 0;
00219   for (int ieta=-41; ieta <= 41; ieta++) {
00220     for (int iphi = 1; iphi <= 72; iphi++) {
00221       for (int depth = 1; depth <= 3; depth++) {
00222         did=HcalDetId(HcalBarrel,ieta,iphi,depth);
00223         if (theTopo.valid(did)) {
00224           rawid = GetLUTID(HcalBarrel, ieta, iphi, depth);
00225           if (inputLUT[rawid] != 0) std::cout << "Error: LUT with (ieta,iphi,depth) = (" << ieta << "," << iphi << "," << depth << ") has been previously allocated!" << std::endl;
00226           else inputLUT[rawid] = new LUT[INPUT_LUT_SIZE];
00227           if (rawid < minid) minid = rawid;
00228           if (rawid > maxid) maxid = rawid;
00229         }
00230 
00231         did=HcalDetId(HcalEndcap,ieta,iphi,depth);
00232         if (theTopo.valid(did)) {
00233           rawid = GetLUTID(HcalEndcap, ieta, iphi, depth);
00234           if (inputLUT[rawid] != 0) std::cout << "Error: LUT with (ieta,iphi,depth) = (" << ieta << "," << iphi << "," << depth << ") has been previously allocated!" << std::endl;
00235           else inputLUT[rawid] = new LUT[INPUT_LUT_SIZE];
00236           if (rawid < minid) minid = rawid;
00237           if (rawid > maxid) maxid = rawid;
00238         }
00239         did=HcalDetId(HcalForward,ieta,iphi,depth);
00240         if (theTopo.valid(did)) {
00241           rawid = GetLUTID(HcalForward, ieta, iphi, depth);
00242           if (inputLUT[rawid] != 0) std::cout << "Error: LUT with (ieta,iphi,depth) = (" << ieta << "," << iphi << "," << depth << ") has been previously allocated!" << std::endl;
00243           else inputLUT[rawid] = new LUT[INPUT_LUT_SIZE];
00244           if (rawid < minid) minid = rawid;
00245           if (rawid > maxid) maxid = rawid;
00246         }
00247       }
00248     }
00249   }
00250 
00251 }

void HcaluLUTTPGCoder::compress ( const IntegerCaloSamples ics,
const std::vector< bool > &  featureBits,
HcalTriggerPrimitiveDigi tp 
) const [virtual]

Implements HcalTPGCoder.

Definition at line 197 of file HcaluLUTTPGCoder.cc.

References Exception.

00197                                                                                                                                      {
00198   throw cms::Exception("PROBLEM: This method should never be invoked!");
00199 }

float HcaluLUTTPGCoder::getLUTGain ( HcalDetId  id  )  const [virtual]

Implements HcalTPGCoder.

Definition at line 532 of file HcaluLUTTPGCoder.cc.

References _gain, and GetLUTID().

00532                                                      {
00533   int ref = GetLUTID(id.subdet(), id.ieta(), id.iphi(), id.depth());
00534   return _gain[ref];
00535 }

int HcaluLUTTPGCoder::GetLUTID ( HcalSubdetector  id,
int  ieta,
int  iphi,
int  depth 
) const [private]

Definition at line 253 of file HcaluLUTTPGCoder.cc.

References HcalEndcap, and HcalForward.

Referenced by adc2Linear(), AllocateLUTs(), getLUTGain(), getLUTPedestal(), and update().

00253                                                                                       {
00254   int detid = 0;
00255   if (id == HcalEndcap) detid = 1;
00256   else if (id == HcalForward) detid = 2;
00257   return iphi + 72 * ((ieta + 41) + 83 * (depth + 3 * detid)) - 7777;
00258 }

float HcaluLUTTPGCoder::getLUTPedestal ( HcalDetId  id  )  const [virtual]

Implements HcalTPGCoder.

Definition at line 527 of file HcaluLUTTPGCoder.cc.

References _ped, and GetLUTID().

00527                                                          {
00528   int ref = GetLUTID(id.subdet(), id.ieta(), id.iphi(), id.depth());
00529   return _ped[ref];
00530 }

void HcaluLUTTPGCoder::getRecHitCalib ( const char *  filename  )  [private]

Definition at line 260 of file HcaluLUTTPGCoder.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), j, and Rcalib.

Referenced by HcaluLUTTPGCoder().

00260                                                           {
00261 
00262    std::ifstream userfile;
00263    userfile.open(filename);
00264    int tool;
00265    float Rec_calib_[87];
00266  
00267    if (userfile) {
00268                userfile >> tool;
00269 
00270                if (tool != 86) {
00271                  std::cout << "Wrong RecHit calibration filesize: " << tool << " (expect 86)" << std::endl;
00272                }
00273      for (int j=1; j<87; j++) {
00274        userfile >> Rec_calib_[j]; // Read the Calib factors
00275        Rcalib[j] = Rec_calib_[j] ;
00276      }
00277    
00278      userfile.close();  
00279    }
00280    else  std::cout << "File " << filename << " with RecHit calibration factors not found" << std::endl;
00281 }

void HcaluLUTTPGCoder::loadILUTs ( const char *  filename  )  [private]

void HcaluLUTTPGCoder::PrintTPGMap (  ) 

Definition at line 35 of file HcaluLUTTPGCoder.cc.

References GenMuonPlsPt100GeV_cfg::cout, dd, HcalBarrel, HcalEndcap, HcalForward, HcalTrigTowerDetId::ieta(), HcalTrigTowerDetId::iphi(), n, DetId::rawId(), size, HcalTrigTowerGeometry::towerIds(), tt, and HcalTopology::valid().

00035                                    {
00036         HcalTopology theTopo;
00037         HcalDetId did;
00038 //      std::string HCAL[3] = {"HB", "HE", "HF"};  
00039 
00040         //std::cout << "HB Calorimeter Tower Mapping" << std::endl;
00041         //std::cout << "ieta depth phi span" << std::endl;
00042         for (int ieta=1; ieta <= 41; ieta++) {
00043                 for (int depth = 1; depth <= 3; depth++) {
00044                         bool newdepth = true, OK = false;
00045                         int lastphi = 0;
00046                         for (int iphi = 1; iphi <= 72; iphi++) {
00047                         did=HcalDetId(HcalBarrel,ieta,iphi,depth);
00048                             if (theTopo.valid(did)) {
00049                                         if (newdepth) {
00050                                           //                                      std::cout << "eta/depth = " << ieta << "/" << depth << ": ";
00051                                                 newdepth = false;
00052                                                 OK = true;
00053                                         }
00054                                         if (lastphi == 0) std::cout << iphi << " ";
00055                                         lastphi = iphi;
00056                         }  else lastphi = 0;
00057                         }
00058                         //                      if (lastphi != 0) std::cout << "- " << lastphi;
00059                         //                      if (OK) std::cout << std::endl;
00060                 }
00061         }
00062         //      std::cout << "--------------------------------------------------------------" << std::endl;
00063 
00064         //      std::cout << "HE Calorimeter Tower Mapping" << std::endl;
00065         //      std::cout << "ieta depth phi span" << std::endl;
00066         for (int ieta=-41; ieta <= 41; ieta++) {
00067                 for (int depth = 1; depth <= 3; depth++) {
00068                         bool newdepth = true, OK = false;
00069                         int lastphi = 0;
00070                         for (int iphi = 1; iphi <= 72; iphi++) {
00071                         did=HcalDetId(HcalEndcap,ieta,iphi,depth);
00072                             if (theTopo.valid(did)) {
00073                                         if (newdepth) {
00074                                           //                                            std::cout << "eta/depth = " << ieta << "/" << depth << ": ";
00075                                                 newdepth = false;
00076                                                 OK = true;
00077                                         }
00078                                         if (lastphi == 0) std::cout << iphi << " ";
00079                                         lastphi = iphi;
00080                         }  else lastphi = 0;
00081                         }
00082                         //                      if (lastphi != 0) std::cout << "- " << lastphi;
00083                         //                      if (OK) std::cout << std::endl;
00084                 }
00085         }
00086         //      std::cout << "--------------------------------------------------------------" << std::endl;
00087 
00088         //      std::cout << "HF Calorimeter Tower Mapping" << std::endl;
00089         //      std::cout << "ieta depth phi span" << std::endl;
00090         for (int ieta=1; ieta <= 41; ieta++) {
00091                 for (int depth = 1; depth <= 3; depth++) {
00092                         bool newdepth = true, OK = false;
00093                         int lastphi = 0;
00094                         for (int iphi = 1; iphi <= 72; iphi++) {
00095                         did=HcalDetId(HcalForward,ieta,iphi,depth);
00096                             if (theTopo.valid(did)) {
00097                                         if (newdepth) {
00098                                           //                                            std::cout << "eta/depth = " << ieta << "/" << depth << ": ";
00099                                                 newdepth = false;
00100                                                 OK = true;
00101                                         }
00102                                         if (lastphi == 0) std::cout << iphi << " ";
00103                                         lastphi = iphi;
00104                         }  else lastphi = 0;
00105                         }
00106                         //                      if (lastphi != 0) std::cout << "- " << lastphi;
00107                         //                      if (OK) std::cout << std::endl;
00108                 }
00109         }
00110         //      std::cout << "--------------------------------------------------------------" << std::endl;
00111 
00112         HcalDetId dd;
00113         HcalTrigTowerDetId tt;
00114         HcalTrigTowerGeometry tg;
00115         std::vector<HcalTrigTowerDetId> towerids;
00116         std::vector<HcalDetId> detids;
00117         std::vector<HcalDetId> ttmap[64][72];
00118         
00119 //      std::cout << "HB Tower Mapping:" << std::endl;
00120         for (int ieta=1; ieta <= 41; ieta++) {
00121                 for (int depth = 1; depth <= 3; depth++) {
00122                         for (int iphi = 1; iphi <= 72; iphi++) {
00123                                 did=HcalDetId(HcalBarrel,ieta,iphi,depth);
00124                                 if (theTopo.valid(did)) {
00125                                         tt = HcalTrigTowerDetId(did.rawId());
00126 //                                      std::cout << "ieta, depth, iphi = " << ieta << ", " << depth << ", " << iphi;
00127                                         towerids = tg.towerIds(did.rawId());
00128                                         for(unsigned int n = 0; n < towerids.size(); ++n)
00129                                         {
00130 //                                              std::cout << "Towerid[" << n << "]:" << towerids[n] << " HcalDetId:" << did << std::endl;
00131                                                 int ie = towerids[n].ieta();
00132                                                 if (ie < 0) ie = 32 - ie;
00133                                                 int ip = towerids[n].iphi();
00134                                                 ttmap[ie-1][ip-1].push_back(did);
00135                                         }
00136                                 }
00137                         }
00138                 }
00139         }
00140 //      std::cout << "HE Tower Mapping:" << std::endl;
00141         for (int ieta=1; ieta <= 41; ieta++) {
00142                 for (int depth = 1; depth <= 3; depth++) {
00143                         for (int iphi = 1; iphi <= 72; iphi++) {
00144                                 did=HcalDetId(HcalEndcap,ieta,iphi,depth);
00145                                 if (theTopo.valid(did)) {
00146                                         tt = HcalTrigTowerDetId(did.rawId());
00147 //                                      std::cout << "ieta, depth, iphi = " << ieta << ", " << depth << ", " << iphi;
00148                                         towerids = tg.towerIds(did.rawId());
00149                                         for(unsigned int n = 0; n < towerids.size(); ++n)
00150                                         {
00151                                                 int ie = towerids[n].ieta();
00152                                                 if (ie < 0) ie = 32 - ie;
00153                                                 int ip = towerids[n].iphi();
00154                                                 ttmap[ie-1][ip-1].push_back(did);
00155 //                                              std::cout << "Towerid[" << n << "]:" << towerids[n] << " HcalDetId:" << did << std::endl;
00156                                         }
00157                                 }
00158                         }
00159                 }
00160         }
00161 //      std::cout << "HF Tower Mapping:" << std::endl;
00162         for (int ieta=1; ieta <= 41; ieta++) {
00163                 for (int iphi = 1; iphi <= 72; iphi++) {
00164                         for (int depth = 1; depth <= 3; depth++) {
00165                                 did=HcalDetId(HcalForward,ieta,iphi,depth);
00166                                 if (theTopo.valid(did)) {
00167                                         tt = HcalTrigTowerDetId(did.rawId());
00168 //                                      std::cout << "ieta, iphi, depth = " << ieta << ", " << iphi << ", " << depth << " ";
00169                                         towerids = tg.towerIds(did.rawId());
00170                                         for(unsigned int n = 0; n < towerids.size(); ++n)
00171                                         {
00172                                                 int ie = towerids[n].ieta();
00173                                                 if (ie < 0) ie = 32 - ie;
00174                                                 int ip = towerids[n].iphi();
00175                                                 ttmap[ie-1][ip-1].push_back(did);
00176 //                                              detids = tg.detIds(towerids[n]);
00177 //                                              for(unsigned int m = 0; m < detids.size(); ++m) std::cout << detids[m] << "; ";
00178 //                                              std::cout << towerids[n] << " HcalDetId:" << did << "; ";
00179                                         }
00180 //                                      std::cout << std::endl;
00181                                 }
00182                         }
00183                 }
00184         }
00185         
00186         for (int ieta = 1; ieta <= 32; ieta++) {
00187                 for (int iphi = 1; iphi <=72; iphi++) {
00188                         if (ttmap[ieta-1][iphi-1].size() > 0) {
00189                           //                            std::cout << "Trigger tower [" << ieta << "," << iphi << "] contains: ";
00190                           //                            for(std::vector<HcalDetId>::const_iterator itr = (ttmap[ieta-1][iphi-1]).begin(); itr != (ttmap[ieta-1][iphi-1]).end(); ++itr) std::cout << (*itr) << ", ";
00191                                 //                              std::cout << std::endl;
00192                         }
00193                 }
00194         }
00195 }

void HcaluLUTTPGCoder::update ( const char *  filename  ) 

Definition at line 283 of file HcaluLUTTPGCoder.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), Exception, GetLUTID(), HCAL, HcalBarrel, HcalEndcap, HcalForward, i, id, index, INPUT_LUT_SIZE, inputLUT, inputluts_, j, nluts, s, and HcalTopology::valid().

00283                                                   {
00284   HcalTopology theTopo;
00285   int tool;
00286   std::string HCAL[3] = {"HB", "HE", "HF"};  
00287   std::ifstream userfile;
00288   userfile.open(filename);
00289   std::cout << filename << std::endl;
00290   if( userfile ) {
00291     int nluts = 0;
00292         std::string s;
00293     std::vector<int> loieta,hiieta;
00294     std::vector<int> loiphi,hiiphi;    
00295         std::vector<int> loidep,hiidep;
00296         std::vector<int> idet;
00297     getline(userfile,s);
00298     //  std::cout << "Reading LUT's for: " << s << std::endl;
00299     getline(userfile,s);
00300 //
00301         unsigned int index = s.find("H",0);     
00302         while (index < s.length()) {
00303                 std::string det = s.substr(index,2);
00304                 if (det == "HB") idet.push_back(0); // HB
00305                 else if (det == "HE") idet.push_back(1); //HE
00306                 else if (det == "HF") idet.push_back(2); // HF
00307                 else std::cout << "Wrong LUT detector description in " << s << std::endl;
00308                 //              std::cout << det.data() << " ";
00309                 nluts++;
00310                 index +=2;
00311                 index = s.find("H",index);
00312         }
00313         //      if (nluts != 0) std::cout << std::endl;
00314         //      std::cout << "Found " << nluts << " LUTs" << std::endl;
00315 
00316     inputluts_.resize(nluts);
00317     for (int i=0; i<nluts; i++) {
00318       inputluts_[i].resize(INPUT_LUT_SIZE); 
00319     }
00320     
00321     //  std::cout << "EtaMin = ";
00322     for (int i=0; i<nluts; i++) {
00323       userfile >> tool;
00324       loieta.push_back(tool);
00325       //          std::cout << tool << " ";
00326     }
00327     //  std::cout << std::endl << "EtaMax = ";
00328     for (int i=0; i<nluts; i++) {
00329       userfile >> tool;
00330       hiieta.push_back(tool);
00331       //          std::cout << tool << " ";
00332     }
00333     //  std::cout << std::endl << "PhiMin = ";
00334     for (int i=0; i<nluts; i++) {
00335       userfile >> tool;
00336       loiphi.push_back(tool);
00337       //          std::cout << tool << " ";
00338     }
00339     //  std::cout << std::endl << "PhiMax = ";
00340     for (int i=0; i<nluts; i++) {
00341       userfile >> tool;
00342       hiiphi.push_back(tool);
00343       //          std::cout << tool << " ";
00344     }
00345     //  std::cout << std::endl << "DepMin = ";
00346     for (int i=0; i<nluts; i++) {
00347       userfile >> tool;
00348       loidep.push_back(tool);
00349       //          std::cout << tool << " ";
00350     }
00351     //  std::cout << std::endl << "DepMax = ";
00352     for (int i=0; i<nluts; i++) {
00353       userfile >> tool;
00354       hiidep.push_back(tool);
00355       //          std::cout << tool << " ";
00356     }    
00357     //  std::cout << std::endl;
00358         
00359     for (int j=0; j<INPUT_LUT_SIZE; j++) { 
00360       for(int i = 0; i <nluts; i++) {
00361                 userfile >> inputluts_[i][j];
00362                 if (userfile.eof()) std::cout << "Error: LUT file is truncated or has a wrong format: " << i << "," << j << std::endl;
00363           }
00364     }
00365     userfile.close();
00366         
00367         HcalDetId cell;
00368         int id, ntot = 0;
00369         for (int i=0; i < nluts; i++) {
00370                 int nini = 0;
00371         for (int depth = loidep[i]; depth <= hiidep[i]; depth++) {
00372                 for (int iphi = loiphi[i]; iphi <= hiiphi[i]; iphi++) {      
00373                         for (int ieta=loieta[i]; ieta <= hiieta[i]; ieta++) {
00374                                         if (idet[i] == 0) cell = HcalDetId(HcalBarrel,ieta,iphi,depth);
00375                                         else if (idet[i] == 1) cell = HcalDetId(HcalEndcap,ieta,iphi,depth);
00376                                         else if (idet[i] == 2) cell = HcalDetId(HcalForward,ieta,iphi,depth);
00377                                         if (theTopo.valid(cell)) {  
00378                                                 if (idet[i] == 0) id = GetLUTID(HcalBarrel,ieta,iphi,depth);
00379                                                 else if (idet[i] == 1) id = GetLUTID(HcalEndcap,ieta,iphi,depth);
00380                                                 else if (idet[i] == 2) id = GetLUTID(HcalForward,ieta,iphi,depth);
00381                                                 if (inputLUT[id] == 0) throw cms::Exception("PROBLEM: inputLUT has not been initialized for idet, ieta, iphi, depth, id = ") << idet[i] << "," << ieta << "," << iphi << "," << depth << "," << id << std::endl;
00382                                         for (int j = 0; j <= 0x7F; j++) inputLUT[id][j] = inputluts_[i][j];
00383                                                 nini++;
00384                                                 ntot++;
00385                                         }
00386                         }
00387                         }
00388        }
00389         //         std::cout << nini << " LUT's have been initialized for " << HCAL[idet[i]] << ": eta = [" << loieta[i] << "," << hiieta[i] << "]; iphi = [" << loiphi[i] << "," << hiiphi[i] << "]; depth = [" << loidep[i] << "," << hiidep[i] << "]" << std::endl;
00390     }
00391         //    std::cout << "Total of " << ntot << " have been initialized" << std::endl;
00392   } 
00393 }

void HcaluLUTTPGCoder::update ( const HcalDbService conditions  ) 

Definition at line 395 of file HcaluLUTTPGCoder.cc.

References _gain, _ped, funct::abs(), ecalMGPA::adc(), HcalCoderDb::adc2fC(), lat::endl(), Exception, sistrip::extrainfo::gain_, HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), GetLUTID(), HcalBarrel, HcalEndcap, HcalForward, i, id, inputLUT, j, max, min, nominal_gain, HcalCalibrations::pedestal(), Rcalib, HcalCalibrations::respcorrgain(), HBHEDataFrame::setSample(), HFDataFrame::setSample(), HBHEDataFrame::setSize(), HFDataFrame::setSize(), theHFEtaBounds, and HcalTopology::valid().

Referenced by HcalTPGCoderULUT::dbRecordCallback(), and HcaluLUTTPGCoder().

00395                                                              {
00396    const HcalQIEShape* shape = conditions.getHcalShape();
00397    HcalCalibrations calibrations;
00398    int id;
00399    float divide;
00400    HcalTopology theTopo;
00401 
00402    float cosheta_[41], lsb_ = 1./16.;
00403    for (int i = 0; i < 13; i++) cosheta_[i+29] = cosh((theHFEtaBounds[i+1] + theHFEtaBounds[i])/2.);
00404     
00405    for (int depth = 1; depth <= 3; depth++) {
00406      for (int iphi = 1; iphi <= 72; iphi++) {
00407        divide = 1.*nominal_gain;
00408        for (int ieta=-16; ieta <= 16; ieta++) {
00409          HcalDetId cell(HcalBarrel,ieta,iphi,depth);
00410          if (theTopo.valid(cell)) {  
00411            id = GetLUTID(HcalBarrel,ieta,iphi,depth);
00412            if (inputLUT[id] == 0) throw cms::Exception("PROBLEM: inputLUT has not been initialized for HB, ieta, iphi, depth, id = ") << ieta << "," << iphi << "," << depth << "," << id << std::endl;
00413            //conditions.makeHcalCalibration (cell, &calibrations);
00414            HcalCalibrations calibrations = conditions.getHcalCalibrations(cell);
00415 
00416            const HcalQIECoder* channelCoder = conditions.getHcalCoder (cell);
00417            HcalCoderDb coder (*channelCoder, *shape);
00418            float ped_ = (calibrations.pedestal(0)+calibrations.pedestal(1)+calibrations.pedestal(2)+calibrations.pedestal(3))/4;
00419            float gain_= (calibrations.respcorrgain(0)+calibrations.respcorrgain(1)+calibrations.respcorrgain(2)+calibrations.respcorrgain(3))/4;          
00420            HBHEDataFrame frame(cell);
00421            frame.setSize(1);
00422            CaloSamples samples(cell, 1);
00423            _ped[id] = ped_;
00424            _gain[id] = gain_;
00425            for (int j = 0; j <= 0x7F; j++) {
00426              HcalQIESample adc(j);
00427              frame.setSample(0,adc);
00428              coder.adc2fC(frame,samples);
00429              float adc2fC_ = samples[0];
00430              if (ieta <0 )inputLUT[id][j] = (LUT) std::min(std::max(0,int((adc2fC_ - ped_)*gain_*Rcalib[abs(ieta)]/divide)), 0x3FF);
00431              else inputLUT[id][j] = (LUT) std::min(std::max(0,int((adc2fC_ - ped_)*gain_*Rcalib[abs(ieta)+43]/divide)), 0x3FF);
00432            }
00433          }
00434        }
00435        for (int ieta=-29; ieta <= 29; ieta++) {
00436          HcalDetId cell(HcalEndcap,ieta,iphi,depth);
00437          if (theTopo.valid(cell)) {  
00438            if (abs(ieta) < 21) divide = 1.*nominal_gain;
00439            else if (abs(ieta) < 27) divide = 2.*nominal_gain;
00440            else divide = 5.*nominal_gain;
00441            id = GetLUTID(HcalEndcap,ieta,iphi,depth);
00442            if (inputLUT[id] == 0) throw cms::Exception("PROBLEM: inputLUT has not been initialized for HE, ieta, iphi, depth, id = ") << ieta << "," << iphi << "," << depth << "," << id << std::endl;
00443            //conditions.makeHcalCalibration (cell, &calibrations);
00444            HcalCalibrations calibrations = conditions.getHcalCalibrations(cell);
00445            const HcalQIECoder* channelCoder = conditions.getHcalCoder (cell);
00446            HcalCoderDb coder (*channelCoder, *shape);
00447            float ped_ = (calibrations.pedestal(0)+calibrations.pedestal(1)+calibrations.pedestal(2)+calibrations.pedestal(3))/4;
00448            float gain_= (calibrations.respcorrgain(0)+calibrations.respcorrgain(1)+calibrations.respcorrgain(2)+calibrations.respcorrgain(3))/4;          
00449            HBHEDataFrame frame(cell);
00450            frame.setSize(1);
00451            CaloSamples samples(cell, 1);
00452            _ped[id] = ped_;
00453            _gain[id] = gain_;
00454            for (int j = 0; j <= 0x7F; j++) {
00455              HcalQIESample adc(j);
00456              frame.setSample(0,adc);
00457              coder.adc2fC(frame,samples);
00458              float adc2fC_ = samples[0];
00459              if ( ieta < 0 ) inputLUT[id][j] = (LUT) std::min(std::max(0,int((adc2fC_ - ped_)*gain_*Rcalib[abs(ieta)+1]/divide)), 0x3FF);
00460              else inputLUT[id][j] = (LUT) std::min(std::max(0,int((adc2fC_ - ped_)*gain_*Rcalib[abs(ieta)+44]/divide)), 0x3FF);
00461            }
00462          }
00463        }        
00464        for (int ieta=-41; ieta <= 41; ieta++) {
00465          HcalDetId cell(HcalForward,ieta,iphi,depth);
00466          if (theTopo.valid(cell)) {  
00467            id = GetLUTID(HcalForward,ieta,iphi,depth);
00468            if (inputLUT[id] == 0) throw cms::Exception("PROBLEM: inputLUT has not been initialized for HF, ieta, iphi, depth, id = ") << ieta << "," << iphi << "," << depth << "," << id << std::endl;
00469            //conditions.makeHcalCalibration (cell, &calibrations);
00470            HcalCalibrations calibrations = conditions.getHcalCalibrations(cell);
00471            const HcalQIECoder* channelCoder = conditions.getHcalCoder (cell);
00472            HcalCoderDb coder (*channelCoder, *shape);
00473            float ped_ = (calibrations.pedestal(0)+calibrations.pedestal(1)+calibrations.pedestal(2)+calibrations.pedestal(3))/4;
00474            float gain_= (calibrations.respcorrgain(0)+calibrations.respcorrgain(1)+calibrations.respcorrgain(2)+calibrations.respcorrgain(3))/4;          
00475 
00476 
00477            HFDataFrame frame(cell);
00478            frame.setSize(1);
00479            CaloSamples samples(cell, 1);
00480            _ped[id] = ped_;
00481            _gain[id] = gain_;
00482            for (int j = 0; j <= 0x7F; j++) {
00483              HcalQIESample adc(j);
00484              frame.setSample(0,adc);
00485              coder.adc2fC(frame,samples);
00486              float adc2fC_ = samples[0];
00487              if (ieta < 0 ) inputLUT[id][j] = (LUT) std::min(std::max(0,int((adc2fC_ - ped_)*Rcalib[abs(ieta)+2]*gain_/lsb_/cosheta_[abs(ieta)])), 0x3FF);
00488              else inputLUT[id][j] = (LUT) std::min(std::max(0,int((adc2fC_ - ped_)*Rcalib[abs(ieta)+45]*gain_/lsb_/cosheta_[abs(ieta)])), 0x3FF);
00489            }
00490          }
00491        }
00492      }
00493    }
00494  }


Member Data Documentation

float* HcaluLUTTPGCoder::_gain [private]

Definition at line 57 of file HcaluLUTTPGCoder.h.

Referenced by AllocateLUTs(), getLUTGain(), update(), and ~HcaluLUTTPGCoder().

float* HcaluLUTTPGCoder::_ped [private]

Definition at line 58 of file HcaluLUTTPGCoder.h.

Referenced by AllocateLUTs(), getLUTPedestal(), update(), and ~HcaluLUTTPGCoder().

const int HcaluLUTTPGCoder::INPUT_LUT_SIZE = 128 [static, private]

Definition at line 50 of file HcaluLUTTPGCoder.h.

Referenced by adc2Linear(), AllocateLUTs(), and update().

LUT* HcaluLUTTPGCoder::inputLUT[nluts] [private]

Definition at line 56 of file HcaluLUTTPGCoder.h.

Referenced by adc2Linear(), AllocateLUTs(), update(), and ~HcaluLUTTPGCoder().

std::vector<LUTType> HcaluLUTTPGCoder::inputluts_ [private]

Definition at line 49 of file HcaluLUTTPGCoder.h.

Referenced by update().

const int HcaluLUTTPGCoder::nluts = 46007 [static, private]

Definition at line 50 of file HcaluLUTTPGCoder.h.

Referenced by AllocateLUTs(), update(), and ~HcaluLUTTPGCoder().

const float HcaluLUTTPGCoder::nominal_gain = 0.177 [static, private]

Definition at line 59 of file HcaluLUTTPGCoder.h.

Referenced by update().

float HcaluLUTTPGCoder::Rcalib[87] [private]

Definition at line 54 of file HcaluLUTTPGCoder.h.

Referenced by getRecHitCalib(), and update().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:24:03 2009 for CMSSW by  doxygen 1.5.4