CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DigiCollectionProfiler.h
Go to the documentation of this file.
1 #ifndef DPGAnalysis_SiStripTools_DigiCollectionProfile_H
2 #define DPGAnalysis_SiStripTools_DigiCollectionProfile_H
3 
4 #include <vector>
10 
11 class TH1F;
12 class TProfile;
13 class TH2F;
14 
15 namespace edm {
16  class ParameterSet;
17 }
18 
19 template <class T>
21 
22  public:
26 
27  void fill(edm::Handle<T> digis, const std::vector<TH1F*>&, const std::vector<TProfile*>&, const std::vector<TH2F*>&) const;
28 
29  private:
30 
31  bool m_folded;
35 
36  std::vector<DetIdSelector> m_selections;
37 
38 };
39 
40 template <class T>
42  m_folded(false), m_want1dHisto(false), m_wantProfile(false), m_want2dHisto(false), m_selections() { }
43 
44 template <class T>
46  m_folded(iConfig.getUntrackedParameter<bool>("foldedStrips",false)),
47  m_want1dHisto(iConfig.getUntrackedParameter<bool>("want1dHisto",true)),
48  m_wantProfile(iConfig.getUntrackedParameter<bool>("wantProfile",true)),
49  m_want2dHisto(iConfig.getUntrackedParameter<bool>("want2dHisto",false))
50 
51 {
52 
53  std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
54 
55  for(std::vector<edm::ParameterSet>::const_iterator selconfig=selconfigs.begin();selconfig!=selconfigs.end();++selconfig) {
56  DetIdSelector selection(*selconfig);
57  m_selections.push_back(selection);
58  }
59 
60 }
61 
62 template <class T>
63 void DigiCollectionProfiler<T>::fill(edm::Handle<T> digis, const std::vector<TH1F*>& hist, const std::vector<TProfile*>& hprof, const std::vector<TH2F*>& hist2d) const {
64 
65 }
66 
67 
68 template <>
69 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 {
70 
71  for(edm::DetSetVector<SiStripDigi>::const_iterator mod = digis->begin();mod!=digis->end();mod++) {
72 
73  for(unsigned int isel=0;isel< m_selections.size(); ++isel) {
74 
75  if(m_selections[isel].isSelected(mod->detId())) {
76  TH1F* tobefilled1d=0;
77  TProfile* tobefilledprof=0;
78  TH2F* tobefilled2d=0;
79 
80  if(m_want1dHisto) tobefilled1d = hist[isel];
81  if(m_wantProfile) tobefilledprof = hprof[isel];
82  if(m_want2dHisto) tobefilled2d = hist2d[isel];
83 
84  for(edm::DetSet<SiStripDigi>::const_iterator digi=mod->begin();digi!=mod->end();digi++) {
85 
86  if(digi->adc()>0) {
87  unsigned int strip = digi->strip();
88  if(m_folded) strip = strip%256;
89  if(tobefilled1d) tobefilled1d->Fill(strip);
90  if(tobefilledprof) tobefilledprof->Fill(strip,digi->adc());
91  if(tobefilled2d) tobefilled2d->Fill(strip,digi->adc());
92  }
93  }
94  }
95  }
96  }
97 }
98 
99 template <>
100 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 {
101 
102  for(edmNew::DetSetVector<SiStripCluster>::const_iterator mod = digis->begin();mod!=digis->end();mod++) {
103 
104  for(unsigned int isel=0;isel< m_selections.size(); ++isel) {
105 
106  if(m_selections[isel].isSelected(mod->detId())) {
107  TH1F* tobefilled1d=0;
108  TProfile* tobefilledprof=0;
109  TH2F* tobefilled2d=0;
110 
111  if(m_want1dHisto) tobefilled1d = hist[isel];
112  if(m_wantProfile) tobefilledprof = hprof[isel];
113  if(m_want2dHisto) tobefilled2d = hist2d[isel];
114 
115  for(edmNew::DetSet<SiStripCluster>::const_iterator clus=mod->begin();clus!=mod->end();clus++) {
116 
117  for(unsigned int digi=0; digi < clus->amplitudes().size() ; ++digi) {
118 
119  if(clus->amplitudes()[digi]>0) {
120  unsigned int strip = clus->firstStrip()+digi;
121  if(m_folded) strip = strip%256;
122  if(tobefilled1d) tobefilled1d->Fill(strip);
123  if(tobefilledprof) tobefilledprof->Fill(strip,clus->amplitudes()[digi]);
124  if(tobefilled2d) tobefilled2d->Fill(strip,clus->amplitudes()[digi]);
125  }
126  }
127  }
128  }
129  }
130  }
131 }
132 
133 #endif // DPGAnalysis_SiStripTools_DigiCollectionProfile_H
T getParameter(std::string const &) const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
string fill
Definition: lumiContext.py:319
std::vector< DetIdSelector > m_selections
selection
main part
Definition: corrVsCorr.py:98
data_type const * const_iterator
Definition: DetSetNew.h:25
void fill(edm::Handle< T > digis, const std::vector< TH1F * > &, const std::vector< TProfile * > &, const std::vector< TH2F * > &) const
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4