FairRoot/PandaRoot
PndEventBuilderOnMCEvents.cxx
Go to the documentation of this file.
1 /* $Id: */
2 
3 // -------------------------------------------------------------------------
4 // ----- PndEventBuilderOnMCEvents source file -----
5 // ----- Created 22/08/2013 by R. Karabowicz -----
6 // -------------------------------------------------------------------------
7 
19 
20 #include "FairEventHeader.h"
21 
22 #include "PndDetectorList.h"
23 #include "FairRecoEventHeader.h"
24 
25 #include "FairRootManager.h"
26 #include "FairRunAna.h"
27 #include "FairRuntimeDb.h"
28 
29 #include "TClonesArray.h"
30 #include "TMath.h"
31 #include "TRandom2.h"
32 
33 #include <iomanip>
34 
35 using std::cout;
36 using std::cerr;
37 using std::endl;
38 using std::flush;
39 using std::fixed;
40 using std::right;
41 using std::left;
42 using std::setw;
43 using std::setprecision;
44 using std::set;
45 using std::map;
46 
47 using std::sort;
48 
49 // ----- Default constructor ------------------------------------------
51  : FairEventBuilder(),
52  fTNofEvents (0),
53  fTNofRecoEvents(0),
54  fExecTime (0.)
55 {
56 }
57 // -------------------------------------------------------------------------
58 
59 
60 
61 // ----- Constructor with name -----------------------------------------
63  : FairEventBuilder(),
64  fTNofEvents (0),
65  fTNofRecoEvents(0),
66  fExecTime (0.)
67 {
68  SetBuilderName(name);
70 }
71 // -------------------------------------------------------------------------
72 
73 
74 
75 // ----- Destructor ----------------------------------------------------
77 }
78 // -------------------------------------------------------------------------
79 
80 
81 
82 // ----- Public method Exec --------------------------------------------
83 std::vector<std::pair<double, FairRecoEventHeader*> > PndEventBuilderOnMCEvents::FindEvents() {
84  if ( fVerbose )
85  cout << endl << "======== PndEventBuilderOnMCEvents::FindEvents(Event = " << fTNofEvents << " ) ====================" << endl;
86 
87  fTimer.Start();
88 
89  fTNofEvents += 1;
90 
91  fTNofRecoEvents += 1;
92 
93  std::vector<std::pair<double, FairRecoEventHeader*> > result;
94  std::pair<double,FairRecoEventHeader*> singleResult;
95 
96  FairRecoEventHeader* recoEvent = new FairRecoEventHeader();
97  recoEvent->SetEventTime(fEventHeader->GetEventTime(),0.001);
98  recoEvent->SetIdentifier(GetIdentifier());
99  SetMaxAllowedTime(fEventHeader->GetEventTime());
100 
101  singleResult.first = recoEvent->GetEventTime();
102  singleResult.second = recoEvent;
103 
104  result.push_back(singleResult);
105 
106  fExecTime += fTimer.RealTime();
107  fTimer.Stop();
108 
109  return result;
110 }
111 // -------------------------------------------------------------------------
112 
113 // -------------------------------------------------------------------------
115 }
116 // -------------------------------------------------------------------------
117 
118 // -------------------------------------------------------------------------
119 void PndEventBuilderOnMCEvents::StoreEventData(FairRecoEventHeader* recoEvent) {
120 }
121 
122 std::vector<std::pair<double, FairRecoEventHeader*> > PndEventBuilderOnMCEvents::Modify(std::pair<double, FairRecoEventHeader*> oldData, std::pair<double, FairRecoEventHeader*> newData)
123 {
124  std::vector<std::pair<double, FairRecoEventHeader*> > result;
125  result.push_back(newData);
126  return result;
127 }
128 
130 {
131  // FairRootManager* ioman = FairRootManager::Instance();
132  // TClonesArray* myArray = ioman->GetTClonesArray(fBranchName);
133  // if (fVerbose > 1) std::cout << "Data Inserted: " << *(FairRecoEventHeader*)(data) << std::endl;
134  // new ((*myArray)[myArray->GetEntries()]) FairRecoEventHeader(*(FairRecoEventHeader*)(data));
135 }
136 
137 double PndEventBuilderOnMCEvents::FindTimeForData(FairTimeStamp* data)
138 {
139  // std::map<FairRecoEventHeader, double>::iterator it;
140  // FairRecoEventHeader myData = *(FairRecoEventHeader*)data;
141  // it = fData_map.find(myData);
142  // if (it == fData_map.end())
143  // return -1;
144  // else
145  // return it->second;
146 }
147 void PndEventBuilderOnMCEvents::FillDataMap(FairTimeStamp* data, double activeTime)
148 {
149  // FairRecoEventHeader myData = *(FairRecoEventHeader*)data;
150  // fData_map[myData] = activeTime;
151 }
152 
154 {
155  // FairRecoEventHeader myData = *(FairRecoEventHeader*)data;
156  // if (fData_map.find(myData) != fData_map.end())
157  // fData_map.erase(fData_map.find(myData));
158 }
159 
160 // ----- Private method SetParContainers -------------------------------
162 
163  // Get run and runtime database
164  FairRunAna* run = FairRunAna::Instance();
165  if ( ! run ) Fatal("SetParContainers", "No analysis run");
166 
167  FairRuntimeDb* db = run->GetRuntimeDb();
168  if ( ! db ) Fatal("SetParContainers", "No runtime database");
169 }
170 // -------------------------------------------------------------------------
171 
172 // ----- Private method Init -------------------------------------------
174 
175  // Get input array
176  FairRootManager* ioman = FairRootManager::Instance();
177  if ( ! ioman ) Fatal("Init", "No FairRootManager");
178 
179  fEventHeader = (FairEventHeader*) ioman->GetObject("EventHeader.");
180 
181  return kTRUE;
182 }
183 // -------------------------------------------------------------------------
184 
185 
186 
187 
188 // ----- Private method ReInit -----------------------------------------
190 
191  // Create sectorwise digi sets
192  // MakeSets();
193 
194  return kTRUE;
195 }
196 // -------------------------------------------------------------------------
197 
198 
199 
200 // ----- Public method Finish ------------------------------------------
202 
203  cout << "-------------------- " << GetBuilderName() << " : Summary -----------------------" << endl;
204  cout << " Events: " << setw(10) << fTNofEvents << endl;
205  cout << " Reco Events: " << setw(10) << fTNofRecoEvents << endl;
206  cout << " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " << endl;
207  cout << " >>> EB >>> all time = " << fExecTime << "s" << endl;
208  cout << "---------------------------------------------------------------------" << endl;
209 }
210 // -------------------------------------------------------------------------
211 
212 
214 
int fVerbose
Definition: poormantracks.C:24
Int_t run
Definition: autocutx.C:47
virtual void StoreEventData(FairRecoEventHeader *recoEvent)
void EraseDataFromDataMap(FairTimeStamp *data)
std::vector< std::pair< double, FairRecoEventHeader * > > FindEvents()
PndTransMap * map
Definition: sim_emc_apd.C:99
void AddNewDataToTClonesArray(FairTimeStamp *data)
void FillDataMap(FairTimeStamp *data, double activeTime)
TString name
double FindTimeForData(FairTimeStamp *data)
ClassImp(PndAnaContFact)
Int_t iVerbose
std::vector< std::pair< double, FairRecoEventHeader * > > Modify(std::pair< double, FairRecoEventHeader * > oldData, std::pair< double, FairRecoEventHeader * > newData)