/[PAMELA software]/yoda/techmodel/physics/TrackerReader.cpp
ViewVC logotype

Contents of /yoda/techmodel/physics/TrackerReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Jul 26 23:09:47 2004 UTC (20 years, 4 months ago) by kusanagi
Branch: MAIN
Changes since 1.2: +7 -3 lines
*** empty log message ***

1 /** @file
2 * $Source: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v $
3 * $Id: TrackerReader.cpp,v 1.2 2004/07/17 20:03:48 kusanagi Exp $
4 * $Author: kusanagi $
5 *
6 * Implementation of the TrackerPhysicsReader class.
7 */
8
9 #include <string>
10 #include <log4cpp/Category.hh>
11 #include "TrackerReader.h"
12 #include "event/physics/tracker/TrackerEvent.h"
13
14 extern "C" {
15 //Passo il path verso la il file temporaneo
16 extern void trkeventpkt_(int*, char*);
17 //Struct per il passaggio di dati da e verso la chiamata fortran
18 extern struct {
19 int DAQmode[12];
20 int DSPnumber[12];
21 int DATAlength[12];
22 int eventn[12];
23 int nclust[12];
24 int cutc[12];
25 int cutcl[12];
26 int addrcluster[12][3];
27 int signcluster[12][3];
28 int fc[12];
29 int compressiontime[12];
30 int fl5[12];
31 int fl4[12];
32 int fl3[12];
33 int fl2[12];
34 int fl1[12];
35 int fl6[12];
36 int checksum[12];
37 int pnum[12];
38 int cmdnum[12];
39 int bid[12];
40 int alarm[12];
41 int aswr[12];
42 int TOTDATAlength;
43 int datatracker[49152];
44 } level0_;
45
46 #include <dirent.h>
47 }
48
49 using namespace pamela;
50 using namespace pamela::tracker;
51
52 static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.tracker.TrackerReader");
53
54 /**
55 * Constructor.
56 */
57 TrackerReader::TrackerReader(void):
58 TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") {
59 cat.debug("Constructor");
60 tracker = new TrackerEvent();
61 }
62
63 /**
64 * Get a string with the version info of the algorithm.
65 */
66 std::string TrackerReader::GetVersionInfo(void) const {
67 return
68 "$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 1.2 2004/07/17 20:03:48 kusanagi Exp $";
69 }
70
71 /**
72 * Initialize the algorithm with a special run. This will initialize the
73 * event reader routines for all packet types.
74 */
75 void TrackerReader::Init(PamelaRun *run) {
76 SetInputStream(run);
77 run->WriteSubPacket(this, &tracker, tracker->Class());
78 }
79
80 /**
81 * Unpack the orbital event from an input file.
82 */
83 void TrackerReader::RunEvent(int EventNumber) {
84
85 }
86
87 /**
88 * Unpack the Tracker data event from the physical packet.
89 */
90 void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) {
91 int ERROR;
92
93 //Scrivo un file temporaneo per passarlo alla routine
94 //Speriamo di cambiare la routine per passargli un buffer.....
95 DIR *dirp;
96 std::string pathDir((char*)getenv("YODA_DATA"));
97 pathDir = pathDir + "/todatemp.dat";
98 FILE *pfile;
99 pfile = fopen((char*)pathDir.c_str(), "wb");
100 fwrite(subData, 1, length, pfile);
101 fclose(pfile);
102
103 //Call to the FORTRAN routin that unpack tracker events
104 trkeventpkt_(&ERROR, (char*)pathDir.c_str());
105
106 remove((char*)pathDir.c_str());
107
108 //Store the unpacked data
109 memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode));
110 memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber));
111 memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength));
112 memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn));
113 memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust));
114 memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc));
115 memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl));
116 memcpy(tracker->addrcluster, level0_.addrcluster, sizeof(tracker->addrcluster));
117 memcpy(tracker->signcluster, level0_.signcluster, sizeof(tracker->signcluster));
118 memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc));
119 memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime));
120 memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1));
121 memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2));
122 memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3));
123 memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4));
124 memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5));
125 memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6));
126 memcpy(tracker->checksum, level0_.checksum, sizeof(tracker->checksum));
127 memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum));
128 memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum));
129 memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid));
130 memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm));
131 memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr));
132 tracker->TOTDATAlength = level0_.TOTDATAlength;
133 memcpy(tracker->datatracker, level0_.datatracker, sizeof(tracker->datatracker));
134
135 cat << log4cpp::Priority::ERROR
136 << "Fortran77 function trkcalibpkt error code = " << ERROR
137 << "\n " << log4cpp::CategoryStream::ENDLINE;
138 }

  ViewVC Help
Powered by ViewVC 1.1.23