/[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 6.2 - (show annotations) (download)
Fri Oct 20 11:07:46 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
CVS Tags: YODA6_3/19, YODA6_3/18, YODA6_3/17, YODA6_3/16, YODA6_3/15, YODA6_3/14, YODA6_3/20, HEAD
Changes since 6.1: +8 -4 lines
Error occurred while calculating annotation data.
YODA crash bugs fixed + further reduced printout

1 /** @file
2 * $Source: /afs/ba.infn.it/user/pamela/src/CVS/yoda/techmodel/physics/TriggerReader.cpp,v $
3 * $Id: TriggerReader.cpp,v 6.1 2006/09/12 08:56:31 mocchiut Exp $
4 * $Author: mocchiut $
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: /afs/ba.infn.it/user/pamela/src/CVS/yoda/techmodel/physics/TriggerReader.cpp,v 6.1 2006/09/12 08:56:31 mocchiut 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 if ( length < 500000 && length >= 0 ){
92 triggerunpack_((unsigned char*)data, &length, &ERROR);
93 } else {
94 ERROR = 1;
95 };
96
97
98 if (ERROR != 0) {
99 char *errmsg;
100 switch (ERROR){
101 case 1: errmsg = "GENERIC TRIGGER ERROR";
102 break;
103 default: errmsg = "TRIGGER ERRROR CODE UNIDENTIFIED";
104 }
105 oss.str("");
106 oss << "Fortran77 function triggerunpack: " << errmsg;
107 logger->warn(oss.str().c_str());
108 }
109 // In case of "ERROR != 0" the calunpack will take care to set all
110 // parameters to zero
111 //} else {
112 trigger->unpackError = (unsigned short)ERROR;
113 trigger->evcount = trig_.evcount;
114 memcpy(trigger->pmtpl, trig_.pmtpl, sizeof(trigger->pmtpl));
115 memcpy(trigger->trigrate, trig_.trigrate, sizeof(trigger->trigrate));
116 memcpy(trigger->dltime, trig_.dltime, sizeof(trigger->dltime));
117 memcpy(trigger->s4calcount, trig_.s4calcount, sizeof(trigger->s4calcount));
118 memcpy(trigger->pmtcount1, trig_.pmtcount1, sizeof(trigger->pmtcount1));
119 memcpy(trigger->pmtcount2, trig_.pmtcount2, sizeof(trigger->pmtcount2));
120 memcpy(trigger->patternbusy, trig_.patternbusy, sizeof(trigger->patternbusy));
121 memcpy(trigger->patterntrig, trig_.patterntrig, sizeof(trigger->patterntrig));
122 trigger->trigconf = trig_.trigconf;
123
124 delete [] data;
125 }

  ViewVC Help
Powered by ViewVC 1.1.23