source: trunk/MagicSoft/Mars/mtemp/mifae/library/MDispCalc.cc@ 4408

Last change on this file since 4408 was 4316, checked in by domingo, 20 years ago
*** empty log message ***
File size: 3.2 KB
Line 
1#include "MDispCalc.h"
2
3#include "MParList.h"
4
5#include "MDisp.h"
6#include "MHillas.h"
7#include "MHillasSrc.h"
8
9#include "MLog.h"
10#include "MLogManip.h"
11
12ClassImp(MDispCalc);
13
14using namespace std;
15
16static const TString gsDefName = "MDispCalc";
17static const TString gsDefTitle = "Calculate Disp related parameters";
18
19// -------------------------------------------------------------------------
20//
21// Default constructor.
22//
23MDispCalc::MDispCalc(const char *name, const char *title)
24 : fHillas(NULL), fHillasSrc(NULL), fSrcPos(NULL), fDisp(NULL)
25{
26 fName = name ? name : gsDefName.Data();
27 fTitle = title ? title : gsDefTitle.Data();
28
29}
30
31// -------------------------------------------------------------------------
32//
33Int_t MDispCalc::PreProcess(MParList *pList)
34{
35
36 fHillas = (MHillas*)pList->FindObject("MHillas");
37 if (!fHillas)
38 {
39 *fLog << err << dbginf << "MHillas not found... aborting." << endl;
40 return kFALSE;
41 }
42
43 fHillasSrc = (MHillasSrc*)pList->FindObject("MHillasSrc");
44 if (!fHillasSrc)
45 {
46 *fLog << err << dbginf << "MHillasSrc not found... aborting." << endl;
47 return kFALSE;
48 }
49
50 fSrcPos = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
51 if (!fSrcPos)
52 {
53 *fLog << err << dbginf << "SrcPosCam not found... aborting." << endl;
54 return kFALSE;
55 }
56
57 fDisp = (MDisp*)pList->FindCreateObj("MDisp");
58 if (!fDisp)
59 return kFALSE;
60
61 return kTRUE;
62}
63
64// -------------------------------------------------------------------------
65//
66Int_t MDispCalc::Process()
67{
68
69 fDisp->SetPsi(fPsi);
70
71 if ( fHillas->GetWidth()==-1 || fHillas->GetLength()==-1 )
72 {
73 fErrors++;
74 return kTRUE;
75 }
76
77 Float_t xshift = 0.;
78 Float_t yshift = 0.;
79
80 if ( fSrcPos )
81 {
82 xshift = fSrcPos->GetX();
83 yshift = fSrcPos->GetY();
84 }
85
86 fDisp->SetDisp(fPsi*(1-(fHillas->GetWidth()/fHillas->GetLength())));
87 fDisp->SetPosDisp("X1", fHillas->GetMeanX() - (fDisp->GetDisp()*fHillas->GetCosDelta()) - xshift);
88 fDisp->SetPosDisp("Y1", fHillas->GetMeanY() - (fDisp->GetDisp()*fHillas->GetSinDelta()) - yshift);
89 fDisp->SetPosDisp("X2", fHillas->GetMeanX() + (fDisp->GetDisp()*fHillas->GetCosDelta()) - xshift);
90 fDisp->SetPosDisp("Y2", fHillas->GetMeanY() + (fDisp->GetDisp()*fHillas->GetSinDelta()) - yshift);
91
92 if ( (1-fHillas->GetWidth()/fHillas->GetLength()) == 0. )
93 {
94 fErrors++;
95 return kTRUE;
96 }
97
98 fDisp->SetPsiEvent(fHillasSrc->GetDist()/(1-fHillas->GetWidth()/fHillas->GetLength()));
99
100 fDisp->SetReadyToSave();
101
102 return kTRUE;
103}
104
105// --------------------------------------------------------------------------
106//
107// Prints some statistics about the disp calculation. The percentage
108// is calculated with respect to the number of executions of this task.
109//
110Int_t MDispCalc::PostProcess()
111{
112 if (GetNumExecutions()==0)
113 return kTRUE;
114
115 *fLog << inf << endl;
116 *fLog << GetDescriptor() << " execution statistics:" << endl;
117 *fLog << dec << setfill(' ');
118 *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: (1-w/l)==0 or (Width or Length == -1)" << endl;
119 *fLog << endl;
120
121 /*
122 delete fHillas;
123 delete fHillasSrc;
124 delete fSrcPos;
125 delete fDisp;
126 */
127
128 return kTRUE;
129}
Note: See TracBrowser for help on using the repository browser.