EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRingSorterTask.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRingSorterTask.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairRingSorterTaskT source file -----
3 // -------------------------------------------------------------------------
4 
5 #include "FairRingSorterTask.h"
6 #include "FairRootManager.h"
7 
8 
9 
10 
12 {
13  return kSUCCESS;
14 }
15 
16 // ----- Public method Init --------------------------------------------
18 {
19 
21  if ( ! ioman ) {
22  std::cout << "-E- FairRingSorterTaskT::Init: "
23  << "RootManager not instantiated!" << std::endl;
24  return kFATAL;
25  }
26 
28 
29  // Create and register output array
31 
32  if(fVerbose>1) { Info("Init","Registering this branch: %s/%s",fFolder.Data(),fOutputBranch.Data()); }
33  fOutputArray = ioman->Register(fOutputBranch, fInputArray->GetClass()->GetName(), fFolder, fPersistance);
34 
35 
36  return kSUCCESS;
37 }
38 // -------------------------------------------------------------------------
39 
40 // ----- Public method Exec --------------------------------------------
41 void FairRingSorterTask::Exec(Option_t* opt)
42 {
43 
44 
45 
47  if (fVerbose > 1) {
48  std::cout << "-I- FairRingSorterTask: Size PixelArray: " << fInputArray->GetEntriesFast() << std::endl;
49  }
50  for (int i = 0; i < fInputArray->GetEntriesFast(); i++) {
51  FairTimeStamp* myData = (FairTimeStamp*)fInputArray->At(i);
52  myData->SetEntryNr(FairLink(0, fEntryNr, fInputBranch, i));
53  if (fVerbose > 1) {
54  std::cout << "Sorter filled with: ";
55  myData->Print();
56  std::cout<< std::endl;
57  }
58  fSorter->AddElement(myData, myData->GetTimeStamp());
59  }
60  if (fVerbose > 2) { fSorter->Print(); }
61 
62  std::vector<FairTimeStamp*> sortedData = fSorter->GetOutputData();
63 
64 
66  for (int i = 0; i < sortedData.size(); i++) {
67  AddNewDataToTClonesArray(sortedData[i]);
68  }
70  fEntryNr++;
71 }
72 
73 // -------------------------------------------------------------------------
74 
76 {
77  fOutputArray->Delete();
78 }
79 
81 {
83  if (fVerbose > 2) { std::cout << "-I- FairRingSorterTaskT::FinishTask Size InputArray: " << fInputArray->GetEntriesFast() << std::endl; }
84  for (int i = 0; i < fInputArray->GetEntriesFast(); i++) {
85  FairTimeStamp* myDigi = (FairTimeStamp*) fInputArray->At(i);
86  fSorter->AddElement(myDigi, ((FairTimeStamp*)myDigi)->GetTimeStamp());
87  }
88  fSorter->Print();
90  std::vector<FairTimeStamp*> sortedData = fSorter->GetOutputData();
91 
94  for (int i = 0; i < sortedData.size(); i++) {
95  if (fVerbose > 2) {
96  std::cout << i << " FinishTask : ";
97  sortedData[i]->Print();
98  std::cout << std::endl;
99  }
100 
101  AddNewDataToTClonesArray(sortedData[i]);
102  }
104  if (fVerbose > 1) {
105  fSorter->Print();
106  }
107  ioman->SetLastFill();
108 }
109