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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Sep 23 07:20:22 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: v0r00
CVS Tags: v1r02, v1r00, v1r01, start
Changes since 1.1: +0 -0 lines
Imported sources, 23/09/2008

1 mocchiut 1.1 /** @file
2     * $Source: /repository/PamOffLineSW/physics/TriggerReader.cpp,v $
3     * $Id: TriggerReader.cpp,v 1.4 2008-03-05 11:37:37 messineo Exp $
4     * $Author: messineo $
5     *
6     * Implementation of the CalorimeterReader class.
7     */
8    
9     #include <iostream>
10     #include <string>
11     #include "TriggerReader.h"
12    
13     extern "C" {
14    
15    
16     extern struct {
17     int evcount;
18     int pmtpl[3];
19     int trigrate[6];
20     int dltime[2];
21     int s4calcount[2];
22     int pmtcount1[24];
23     int pmtcount2[24];
24     int patternbusy[3];
25     int patterntrig[6];
26     int trigconf;
27     } trig_;
28    
29     void triggerunpack_(unsigned char[], long int*, int*);
30    
31     //Struct per il passaggio di dati da e verso la chiamata fortran
32     }
33    
34     using namespace pamela;
35     using namespace pamela::trigger;
36    
37    
38     /**
39     * Constructor.
40     */
41     TriggerReader::TriggerReader(void):
42     TechmodelAlgorithm(PacketType::Physics, "TechmodelTriggerReader") {
43     trigger = new TriggerEvent();
44     }
45    
46     /**
47     * Get a string with the version info of the algorithm.
48     */
49     std::string TriggerReader::GetVersionInfo(void) const {
50     return
51     "$Header: /repository/PamOffLineSW/physics/TriggerReader.cpp,v 1.4 2008-03-05 11:37:37 messineo Exp $";
52     }
53    
54     /**
55     * Initialize the algorithm with a special run. This will initialize the
56     * event reader routines for all packet types.
57     */
58     void TriggerReader::Init(PamelaRun *run) {
59     run->WriteSubPacket(this, &trigger, trigger->Class());
60     }
61    
62     /**
63     * Unpack the trigger event from an input file.
64     */
65     void TriggerReader::RunEvent(int EventNumber) {
66    
67     }
68    
69     /**
70     * Unpack the Trigger data event from the physical packet.
71     */
72     void TriggerReader::RunEvent(int EventNumber, const char subData[], long int length) {
73     std::stringstream oss;
74     string msg;
75    
76     char *data = new char[length];
77     memcpy(data, subData, length);
78     int ERROR = 0;
79    
80     /*unsigned short convdata[length];
81     for (int i = 0; i<length; i++){
82     convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF);
83     }*/
84    
85    
86     //Call to the routine that unpack trigger events
87     if ( length < 500000 && length >= 0 ){
88     triggerunpack_((unsigned char*)data, &length, &ERROR);
89     } else {
90     ERROR = 1;
91     };
92    
93    
94     if (ERROR != 0) {
95     char *errmsg;
96     switch (ERROR){
97     case 1: errmsg = "GENERIC TRIGGER ERROR";
98     break;
99     default: errmsg = "TRIGGER ERRROR CODE UNIDENTIFIED";
100     }
101     oss.str("");
102     oss << "Trigger: Fortran77 function triggerunpack: " << errmsg;
103     msg=oss.str();
104     PamOffLineSW::mainLogUtil->logWarning(msg);
105    
106     }
107     // In case of "ERROR != 0" the calunpack will take care to set all
108     // parameters to zero
109     //} else {
110     trigger->unpackError = (unsigned short)ERROR;
111     trigger->evcount = trig_.evcount;
112     memcpy(trigger->pmtpl, trig_.pmtpl, sizeof(trigger->pmtpl));
113     memcpy(trigger->trigrate, trig_.trigrate, sizeof(trigger->trigrate));
114     memcpy(trigger->dltime, trig_.dltime, sizeof(trigger->dltime));
115     memcpy(trigger->s4calcount, trig_.s4calcount, sizeof(trigger->s4calcount));
116     memcpy(trigger->pmtcount1, trig_.pmtcount1, sizeof(trigger->pmtcount1));
117     memcpy(trigger->pmtcount2, trig_.pmtcount2, sizeof(trigger->pmtcount2));
118     memcpy(trigger->patternbusy, trig_.patternbusy, sizeof(trigger->patternbusy));
119     memcpy(trigger->patterntrig, trig_.patterntrig, sizeof(trigger->patterntrig));
120     trigger->trigconf = trig_.trigconf;
121     delete [] data;
122    
123     }

  ViewVC Help
Powered by ViewVC 1.1.23