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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.1 - (hide annotations) (download)
Tue Sep 12 08:56:31 2006 UTC (18 years, 3 months ago) by mocchiut
Branch: MAIN
CVS Tags: YODA6_3/13, YODA6_3/12, YODA6_3/11, YODA6_3/10, YODA6_3/08, YODA6_3/09
Changes since 6.0: +4 -4 lines
Added unpackError flag to trigger and tof, small change in the calo unpackError flag

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

  ViewVC Help
Powered by ViewVC 1.1.23