CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/SimCalorimetry/HcalZeroSuppressionProducers/src/HcalZSAlgoRealistic.cc

Go to the documentation of this file.
00001 #include "HcalZSAlgoRealistic.h"
00002 #include <iostream>
00003 
00004 HcalZSAlgoRealistic::HcalZSAlgoRealistic(bool mp, int levelHB, int levelHE, int levelHO, int levelHF, std::pair<int,int> HBsearchTS, std::pair<int,int> HEsearchTS, std::pair<int,int> HOsearchTS, std::pair<int,int> HFsearchTS) : 
00005   HcalZeroSuppressionAlgo(mp),
00006   thresholdHB_(levelHB),
00007   thresholdHE_(levelHE),
00008   thresholdHO_(levelHO),
00009   thresholdHF_(levelHF),
00010   HBsearchTS_(HBsearchTS),
00011   HEsearchTS_(HEsearchTS),
00012   HOsearchTS_(HOsearchTS),
00013   HFsearchTS_(HFsearchTS)
00014 {
00015   usingDBvalues = false;
00016 }
00017 
00018 HcalZSAlgoRealistic::HcalZSAlgoRealistic(bool mp, std::pair<int,int> HBsearchTS, std::pair<int,int> HEsearchTS, std::pair<int,int> HOsearchTS, std::pair<int,int> HFsearchTS) : 
00019   HcalZeroSuppressionAlgo(mp),
00020   HBsearchTS_(HBsearchTS),
00021   HEsearchTS_(HEsearchTS),
00022   HOsearchTS_(HOsearchTS),
00023   HFsearchTS_(HFsearchTS)
00024 {
00025   thresholdHB_ = -1;
00026   thresholdHE_ = -1;
00027   thresholdHO_ = -1;
00028   thresholdHF_ = -1;
00029   usingDBvalues = true;
00030 
00031 }
00032 
00033 
00034   
00035 //template <class DIGI> 
00036 //For HBHE Data Frame 
00037 bool HcalZSAlgoRealistic::keepMe(const HBHEDataFrame& inp, int start, int finish, int threshold, uint32_t hbhezsmask) const{
00038   
00039   bool keepIt=false;
00040   //int mask = 999;
00041   if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
00042     threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
00043   }
00044 
00045   //determine the sum of 2 timeslices
00046   for (int i = start; i < finish && !keepIt; i++) {
00047     int sum=0;
00048     
00049     for (int j = i; j < (i+2); j++){
00050       sum+=inp[j].adc();
00051       //pedsum+=pedave;
00052     }
00053     if ((hbhezsmask&(1<<i)) !=0) continue; 
00054     else if (sum>=threshold) keepIt=true;
00055   }
00056   return keepIt;
00057 }
00058 
00059 //For HO Data Frame 
00060 bool HcalZSAlgoRealistic::keepMe(const HODataFrame& inp, int start, int finish, int threshold, uint32_t hozsmask) const{
00061   
00062   bool keepIt=false;
00063   //  int mask = 999;
00064   if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
00065     threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
00066   }
00067 
00068   //determine the sum of 2 timeslices
00069   for (int i = start; i < finish && !keepIt; i++) {
00070     int sum=0;
00071     
00072     for (int j = i; j < (i+2); j++){
00073       sum+=inp[j].adc();
00074       //pedsum+=pedave;
00075     }
00076     if ((hozsmask&(1<<i)) !=0) continue; 
00077     else if (sum>=threshold) keepIt=true;
00078   }
00079   return keepIt;
00080 }
00081 
00082 //For HF Data Frame 
00083 bool HcalZSAlgoRealistic::keepMe(const HFDataFrame& inp, int start, int finish, int threshold, uint32_t hfzsmask) const{
00084   
00085   bool keepIt=false;
00086   //  int mask = 999;
00087   if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
00088     threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
00089   }
00090   
00091   //determine the sum of 2 timeslices
00092   for (int i = start; i < finish && !keepIt; i++) {
00093     int sum=0;
00094     
00095     for (int j = i; j < (i+2); j++){
00096       sum+=inp[j].adc();
00097       //pedsum+=pedave;
00098     }
00099     if ((hfzsmask&(1<<i)) !=0) continue; 
00100     else if (sum>=threshold) keepIt=true;
00101   }
00102   return keepIt;
00103 }
00104 
00105 
00106 bool HcalZSAlgoRealistic::shouldKeep(const HBHEDataFrame& digi) const{
00107   // uint32_t hbhezsmask = digi.zsCrossingMask();
00108   if (digi.id().subdet()==HcalBarrel) {
00109     
00110     int start  = std::max(0,HBsearchTS_.first);
00111     int finish = std::min(digi.size()-1,HBsearchTS_.second);
00112 
00113     /*
00114     std::cout << " HBsearchTS_ : " <<  HBsearchTS_.first 
00115               << ", " << HBsearchTS_.second << std::endl;
00116     std::cout << " HB start, finish = " << start << ", "
00117               << finish << std::endl;
00118     */
00119 
00120     return keepMe(digi,start,finish,thresholdHB_,digi.zsCrossingMask());
00121 
00122 
00123   }
00124   else {
00125 
00126     int start  = std::max(0,HEsearchTS_.first);
00127     int finish = std::min(digi.size()-1,HEsearchTS_.second);
00128     return keepMe(digi,start,finish,thresholdHE_,digi.zsCrossingMask());
00129 
00130   }
00131 }  
00132 
00133 bool HcalZSAlgoRealistic::shouldKeep(const HODataFrame& digi) const{
00134 
00135   int start  = std::max(0,HOsearchTS_.first);
00136   int finish = std::min(digi.size()-1,HOsearchTS_.second);
00137   return keepMe(digi,start,finish,thresholdHO_,digi.zsCrossingMask());
00138 }
00139 
00140 bool HcalZSAlgoRealistic::shouldKeep(const HFDataFrame& digi) const{
00141 
00142   int start  = std::max(0,HFsearchTS_.first);
00143   int finish = std::min(digi.size()-1,HFsearchTS_.second);
00144   return keepMe(digi,start,finish,thresholdHF_,digi.zsCrossingMask());
00145 }