source: trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc@ 2872

Last change on this file since 2872 was 2785, checked in by raducci, 21 years ago
*** empty log message ***
File size: 4.4 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
19!
20! Copyright: MAGIC Software Development, 2002-2003
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MArrivalTimeCalc
28//
29// This is a task that calculates the arrival times of photons.
30// It returns the absolute maximum of the spline that interpolates
31// the FADC slices
32//
33// Input Containers:
34// MRawEvtData
35//
36// Output Containers:
37// MArrivalTime
38// MRawEvtData
39//////////////////////////////////////////////////////////////////////////////
40
41#include "MArrivalTime.h"
42#include "MArrivalTimeCalc.h"
43
44#include "MParList.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49#include "MGeomCam.h"
50#include "MMcRunHeader.hxx"
51
52#include "MRawRunHeader.h"
53#include "MRawEvtData.h" // MRawEvtData::GetNumPixels
54#include "MCameraData.h"
55#include "MRawEvtPixelIter.h"
56
57ClassImp(MArrivalTimeCalc);
58
59using namespace std;
60
61// --------------------------------------------------------------------------
62//
63// Default constructor.
64//
65
66MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
67{
68 fName = name ? name : "MArrivalTimeCalc";
69 fTitle = title ? title : "Calculate photons arrival time";
70
71// AddToBranchList("MRawEvtData.fHiGainPixId");
72// AddToBranchList("MRawEvtData.fLoGainPixId");
73// AddToBranchList("MRawEvtData.fHiGainFadcSamples");
74// AddToBranchList("MRawEvtData.fLoGainFadcSamples");
75
76}
77
78// --------------------------------------------------------------------------
79//
80// The PreProcess searches for the following input containers:
81// - MRawRunHeader
82// - MRawEvtData
83// - MArrivalTime
84// - MGeomCam
85//
86// The following output containers are also searched and created if
87// they were not found:
88// - MArrivalTime
89// - MRawEvtData
90//
91
92Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
93{
94 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
95 if (!fRunHeader)
96 {
97 *fLog << err << "MRawRunHeader not found... aborting." << endl;
98 return kFALSE;
99 }
100
101 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
102 if (!fRawEvt)
103 {
104 *fLog << err << "MRawEvtData not found... aborting." << endl;
105 return kFALSE;
106 }
107
108 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
109 if (!fGeom)
110 {
111 *fLog << err << "MGeomCam not found... aborting." << endl;
112 return kFALSE;
113 }
114
115 fArrTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
116 if (!fArrTime)
117 return kFALSE;
118
119 return kTRUE;
120}
121
122
123// --------------------------------------------------------------------------
124// Evaluation of the mean arrival times (spline interpolation)
125// per pixel and store them in the MArrivalTime container.
126//
127Int_t MArrivalTimeCalc::Process()
128{
129 MRawEvtPixelIter pixel(fRawEvt);
130
131// Every pixel is set to -1
132 fArrTime->CleanArray((const MGeomCam&) *fGeom);
133
134 while (pixel.Next())
135 {
136 const UInt_t idx = pixel.GetPixelId();
137// If pixel is saturated we use LoGains
138 if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
139 {
140 const Byte_t *ptr = pixel.GetLoGainSamples();
141 const Short_t nSlice = fRawEvt->GetNumLoGainSamples();
142 fArrTime->Calc(ptr, nSlice, idx, (const MGeomCam&) *fGeom);
143 }
144// Use HiGains
145 else
146 {
147 const Byte_t *ptr = pixel.GetHiGainSamples();
148 const Short_t nSlice = fRawEvt->GetNumHiGainSamples();
149 fArrTime->Calc(ptr, nSlice, idx, (const MGeomCam&) *fGeom);
150 }
151// If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
152 }
153
154 fArrTime->SetReadyToSave();
155
156 return kTRUE;
157}
Note: See TracBrowser for help on using the repository browser.