#include <SimCalorimetry/HcalTrigPrimAlgos/interface/HcalTriggerPrimitiveAlgo.h>
Definition at line 17 of file HcalTriggerPrimitiveAlgo.h.
typedef std::map<HcalTrigTowerDetId, IntegerCaloSamples> HcalTriggerPrimitiveAlgo::SumMap [private] |
Definition at line 46 of file HcalTriggerPrimitiveAlgo.h.
typedef std::map<uint32_t, IntegerCaloSamples> HcalTriggerPrimitiveAlgo::SumMapFG [private] |
Definition at line 49 of file HcalTriggerPrimitiveAlgo.h.
typedef std::multimap<HcalTrigTowerDetId, IntegerCaloSamples> HcalTriggerPrimitiveAlgo::TowerMapFG [private] |
Definition at line 52 of file HcalTriggerPrimitiveAlgo.h.
HcalTriggerPrimitiveAlgo::HcalTriggerPrimitiveAlgo | ( | bool | pf, | |
const std::vector< double > & | w, | |||
int | latency, | |||
uint32_t | FG_threshold | |||
) |
Definition at line 10 of file HcalTriggerPrimitiveAlgo.cc.
00012 : incoder_(0), outcoder_(0), theThreshold(0), 00013 peakfind_(pf), weights_(w), latency_(latency), FG_threshold_(FG_threshold) 00014 { 00015 }
HcalTriggerPrimitiveAlgo::~HcalTriggerPrimitiveAlgo | ( | ) |
void HcalTriggerPrimitiveAlgo::addSignal | ( | const IntegerCaloSamples & | samples | ) | [private] |
Definition at line 136 of file HcalTriggerPrimitiveAlgo.cc.
References i, IntegerCaloSamples::id(), id, IntegerCaloSamples::size(), and theSumMap.
00136 { 00137 HcalTrigTowerDetId id(samples.id()); 00138 SumMap::iterator itr = theSumMap.find(id); 00139 if(itr == theSumMap.end()) { 00140 theSumMap.insert(std::make_pair(id, samples)); 00141 } else { 00142 // wish CaloSamples had a += 00143 for(int i = 0; i < samples.size(); ++i) { 00144 (itr->second)[i] += samples[i]; 00145 } 00146 } 00147 }
void HcalTriggerPrimitiveAlgo::addSignal | ( | const HFDataFrame & | frame | ) | [private] |
Definition at line 90 of file HcalTriggerPrimitiveAlgo.cc.
References HcalTPGCoder::adc2Linear(), addSignal(), HcalDetId::depth(), i, HFDataFrame::id(), incoder_, n, HFDataFrame::presamples(), DetId::rawId(), HFDataFrame::size(), theFGSumMap, theTowerMapFG, theTrigTowerGeometry, and HcalTrigTowerGeometry::towerIds().
00090 { 00091 00092 00093 if(frame.id().depth() == 1 || frame.id().depth() == 2) { 00094 std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry.towerIds(frame.id()); 00095 assert(ids.size() == 1); 00096 IntegerCaloSamples samples(ids[0], frame.size()); 00097 samples.setPresamples(frame.presamples()); 00098 // for(int i = 0; i < frame.size(); i++) 00099 // {cout<<frame.sample(i).adc()<<" ";} 00100 //cout<<endl; 00101 incoder_->adc2Linear(frame, samples); 00102 00103 addSignal(samples); 00104 00105 uint32_t fgid; 00106 00107 // Mask off depths: fgid is the same for both depths 00108 00109 fgid = (frame.id().rawId() | 0x1c000) ; 00110 00111 SumMapFG::iterator itr = theFGSumMap.find(fgid); 00112 00113 if(itr == theFGSumMap.end()) { 00114 theFGSumMap.insert(std::make_pair(fgid, samples)); 00115 } 00116 else { 00117 // wish CaloSamples had a += 00118 for(int i = 0; i < samples.size(); ++i) { 00119 (itr->second)[i] += samples[i]; 00120 } 00121 } 00122 00123 // Depth =2 is the second entry in map (sum). Use its original Hcal Det Id to obtain trigger tower 00124 if (frame.id().depth()==2) 00125 { 00126 for(unsigned int n = 0; n < ids.size(); n++) 00127 { 00128 theTowerMapFG.insert(TowerMapFG::value_type(ids[n],itr->second)); 00129 } 00130 } 00131 00132 } 00133 }
void HcalTriggerPrimitiveAlgo::addSignal | ( | const HBHEDataFrame & | frame | ) | [private] |
adds the signal to the map
Definition at line 66 of file HcalTriggerPrimitiveAlgo.cc.
References HcalTPGCoder::adc2Linear(), i, HBHEDataFrame::id(), incoder_, HBHEDataFrame::presamples(), HBHEDataFrame::size(), theTrigTowerGeometry, and HcalTrigTowerGeometry::towerIds().
Referenced by addSignal(), and run().
00066 { 00067 00068 std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry.towerIds(frame.id()); 00069 assert(ids.size() == 1 || ids.size() == 2); 00070 IntegerCaloSamples samples1(ids[0], int(frame.size())); 00071 00072 samples1.setPresamples(frame.presamples()); 00073 incoder_->adc2Linear(frame, samples1); 00074 00075 if(ids.size() == 2) { 00076 // make a second trigprim for the other one, and split the energy 00077 IntegerCaloSamples samples2(ids[1], samples1.size()); 00078 for(int i = 0; i < samples1.size(); ++i) 00079 { 00080 samples1[i] = uint32_t(samples1[i]*0.5); 00081 samples2[i] = samples1[i]; 00082 } 00083 samples2.setPresamples(frame.presamples()); 00084 addSignal(samples2); 00085 } 00086 addSignal(samples1); 00087 }
void HcalTriggerPrimitiveAlgo::addSignalFG | ( | const IntegerCaloSamples & | samples | ) | [private] |
void HcalTriggerPrimitiveAlgo::analyze | ( | IntegerCaloSamples & | samples, | |
HcalTriggerPrimitiveDigi & | result | |||
) | [private] |
adds the actual RecHits
Definition at line 150 of file HcalTriggerPrimitiveAlgo.cc.
References HcalTPGCompressor::compress(), i, IntegerCaloSamples::id(), int, latency_, outcoder_, output(), peakfind_, IntegerCaloSamples::presamples(), IntegerCaloSamples::size(), sum(), theThreshold, and weights_.
Referenced by run().
00152 { 00153 00154 //cout<<"TPG calc" 00155 // HcalTrigTowerDetId detId(samples.id()); 00156 //find output samples length and new presamples 00157 int shrink = weights_.size()-1; //REAL LINE 00158 int outlength=samples.size() - shrink; 00159 int newprelength = ((samples.presamples()+1)-weights_.size())+latency_; 00160 std::vector<bool> finegrain(outlength,false); 00161 IntegerCaloSamples sum(samples.id(), outlength); 00162 00163 bool SOI_pegged = false; 00164 //Test is SOI input is pegged before summing 00165 if(samples[samples.presamples()]> 0x3FF) SOI_pegged = true; 00166 bool highvalue = false; 00167 //slide algo window 00168 for(int ibin = 0; ibin < int(samples.size())- shrink; ++ibin) 00169 { 00170 if(samples[ibin+1]>10){highvalue = true;} 00171 int algosumvalue = 0; 00172 for(unsigned int i = 0; i < weights_.size(); i++) { 00173 algosumvalue += int(samples[ibin+i] * weights_[i]); 00174 }//add up value * scale factor 00175 if (algosumvalue<0) sum[ibin]=0; // low-side 00176 else if (algosumvalue>0x3FF) sum[ibin]=0x3FF; //high-side 00177 else sum[ibin] = algosumvalue;//assign value to sum[] 00178 } 00179 00180 if(highvalue) 00181 { 00182 // cout<<"ICS "; 00183 for(int ibin = 0; ibin < int(samples.size())- shrink; ++ibin) 00184 { 00185 // cout<<samples[ibin+1]<<" "; 00186 } 00187 // cout<<endl; 00188 } 00189 //Do peak finding if requested 00190 00191 00192 if(peakfind_) 00193 { 00194 IntegerCaloSamples output(samples.id(),outlength-2); 00195 output.setPresamples(newprelength-1); 00196 for(int ibin2 = 1; ibin2 < (sum.size())-1; ++ibin2) 00197 { 00198 //use if peak finding true 00199 //Old equalities 00200 // if ( sum[ibin2] > sum[ibin2-1] && 00201 // sum[ibin2] >= sum[ibin2+1] && 00202 // sum[ibin2] > theThreshold) 00203 if ( sum[ibin2] >= sum[ibin2-1] && 00204 sum[ibin2] > sum[ibin2+1] && 00205 sum[ibin2] > theThreshold) 00206 { 00207 output[ibin2-1]=sum[ibin2];//if peak found 00208 } 00209 else{output[ibin2-1]=0;}//if no peak 00210 } 00211 if(SOI_pegged == true) 00212 { 00213 output[output.presamples()] = 0x3FF; 00214 } 00215 outcoder_->compress(output, finegrain, result);//send to transcoder 00216 // outcoder_->loadhcalUncompress(); 00217 } 00218 00219 else//No peak finding 00220 { 00221 IntegerCaloSamples output(samples.id(),outlength); 00222 output.setPresamples(newprelength); 00223 for(int ibin2 = 0; ibin2<sum.size(); ++ibin2) 00224 { 00225 output[ibin2]=sum[ibin2];//just pass value 00226 } 00227 outcoder_->compress(output, finegrain, result); 00228 } 00229 }
void HcalTriggerPrimitiveAlgo::analyzeHF | ( | IntegerCaloSamples & | samples, | |
HcalTriggerPrimitiveDigi & | result | |||
) | [private] |
Definition at line 232 of file HcalTriggerPrimitiveAlgo.cc.
References HcalTPGCompressor::compress(), detId, FG_threshold_, i, IntegerCaloSamples::id(), outcoder_, output(), IntegerCaloSamples::presamples(), IntegerCaloSamples::size(), and theTowerMapFG.
Referenced by run().
00234 { 00235 std::vector<bool> finegrain(samples.size(),false); 00236 // IntegerCaloSamples sum(samples.id(), samples.size()); 00237 HcalTrigTowerDetId detId_(samples.id()); 00238 00239 // get information from Tower map 00240 for(TowerMapFG::iterator mapItr = theTowerMapFG.begin(); mapItr != theTowerMapFG.end(); ++mapItr) 00241 { 00242 bool set_fg = false; 00243 HcalTrigTowerDetId detId(mapItr->first); 00244 if (detId == detId_) { 00245 for (int i=0; i < samples.size(); ++i) { 00246 mapItr->second[i] >= FG_threshold_ ? set_fg = true : false; 00247 finegrain[i] = (finegrain[i] || set_fg); 00248 } 00249 } 00250 } 00251 IntegerCaloSamples output(samples.id(),samples.size()); 00252 output.setPresamples(samples.presamples()); 00253 //cout<<"Presamples = "<<samples.presamples()<<endl; 00254 for(int ibin2 = 0; ibin2 < samples.size(); ++ibin2) 00255 {//output[ibin2]=sum[ibin2]; 00256 samples[ibin2] /= 8; 00257 //cout << "samples: " << samples[i] << endl; 00258 if (samples[ibin2] > 0x3FF) samples[ibin2] = 0x3FF; //Compression is 1 to 1 with saturation at 8 bits 00259 output[ibin2]=samples[ibin2]; 00260 } 00261 //cout<<endl; 00262 outcoder_->compress(output, finegrain, result); 00263 }
void HcalTriggerPrimitiveAlgo::run | ( | const HcalTPGCoder * | incoder, | |
const HcalTPGCompressor * | outcoder, | |||
const HBHEDigiCollection & | hbheDigis, | |||
const HFDigiCollection & | hfDigis, | |||
HcalTrigPrimDigiCollection & | result | |||
) |
Definition at line 23 of file HcalTriggerPrimitiveAlgo.cc.
References addSignal(), analyze(), analyzeHF(), edm::SortedCollection< T, SORT >::back(), edm::SortedCollection< T, SORT >::begin(), detId, edm::SortedCollection< T, SORT >::end(), HcalTrigTowerGeometry::firstHFTower(), incoder_, outcoder_, edm::SortedCollection< T, SORT >::push_back(), theFGSumMap, theSumMap, theTowerMapFG, and theTrigTowerGeometry.
Referenced by HcalTrigPrimDigiProducer::produce().
00028 { 00029 00030 incoder_=incoder; 00031 outcoder_=outcoder; 00032 00033 theSumMap.clear(); 00034 theFGSumMap.clear(); 00035 theTowerMapFG.clear(); 00036 // do the HB/HE digis 00037 for(HBHEDigiCollection::const_iterator hbheItr = hbheDigis.begin(); 00038 hbheItr != hbheDigis.end(); ++hbheItr) 00039 { 00040 addSignal(*hbheItr); 00041 } 00042 00043 // and the HF digis 00044 for(HFDigiCollection::const_iterator hfItr = hfDigis.begin(); 00045 hfItr != hfDigis.end(); ++hfItr) 00046 { 00047 addSignal(*hfItr); 00048 00049 } 00050 00051 00052 for(SumMap::iterator mapItr = theSumMap.begin(); mapItr != theSumMap.end(); ++mapItr) 00053 { 00054 result.push_back(HcalTriggerPrimitiveDigi(mapItr->first)); 00055 HcalTrigTowerDetId detId(mapItr->second.id()); 00056 if(detId.ietaAbs() >= theTrigTowerGeometry.firstHFTower()) 00057 { analyzeHF(mapItr->second, result.back());} 00058 else{analyze(mapItr->second, result.back());} 00059 } 00060 00061 theSumMap.clear(); 00062 return; 00063 }
std::vector<HcalTrigTowerDetId> HcalTriggerPrimitiveAlgo::towerIds | ( | const HcalDetId & | id | ) | const [private] |
uint32_t HcalTriggerPrimitiveAlgo::FG_threshold_ [private] |
const HcalTPGCoder* HcalTriggerPrimitiveAlgo::incoder_ [private] |
int HcalTriggerPrimitiveAlgo::latency_ [private] |
const HcalTPGCompressor* HcalTriggerPrimitiveAlgo::outcoder_ [private] |
Definition at line 44 of file HcalTriggerPrimitiveAlgo.h.
Referenced by analyze(), analyzeHF(), and run().
bool HcalTriggerPrimitiveAlgo::peakfind_ [private] |
SumMap HcalTriggerPrimitiveAlgo::theSumMap [private] |
double HcalTriggerPrimitiveAlgo::theThreshold [private] |
Definition at line 53 of file HcalTriggerPrimitiveAlgo.h.
Referenced by addSignal(), analyzeHF(), and run().
std::vector<double> HcalTriggerPrimitiveAlgo::weights_ [private] |