source: trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc@ 1211

Last change on this file since 1211 was 1211, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 2.7 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): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19! Author(s): Harald Kornmayer 1/2001
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26#include "MMcTimeGenerate.h"
27
28#include "MLog.h"
29#include "MLogManip.h"
30
31#include "MParList.h"
32#include "MTime.h"
33
34ClassImp(MMcTimeGenerate);
35
36// --------------------------------------------------------------------------
37//
38MMcTimeGenerate::MMcTimeGenerate(const char *name, const char *title)
39{
40 fName = name ? name : "MMcTimeGenerate";
41 fTitle = title ? title : "Task to generate a random event time";
42
43 const Double_t lambda = 100; // [Hz]
44
45 fFunc = new TF1("Poisson", "[0] * exp(-[0]*x)", 0, 1);
46 fFunc->SetParameter(0, lambda);
47
48 fDeadTime = 0.1/lambda;
49}
50
51MMcTimeGenerate::~MMcTimeGenerate()
52{
53 delete fFunc;
54}
55
56
57// --------------------------------------------------------------------------
58//
59// The PreProcess connects the raw data with this task. It checks if the
60// input containers exist, if not a kFalse flag is returned. It also checks
61// if the output contaniers exist, if not they are created.
62// This task can read either Montecarlo files with multiple trigger
63// options, either Montecarlo files with a single trigger option.
64//
65Bool_t MMcTimeGenerate::PreProcess (MParList *pList)
66{
67 // connect the raw data with this task
68
69 fTime = (MTime*)pList->FindCreateObj("MTime");
70 if (!fTime)
71 return kFALSE;
72
73 return kTRUE;
74}
75
76// --------------------------------------------------------------------------
77//
78// The Process-function counts the number of simulated showers, the
79// number of analised showers and the number of triggers. It also updates
80// the limits for theta, phi, energy and impact parameter in the
81// MHMcRate container.
82//
83Bool_t MMcTimeGenerate::Process()
84{
85 Double_t dt;
86
87 do dt = fFunc->GetRandom();
88 while (dt < fDeadTime);
89
90 const Int_t t = fTime->GetTimeLo();
91
92 fTime->SetTime(t+dt*10000, 0); // [ms]
93
94 return kTRUE;
95}
Note: See TracBrowser for help on using the repository browser.