StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
digevent.cxx
1 // //
3 // DIGEvent //
4 // //
5 // Event class //
6 // -> particle list, cluster list and digital output of the plane ( fDIGReadoutmap) //
7 // //
8 // //
9 // //
10 // //
11 // //
13 #include <digevent.h>
14 
15 #include <TROOT.h> // for gROOT object
16 #include <TMath.h>
17 #include <TMatrixD.h>
18 #include <TCanvas.h>
19 #include <TGraph.h>
20 #include <TAxis.h>
21 #include <TRandom3.h>
22 #include <TFile.h>
23 #include <TTree.h>
24 #include <TBranch.h>
25 #include <TClonesArray.h>
26 
27 #include "digparticle.h"
28 #include "digcluster.h"
29 #include "digreadoutmap.h"
30 #include "digplane.h"
31 
32 using namespace std;
33 
34 //==============================================================================
35 ClassImp(DIGEvent)
37 {
38  //
39  // default constructor
40  //
41  fNParticles=0;
42  fDIGParticleArray=0;
43  fDIGParticleArray = new TClonesArray("DIGParticle", 10);
44  fNClusters=0;
45  fDIGClusterArray=0;
46  fDIGClusterArray = new TClonesArray("DIGCluster", 10);
47  fDIGReadoutmap= new DIGReadoutmap();
48 }
49 //______________________________________________________________________________
50 //
51 DIGEvent::DIGEvent(DIGEvent & adigevent) : TObject()
52 {
53 
54  //----copy the particle array
55  TClonesArray *particleArray2 = adigevent.GetParticle();
56  Int_t npart =adigevent.GetNParticles();
57  for (Int_t ipart = 0; ipart < npart ; ipart++){
58  DIGParticle *papa = 0;
59  papa = (DIGParticle*)particleArray2->At(ipart);
60  AddParticle(*papa);
61  delete papa;
62  }
63  //----copy the cluster array
64  TClonesArray *clusterArray2 = adigevent.GetCluster();
65  Int_t nclus =adigevent.GetNClusters();
66  for (Int_t iclus = 0; iclus < nclus ; iclus++){
67  DIGCluster *clus = 0;
68  clus = (DIGCluster*)clusterArray2->At(iclus);
69  AddCluster(*clus);
70  delete clus;
71  }
72 
73 
74  //----copy the read out map object:
75  DIGReadoutmap &adigreadout = *(adigevent.GetReadoutmap());
76  fDIGReadoutmap= new DIGReadoutmap(adigreadout);
77 
78 
79  fConfigurationNumber =adigevent.GetConfigurationNumber();
80 }
81 //______________________________________________________________________________
82 //
83 DIGEvent::~DIGEvent() { //
84  // virtual destructor
85  //
86  // delete fLayers;
87  fDIGParticleArray->Clear("C");
88  delete fDIGReadoutmap;
89  // fDIGReadoutmap=0;
90  fNParticles=0;
91 
92  fDIGClusterArray->Clear("C");
93  fNClusters=0;
94 
95 }
96 //______________________________________________________________________________
97 //
98 void DIGEvent::Clear(const Option_t *)
99 {
100  fDIGParticleArray->Clear("C");
101  delete fDIGReadoutmap;
102  fNParticles=0;
103  fDIGClusterArray->Clear("C");
104  fNClusters=0;
105 }
106 
107 //______________________________________________________________________________
108 //
109 
110 void DIGEvent::PrintInfo() {
111  std::cout<<"---------------------------Event properties------------- "<<endl;
112  TClonesArray *particules = GetParticle();
113  DIGParticle *apart;
114  std::cout<<" number of particles "<<fNParticles<<" "<<particules->GetLast()+1<<endl;
115  for (Int_t i=0 ; i<(particules->GetLast()+1) ; i++){
116  apart = (DIGParticle*)particules->At(i);
117  apart->PrintInfo();
118  }
119  if( fNParticles != (particules->GetLast()+1)){
120  cout<< "DIGEvent::PrintInfo WARNING PROBLEM IN PARTICLES RECORDING "<<fNParticles<<" != "<<particules->GetLast()+1<<endl;
121  }
122 
123  TClonesArray *clusters = GetCluster();
124  DIGCluster *acluster;
125  std::cout<<" number of clusters "<<fNClusters<<" "<<clusters->GetLast()+1<<endl;
126  for (Int_t i=0 ; i<(clusters->GetLast()+1) ; i++){
127  acluster = (DIGCluster*)clusters->At(i);
128  acluster->PrintInfo();
129  }
130  if( fNClusters != (clusters->GetLast()+1)){
131  cout<< "DIGEvent::PrintInfo WARNING PROBLEM IN CLUSTERS RECORDING "<<fNClusters<<" != "<<clusters->GetLast()+1<<endl;
132  }
133 
134  GetReadoutmap()->PrintInfo();
135 }
136 //______________________________________________________________________________
137 //
138 void DIGEvent::SetNParticles(Int_t Nparticles){
139  fNParticles = Nparticles;
140 }
141 //______________________________________________________________________________
142 //
143 void DIGEvent::SetNClusters(Int_t NClusters){
144  fNClusters=NClusters;
145 }
146 //______________________________________________________________________________
147 //
148 void DIGEvent::SetConfigurationNumber(Int_t ConfigurationNumber){
149  fConfigurationNumber = ConfigurationNumber;
150 }
151 //______________________________________________________________________________
152 //
153 void DIGEvent::AddParticle(DIGParticle& particle)
154 {
155  // fNParticles++;
156  TClonesArray &particleArray = *fDIGParticleArray;
157  new(particleArray[fNParticles++]) DIGParticle(particle); // utilise le copieur
158 
159 
160 
161 }
162 //______________________________________________________________________________
163 //
164 void DIGEvent::AddCluster(DIGCluster& cluster)
165 {
166  TClonesArray &clusterArray = *fDIGClusterArray;
167  new(clusterArray[fNClusters++]) DIGCluster(cluster); // utilise le copieur
168 }
169 //______________________________________________________________________________
170 //
171 void DIGEvent::BuildTrueClusters(DIGPlane *myDIGPlane){
172  // this method builds "monte carlo truth" clusters.
173  // In others words, it takes the generated charge from the particles to build the clusters.
174  // Its purpose is to compare other algorithms with ideal clustering reconstruction.
175 
176  TClonesArray *particules = GetParticle();
177  if( GetNParticles() != (particules->GetLast()+1)){
178  cout<< "DIGEvent::BuildTrueClusters WARNING PROBLEM IN PARTICLES RECORDING"<<endl;
179  }
180 
181 
182 
183  DIGParticle *myparticle = 0;
184  TClonesArray *particleArray = GetParticle();
185  DIGCluster *mycluster=0;
186  for (Int_t i = 0; i < fNParticles ; i++){
187  myparticle = (DIGParticle*)particleArray->At(i);
188  //myparticle->PrintInfo();
189  mycluster = new DIGCluster();
190  for (Int_t npix = 0; npix < myparticle->GetNpixels() ; npix++){
191  if(myparticle->GetDigitalCharge()[npix]>0){
192  mycluster->AddPixel(myparticle->GetDigitalCharge()[npix],myparticle->GetPixelMap()[npix]);
193  }
194  }
195  mycluster->Compute_CoG(myDIGPlane);
196  mycluster->Compute_SeedPixel(myDIGPlane);
197 
198  if(mycluster->GetNpixels()>0){
199  //mycluster->PrintInfo();
200  AddCluster(*mycluster);
201  }
202  }
203 
204  TClonesArray *aclusterArray = GetCluster();
205  if(GetNClusters() != aclusterArray->GetLast()+1){
206  cout<<" TEST cluster number "<<GetNClusters()<<" "<<aclusterArray->GetLast()+1<<endl;
207  }
208  delete mycluster;
209 }
210 //______________________________________________________________________________
211 //
212