FairRoot/PandaRoot
PndMvdReadInTBDataTask.cxx
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <fstream>
5 
6 
7 // Root includes
8 #include "TROOT.h"
9 #include "TString.h"
10 #include "TClonesArray.h"
11 #include "TParticlePDG.h"
12 #include "PndSdsDigiTopix4.h"
13 #include "PndSdsDigiTopix4Header.h"
14 
15 // framework includes
16 #include "FairRootManager.h"
17 #include "FairRun.h"
18 #include "FairRuntimeDb.h"
19 #include "FairRunAna.h"
20 
21 // PndMvd includes
22 
23 
24 
26  FairTask("MVDReadInTBDataTask"), fClockFrequency(50), fEvent(0)
27 {
28 }
29 
31 {
32  for (int i = 0; i < fReader.size(); i++){
33  delete(fReader[i]);
34  }
35  fReader.clear();
36 }
37 
39 {
40  FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
41 }
42 
44 {
45  fInitDone = kTRUE;
46  return kSUCCESS;
47 }
48 
49 // ----- Public method Init --------------------------------------------
51 {
52  FairRootManager* ioman = FairRootManager::Instance();
53  std::cout << "PndMvdReadInTBDataTask::Init start of Init" << std::endl;
54 
55  if ( ! ioman )
56  {
57  std::cout << "-E- PndMvdReadInTBDataTask::Init: "
58  << "RootManager not instantiated!" << std::endl;
59  return kFATAL;
60  }
61 
62  for (int i = 0; i < fFileNames.size(); i++) {
63  std::cout << "PndMvdReadInTBDataTask::Init FileName: " << fFileNames[i][0] << std::endl;
64  fReader.push_back(new PndMvdReadInToPix4TBData());
65  fEndOfFile.push_back(kFALSE);
66  fReader[i]->SetFileName(fFileNames[i]);
67  fReader[i]->SetClockFrequency(fClockFrequency);
68  fReader[i]->SetVerbose(fVerbose);
69  fReader[i]->SetFE(i+1);
70  std::cout << "PndMvdReadInTBDataTask::Init before Reader Init" << std::endl;
71  fReader[i]->Init();
72  }
73 
74  fDigiArray = ioman->Register("ToPix4Hits", "PndSdsDigiTopix4", "MVD", kTRUE);
75  fFrameHeaderArray = ioman->Register("ToPix4FrameHeader","PndSdsDigiTopix4Header","MVD", kTRUE);
76  // fAllFrameHeaderArray = ioman->Register("AllToPix4FrameHeader","PndSdsDigiTopix4Header","MVD", kTRUE);
77 
78  std::cout << "-I- PndMvdReadInTBDataTask: Initialisation successfull" << std::endl;
79  fInitDone = kTRUE;
80  return kSUCCESS;
81 }
82 
83 // ----- Public method Exec --------------------------------------------
85 {
86  if (fEvent % 10000 == 0) {
87  std::cout << "PndMvdReadInTBDataTask::Exec called - Event " <<std::dec<< fEvent << std::endl;
88  }
89  fEvent++;
90 
91  for(int i = 0; i < fReader.size(); i++){
92  if (fEndOfFile[i] != kTRUE){
93  if (fVerbose > 1)
94  std::cout << std::endl << "Reader: " << i << " running " << std::endl;
95  std::vector<std::vector<PndSdsDigiTopix4> > data;
96  fEndOfFile[i] = fReader[i]->ReadInData(data);
98  }
99  }
100  Bool_t endOfFiles = kTRUE;
101  for (int j = 0; j < fEndOfFile.size(); j++){
102  endOfFiles &= fEndOfFile[j];
103  }
104  if (endOfFiles == kTRUE){
105  std::cout << "Number of: " << std::endl;
106  for(int i = 0; i < fReader.size(); i++){
107  UInt_t nonSequential = fReader[i]->GetNonSequenctialFC();
108  std::cout << i << " : non sequential header " << nonSequential
109  << " double header: " << fReader[i]->GetDoubleHeader()
110  << " double trailer: " << fReader[i]->GetDoubleTrailer() << std::endl;
111  std::cout << i << " SuperFrameCount: " << fReader[i]->GetSuperFrameCount() << std::endl;
112 
113  std::cout << i << " Total Header Count : " << fReader[i]->GetTotalHeaderCount() << std::endl;
114  std::cout << i << " Total Trailer Count : " << fReader[i]->GetTotalTrailerCount() << std::endl;
115 
116  std::cout << i << " Total (build) Frames : " << fReader[i]->GetTotalFrameCount() << std::endl;
117  std::cout << i << " Hamming Loss Frame Count: " << fReader[i]->GetHammingLossFrameCount() << std::endl;
118  std::cout << i << " CRC Loss Frame Count: " << fReader[i]->GetCRCLossFrameCount() << std::endl;
119  std::cout << i << " Correct Frame Count: " << fReader[i]->GetCorrectFrameCount() << std::endl;
120 
121  std::cout << i << " Total Hits : " << fReader[i]->GetTotalHitCount() << std::endl;
122  std::cout << i << " Pre Frame Loss Hit Count : " << fReader[i]->GetPreFrameLossHitCount() << std::endl;
123  std::cout << i << " Hamming Loss Hit Count : " << fReader[i]->GetHammingLossHitCount() << std::endl;
124  std::cout << i << " CRC Loss Hit Count : " << fReader[i]->GetCRCLossHitCount() << std::endl;
125  std::cout << i << " Correct Hit Count : " << fReader[i]->GetCorrectHitCount() << std::endl;
126 
127  }
128  FairRootManager::Instance()->SetFinishRun(kTRUE);
129  }
130 
131 }
132 
134 {
135  fDigiArray->Delete();
136  fFrameHeaderArray->Delete();
137 // fAllFrameHeaderArray->Delete();
138 }
139 
141 {
142  for(int i=0; i< numberfrontends; i++)
143  {
144  std::vector<std::string> vector;
145  fFileNames.push_back(vector);
146  }
147 }
148 
150 {
151  new ((*fDigiArray)[fDigiArray->GetEntriesFast()]) PndSdsDigiTopix4(data);
152 }
153 
154 void PndMvdReadInTBDataTask::WriteoutToPix4Frames(std::vector<std::vector<PndSdsDigiTopix4> > &frames)
155 {
156  for (auto it1 : frames){
157  for(auto it2 : it1) {
158  WriteoutToPix4Digi(it2);
159  }
160  }
161 }
162 
int fVerbose
Definition: poormantracks.C:24
std::vector< Bool_t > fEndOfFile
Int_t i
Definition: run_full.C:25
Data class to store the digi output of a pixel module.
void SetNumberOfFrontEnds(Int_t numberfe)
virtual void Exec(Option_t *opt)
void WriteoutToPix4Frames(std::vector< std::vector< PndSdsDigiTopix4 > > &frames)
std::vector< PndMvdReadInToPix4TBData * > fReader
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
void WriteoutToPix4Digi(PndSdsDigiTopix4 &data)
std::vector< std::vector< std::string > > fFileNames
ClassImp(PndAnaContFact)