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

Contents of /chewbacca/PamOffLineSW/physics/CalorimeterReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Sep 23 07:20:23 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 /** @file
2 * $Source: /repository/PamOffLineSW/physics/CalorimeterReader.cpp,v $
3 * $Id: CalorimeterReader.cpp,v 1.3 2008-03-05 11:37:37 messineo Exp $
4 * $Author: messineo $
5 *
6 * Implementation of the CalorimeterReader class.
7 */
8
9
10 #include <iostream>
11 #include <string>
12 #include "CalorimeterReader.h"
13
14 extern "C" {
15
16
17 extern struct {
18 int iev;
19 int stwerr[4];
20 float perror[4];
21 float dexy[2][22][96];
22 float dexyc[2][22][96];
23 float base[2][22][6];
24 float calselftrig[4][7];
25 float calIItrig[4];
26 float calstriphit[4];
27 float calDSPtaberr[4];
28 float calevnum[4];
29 } evento_;
30
31 void calunpack_(unsigned char[], long int*, int*);
32 //Struct per il passaggio di dati da e verso la chiamata fortran
33 }
34
35 using namespace pamela;
36 using namespace pamela::calorimeter;
37
38
39 /**
40 * Constructor.
41 */
42 CalorimeterReader::CalorimeterReader(void):
43 TechmodelAlgorithm(PacketType::Physics, "TechmodelCalorimeterReader") {
44 calorimeter = new CalorimeterEvent();
45 }
46
47 /**
48 * Get a string with the version info of the algorithm.
49 */
50 std::string CalorimeterReader::GetVersionInfo(void) const {
51 return
52 "$Header: /repository/PamOffLineSW/physics/CalorimeterReader.cpp,v 1.3 2008-03-05 11:37:37 messineo Exp $";
53 }
54
55 /**
56 * Initialize the algorithm with a special run. This will initialize the
57 * event reader routines for all packet types.
58 */
59 void CalorimeterReader::Init(PamelaRun *run) {
60 run->WriteSubPacket(this, &calorimeter, calorimeter->Class());
61 }
62
63 /**
64 * Unpack the calorimeter event from an input file.
65 */
66 void CalorimeterReader::RunEvent(int EventNumber) {
67
68 }
69
70 /**
71 * Unpack the Calorimeter data event from the physical packet.
72 */
73 void CalorimeterReader::RunEvent(int EventNumber, const char subData[], long int length) {
74 std::stringstream oss;
75 string msg;
76
77 char *data = new char[length];
78 memcpy(data, subData, length);
79 int ERROR = 0;
80
81 /*unsigned short convdata[length];
82 for (int i = 0; i<length; i++){
83 convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF);
84 }*/
85
86 //Call to the routine that unpack calorimeter events
87 calunpack_((unsigned char*)data, &length, &ERROR);
88
89 if (ERROR != 0) {
90 char *errmsg;
91 switch (ERROR){
92 case 1: errmsg = "CALORIMETER NOT FOUND";
93 break;
94 default: errmsg = "CALORIMETER ERRROR CODE UNIDENTIFIED";
95 }
96 oss.str("");
97 oss << "Calorimeter: Fortran77 function calunpack: " << errmsg;
98 msg=oss.str();
99 PamOffLineSW::mainLogUtil->logWarning(msg);
100 }
101 //
102 ERROR = 0;
103 Int_t cmask = 119;
104 for (int i=0; i<4 ; i++){
105 if ( evento_.perror[i] ){
106 ERROR = 1;
107 break;
108 };
109 if ( evento_.stwerr[i] & cmask ){
110 ERROR = 1;
111 break;
112 };
113 };
114 //
115 calorimeter->unpackError = ERROR;
116 // In case of "ERROR != 0" the calunpack will take care to set all
117 // parameters to zero
118 //} else {
119 calorimeter->iev = evento_.iev;
120 memcpy(calorimeter->stwerr, evento_.stwerr, sizeof(calorimeter->stwerr));
121 memcpy(calorimeter->perror, evento_.perror, sizeof(calorimeter->perror));
122 //--------have to invert array because of FORTRAN <-> C different management of the indexes
123 float tempDexy[96][22][2];
124 float tempDexyc[96][22][2];
125 float tempBase[6][22][2];
126 float tempCalselftrig[7][4];
127 memcpy(tempDexy, evento_.dexy, sizeof(tempDexy));
128 memcpy(tempDexyc, evento_.dexyc, sizeof(tempDexyc));
129 memcpy(tempBase, evento_.base, sizeof(tempBase));
130 memcpy(tempCalselftrig, evento_.calselftrig, sizeof(tempCalselftrig));
131
132 for (int i = 0; i < 4; i++){
133 for (int j = 0; j < 7; j++){
134 calorimeter->calselftrig[i][j] = tempCalselftrig[j][i];
135 }
136 }
137
138 for (int i = 0; i < 2; i++){
139 for (int j = 0; j < 22; j++){
140 for (int z = 0; z < 96; z++){
141 calorimeter->dexy[i][j][z] = tempDexy[z][j][i];
142 calorimeter->dexyc[i][j][z] = tempDexyc[z][j][i];
143 }
144 for (int z = 0; z < 6; z++){
145 calorimeter->base[i][j][z] = tempBase[z][j][i];
146 }
147 }
148 }
149 //-----------------------------------------------------------------------------------------
150 memcpy(calorimeter->calIItrig, evento_.calIItrig, sizeof(calorimeter->calIItrig));
151 memcpy(calorimeter->calstriphit, evento_.calstriphit, sizeof(calorimeter->calstriphit));
152 memcpy(calorimeter->calDSPtaberr, evento_.calDSPtaberr, sizeof(calorimeter->calDSPtaberr));
153 memcpy(calorimeter->calevnum, evento_.calevnum, sizeof(calorimeter->calevnum));
154 //}
155 delete [] data;
156 }

  ViewVC Help
Powered by ViewVC 1.1.23