StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
digreadoutmap.cxx
1 // //
3 // DIGReadoutmap //
4 // //
5 // final output of the event //
6 // -list of pixels with a collected charge >0 //
7 // -Analog charge list //
8 // -Digital charge list //
9 // //
10 // //
11 // //
13 #include <digreadoutmap.h>
14 
15 
16 #include <TROOT.h> // for gROOT object
17 #include <TMath.h>
18 #include <TMatrixD.h>
19 #include <TCanvas.h>
20 #include <TGraph.h>
21 #include <TAxis.h>
22 #include <TRandom3.h>
23 #include <TFile.h>
24 #include <TTree.h>
25 #include <TBranch.h>
26 #include <TClonesArray.h>
27 
28 //include other classes.h:
29 #include "digplane.h"
30 #include "digadc.h"
31 
32 
33 using namespace std;
34 
35 //==============================================================================
36 ClassImp(DIGReadoutmap)
37 //______________________________________________________________________________
38 //
40 {
41  fNpixels=0;
42  //
43  // default constructor
44  //
45 }
46 //______________________________________________________________________________
47 //
48 DIGReadoutmap::DIGReadoutmap(Int_t Npixels)
49 {
50  fNpixels = Npixels;
51  fPixelMap.resize(fNpixels);
52  fAnalogChargeMap.resize(fNpixels);
53  fDigitalChargeMap.resize(fNpixels);
54 }
55 //______________________________________________________________________________
56 //
57 DIGReadoutmap::~DIGReadoutmap() {
58  //
59  // virtual destructor
60 
61 }
62 //______________________________________________________________________________
63 //
64 DIGReadoutmap::DIGReadoutmap(DIGReadoutmap & adigreadoutmap) : TObject()
65 {
66  //copy constructor:
67  fNpixels = adigreadoutmap.GetNpixels();
68  fPixelMap.resize(fNpixels);
69  fAnalogChargeMap.resize(fNpixels);
70  fDigitalChargeMap.resize(fNpixels);
71  for (Int_t i=0 ; i<fNpixels ; i++){
72  fPixelMap[i] = adigreadoutmap.GetPixelMap()[i];
73  fAnalogChargeMap[i] = adigreadoutmap.GetAnalogCharge()[i];
74  fDigitalChargeMap[i] = adigreadoutmap.GetDigitalCharge()[i];
75  }
76 }
77 //______________________________________________________________________________
78 //
79 void DIGReadoutmap::Clear(const Option_t *)
80 {
81  // delete pointers. fDIGParticleArray->Clear("C");
82 
83 }
84 //______________________________________________________________________________
85 //
86 void DIGReadoutmap::PrintInfo() {
87  std::cout<<"---------DIGReadoutmap properties------------- "<<endl;
88  std::cout<<fNpixels<<" fNpixels map analog digital "<<endl;
89  if(fNpixels>0){
90  std::cout<<" size vectors "<< fPixelMap.size()<<" "<<fAnalogChargeMap.size()<<" "<<fDigitalChargeMap.size()<<endl;
91  for (Int_t i=0 ; i<fNpixels ; i++){
92  std::cout<<i<<" "<<fPixelMap[i]<<" "<<fAnalogChargeMap[i]<<" "<<fDigitalChargeMap[i]<<endl;
93  }
94  }
95  std::cout<<"---------END OF DIGReadoutmap properties------------- "<<endl;
96 }
97 //______________________________________________________________________________
98 //
99 void DIGReadoutmap::PrintOuput(Int_t Nx ,Int_t Ny) {
100  std::cout<<"---------DIGReadoutmap PrintOuput------------- "<<endl;
101  std::cout<<fNpixels<<" fNpixels "<<endl;
102  if(fNpixels>0){
103  std::cout<<" size vectors "<< fPixelMap.size()<<" "<<fAnalogChargeMap.size()<<" "<<fDigitalChargeMap.size()<<endl;
104  for (Int_t iy=0 ; iy<Ny ; iy++){
105  for (Int_t ix=0 ; ix<Nx ; ix++){
106  //search pixel:
107  Int_t Npixel = ix+Nx*iy;
108  Bool_t found = false;
109  Int_t j=0;
110  while((!found)&&(j<fNpixels)){
111  if(Npixel==fPixelMap[j]){
112  found=true;
113  cout<<" "<<fDigitalChargeMap[j];
114  }else{
115  j++;
116  }
117  }
118  if(!found){
119  cout<<" -";
120  }
121  }
122  cout<<endl;
123  }
124  }
125 
126  std::cout<<"---------END OF DIGReadoutmap PrintOuput------------- "<<endl;
127 }
128 //______________________________________________________________________________
129 //
130 void DIGReadoutmap::AddPixel(Float_t AnalogCharge, Int_t PixelNumber) {
131  fNpixels++;
132  fPixelMap.push_back(PixelNumber);
133  fAnalogChargeMap.push_back(AnalogCharge);
134  fDigitalChargeMap.push_back(0);
135 }
136 //______________________________________________________________________________
137 //
138 void DIGReadoutmap::UpdatePixel(Float_t AnalogCharge, Int_t PixelNumber) {
139  Bool_t found = false;
140  Int_t i=0;
141  while((!found)&&(i<fNpixels)){
142  if(PixelNumber==fPixelMap[i]){
143  found=true;
144  fAnalogChargeMap[i]+=AnalogCharge;
145  }
146  i++;
147  }
148  if(!found){
149  AddPixel(AnalogCharge, PixelNumber);
150  }
151 }
152 
153 //______________________________________________________________________________
154 //
155 void DIGReadoutmap::AnalogToDigitalconversion(DIGADC *myDIGADC, DIGPlane *myDIGPlane ){
156  Double_t Noisefix = myDIGPlane->GetNoiseElectrons();
157  if(Noisefix<=0.0){
158  std::cout <<"<---- DIGReadoutmap::AnalogToDigitalconversion --->"<<endl;
159  std::cout<<"WARNING negative or null Noise is not physical, please correct the input file"<<endl;
160  Noisefix = 1.0;
161  }
162  for (Int_t i = 0; i < fNpixels ; i++){
163  if (fAnalogChargeMap[i]<=0.0){
164  fDigitalChargeMap[i]=0;
165  }else{
166  Bool_t thresholdfound = false;
167  Int_t ithres = 0;
168  fDigitalChargeMap[i]=0;
169  while((thresholdfound==false)&&(ithres< (myDIGADC->GetNThresholds()) )){
170  if( (fAnalogChargeMap[i]/Noisefix) < myDIGADC->GetADC_thresholds()[ithres] ){
171  thresholdfound = true;
172  }else{
173  fDigitalChargeMap[i]++;
174  ithres++;
175  }
176  }
177  }
178  }
179 
180 }
181 //______________________________________________________________________________
182 //
Definition: digadc.h:36