source: trunk/MagicSoft/MarsOctober/mbase/MParRead.cc@ 8709

Last change on this file since 8709 was 447, checked in by harald, 24 years ago
Bringing the sources for the octobertest under CVS controll. (november, 3rd, 2000)
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1////////////////////////////////////////////////////////////////////////
2//
3// MParRead
4//
5// This is the task to read in the cosmic raw data from one file.
6// Cosmics are stored in the root file under the Tree "EvtTree".
7// This task reads them in to the needed MRawEvtBuf in the Parameter
8// list.
9//
10////////////////////////////////////////////////////////////////////////
11
12#include "MParRead.h"
13
14#include <iostream.h>
15
16#include "MParList.h"
17#include "MObjBuffer.h"
18#include "MInputStreamID.h"
19
20ClassImp(MParRead)
21
22MParRead::MParRead()
23{
24}
25
26Bool_t MParRead::PreProcess (MParList *pList)
27{
28 //
29 // remember the pointer to the parameter list fur further usage
30 //
31 pParList = pList;
32
33 //
34 // check if MEvtHeader exists in the Parameter list already.
35 // if not create one and add them to the list
36 //
37 fID = (MInputStreamID*)pList->FindObject("MInputStreamID");
38 if (!fID)
39 {
40 cout << "MReadEvt::PreProcess - WARNING: MEvtHeader not found... creating." << endl;
41 fID = new MInputStreamID;
42 pList->AddToList(fID);
43 }
44
45 return kTRUE;
46}
47
48Bool_t MParRead::Process()
49{
50 //
51 // Read in the next event
52 //
53
54 //
55 // Make sure that all buffers are filled
56 //
57 MParContainer *pCont;
58
59 //
60 // start with the first entry in the parlist
61 //
62 pParList->Reset();
63 // loop over all entries
64 while ((pCont=pParList->Next()))
65 {
66 // if the entry is a buffer and not only a container
67 // we can ask the container whether it is a input
68 // container or not
69 if (!pCont->IsBuffer())
70 continue;
71
72 MObjBuffer *pBuf = (MObjBuffer*)pCont;
73
74 // if it is an input container we tell the container
75 // that it should be filled if it is not filled already
76 if (pBuf->IsInput())
77 pBuf->Fill();
78 }
79
80 //
81 // look which is the next tree which we have to read
82 //
83 MObjBuffer *evt;
84 Int_t up = 0;
85
86 // start from scratch
87 pParList->Reset();
88 // loop over all emtries
89 while ((pCont=pParList->Next()))
90 {
91 // ask whether it is a buffer or not
92 if (!pCont->IsBuffer())
93 continue;
94
95 MObjBuffer *pBuf = (MObjBuffer*)pCont;
96
97 // ask whether the buffer is set as an input buffer or not
98 if (!pBuf->IsInput())
99 continue;
100
101 // time of event which was processed last time
102 Int_t t1=fTime.GetTime();
103
104 // time of next event in this buffer
105 Int_t t2=pBuf->GetEntry(1)->GetTime();
106
107 // compare the time of the actual event with the next
108 // event in this buffer
109 if (t2<=t1)
110 continue;
111
112 // if no event is scheduled as event to read next
113 // set this container as next
114 if (!up)
115 {
116 up = t2;
117 evt = pBuf;
118 }
119
120 // if this container has a smaller time, than
121 // the 'actual' next event set this container
122 // as next input
123 if (t2<up)
124 {
125 up = t2;
126 evt = pBuf;
127 }
128 }
129
130 //
131 // now we have the time of the next event we want to read
132 // and a pointer to this event in 'up' and 'evt'
133 //
134
135 //
136 // set 'system-time' to time of this event
137 //
138 fTime.SetTime(up);
139
140 //
141 // set event-type to type of this event
142 //
143 fID->SetEvtType(evt->GetName());
144
145 //
146 // Get next event from the determined tree
147 //
148 evt->GetNextEvent(0);
149
150 return kTRUE;
151
152/*
153 return nr != fPtrTree->GetEntries();
154*/
155}
156
Note: See TracBrowser for help on using the repository browser.