FairRoot/PandaRoot
PndSdsIdealClusterTask.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndSdsIdealClusterTask source file -----
3 // -------------------------------------------------------------------------
4 
5 
6 #include "TClonesArray.h"
7 #include "TArrayD.h"
8 #include "TGeoManager.h"
9 
10 #include "FairRootManager.h"
11 #include "FairRun.h"
12 #include "FairRuntimeDb.h"
13 #include "FairGeoNode.h"
14 #include "FairGeoVector.h"
15 
16 #include "PndStringSeparator.h"
17 
18 #include "PndSdsIdealClusterTask.h"
19 #include "PndSdsMCPoint.h"
20 // #include "PndSdsHit.h"
21 #include "PndSdsCalcPixel.h"
22 //#include "PndSdsCalcFePixel.h"
23 #include "PndSdsDigiPixel.h"
24 // #include "PndSdsPixelCluster.h"
25 #include "PndSdsClusterPixel.h"
26 
27 
28 // ----- Default constructor -------------------------------------------
30  PndSdsTask("SDS Clustertisation Task"),
31  fDigiArray(NULL),
32  fClustBranchName(""),
33  fClusterType(-1),
34  fClusterArray(NULL),
35  fHitArray(NULL),
36  fGeoH(PndGeoHandling::Instance()),
37  fRadius(0),
38  fFEcolumns(0),
39  fFErows(0),
40  fGeoFile(""),
41  finder(NULL),
42  mapping(NULL)
43 {
44  //TGeoManager* geoMan;// = new TGeoManager("geoMan","geoMan");
45  //geoMan = gGeoManager;
46  //fGeoH = PndGeoHandling::Instance();
47  SetPersistency(kTRUE);
48 }
49 
50 PndSdsIdealClusterTask::PndSdsIdealClusterTask(Double_t radius, Int_t FEcolumns, Int_t FErows, TString geoFile) :
51  PndSdsTask("SDS Clustertisation Task"),
52  fDigiArray(NULL),
53  fClustBranchName(""),
54  fClusterType(-1),
55  fClusterArray(NULL),
56  fHitArray(NULL),
57  fGeoH(PndGeoHandling::Instance()),
58  fRadius(radius),
59  fFEcolumns(FEcolumns),
60  fFErows(FErows),
61  fGeoFile(geoFile),
62  finder(NULL),
63  mapping(NULL)
64 {
65  //TGeoManager* geoMan;// = new TGeoManager("geoMan","geoMan");
66  //geoMan = gGeoManager;
67  //fGeoH = PndGeoHandling::Instance();
68  SetPersistency(kTRUE);
69 }
70 
71 // -------------------------------------------------------------------------
72 
73 
74 // ----- Destructor ----------------------------------------------------
76 {
77 }
78 // -------------------------------------------------------------------------
79 
80 // ----- Initialization of Parameter Containers -------------------------
82 {
84 }
85 
87 {
88  InitStatus stat=kSUCCESS; //kERROR;
89  return stat;
90 }
91 
92 // ----- Public method Init --------------------------------------------
94 {
95 
97  SetInBranchId();
98 
99  FairRootManager* ioman = FairRootManager::Instance();
100 
101  if ( ! ioman )
102  {
103  std::cout << "-E- PndSdsIdealClusterTask::Init: "
104  << "RootManager not instantiated!" << std::endl;
105  return kFATAL;
106  }
107 
108  // Get input array
109  fDigiArray = (TClonesArray*) ioman->GetObject(fInBranchName);
110 
111  if ( ! fDigiArray )
112  {
113  std::cout << "-W- PndSdsIdealClusterTask::Init: "
114  << "No SDSDigi array!" << std::endl;
115  return kERROR;
116  }
117 
118  fClusterArray = new TClonesArray("PndSdsClusterPixel");
120 
121  fHitArray = new TClonesArray("PndSdsHit");
122  ioman->Register(fOutBranchName , fFolderName, fHitArray, GetPersistency());
123 
128 
129  std::cout << "-I- PndSdsIdealClusterTask: Initialisation successfull" << std::endl;
130  return kSUCCESS;
131 }
132 // -------------------------------------------------------------------------
133 
134 
135 
136 // ----- Public method Exec --------------------------------------------
138 {
139  std::vector<PndSdsDigiPixel> DigiPixelArray;
140  // Reset output array
141  if ( ! fClusterArray )
142  Fatal("Exec", "No ClusterArray");
143  fClusterArray->Delete();
144 
145  if ( ! fHitArray )
146  Fatal("Exec", "No HitArray");
147  fHitArray->Delete();
148 
149  Int_t
150  nPoints = fDigiArray->GetEntriesFast();
151 
152  for (Int_t iPoint = 0; iPoint < nPoints; iPoint++){
153  PndSdsDigiPixel myDigi = *(PndSdsDigiPixel*)(fDigiArray->At(iPoint));
154  DigiPixelArray.push_back(myDigi);
155  }
156 
157  std::vector< std::vector< Int_t> > clusters = finder->GetClusters(DigiPixelArray);
158  std::cout << clusters.size() << std::endl;
159  for (UInt_t i = 0; i < clusters.size(); i++)
160  {
161  new((*fClusterArray)[i]) PndSdsClusterPixel(fClusterType, clusters[i]);
162  }
163 
164  for (UInt_t i = 0; i < clusters.size(); i++){
165  std::cout << clusters[i].size() << " " << std::endl;
166  std::vector<PndSdsDigiPixel> clusterArray;
167  for (UInt_t j=0;j < clusters[i].size();j++)
168  clusterArray.push_back(DigiPixelArray[clusters[i][j]]);
169  PndSdsHit myCluster = mapping->GetCluster(clusterArray);
170  myCluster.SetClusterIndex(FairRootManager::Instance()->GetBranchId(fClustBranchName), i);
171  std::cout << "ClusterData: " << std::endl;
172  myCluster.Print();
173  new ((*fHitArray)[i]) PndSdsHit(myCluster);
174  }
175  std::cout << std::endl;
176 
177  return;
178 
179 }
180 
182 
int fVerbose
Definition: poormantracks.C:24
virtual void Exec(Option_t *opt)
virtual void Print(const Option_t *opt=0) const
Definition: PndSdsHit.cxx:66
TString fOutBranchName
Definition: PndSdsTask.h:40
Int_t i
Definition: run_full.C:25
PndGeoHandling * fGeoH
Definition: anasim.C:34
void SetClusterIndex(Int_t datasource, Int_t id, Int_t fileId=-1, Int_t evtId=-1)
Definition: PndSdsHit.h:82
virtual void SetParContainers()
void SetPersistency(Bool_t val=kTRUE)
PndSdsChargedWeightedPixelMapping: Gets a vector of DigiHits and calculates the cluster center weight...
PndSdsIdealPixelClusterFinder * finder
PndSdsChargeWeightedPixelMapping * mapping
PndStraightLineTrackFinderTask * finder
PndSdsHit GetCluster(std::vector< PndSdsDigiPixel > pixelArray)
Main function of class to calculate the PndSdsHit out of the given PndSdsDigis.
Class to access the naming information of the MVD.
std::vector< std::vector< Int_t > > GetClusters(std::vector< PndSdsDigiPixel > hits)
Double_t
TString fInBranchName
Definition: PndSdsTask.h:39
virtual void SetBranchNames()=0
TString fFolderName
Definition: PndSdsTask.h:41
ClassImp(PndAnaContFact)
Data class to store the digi output of a pixel module.
TString fGeoFile