/[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.1 - (show annotations) (download)
Tue Jul 6 12:20:23 2004 UTC (20 years, 5 months ago) by kusanagi
Branch: MAIN
Initial revision

1 /** @file
2 * $Source: /home/cvspamela/yoda/techmodel/physics/tracker/TrackerPhysicsReader.cpp,v $
3 * $Id: TrackerPhysicsReader.cpp,v 1.6 2004/03/16 10:18:28 nagni Exp $
4 * $Author: nagni $
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 } level0_;
43
44 #include <dirent.h>
45 }
46
47 using namespace pamela;
48 using namespace pamela::tracker;
49
50 static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.tracker.TrackerReader");
51
52 /**
53 * Constructor.
54 */
55 TrackerReader::TrackerReader(void):
56 TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") {
57 cat.debug("Constructor");
58 tracker = new TrackerEvent();
59 }
60
61 /**
62 * Get a string with the version info of the algorithm.
63 */
64 std::string TrackerReader::GetVersionInfo(void) const {
65 return
66 "$Header: /home/cvspamela/yoda/techmodel/physics/tracker/TrackerPhysicsReader.cpp,v 1.6 2004/03/16 10:18:28 nagni Exp $";
67 }
68
69 /**
70 * Initialize the algorithm with a special run. This will initialize the
71 * event reader routines for all packet types.
72 */
73 void TrackerReader::Init(PamelaRun *run) {
74 SetInputStream(run);
75 run->WriteSubPacket(this, &tracker, tracker->Class());
76 }
77
78 /**
79 * Unpack the orbital event from an input file.
80 */
81 void TrackerReader::RunEvent(int EventNumber) {
82
83 }
84
85 /**
86 * Unpack the Tracker data event from the physical packet.
87 */
88 void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) {
89 char data[length];
90 memcpy(data, subData, 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 + "/";
98 pathDir = pathDir + PamelaRun::GetRunName(EventNumber) + "/todatemp.dat";
99 FILE *pfile;
100 pfile = fopen((char*)pathDir.c_str(), "wb");
101 fwrite(subData, 1, length, pfile);
102 fclose(pfile);
103
104 //Call to the FORTRAN routin that unpack tracker events
105 trkeventpkt_(&ERROR, (char*)pathDir.c_str());
106
107 remove((char*)pathDir.c_str());
108
109 //Store the unpacked data
110 memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode));
111 memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber));
112 memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength));
113 memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn));
114 memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust));
115 memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc));
116 memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl));
117 memcpy(tracker->addrcluster, level0_.addrcluster, sizeof(tracker->addrcluster));
118 memcpy(tracker->signcluster, level0_.signcluster, sizeof(tracker->signcluster));
119 memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc));
120 memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime));
121 memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1));
122 memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2));
123 memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3));
124 memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4));
125 memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5));
126 memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6));
127 memcpy(tracker->checksum, level0_.checksum, sizeof(tracker->checksum));
128 memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum));
129 memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum));
130 memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid));
131 memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm));
132 memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr));
133
134 cat << log4cpp::Priority::ERROR
135 << "Fortran77 function trkcalibpkt error code = " << ERROR
136 << "\n " << log4cpp::CategoryStream::ENDLINE;
137 }

  ViewVC Help
Powered by ViewVC 1.1.23