/[PAMELA software]/yoda/techmodel/PhysicsReader.cpp
ViewVC logotype

Annotation of /yoda/techmodel/PhysicsReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.1 - (hide annotations) (download)
Wed Aug 16 13:15:23 2006 UTC (18 years, 3 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA6_3/06
Changes since 6.0: +47 -2 lines
*** empty log message ***

1 kusanagi 1.9 /** @file
2 kusanagi 1.2 * $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $
3 kusanagi 6.1 * $Id: PhysicsReader.cpp,v 6.0 2006/02/07 17:11:10 kusanagi Exp $
4 kusanagi 6.0 * $Author: kusanagi $
5 kusanagi 1.1 *
6     * Implementation of the LogReader class.
7     * ToBeDone:
8     * Control the CRC for the entire data Packet not just for single records
9     */
10    
11     #define UINT unsigned int
12     #define BYTE unsigned char
13     #include <string>
14 kusanagi 1.9 #include <log4cxx/logger.h>
15 kusanagi 1.1 extern "C" {
16     #include <sys/time.h>
17     #include "CRC.h"
18     }
19    
20     #include <fstream>
21     #include "stdio.h"
22 kusanagi 6.1 #include <sys/wait.h>
23 kusanagi 1.1 #include "ReaderAlgorithms.h"
24    
25    
26     using namespace pamela;
27     using namespace pamela::techmodel;
28     using namespace pamela::tracker;
29 kusanagi 1.3 using namespace pamela::anticounter;
30     using namespace pamela::calorimeter;
31 kusanagi 1.4 using namespace pamela::neutron;
32 kusanagi 2.2 using namespace pamela::S4;
33 kusanagi 2.4 using namespace pamela::tof;
34     using namespace pamela::trigger;
35 kusanagi 1.1
36 kusanagi 1.9 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.PhysicsReader"));
37 kusanagi 1.1
38     /**
39     * Constructor.
40     */
41     PhysicsReader::PhysicsReader(void):
42 kusanagi 2.4 TechmodelAlgorithm(PacketType::Physics, "TechmodelPhysicsReader") {
43     logger->debug(_T("Constructor"));
44     trackerReader = new TrackerReader;
45     anticounterReader = new AnticounterReader;
46     calorimeterReader = new CalorimeterReader;
47     neutronReader = new NeutronDetectorReader;
48     s4Reader = new S4Reader;
49     tofReader = new TofReader;
50     triggerReader = new TriggerReader;
51 kusanagi 1.1 }
52    
53     /**
54     * Get a string with the version info of the algorithm.
55     */
56     std::string PhysicsReader::GetVersionInfo(void) const {
57     return
58 kusanagi 6.1 "$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v 6.0 2006/02/07 17:11:10 kusanagi Exp $\n";
59 kusanagi 1.1 }
60    
61     /**
62     * Initialize the algorithm with a special run. This will initialize the
63     * event reader routines for all packet types.
64     */
65     void PhysicsReader::Init(PamelaRun *run) {
66 kusanagi 2.4 SetInputStream(run);
67     trackerReader->Init(run);
68     anticounterReader->Init(run);
69     calorimeterReader->Init(run);
70     neutronReader->Init(run);
71     s4Reader->Init(run);
72     tofReader->Init(run);
73     triggerReader->Init(run);
74 kusanagi 1.1 //run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class());
75 kusanagi 1.9 logger->debug(_T("Initialize"));
76 kusanagi 1.1 }
77    
78     /**
79     * Unpack the Physics event from an input file.
80     */
81 kusanagi 2.1 void PhysicsReader::RunEvent(int EventNumber, long int dataLenght) throw (Exception){
82 kusanagi 1.4 char *subData = new char[dataLenght];
83     InputFile->read(subData, sizeof(unsigned char)*dataLenght);
84 kusanagi 1.1
85 kusanagi 2.4 /*-----------------*/
86 kusanagi 6.1 /*
87 kusanagi 2.4 //passo packetData a tutti i reader dei vari rivelatori
88 kusanagi 6.1 int childtrk, childac, childcalo, childnd, childs4, childtof, childtrig, Status;
89     int retctrk, retcac, retccalo, retcnd, retcs4, retctof, retctrig;
90    
91     if ((childtrk = fork()) > 0) {
92     trackerReader->RunEvent(EventNumber, subData, dataLenght);
93     }
94     if ((childac = fork()) > 0) {
95     anticounterReader->RunEvent(EventNumber, subData, dataLenght);
96     }
97     if ((childcalo = fork()) > 0) {
98     calorimeterReader->RunEvent(EventNumber, subData, dataLenght);
99     }
100     if ((childnd = fork()) > 0) {
101     neutronReader->RunEvent(EventNumber, subData, dataLenght);
102     }
103     if ((childs4 = fork()) > 0) {
104     s4Reader->RunEvent(EventNumber, subData, dataLenght);
105     }
106     if ((childtof = fork()) > 0) {
107     tofReader->RunEvent(EventNumber, subData, dataLenght);
108     }
109     if ((childtrig = fork()) > 0) {
110     triggerReader->RunEvent(EventNumber, subData, dataLenght);
111     }
112    
113     do {
114     retctrk = waitpid(childtrk, &Status, 0);
115     retcac = waitpid(childac, &Status, 0);
116     retccalo = waitpid(childcalo, &Status, 0);
117     retcnd = waitpid(childnd, &Status, 0);
118     retcs4 = waitpid(childs4, &Status, 0);
119     retctof = waitpid(childtof, &Status, 0);
120     retctrig = waitpid(childtrig, &Status, 0);
121     } while( (retctrk > 0 || (retctrk == -1)) &&
122     (retcac > 0 || (retcac == -1)) &&
123     (retccalo > 0 || (retccalo == -1)) &&
124     (retcnd > 0 || (retcnd == -1)) &&
125     (retcs4 > 0 || (retcs4 == -1)) &&
126     (retctof > 0 || (retctof == -1)) &&
127     (retctrig > 0 || (retctrig == -1)) );
128     */
129    
130 kusanagi 2.4 trackerReader->RunEvent(EventNumber, subData, dataLenght);
131     anticounterReader->RunEvent(EventNumber, subData, dataLenght);
132     calorimeterReader->RunEvent(EventNumber, subData, dataLenght);
133     neutronReader->RunEvent(EventNumber, subData, dataLenght);
134     s4Reader->RunEvent(EventNumber, subData, dataLenght);
135     tofReader->RunEvent(EventNumber, subData, dataLenght);
136     triggerReader->RunEvent(EventNumber, subData, dataLenght);
137 kusanagi 6.1
138 kusanagi 2.4 /*-----------------*/
139 kusanagi 3.1 delete [] subData;
140 kusanagi 1.1 }
141    

  ViewVC Help
Powered by ViewVC 1.1.23