FairRoot/PandaRoot
PndHypStripClusterBuilder.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndMvdStripClusterBuilder source file -----
3 // ----- Converted 27.11.2007 from R.Jaekel by R.Kliemt -----
4 // -------------------------------------------------------------------------
5 
7 
8 // includes for sort algorithms
9 #include <algorithm>
10 #include <functional>
11 #include <vector>
12 #include <cmath>
13 #include "TMath.h"
14 
16 {
17  // dummy
18 }
19 
21 {
22 }
23 
27 
29 {
30 fSortedDigis.clear();
31 fClusters.clear();
32 fTopclusters.clear();
33 fBotclusters.clear();
34 }
35 
36 void PndHypStripClusterBuilder::AddDigi(std::string detName, SensorSide side, Int_t strip, Int_t iPoint)
37 {
38  fSortedDigis[detName][side][strip] = iPoint;
39  //std::cout<<" det name "<<detName<<" ipoint "<<iPoint<<std::endl;
40 
41 }
42 
43 
44 
45 std::vector< PndHypCluster> PndHypStripClusterBuilder::SearchClusters()
46 {
50  fClusters.clear();
51  fTopclusters.clear();
52  fBotclusters.clear();
53  std::vector< Int_t > onecluster;
54 
55  for (Fullmap::iterator itSensors = fSortedDigis.begin();
56  itSensors != fSortedDigis.end(); ++itSensors)
57  {
58  //std::cout<< "name "<<itSensors->first<<std::endl;
59  for (std::map<SensorSide,Indexpair>::iterator itSide = (itSensors->second).begin();
60  itSide != (itSensors->second).end(); ++itSide)
61  {
62 
63  Indexpair flagmap;
64  //std::cout<< "side "<<itSensors->second<<std::endl;
65  for (Indexpair::iterator itStrip = (itSide->second).begin();
66  itStrip!= (itSide->second).end(); ++itStrip)
67  {flagmap[itStrip->second]=1;}
68 
69  for (Indexpair::iterator itStrip = (itSide->second).begin();
70  itStrip!= (itSide->second).end(); ++itStrip) {
71  if( !(1==flagmap[itStrip->second]) ) continue;
72  for(Indexpair::iterator itStrip3 = itStrip; itStrip3 != (itSide->second).end(); ++itStrip3)
73  {
74  if( !(1==flagmap[itStrip3->second]) ) continue;
75  if( std::abs(itStrip->first - itStrip3->first) > 1) continue;
76 
77  onecluster.push_back(itStrip3->second);
78  // make a helper to the next element
79  flagmap[itStrip3->second]=-1;//do not reuse this digi
80  itStrip=itStrip3;
81  }
82  AddCluster(onecluster,itSide->first);
83  onecluster.clear();
84  }// end loop itStrip
85 
86  if (onecluster.size()>0)
87  {
88  std::cout<<"mvd strip clusterfinder: cluster hangover? "<<onecluster.size()<<std::endl;
89  AddCluster(onecluster,itSide->first);
90  onecluster.clear();
91  }
92  }// end loop it Side
93  }// end loop sensor
94  return fClusters;
95 }
96 
97 
99  {
100  if(0<=i && (int)fClusters.size() < i)
101  return fClusters[i];
102  return PndHypCluster();
103  }
105  {
106  if(0<=i && (int)fTopclusters.size() < i)
107  return fClusters[ (fTopclusters[i]) ];
108  return PndHypCluster();
109  }
111  {
112  if(0<=i && (int)fBotclusters.size() < i)
113  return fClusters[ (fBotclusters[i]) ];
114  return PndHypCluster();
115  }
116 
117 
118 
119 void PndHypStripClusterBuilder::AddCluster(const std::vector< Int_t >& onecluster,SensorSide side)
120 {
121  Int_t clindex = fClusters.size();
122  if(side == kBOTTOM)
123  {
124  fBotclusters.push_back(clindex);
125  //std::cout<<"Adding bot Cluster number "<<clindex<<" side "<<side<<" to the bottom list."<<std::endl;
126  } else if(side == kTOP)
127  {
128  fTopclusters.push_back(clindex);
129  //std::cout<<"Adding top Cluster number "<<clindex<<" side "<<side<<" to the top list."<<std::endl;
130  }
131  PndHypCluster cl(onecluster);
132  cl.SetSensorSide(side);
133  //std::cout<<"side clus cand "<<cl.GetSensorSide()<<std::endl;
134 
135  fClusters.push_back(cl);
136 }
137 
138 
139 
140 
141 
142 
147 
148 // double PndHypStripClusterBuilder::meanColumn(std::vector<PndHypDigiPixel*>& list){
149 // double mean = 0.;
150 // if (list.size() == 0){
151 // std::cout<<" there are no channels in list to form cluster!"<<std::endl;
152 // }
153 // else{
154 // // loop over digis to get weighted mean
155 // double sumWeights = 0.;
156 // double sumChannel = 0.;
157 // for (int loopList = 0; loopList<list.size(); loopList++) {
158 // sumWeights += list[loopList]->getTot();
159 // sumChannel += list[loopList]->getTot() * list[loopList]->getColumn();
160 // }
161 // // calc the weighted mean
162 // mean = sumChannel/sumWeights;
163 // }
164 // return mean;
165 // }
166 //
167 //
168 // double PndHypStripClusterBuilder::errMeanColumn(std::vector<PndHypDigiPixel*>& list, double pitch){
169 //
170 // // only geometric resolution so far....
171 // double errMean = list.size()*pitch/sqrt(12);
172 // return errMean;
173 // }
174 
175 
176 
177 
178 
179 
180 // --- somehow the iterator does not work here with the templates
181 // for(std::vector<T1*>::iterator iterdigi = digiList.begin();
182 // iterdigi!=digiList.end();iterdigi++)
183 //
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
std::vector< PndHypCluster > SearchClusters()
Class to store the Digis which belong to one cluster This class holds the information which Digi belo...
Definition: PndHypCluster.h:18
Int_t i
Definition: run_full.C:25
void Reinit()
-----------------------------------------------------------------------—///
void SetSensorSide(SensorSide s)
Definition: PndHypCluster.h:31
std::map< Int_t, Int_t > Indexpair
int strip
Definition: anaMvdDigi.C:135
void AddDigi(std::string detname, SensorSide side, Int_t strip, Int_t iPoint)
SensorSide
void AddCluster(const std::vector< Int_t > &onecluster, SensorSide side)
--------------------------------------------------------------------——///
ClassImp(PndAnaContFact)
std::vector< PndHypCluster > fClusters