/[PAMELA software]/chewbacca/PamOffLineSW/physics/AnticounterReader.cpp
ViewVC logotype

Annotation of /chewbacca/PamOffLineSW/physics/AnticounterReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue Sep 23 07:20:22 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Branch point for: v0r00
Initial revision

1 mocchiut 1.1 /** @file
2     * $Source: /repository/PamOffLineSW/physics/AnticounterReader.cpp,v $
3     * $Id: AnticounterReader.cpp,v 1.5 2008-03-05 16:52:00 messineo Exp $
4     * $Author: messineo $
5     *
6     * Implementation of the AnticounterReader class.
7     */
8    
9     #include <string>
10     #include "AnticounterReader.h"
11    
12     extern "C" {
13     #include "../forroutines/anticounter/AC.h"
14     extern int ACphysics(int, unsigned char[] , struct physicsstruct*);
15     }
16    
17     using namespace pamela;
18     using namespace pamela::anticounter;
19    
20    
21     /**
22     * Constructor.
23     */
24     AnticounterReader::AnticounterReader(void):
25     TechmodelAlgorithm(PacketType::Physics, "TechmodelAnticounterReader") {
26     anticounter = new AnticounterEvent();
27     }
28    
29     /**
30     * Get a string with the version info of the algorithm.
31     */
32     std::string AnticounterReader::GetVersionInfo(void) const {
33     return
34     "$Header: /repository/PamOffLineSW/physics/AnticounterReader.cpp,v 1.5 2008-03-05 16:52:00 messineo Exp $";
35     }
36    
37     /**
38     * Initialize the algorithm with a special run. This will initialize the
39     * event reader routines for all packet types.
40     */
41     void AnticounterReader::Init(PamelaRun *run) {
42     run->WriteSubPacket(this, &anticounter, anticounter->Class());
43     }
44    
45     /**
46     * Unpack the anticounter event from an input file.
47     */
48     void AnticounterReader::RunEvent(int EventNumber) {
49    
50     }
51    
52     /**
53     * Unpack the Anticounter data event from the physical packet.
54     */
55     void AnticounterReader::RunEvent(int EventNumber, const char subData[], long int length) {
56     std::stringstream oss;
57     string msg;
58    
59     char *data = new char[length];
60     memcpy(data, subData, length);
61     struct physicsstruct output[2] = {0};
62    
63     //Call to the routine that unpack anitocounter events
64     //anticounter->ERROR = ACphysics(length, (unsigned char*) data, &(*output));
65     anticounter->unpackError = ACphysics(length, (unsigned char*) data, output);
66    
67     oss.str("");
68     switch (anticounter->unpackError){
69     case 0xFF:
70     oss << "Anticounter unpacking: " << "data (physics or calibration) from both cards found";
71     //msg=oss.str();
72     //PamOffLineSW::mainLogUtil->logAll(msg);
73     break;
74     case 0xF0:
75     oss << "Anticounter unpacking: " << "only data from main card found";
76     msg=oss.str();
77     PamOffLineSW::mainLogUtil->logError(msg);
78     break;
79     case 0x0F:
80     oss << "Anticounter unpacking: " << "only data from extra card found";
81     msg=oss.str();
82     PamOffLineSW::mainLogUtil->logError(msg);
83     break;
84     case 0x00:
85     oss << "Anticounter unpacking: " << "no data found";
86     msg=oss.str();
87     PamOffLineSW::mainLogUtil->logError(msg);
88     break;
89     oss << "Anticounter unpacking: " << "ANTICOUNTER ERRROR CODE UNIDENTIFIED";
90     msg=oss.str();
91     PamOffLineSW::mainLogUtil->logError(msg);
92     }
93    
94    
95     for(int i = 0; i<2; i++){
96     memcpy(anticounter->header[i], output[i].header, sizeof(anticounter->header[i]));
97     anticounter->status[i] = output[i].status;
98     anticounter->hitmap[i] = output[i].hitmap;
99     memcpy(anticounter->regist[i], output[i].regist, sizeof(output[i].regist));
100     memcpy(anticounter->shift[i], output[i].shift, sizeof(output[i].shift));
101     memcpy(anticounter->counters[i], output[i].counters, sizeof(output[i].counters));
102     memcpy(anticounter->coinc[i], output[i].coinc, sizeof(output[i].coinc));
103     anticounter->trigg[i] = output[i].trigg;
104     memcpy(anticounter->clock[i], output[i].clock, sizeof(output[i].clock));
105     memcpy(anticounter->temp[i], output[i].temp, sizeof(output[i].temp));
106     memcpy(anticounter->DAC[i], output[i].DAC, sizeof(output[i].DAC));
107     anticounter->CRC[i] = output[i].CRC;
108     anticounter->CRCcheck[i] = output[i].CRCcheck;
109     }
110    
111     //}
112     delete [] data;
113     }

  ViewVC Help
Powered by ViewVC 1.1.23