1 |
/** @file |
/** @file |
2 |
* $Author: messineo $ |
* $Author: mocchiut $ |
3 |
* $Date: 2008-03-12 13:48:30 $ |
* $Date: 2009/08/04 13:58:12 $ |
4 |
* $Revision: 1.21 $ |
* $Revision: 1.4 $ |
5 |
* |
* |
6 |
* Implementation of the functions of a sample Algorithm class. |
* Implementation of the functions of a sample Algorithm class. |
7 |
* This file can be used as a templace to develop your own algorithm. |
* This file can be used as a templace to develop your own algorithm. |
9 |
|
|
10 |
#include "EventReader.h" |
#include "EventReader.h" |
11 |
#include "ReaderAlgorithms.h" |
#include "ReaderAlgorithms.h" |
12 |
|
#include <TObjectTable.h> |
13 |
|
|
14 |
extern "C" { |
extern "C" { |
15 |
#include "CRC.h" |
#include "CRC.h" |
86 |
* Initialize the algorithm with a special run. This will initialize the |
* Initialize the algorithm with a special run. This will initialize the |
87 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
88 |
*/ |
*/ |
89 |
void EventReader::Init(PamelaRun *run) { |
TObject *EventReader::GetPtr(TString name){ |
90 |
//Create the structure of directories and create xxx.Header.root files |
for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin(); i != TechmodelAlgorithmMap.end(); i++) { |
91 |
run->WriteHeaders(this, &Header); |
if ( !strcmp(i->second->GetAlgorithmName(),name.Data()) ){ |
92 |
//Create the xxx.root in it's specific directory |
// cout << " Retrieving pointer of " << i->second->GetAlgorithmName()<<endl; |
93 |
for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin(); |
TechmodelAlgorithm* EventAlgorithm(i->second); |
94 |
i != TechmodelAlgorithmMap.end(); i++) { |
return(EventAlgorithm->GetPtr("")); |
95 |
// cout << " Initializing algo " << i->second->GetAlgorithmName()<<endl; |
}; |
96 |
i->second->Init(run); |
}; |
97 |
} |
return(NULL); |
98 |
|
} |
99 |
|
|
|
if ( Header ) { delete Header; Header = new EventHeader(); }; // EMILIANO, reset Counter when opening a new file |
|
100 |
|
|
101 |
Run=run; |
void EventReader::Init(PamelaRun *run) { |
102 |
|
//Create the structure of directories and create xxx.Header.root files |
103 |
|
// printf(" init er \n"); |
104 |
|
run->WriteHeaders(this, &Header); |
105 |
|
// printf(" init er wrote \n"); |
106 |
|
//Create the xxx.root in it's specific directory |
107 |
|
// gObjectTable->Print(); |
108 |
|
// Int_t yy = 0; |
109 |
|
for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin(); |
110 |
|
i != TechmodelAlgorithmMap.end(); i++) { |
111 |
|
// cout << " Initializing algo " << i->second->GetAlgorithmName()<<endl; |
112 |
|
i->second->Init(run); |
113 |
|
// printf(" algo %i \n",yy); |
114 |
|
// yy++; |
115 |
|
} |
116 |
|
// printf(" init er header \n"); |
117 |
|
if ( Header ) { delete Header; Header = new EventHeader(); }; // EMILIANO, reset Counter when opening a new file |
118 |
|
// printf(" init er header done %p \n",run); |
119 |
|
|
120 |
|
Run=run; |
121 |
} |
} |
122 |
|
|
123 |
|
|
133 |
3 CALIBRATION PACKET with error but used |
3 CALIBRATION PACKET with error but used |
134 |
-1 CRC exception packet DISCARDED |
-1 CRC exception packet DISCARDED |
135 |
-2 FATAL exception packet DISCARDED //never happen |
-2 FATAL exception packet DISCARDED //never happen |
136 |
-3 No way to read events of this type. packet DISCARDED( es CalibCal) |
-3 No way to read events of this type. packet DISCARDED( es CalibCal --old) |
137 |
//in PacketUser I will put ret = 10 |
//in PacketUser I will put ret = 10 |
138 |
ret = 10 if the packet is good but comes from a cadre with VRL problems |
ret = 10 if the packet is good but comes from a cadre with VRL problems |
139 |
|
|
204 |
// catch (NotExistingAlgorithmException exc) {} |
// catch (NotExistingAlgorithmException exc) {} |
205 |
|
|
206 |
Run->FillTrees(type); |
Run->FillTrees(type); |
207 |
|
// cout << Header->GetCounter()->Get(type) << endl; |
208 |
Header->GetCounter()->Increment(type); |
Header->GetCounter()->Increment(type); |
209 |
|
// cout << Header->GetCounter()->Get(type) << endl; |
210 |
} |
} |
211 |
else |
else |
212 |
{ |
{ |
213 |
ret=-3; |
ret=-3; |
214 |
oss.str(""); |
oss.str(""); |
215 |
oss << " No way to read events of type " << type->GetName().c_str()<<". The Packet is skipped "; |
// oss << " No way to read events of type " << type->GetName().c_str()<<". The Packet is skipped "; |
216 |
|
oss << " No way to read events of type " << type->GetName()<<". The Packet is skipped "; |
217 |
oss << " Return "<<ret; |
oss << " Return "<<ret; |
218 |
msg=oss.str(); |
msg=oss.str(); |
219 |
PamOffLineSW::mainLogUtil->logWarning(msg); |
PamOffLineSW::mainLogUtil->logWarning(msg); |
234 |
unsigned int OrbitalTime = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) + (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF); |
unsigned int OrbitalTime = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) + (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF); |
235 |
unsigned int PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) + (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF); |
unsigned int PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) + (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF); |
236 |
unsigned char CRC = buff[15]; |
unsigned char CRC = buff[15]; |
237 |
unsigned char FileOffset = 0;// ?? |
// unsigned char FileOffset = 0;// ?? |
238 |
|
|
239 |
Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2); |
Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2); |
240 |
Header->GetPscuHeader()->SetCounter(Counter); |
Header->GetPscuHeader()->SetCounter(Counter); |
254 |
*/ |
*/ |
255 |
std::string EventReader::GetVersionInfo(void) const { |
std::string EventReader::GetVersionInfo(void) const { |
256 |
return |
return |
257 |
"$Header: /repository/PamOffLineSW/techmodel/EventReader.cpp,v 1.21 2008-03-12 13:48:30 messineo Exp $\n"; |
"$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/EventReader.cpp,v 1.4 2009/08/04 13:58:12 mocchiut Exp $\n"; |
258 |
} |
} |
259 |
|
|
260 |
|
|