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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2.2 - (hide annotations) (download)
Wed Dec 22 11:39:16 2004 UTC (19 years, 11 months ago) by kusanagi
Branch: MAIN
Changes since 2.1: +13 -8 lines
*** empty log message ***

1 kusanagi 1.1 /** @file
2 kusanagi 1.2 * $Source: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v $
3 kusanagi 2.2 * $Id: TrackerReader.cpp,v 2.1 2004/10/17 12:28:46 kusanagi Exp $
4 kusanagi 1.2 * $Author: kusanagi $
5 kusanagi 1.1 *
6     * Implementation of the TrackerPhysicsReader class.
7     */
8    
9     #include <string>
10 kusanagi 1.6 #include <log4cxx/logger.h>
11 kusanagi 1.1 #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 kusanagi 1.4 int good0;
20     int nev0;
21 kusanagi 1.1 int DAQmode[12];
22     int DSPnumber[12];
23     int DATAlength[12];
24     int eventn[12];
25     int nclust[12];
26     int cutc[12];
27     int cutcl[12];
28     int addrcluster[12][3];
29     int signcluster[12][3];
30     int fc[12];
31     int compressiontime[12];
32     int fl5[12];
33     int fl4[12];
34     int fl3[12];
35     int fl2[12];
36     int fl1[12];
37     int fl6[12];
38     int pnum[12];
39     int cmdnum[12];
40     int bid[12];
41     int alarm[12];
42     int aswr[12];
43 kusanagi 1.3 int TOTDATAlength;
44     int datatracker[49152];
45 kusanagi 1.1 } level0_;
46     #include <dirent.h>
47     }
48    
49     using namespace pamela;
50     using namespace pamela::tracker;
51    
52 kusanagi 1.6 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.tracker.TrackerReader"));
53 kusanagi 1.1
54     /**
55     * Constructor.
56     */
57     TrackerReader::TrackerReader(void):
58     TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") {
59 kusanagi 1.6 logger->debug(_T("Constructor"));
60 kusanagi 1.1 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 kusanagi 2.2 "$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 2.1 2004/10/17 12:28:46 kusanagi Exp $";
69 kusanagi 1.1 }
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 kusanagi 1.6 logger->debug(_T("Initialize"));
77 kusanagi 1.1 SetInputStream(run);
78     run->WriteSubPacket(this, &tracker, tracker->Class());
79     }
80    
81     /**
82     * Unpack the orbital event from an input file.
83     */
84     void TrackerReader::RunEvent(int EventNumber) {
85    
86     }
87    
88     /**
89     * Unpack the Tracker data event from the physical packet.
90     */
91     void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) {
92     int ERROR;
93    
94     //Scrivo un file temporaneo per passarlo alla routine
95     //Speriamo di cambiare la routine per passargli un buffer.....
96 kusanagi 2.2 //DIR *dirp;
97    
98     //std::string pathDir((char*)getenv("YODA_DATA"));
99    
100     //pathDir = pathDir + "/todatemp.dat";
101     stringstream oss;
102     oss.str("");
103     oss << getenv("YODA_DATA") << "/" << time(NULL) << "trev.dat";
104 kusanagi 1.1 FILE *pfile;
105 kusanagi 2.2 pfile = fopen(oss.str().c_str(), "wb");
106 kusanagi 1.1 fwrite(subData, 1, length, pfile);
107     fclose(pfile);
108    
109     //Call to the FORTRAN routin that unpack tracker events
110 kusanagi 2.2 trkeventpkt_(&ERROR, (char*)oss.str().c_str());
111 kusanagi 1.1
112 kusanagi 2.2 remove(oss.str().c_str());
113 kusanagi 1.1
114 kusanagi 1.5 /*if (ERROR != 0) {
115     char *errmsg;
116     switch (ERROR){
117     case 1: errmsg = "---------------------";
118     }
119     } else {*/
120 kusanagi 1.1 //Store the unpacked data
121     memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode));
122     memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber));
123     memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength));
124     memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn));
125     memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust));
126     memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc));
127     memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl));
128 kusanagi 2.1 // memcpy(tracker->addrcluster, (level0_.addrcluster), sizeof(tracker->addrcluster));
129     // memcpy(tracker->signcluster, (level0_.signcluster), sizeof(tracker->signcluster));
130 kusanagi 1.4 //--------have to invert array because of FORTRAN <-> C different management of the indexes
131     int tempAddr[3][12];
132     int tempSign[3][12];
133     memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));
134     memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));
135 kusanagi 2.1 for (int j = 0; j < 11; j++){
136     for (int i = 0; i < 2; i++){
137 kusanagi 1.4 tracker->addrcluster[j][i] = tempAddr[i][j];
138     tracker->signcluster[j][i] = tempSign[i][j];
139     }
140     }
141     //-----------------------------------------------------------------------------------------
142    
143 kusanagi 1.1 memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc));
144     memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime));
145     memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1));
146     memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2));
147     memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3));
148     memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4));
149     memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5));
150     memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6));
151     memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum));
152     memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum));
153     memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid));
154     memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm));
155     memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr));
156 kusanagi 1.3 tracker->TOTDATAlength = level0_.TOTDATAlength;
157     memcpy(tracker->datatracker, level0_.datatracker, sizeof(tracker->datatracker));
158 kusanagi 1.5 //}
159 kusanagi 1.3
160 kusanagi 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.23