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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4.0 - (show annotations) (download)
Sun Mar 6 04:33:02 2005 UTC (19 years, 9 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA4_1/00, YODA4_0/04, YODA4_0/03, YODA4_0/02, YODA4_0/01, YODA4_3/02, YODA4_3/00, YODA4_3/01, YODA4_2/01, YODA4_2/00, YODA4_2/03
Changes since 3.1: +2 -2 lines
Stable version 4.0 - 6 March 2005 - Maurizio Nagni

1 /** @file
2 * $Source: /home/cvsmanager/yoda/techmodel/physics/TriggerReader.cpp,v $
3 * $Id: TriggerReader.cpp,v 3.1 2005/03/06 04:29:24 kusanagi Exp $
4 * $Author: kusanagi $
5 *
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 "$Header: /home/cvsmanager/yoda/techmodel/physics/TriggerReader.cpp,v 3.1 2005/03/06 04:29:24 kusanagi Exp $";
56 }
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 break;
99 default: errmsg = "TRIGGER ERRROR CODE UNIDENTIFIED";
100 }
101 oss.str("");
102 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
109 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 delete [] data;
121 }

  ViewVC Help
Powered by ViewVC 1.1.23