/[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 2.1 - (hide annotations) (download)
Sat Jan 29 00:31:36 2005 UTC (19 years, 10 months ago) by kusanagi
Branch: MAIN
*** empty log message ***

1 kusanagi 2.1 /** @file
2     * $Source: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v $
3     * $Id: CalorimeterReader.cpp,v 2.3 2004/10/18 14:28:03 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 2.3 2004/10/18 14:28:03 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     }
99     oss.flush();
100     oss << "Fortran77 function triggerunpack: " << errmsg;
101     logger->warn(oss.str().c_str());
102     }
103     // In case of "ERROR != 0" the calunpack will take care to set all
104     // parameters to zero
105     //} else {
106    
107     trigger->evcount = trig_.evcount;
108     memcpy(trigger->pmtpl, trig_.pmtpl, sizeof(trigger->pmtpl));
109     memcpy(trigger->trigrate, trig_.trigrate, sizeof(trigger->trigrate));
110     memcpy(trigger->dltime, trig_.dltime, sizeof(trigger->dltime));
111     memcpy(trigger->s4calcount, trig_.s4calcount, sizeof(trigger->s4calcount));
112     memcpy(trigger->pmtcount1, trig_.pmtcount1, sizeof(trigger->pmtcount1));
113     memcpy(trigger->pmtcount2, trig_.pmtcount2, sizeof(trigger->pmtcount2));
114     memcpy(trigger->patternbusy, trig_.patternbusy, sizeof(trigger->patternbusy));
115     memcpy(trigger->patterntrig, trig_.patterntrig, sizeof(trigger->patterntrig));
116     trigger->trigconf = trig_.trigconf;
117    
118     delete[] data;
119     }

  ViewVC Help
Powered by ViewVC 1.1.23