13 #include <digcluster.h>
26 #include <TClonesArray.h>
46 fDigitalChargeMap.clear();
53 DIGCluster::~DIGCluster() {
60 DIGCluster::DIGCluster(DIGCluster & adigCluster) : TObject()
64 fNpixels = adigCluster.GetNpixels();
66 fPixelMap.resize((adigCluster.GetPixelMap()).size());
67 fDigitalChargeMap.resize((adigCluster.GetPixelMap()).size());
68 for (Int_t i=0 ; i<fNpixels ; i++){
69 fPixelMap[i] = adigCluster.GetPixelMap()[i];
70 fDigitalChargeMap[i] = adigCluster.GetDigitalCharge()[i];
72 Xposition_CoG = adigCluster.GetXposition_CoG();
73 Yposition_CoG = adigCluster.GetYposition_CoG();
74 fSeedPixelIndex = adigCluster.GetSeedPixelIndex();
79 void DIGCluster::Clear(
const Option_t *)
86 Int_t DIGCluster::GetTotalCharge(){
87 Int_t TotalCharge = 0;
88 for (Int_t i=0 ; i<fNpixels ; i++){
89 TotalCharge+=fDigitalChargeMap[i];
95 Int_t DIGCluster::Get1stCrownCharge(
DIGPlane *myDIGPlane){
96 Int_t f1stCrownCharge = 0;
97 std::vector<Int_t> pixmapvector;
98 pixmapvector = Get1stCrownPixelsIndex(myDIGPlane);
99 Int_t imax = pixmapvector.size();
100 for ( Int_t i=0 ; i<imax ; i++ ) {
101 for ( Int_t j=0 ; j<fNpixels; j++ ) {
102 if(pixmapvector[i]==fPixelMap[j]){
103 f1stCrownCharge+=fDigitalChargeMap[j];
111 return f1stCrownCharge;
115 Int_t DIGCluster::Get2ndCrownCharge(
DIGPlane *myDIGPlane){
116 Int_t f2ndCrownCharge = 0;
117 std::vector<Int_t> pixmapvector;
118 pixmapvector = Get2ndCrownPixelsIndex(myDIGPlane);
119 Int_t imax = pixmapvector.size();
120 for ( Int_t i=0 ; i<imax; i++ ) {
121 for ( Int_t j=0 ; j<fNpixels; j++ ) {
122 if(pixmapvector[i]==fPixelMap[j]){
123 f2ndCrownCharge+=fDigitalChargeMap[j];
127 return f2ndCrownCharge;
132 Int_t DIGCluster::Get4NeigboursCharge(
DIGPlane *myDIGPlane){
133 Int_t f4NeigboursCharge = 0;
134 std::vector<Int_t> pixmapvector;
135 pixmapvector = Get4NeigboursPixelsIndex(myDIGPlane);
136 Int_t imax = pixmapvector.size();
137 for ( Int_t i=0 ; i<imax ; i++ ) {
138 for ( Int_t j=0 ; j<fNpixels; j++ ) {
139 if(pixmapvector[i]==fPixelMap[j]){
140 f4NeigboursCharge+=fDigitalChargeMap[j];
144 return f4NeigboursCharge;
148 Int_t DIGCluster::GetMultiplicity(Int_t Threshold){
149 Int_t TotalMultiplicity = 0;
150 for (Int_t i=0 ; i<fNpixels ; i++){
151 if(fDigitalChargeMap[i]>=Threshold){
155 return TotalMultiplicity;
161 void DIGCluster::Compute_CoG(
DIGPlane *myDIGPlane){
165 Double_t TotalCharge = 0.0;
166 for (Int_t i = 0; i < fNpixels ; i++){
167 Int_t PixelNumber = fPixelMap[i];
168 Double_t Xpix = (myDIGPlane->GetPitchY()) * (0.5+PixelNumber%(myDIGPlane->GetNpixelsX()));
169 Double_t Ypix = (myDIGPlane->GetPitchX()) * (0.5+PixelNumber/(myDIGPlane->GetNpixelsX()));
170 Int_t
Charge = fDigitalChargeMap[i];
171 XCoG += Charge * Xpix;
172 YCoG += Charge * Ypix;
173 TotalCharge += Charge;
176 XCoG = XCoG / TotalCharge;
177 YCoG = YCoG / TotalCharge;
182 SetXposition_CoG(XCoG);
183 SetYposition_CoG(YCoG);
188 void DIGCluster::AddPixel(Int_t DigitalCharge, Int_t PixelNumber){
190 fPixelMap.push_back(PixelNumber);
191 fDigitalChargeMap.push_back(DigitalCharge);
195 void DIGCluster::PrintInfo() {
196 std::cout<<
"---------DIGCluster properties------------- "<<endl;
197 std::cout<<
" Total charge, mul1, mul2, mul3, mul4 "<<endl;
198 std::cout<<GetTotalCharge()
199 <<
" "<<GetMultiplicity(1)
200 <<
" "<<GetMultiplicity(2)
201 <<
" "<<GetMultiplicity(3)
202 <<
" "<<GetMultiplicity(4)<<endl;
203 for (Int_t i=0 ; i<fNpixels ; i++){
204 std::cout<<i<<
" "<<fPixelMap[i]<<
" "<<
" "<<fDigitalChargeMap[i]<<endl;
206 std::cout<<
" CoG "<<GetXposition_CoG() <<
" "<< GetYposition_CoG()<<endl;
207 std::cout<<
" SEED index, totalC seedcharge "<< GetSeedPixelIndex()<<
" "<<GetTotalCharge()<<
" "<<GetDigitalCharge()[GetSeedPixelIndex()]<<endl;
212 void DIGCluster::Compute_SeedPixel(
DIGPlane *myDIGPlane){
216 Int_t CurrentDigSeedCharge = 0;
217 Int_t CurrentDigSeedIndex = -1;
218 Float_t CurrentDist = 0;
219 for (Int_t i = 0; i < fNpixels ; i++){
220 if(fDigitalChargeMap[i]>CurrentDigSeedCharge){
221 CurrentDigSeedCharge = fDigitalChargeMap[i];
222 CurrentDigSeedIndex = i;
223 for (Int_t j = 0; j < fNpixels ; j++){
224 if(fDigitalChargeMap[j]==CurrentDigSeedCharge){
225 Int_t SeedCandidatePixelNumber = fPixelMap[i];
226 Double_t SeedCandidateXpix = (myDIGPlane->GetPitchY()) * (0.5+SeedCandidatePixelNumber%(myDIGPlane->GetNpixelsX()));
227 Double_t SeedCandidateYpix = (myDIGPlane->GetPitchX()) * (0.5+SeedCandidatePixelNumber/(myDIGPlane->GetNpixelsX()));
228 Int_t PixelNumber = fPixelMap[j];
229 Double_t Xpix = (myDIGPlane->GetPitchY()) * (0.5+PixelNumber%(myDIGPlane->GetNpixelsX()));
230 Double_t Ypix = (myDIGPlane->GetPitchX()) * (0.5+PixelNumber/(myDIGPlane->GetNpixelsX()));
231 CurrentDist += TMath::Sqrt((Xpix-SeedCandidateXpix)*(Xpix-SeedCandidateXpix)+(Ypix-SeedCandidateYpix)*(Ypix-SeedCandidateYpix));
234 }
else if(fDigitalChargeMap[i]==CurrentDigSeedCharge){
236 for (Int_t j = 0; j < fNpixels ; j++){
237 if(fDigitalChargeMap[j]==CurrentDigSeedCharge){
238 Int_t SeedCandidatePixelNumber = fPixelMap[i];
239 Double_t SeedCandidateXpix = (myDIGPlane->GetPitchY()) * (0.5+SeedCandidatePixelNumber%(myDIGPlane->GetNpixelsX()));
240 Double_t SeedCandidateYpix = (myDIGPlane->GetPitchX()) * (0.5+SeedCandidatePixelNumber/(myDIGPlane->GetNpixelsX()));
241 Int_t PixelNumber = fPixelMap[j];
242 Double_t Xpix = (myDIGPlane->GetPitchY()) * (0.5+PixelNumber%(myDIGPlane->GetNpixelsX()));
243 Double_t Ypix = (myDIGPlane->GetPitchX()) * (0.5+PixelNumber/(myDIGPlane->GetNpixelsX()));
244 newdist += TMath::Sqrt((Xpix-SeedCandidateXpix)*(Xpix-SeedCandidateXpix)+(Ypix-SeedCandidateYpix)*(Ypix-SeedCandidateYpix));
247 if(newdist<CurrentDist){
248 CurrentDigSeedCharge = fDigitalChargeMap[i];
249 CurrentDigSeedIndex = i;
250 CurrentDist = newdist;
254 SetSeedPixelIndex(CurrentDigSeedIndex);
259 void DIGCluster::GetXYPixelNumber(Int_t &Xpix, Int_t &Ypix,
DIGPlane *myDIGPlane, Int_t PixelNumber){
261 Xpix = PixelNumber%(myDIGPlane->GetNpixelsX());
262 Ypix = PixelNumber/(myDIGPlane->GetNpixelsX());
267 Int_t DIGCluster::GetSeedPixelIndex(){
269 return fSeedPixelIndex;
273 void DIGCluster::SetSeedPixelIndex(Int_t Index)
275 fSeedPixelIndex = Index;
279 std::vector<Int_t> DIGCluster::Get4NeigboursPixelsIndex(
DIGPlane *myDIGPlane){
280 vector< Int_t > PixelMap;
284 GetXYPixelNumber(Xpix,Ypix,myDIGPlane,fPixelMap[fSeedPixelIndex]);
285 if(IsPixelInThePlane(Xpix+1,Ypix,myDIGPlane)){
286 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+1);
288 if(IsPixelInThePlane(Xpix-1,Ypix,myDIGPlane)){
289 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-1);
291 if(IsPixelInThePlane(Xpix,Ypix+1,myDIGPlane)){
292 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+myDIGPlane->GetNpixelsX());
294 if(IsPixelInThePlane(Xpix,Ypix-1,myDIGPlane)){
295 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-myDIGPlane->GetNpixelsX());
301 std::vector<Int_t> DIGCluster::Get1stCrownPixelsIndex(
DIGPlane *myDIGPlane){
302 vector< Int_t > PixelMap;
306 GetXYPixelNumber(Xpix,Ypix,myDIGPlane,fPixelMap[fSeedPixelIndex]);
307 if(IsPixelInThePlane(Xpix-1,Ypix-1,myDIGPlane)){
308 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-1-myDIGPlane->GetNpixelsX());
310 if(IsPixelInThePlane(Xpix,Ypix-1,myDIGPlane)){
311 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-myDIGPlane->GetNpixelsX());
313 if(IsPixelInThePlane(Xpix+1,Ypix-1,myDIGPlane)){
314 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+1-myDIGPlane->GetNpixelsX());
316 if(IsPixelInThePlane(Xpix-1,Ypix,myDIGPlane)){
317 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-1);
319 if(IsPixelInThePlane(Xpix+1,Ypix,myDIGPlane)){
320 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+1);
322 if(IsPixelInThePlane(Xpix-1,Ypix+1,myDIGPlane)){
323 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-1+myDIGPlane->GetNpixelsX());
325 if(IsPixelInThePlane(Xpix,Ypix+1,myDIGPlane)){
326 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+myDIGPlane->GetNpixelsX());
328 if(IsPixelInThePlane(Xpix+1,Ypix+1,myDIGPlane)){
329 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+1+myDIGPlane->GetNpixelsX());
335 std::vector<Int_t> DIGCluster::Get2ndCrownPixelsIndex(
DIGPlane *myDIGPlane){
336 vector< Int_t > PixelMap;
340 GetXYPixelNumber(Xpix,Ypix,myDIGPlane,fPixelMap[fSeedPixelIndex]);
341 if(IsPixelInThePlane(Xpix-2,Ypix-2,myDIGPlane)){
342 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-2-2*myDIGPlane->GetNpixelsX());
344 if(IsPixelInThePlane(Xpix-1,Ypix-2,myDIGPlane)){
345 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-1-2*myDIGPlane->GetNpixelsX());
347 if(IsPixelInThePlane(Xpix,Ypix-2,myDIGPlane)){
348 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-2*myDIGPlane->GetNpixelsX());
350 if(IsPixelInThePlane(Xpix+1,Ypix-2,myDIGPlane)){
351 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+1-2*myDIGPlane->GetNpixelsX());
353 if(IsPixelInThePlane(Xpix+2,Ypix-2,myDIGPlane)){
354 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+2-2*myDIGPlane->GetNpixelsX());
358 if(IsPixelInThePlane(Xpix-2,Ypix-1,myDIGPlane)){
359 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-2-myDIGPlane->GetNpixelsX());
361 if(IsPixelInThePlane(Xpix+2,Ypix-1,myDIGPlane)){
362 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+2-myDIGPlane->GetNpixelsX());
365 if(IsPixelInThePlane(Xpix-2,Ypix,myDIGPlane)){
366 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-2);
368 if(IsPixelInThePlane(Xpix+2,Ypix,myDIGPlane)){
369 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+2);
373 if(IsPixelInThePlane(Xpix-2,Ypix+1,myDIGPlane)){
374 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-2+myDIGPlane->GetNpixelsX());
376 if(IsPixelInThePlane(Xpix+2,Ypix+1,myDIGPlane)){
377 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+2+myDIGPlane->GetNpixelsX());
380 if(IsPixelInThePlane(Xpix-2,Ypix+2,myDIGPlane)){
381 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-2+2*myDIGPlane->GetNpixelsX());
383 if(IsPixelInThePlane(Xpix-1,Ypix+2,myDIGPlane)){
384 PixelMap.push_back(fPixelMap[fSeedPixelIndex]-1+2*myDIGPlane->GetNpixelsX());
386 if(IsPixelInThePlane(Xpix,Ypix+2,myDIGPlane)){
387 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+2*myDIGPlane->GetNpixelsX());
389 if(IsPixelInThePlane(Xpix+1,Ypix+2,myDIGPlane)){
390 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+1+2*myDIGPlane->GetNpixelsX());
392 if(IsPixelInThePlane(Xpix+2,Ypix+2,myDIGPlane)){
393 PixelMap.push_back(fPixelMap[fSeedPixelIndex]+2+2*myDIGPlane->GetNpixelsX());
401 Bool_t DIGCluster::IsPixelInThePlane(Int_t Xpix, Int_t Ypix,
DIGPlane *myDIGPlane){
404 Int_t NpixelsX = myDIGPlane->GetNpixelsX();
405 Int_t NpixelsY = myDIGPlane->GetNpixelsY();
406 if(Xpix<0){IsIn =
false;}
407 if(Ypix<0){IsIn =
false;}
408 if(Xpix>=NpixelsX){IsIn =
false;}
409 if(Ypix>=NpixelsY){IsIn =
false;}