FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndEventBuilderManager Class Reference

#include <PndEventBuilderManager.h>

Inheritance diagram for PndEventBuilderManager:

Public Member Functions

 PndEventBuilderManager ()
 
 PndEventBuilderManager (const char *name, Int_t iVerbose=1)
 
virtual ~PndEventBuilderManager ()
 

Private Member Functions

virtual void SetParContainers ()
 
virtual InitStatus Init ()
 
virtual InitStatus ReInit ()
 
virtual void AnalyzeAndExtractEvents (Double_t maxEventTimeAllowed)
 
 ClassDef (PndEventBuilderManager, 1)
 

Private Attributes

FairRecoEventHeader * fOutEvent
 

Detailed Description

Definition at line 39 of file PndEventBuilderManager.h.

Constructor & Destructor Documentation

PndEventBuilderManager::PndEventBuilderManager ( )

Default constructor

Definition at line 54 of file PndEventBuilderManager.cxx.

55  : FairEventBuilderManager(),
56  fOutEvent (NULL)
57 {
58 }
FairRecoEventHeader * fOutEvent
PndEventBuilderManager::PndEventBuilderManager ( const char *  name,
Int_t  iVerbose = 1 
)

Constructor with task name

Definition at line 62 of file PndEventBuilderManager.cxx.

63  : FairEventBuilderManager(name, iVerbose),
64  fOutEvent (NULL)
65 {
66 }
FairRecoEventHeader * fOutEvent
TString name
Int_t iVerbose
PndEventBuilderManager::~PndEventBuilderManager ( )
virtual

Destructor

Definition at line 72 of file PndEventBuilderManager.cxx.

72  {
73 }

Member Function Documentation

void PndEventBuilderManager::AnalyzeAndExtractEvents ( Double_t  maxEventTimeAllowed)
privatevirtual

Definition at line 77 of file PndEventBuilderManager.cxx.

References CAMath::Abs(), Double_t, fOutEvent, fVerbose, and CAMath::Sqrt().

77  {
78  if ( fVerbose )
79  cout << "PndEventBuilderManager::AnalyzeAndExtractEvents(" << maxEventTimeAllowed << ")" << endl;
80 
81  Double_t minEventTime = 10.e6;
82  Double_t minEventTErr = 0.;
83  FairRecoEventHeader* tempREH = NULL;
84  while ( 1==1 ) {
85  minEventTime = 10.e6;
86  // find smallest event time
87  for ( Int_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
88  for ( Int_t iev = 0 ; iev < fPossibleEvents[ieb].size() ; iev++ ) {
89  tempREH = (FairRecoEventHeader*)fPossibleEvents[ieb][iev].second;
90  if ( fVerbose )
91  cout << " fPossibleEvents[" << fEventBuilders[ieb]->GetName()
92  << "][" << iev << "] . " << fPossibleEvents[ieb][iev].first << endl;
93  if ( fPossibleEvents[ieb][iev].second->GetEventTime() < minEventTime ) {// i think it is enough to take .first instead of .second->GetEventTime()
94  minEventTime = fPossibleEvents[ieb][iev].second->GetEventTime();
95  minEventTErr = fPossibleEvents[ieb][iev].second->GetEventTimeError();
96  }
97  }
98  }
99  if ( fVerbose )
100  cout << " minEventTime is now " << minEventTime << " with error " << minEventTErr << endl;
101 
102  // check if can be saved
103  if ( maxEventTimeAllowed > -0.5 && minEventTime > maxEventTimeAllowed-5 ) {
104  // cout << "sorry, larger than " << maxEventTimeAllowed-5 << endl;
105  break;
106  }
107  if ( minEventTime > 9.9e6 ) break;
108  // calculate mean event time and remove close events from the event times' TCAs
109  // in fact it should be a mean event with all event characteristics
110  Double_t meanEventTime = 0.;
111  Double_t nofOfEvents = 0.;
112  Double_t sumTW = 0.;
113  Double_t sumW = 0.;
114  Int_t ident = 0;
115  for ( Int_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
116  for ( Int_t iev = 0 ; iev < fPossibleEvents[ieb].size() ; iev++ ) {
117  tempREH = (FairRecoEventHeader*)fPossibleEvents[ieb][iev].second;
118  if ( TMath::Abs(tempREH->GetEventTime()-minEventTime) < minEventTErr+tempREH->GetEventTimeError() ) {
119  if ( tempREH->GetEventTimeError() < 1.e-6 ) {
120  cout << "ERROR ALMOST 0!!!! " << tempREH->GetEventTimeError() << endl;
121  continue;
122  }
123  // meanEventTime += tempREH->GetEventTime();
124  sumTW += tempREH->GetEventTime()/tempREH->GetEventTimeError()/tempREH->GetEventTimeError();
125  sumW += 1./tempREH->GetEventTimeError()/tempREH->GetEventTimeError();
126  ident |= tempREH->GetIdentifier();
127  minEventTime = sumTW/sumW;
128  minEventTErr = TMath::Sqrt(1./sumW);
129  if ( fVerbose )
130  cout << " added event at " << tempREH->GetEventTime() << " +- " << tempREH->GetEventTimeError() << endl;
131  nofOfEvents += 1.;
132  fPossibleEvents[ieb][iev] = fPossibleEvents[ieb][fPossibleEvents[ieb].size()-1];
133  fPossibleEvents[ieb].pop_back();
134  }
135  }
136  }
137  if ( nofOfEvents == 0 ) continue;
138 
139  if ( fVerbose ) {
140  cout << " CREATED EVENT AT " << meanEventTime/nofOfEvents << " OUT OF " << nofOfEvents << " EVENTS" << endl;
141  cout << " WEIGHTED MEAN AT " << sumTW/sumW << " WITH ERROR OF " << TMath::Sqrt(1./sumW) << endl;
142  }
143 
144  fOutEvent->SetEventTime(sumTW/sumW,TMath::Sqrt(1./sumW));//meanEventTime/nofOfEvents,2.);
145  fOutEvent->SetIdentifier(ident);
146 
147  CreateAndFillEvent(fOutEvent);
148  }
149 }
int fVerbose
Definition: poormantracks.C:24
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
static T Abs(const T &x)
Definition: PndCAMath.h:39
FairRecoEventHeader * fOutEvent
Double_t
PndEventBuilderManager::ClassDef ( PndEventBuilderManager  ,
 
)
private
InitStatus PndEventBuilderManager::Init ( )
privatevirtual

Intialisation

Definition at line 166 of file PndEventBuilderManager.cxx.

References fOutEvent.

Referenced by TB_gem_eventBuild().

166  {
167  // Get input array
168  FairRootManager* ioman = FairRootManager::Instance();
169  if ( ! ioman ) Fatal("Init", "No FairRootManager");
170 
171  cout << "*** PndEventBuilderManager. " << fEventBuilders.size() << " event builders registered." << endl;
172 
173  fOutEvent = new FairRecoEventHeader();
174  FairRootManager::Instance()->Register("RecoEventHeader.", "RecoEvent", fOutEvent, kTRUE);
175 
176  for ( Int_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
177  fEventBuilders[ieb]->SetIdentifier(TMath::Power(2,ieb));
178  fEventBuilders[ieb]->Init();
179  }
180 
181  return kSUCCESS;
182 }
FairRecoEventHeader * fOutEvent
InitStatus PndEventBuilderManager::ReInit ( )
privatevirtual

Reinitialisation

Definition at line 186 of file PndEventBuilderManager.cxx.

186  {
187 
188  return kSUCCESS;
189 }
void PndEventBuilderManager::SetParContainers ( )
privatevirtual

Get parameter containers

Definition at line 154 of file PndEventBuilderManager.cxx.

References run.

154  {
155 
156  // Get run and runtime database
157  FairRunAna* run = FairRunAna::Instance();
158  if ( ! run ) Fatal("SetParContainers", "No analysis run");
159 
160  FairRuntimeDb* db = run->GetRuntimeDb();
161  if ( ! db ) Fatal("SetParContainers", "No runtime database");
162 }
Int_t run
Definition: autocutx.C:47

Member Data Documentation

FairRecoEventHeader* PndEventBuilderManager::fOutEvent
private

Definition at line 58 of file PndEventBuilderManager.h.

Referenced by AnalyzeAndExtractEvents(), and Init().


The documentation for this class was generated from the following files: