Go to the documentation of this file.00001 #ifndef DPGAnalysis_SiStripTools_DigiCollectionProfile_H
00002 #define DPGAnalysis_SiStripTools_DigiCollectionProfile_H
00003
00004 #include <vector>
00005 #include "CommonTools/UtilAlgos/interface/DetIdSelector.h"
00006 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00007 #include "DataFormats/Common/interface/DetSetVector.h"
00008 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00009 #include "DataFormats/Common/interface/DetSet.h"
00010
00011 class TH1F;
00012 class TProfile;
00013 class TH2F;
00014
00015 namespace edm {
00016 class ParameterSet;
00017 }
00018
00019 template <class T>
00020 class DigiCollectionProfiler {
00021
00022 public:
00023 DigiCollectionProfiler();
00024 DigiCollectionProfiler(const edm::ParameterSet& iConfig);
00025 ~DigiCollectionProfiler() {};
00026
00027 void fill(edm::Handle<T> digis, const std::vector<TH1F*>&, const std::vector<TProfile*>&, const std::vector<TH2F*>&) const;
00028
00029 private:
00030
00031 bool m_folded;
00032 bool m_want1dHisto;
00033 bool m_wantProfile;
00034 bool m_want2dHisto;
00035
00036 std::vector<DetIdSelector> m_selections;
00037
00038 };
00039
00040 template <class T>
00041 DigiCollectionProfiler<T>::DigiCollectionProfiler():
00042 m_folded(false), m_want1dHisto(false), m_wantProfile(false), m_want2dHisto(false), m_selections() { }
00043
00044 template <class T>
00045 DigiCollectionProfiler<T>::DigiCollectionProfiler(const edm::ParameterSet& iConfig):
00046 m_folded(iConfig.getUntrackedParameter<bool>("foldedStrips",false)),
00047 m_want1dHisto(iConfig.getUntrackedParameter<bool>("want1dHisto",true)),
00048 m_wantProfile(iConfig.getUntrackedParameter<bool>("wantProfile",true)),
00049 m_want2dHisto(iConfig.getUntrackedParameter<bool>("want2dHisto",false))
00050
00051 {
00052
00053 std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
00054
00055 for(std::vector<edm::ParameterSet>::const_iterator selconfig=selconfigs.begin();selconfig!=selconfigs.end();++selconfig) {
00056 DetIdSelector selection(*selconfig);
00057 m_selections.push_back(selection);
00058 }
00059
00060 }
00061
00062 template <class T>
00063 void DigiCollectionProfiler<T>::fill(edm::Handle<T> digis, const std::vector<TH1F*>& hist, const std::vector<TProfile*>& hprof, const std::vector<TH2F*>& hist2d) const {
00064
00065 }
00066
00067
00068 template <>
00069 void DigiCollectionProfiler<edm::DetSetVector<SiStripDigi> >::fill(edm::Handle<edm::DetSetVector<SiStripDigi> > digis, const std::vector<TH1F*>& hist, const std::vector<TProfile*>& hprof, const std::vector<TH2F*>& hist2d) const {
00070
00071 for(edm::DetSetVector<SiStripDigi>::const_iterator mod = digis->begin();mod!=digis->end();mod++) {
00072
00073 for(unsigned int isel=0;isel< m_selections.size(); ++isel) {
00074
00075 if(m_selections[isel].isSelected(mod->detId())) {
00076 TH1F* tobefilled1d=0;
00077 TProfile* tobefilledprof=0;
00078 TH2F* tobefilled2d=0;
00079
00080 if(m_want1dHisto) tobefilled1d = hist[isel];
00081 if(m_wantProfile) tobefilledprof = hprof[isel];
00082 if(m_want2dHisto) tobefilled2d = hist2d[isel];
00083
00084 for(edm::DetSet<SiStripDigi>::const_iterator digi=mod->begin();digi!=mod->end();digi++) {
00085
00086 if(digi->adc()>0) {
00087 unsigned int strip = digi->strip();
00088 if(m_folded) strip = strip%256;
00089 if(tobefilled1d) tobefilled1d->Fill(strip);
00090 if(tobefilledprof) tobefilledprof->Fill(strip,digi->adc());
00091 if(tobefilled2d) tobefilled2d->Fill(strip,digi->adc());
00092 }
00093 }
00094 }
00095 }
00096 }
00097 }
00098
00099 template <>
00100 void DigiCollectionProfiler<edmNew::DetSetVector<SiStripCluster> >::fill(edm::Handle<edmNew::DetSetVector<SiStripCluster> > digis, const std::vector<TH1F*>& hist, const std::vector<TProfile*>& hprof, const std::vector<TH2F*>& hist2d) const {
00101
00102 for(edmNew::DetSetVector<SiStripCluster>::const_iterator mod = digis->begin();mod!=digis->end();mod++) {
00103
00104 for(unsigned int isel=0;isel< m_selections.size(); ++isel) {
00105
00106 if(m_selections[isel].isSelected(mod->detId())) {
00107 TH1F* tobefilled1d=0;
00108 TProfile* tobefilledprof=0;
00109 TH2F* tobefilled2d=0;
00110
00111 if(m_want1dHisto) tobefilled1d = hist[isel];
00112 if(m_wantProfile) tobefilledprof = hprof[isel];
00113 if(m_want2dHisto) tobefilled2d = hist2d[isel];
00114
00115 for(edmNew::DetSet<SiStripCluster>::const_iterator clus=mod->begin();clus!=mod->end();clus++) {
00116
00117 for(unsigned int digi=0; digi < clus->amplitudes().size() ; ++digi) {
00118
00119 if(clus->amplitudes()[digi]>0) {
00120 unsigned int strip = clus->firstStrip()+digi;
00121 if(m_folded) strip = strip%256;
00122 if(tobefilled1d) tobefilled1d->Fill(strip);
00123 if(tobefilledprof) tobefilledprof->Fill(strip,clus->amplitudes()[digi]);
00124 if(tobefilled2d) tobefilled2d->Fill(strip,clus->amplitudes()[digi]);
00125 }
00126 }
00127 }
00128 }
00129 }
00130 }
00131 }
00132
00133 #endif // DPGAnalysis_SiStripTools_DigiCollectionProfile_H