1 |
///////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////// |
2 |
// Program to convert an gpamela ntuple to pamela raw data (.pam). |
// Program to convert an gpamela ntuple to pamela raw data (.pam). |
3 |
// A root file containing the ntuple is also produced. |
// A root file containing the ntuple is also produced. |
4 |
// The conversion is done using a slightly patched version of |
// The conversion is done using a slightly patched version of |
5 |
// Rene Brun's h2root. |
// Rene Brun's h2root. |
6 |
// |
// |
7 |
// Created : 2006 Jan Conrad (conrad@particle.kth.se) |
// Created : 2006 Jan Conrad (conrad@particle.kth.se) |
8 |
// Modified: 2007 Silvio Orsi (silvio.orsi@roma2.infn.it) |
// Modified: 2007 Silvio Orsi (silvio.orsi@roma2.infn.it) |
9 |
// |
// |
10 |
// |
// |
11 |
// HOWTO (RECOMMENDED): |
// HOWTO (RECOMMENDED): |
12 |
// ./ Pamelagp2Digits filename.his |
// ./ Pamelagp2Digits filename.his |
13 |
// It generates filename.pam (PAMELA raw data) and filename.gp.root (sim info) |
// It generates filename.pam (PAMELA raw data) and filename.gp.root (sim info) |
14 |
// |
// |
15 |
// NB: more details are present in the file HOW-TO-DIGIT.TXT |
// NB: more details are present in the file HOW-TO-DIGIT.TXT |
16 |
// |
// |
17 |
// HOWTO (only for testing purposes) |
// HOWTO (only for testing purposes) |
18 |
// Pamelagp2Digits hbook_filename root_filename raw_filename compress tolower |
// Pamelagp2Digits hbook_filename root_filename raw_filename compress tolower |
19 |
// - If the 2nd and 3rd parameters are missing the names are generated from the hbook file name. |
// - If the 2nd and 3rd parameters are missing the names are generated from the hbook file name. |
20 |
// - The following flags are from h2root and default values are used: |
// - The following flags are from h2root and default values are used: |
21 |
// if compress is missing (or = 1) the ROOT file will be compressed |
// if compress is missing (or = 1) the ROOT file will be compressed |
22 |
// if compress = 0 the ROOT file will not be compressed. |
// if compress = 0 the ROOT file will not be compressed. |
23 |
// if tolower is missing (or = 1) ntuple column names are converted to lower case |
// if tolower is missing (or = 1) ntuple column names are converted to lower case |
24 |
// but the first character is converted to upper case. |
// but the first character is converted to upper case. |
25 |
// if tolower = 2 same as tolower=1 except that the first character is also |
// if tolower = 2 same as tolower=1 except that the first character is also |
26 |
// convertex to lower case |
// convertex to lower case |
27 |
// |
// |
28 |
// MODIFICATIONS: |
// MODIFICATIONS: |
29 |
// |
// v. 1.5 (S.Orsi, Roma2, 11 October 2007) |
30 |
// rev. 1.8 tag 2r01 (S.Orsi, Roma2, 5 December 2007) |
// - file HOW-TO-DIGIT.TXT written (mainly by S.Bottai): contains information on how to run the chain from the DB creation to DarthVader through Digitizer, yoda and YodaProfiler |
31 |
// - first tagged version |
// |
32 |
// - options "--version" and "--help" implemented in Makefile (file digitVersion.h added) |
// v. 1.4 (S.Orsi, Roma2, 11 October 2007) |
33 |
// - TRG: + number of words corrected from 153 to 152 (the trg/tof code accidentally accounted for this error in all (?) cases) |
// - similar to v. 1.3 |
34 |
// + variables event_count (=Ievnt from gpamela), pattern_trigger, trigger_conf (always acq.mode TOF4) implemented (they were all 0 before!) |
// |
35 |
// - AC : attenuation of light as function of distance from PMT implemented for CAS (see Digitizer.cxx for further references and comments) |
// v. 1.3 (S.Orsi, Roma2, 11 October 2007) |
36 |
// - RunHeader and RunTrailer implemented (filled with flight-like information) |
// - TOF: + changes and major corrections in ADC and TDC (W.Menn, D.Campana, S.Orsi) |
37 |
// |
// + flag DEBUG added (default: DEBUG=false; if true, print on screem some messages to debug) |
38 |
// rev. 1.7 (S.Orsi, Roma2, 28 November 2007) |
// - AC: + shift register filled; |
39 |
// - TOF: + mapping S21 corrected (WM) |
// + minor bugs fixed |
40 |
// + time resolution increased to 425ps (WM) |
// + counters increment by 1 at each event (they were constant before) |
41 |
// + new scale factors (WM) |
// - S4: + minor bugs fixed (S.Borisov) |
42 |
// + various corrections |
// + the routine DigitizeS4() is now inserted in the code. For DV versions earlier than October 2007, the option "-S4" is still needed because S4 calibration is not present |
43 |
// - file README removed (usage and install information are present in the file HOW-TO-DIGIT.TXT) |
// - corrected severe bug that caused yoda to process only part of large data files (file.pam). S4 data were written to file even if the DigitizeS4() routine was not called. Previous versions of the digitizer should have crashed always, but unexpectedly worked on small files. |
44 |
// - Makefile: option "install" added |
// - file HOW-TO-DIGIT.TXT written (mainly by S.Bottai): contains information on how to run the chain from the DB creation to DarthVader through Digitizer, yoda and YodaProfiler. The file is included only from release 1.5 |
45 |
// |
// - digitizer version numbers modified according to CVS repository (v1.00->v1.1, v1.01->v1.2) |
46 |
// rev. 1.6 (S.Orsi, Roma2, 31 October 2007) |
// - some flags (LDFLAGS) in the Makefile have been changed; they are needed on some machines (e.g. pamelatov.roma2.infn.it), but give errors on others (e.g. pamelaws02.na.infn.it). See Makefile for details if the compilation fails due to library errors) |
47 |
// - TOF: (Campana, Menn, Orsi) |
// |
48 |
// + bugs fixed |
// v. 1.2 (S.Orsi, Roma2, 28 September 2007) |
49 |
// + crc included |
// - TOF TDC inserted (to be tuned) |
50 |
// + introduction of 3 control bits in the ADC and TDC words before writing fDataTof |
// - improved tracker dEdx, tracker saturation inserted (S.Bottai) |
51 |
// + channel map corrected (correspondence between PMT# and TDC channel) |
// - S4 routine inserted in code (not in read-out) |
52 |
// + new conversion pC to ADC |
// - bugs with packet length corrected |
53 |
// + scaling factors to tune MC data to real ones |
// - small bugs fixed |
54 |
// - HOW-TO-DIGIT.TXT file updated (E.Vannuccini) |
// - NB: Run DarthVader with the options: "DarthVader -zerofill -idRun 1 -ALL +RUN +CAL [ --no-crosstalk ] +TRK +TOF +AC +TRG +ND" or "DarthVader -zerofill -idRun 1 +CAL [ --no-crosstalk ] -S4", i.e. without S4 |
55 |
// |
// |
56 |
// v. 1.5 (S.Orsi, Roma2, 11 October 2007) |
// v. 1.1 (S.Orsi, Roma2, 13 September 2007) |
57 |
// - file HOW-TO-DIGIT.TXT written (mainly by S.Bottai): contains information on how to run the chain from the DB creation to DarthVader through Digitizer, yoda and YodaProfiler |
// - trigger (dummy), tof (preliminary, adc only), ND (preliminary) inserted |
58 |
// |
// - various changes and bug fixes |
59 |
// v. 1.4 (S.Orsi, Roma2, 11 October 2007) |
// - padding increased (fPADbuffer=64, fPadding = padbytes+64) |
60 |
// - similar to v. 1.3 |
// |
61 |
// |
// v. beta (J.Conrad, KTH, 2006) |
62 |
// v. 1.3 (S.Orsi, Roma2, 11 October 2007) |
// - compiles; includes pscu, calo, trk, ac; not present on cvs |
63 |
// - TOF: + changes and major corrections in ADC and TDC (W.Menn, D.Campana, S.Orsi) |
// |
64 |
// + flag DEBUG added (default: DEBUG=false; if true, print on screem some messages to debug) |
///////////////////////////////////////////////////////////////////////// |
65 |
// - AC: + shift register filled; |
|
66 |
// + minor bugs fixed |
#include <stdlib.h> |
67 |
// + counters increment by 1 at each event (they were constant before) |
#include <string.h> |
68 |
// - S4: + minor bugs fixed (S.Borisov) |
#include <ctype.h> |
69 |
// + the routine DigitizeS4() is now inserted in the code. For DV versions earlier than October 2007, the option "-S4" is still needed because S4 calibration is not present |
#include "Riostream.h" |
70 |
// - corrected severe bug that caused yoda to process only part of large data files (file.pam). S4 data were written to file even if the DigitizeS4() routine was not called. Previous versions of the digitizer should have crashed always, but unexpectedly worked on small files. |
#include "TFile.h" |
71 |
// - file HOW-TO-DIGIT.TXT written (mainly by S.Bottai): contains information on how to run the chain from the DB creation to DarthVader through Digitizer, yoda and YodaProfiler. The file is included only from release 1.5 |
#include "TDirectory.h" |
72 |
// - digitizer version numbers modified according to CVS repository (v1.00->v1.1, v1.01->v1.2) |
#include "TTree.h" |
73 |
// - some flags (LDFLAGS) in the Makefile have been changed; they are needed on some machines (e.g. pamelatov.roma2.infn.it), but give errors on others (e.g. pamelaws02.na.infn.it). See Makefile for details if the compilation fails due to library errors) |
#include "TLeafI.h" |
74 |
// |
#include "TH1.h" |
75 |
// v. 1.2 (S.Orsi, Roma2, 28 September 2007) |
#include "TH2.h" |
76 |
// - TOF TDC inserted (to be tuned) |
#include "TProfile.h" |
77 |
// - improved tracker dEdx, tracker saturation inserted (S.Bottai) |
#include "TGraph.h" |
78 |
// - S4 routine inserted in code (not in read-out) |
#include "TMath.h" |
79 |
// - bugs with packet length corrected |
#include "Digitizer.h" |
80 |
// - small bugs fixed |
|
81 |
// - NB: Run DarthVader with the options: "DarthVader -zerofill -idRun 1 -ALL +RUN +CAL [ --no-crosstalk ] +TRK +TOF +AC +TRG +ND" or "DarthVader -zerofill -idRun 1 +CAL [ --no-crosstalk ] -S4", i.e. without S4 |
int Error; //to be removed soon |
82 |
// |
|
83 |
// v. 1.1 (S.Orsi, Roma2, 13 September 2007) |
// Define the names of the Fortran common blocks for the different OSs |
84 |
// - trigger (dummy), tof (preliminary, adc only), ND (preliminary) inserted |
|
85 |
// - various changes and bug fixes |
#ifndef WIN32 |
86 |
// - padding increased (fPADbuffer=64, fPadding = padbytes+64) |
#define PAWC_SIZE 5000000 |
87 |
// |
# define pawc pawc_ |
88 |
// v. beta (J.Conrad, KTH, 2006) |
# define quest quest_ |
89 |
// - compiles; includes pscu, calo, trk, ac; not present on cvs |
# define hcbits hcbits_ |
90 |
// |
# define hcbook hcbook_ |
91 |
///////////////////////////////////////////////////////////////////////// |
# define rzcl rzcl_ |
92 |
// |
int pawc[PAWC_SIZE]; |
93 |
#include <stdlib.h> |
int quest[100]; |
94 |
#include <string.h> |
int hcbits[37]; |
95 |
#include <ctype.h> |
int hcbook[51]; |
96 |
#include "Riostream.h" |
int rzcl[11]; |
97 |
#include "TFile.h" |
#else |
98 |
#include "TDirectory.h" |
// on windows /pawc/ must have the same length as in libPacklib.a !! |
99 |
#include "TTree.h" |
#define PAWC_SIZE 2000000 |
100 |
#include "TLeafI.h" |
# define pawc PAWC |
101 |
#include "TH1.h" |
# define quest QUEST |
102 |
#include "TH2.h" |
# define hcbits HCBITS |
103 |
#include "TProfile.h" |
# define hcbook HCBOOK |
104 |
#include "TGraph.h" |
# define rzcl RZCL |
105 |
#include "TMath.h" |
extern "C" int pawc[PAWC_SIZE]; |
106 |
#include "Digitizer.h" |
extern "C" int quest[100]; |
107 |
// |
extern "C" int hcbits[37]; |
108 |
#include "digitVersion.h" |
extern "C" int hcbook[51]; |
109 |
// |
extern "C" int rzcl[11]; |
110 |
int Error; //to be removed soon |
#endif |
111 |
|
|
112 |
// Define the names of the Fortran common blocks for the different OSs |
int *iq, *lq; |
113 |
|
float *q; |
114 |
#ifndef WIN32 |
char idname[128]; |
115 |
#define PAWC_SIZE 5000000 |
int nentries; |
116 |
# define pawc pawc_ |
char chtitl[128]; |
117 |
# define quest quest_ |
int ncx,ncy,nwt,idb; |
118 |
# define hcbits hcbits_ |
int lcont, lcid, lcdir; |
119 |
# define hcbook hcbook_ |
float xmin,xmax,ymin,ymax; |
120 |
# define rzcl rzcl_ |
const Int_t kMIN1 = 7; |
121 |
int pawc[PAWC_SIZE]; |
const Int_t kMAX1 = 8; |
122 |
int quest[100]; |
|
123 |
int hcbits[37]; |
#if defined __linux |
124 |
int hcbook[51]; |
//On linux Fortran wants this, so we give to it! |
125 |
int rzcl[11]; |
int xargv=0; |
126 |
#else |
int xargc=0; |
127 |
// on windows /pawc/ must have the same length as in libPacklib.a !! |
void MAIN__() {} |
128 |
#define PAWC_SIZE 2000000 |
#endif |
129 |
# define pawc PAWC |
|
130 |
# define quest QUEST |
// Define the names of the Fortran subroutine and functions for the different OSs |
131 |
# define hcbits HCBITS |
|
132 |
# define hcbook HCBOOK |
#ifndef WIN32 |
133 |
# define rzcl RZCL |
# define hlimit hlimit_ |
134 |
extern "C" int pawc[PAWC_SIZE]; |
# define hropen hropen_ |
135 |
extern "C" int quest[100]; |
# define hrin hrin_ |
136 |
extern "C" int hcbits[37]; |
# define hnoent hnoent_ |
137 |
extern "C" int hcbook[51]; |
# define hgive hgive_ |
138 |
extern "C" int rzcl[11]; |
# define hgiven hgiven_ |
139 |
#endif |
# define hprntu hprntu_ |
140 |
|
# define hgnpar hgnpar_ |
141 |
int *iq, *lq; |
# define hgnf hgnf_ |
142 |
float *q; |
# define hgnt hgnt_ |
143 |
char idname[128]; |
# define rzink rzink_ |
144 |
int nentries; |
# define hdcofl hdcofl_ |
145 |
char chtitl[128]; |
# define hmaxim hmaxim_ |
146 |
int ncx,ncy,nwt,idb; |
# define hminim hminim_ |
147 |
int lcont, lcid, lcdir; |
# define hdelet hdelet_ |
148 |
float xmin,xmax,ymin,ymax; |
# define hntvar2 hntvar2_ |
149 |
const Int_t kMIN1 = 7; |
# define hbname hbname_ |
150 |
const Int_t kMAX1 = 8; |
# define hbnamc hbnamc_ |
151 |
|
# define hbnam hbnam_ |
152 |
#if defined __linux |
# define hi hi_ |
153 |
//On linux Fortran wants this, so we give to it! |
# define hie hie_ |
154 |
int xargv=0; |
# define hif hif_ |
155 |
int xargc=0; |
# define hij hij_ |
156 |
void MAIN__() {} |
# define hix hix_ |
157 |
#endif |
# define hijxy hijxy_ |
158 |
|
# define hije hije_ |
159 |
// Define the names of the Fortran subroutine and functions for the different OSs |
# define hcdir hcdir_ |
160 |
|
# define zitoh zitoh_ |
161 |
#ifndef WIN32 |
# define uhtoc uhtoc_ |
162 |
# define hlimit hlimit_ |
|
163 |
# define hropen hropen_ |
# define type_of_call |
164 |
# define hrin hrin_ |
# define DEFCHAR const char* |
165 |
# define hnoent hnoent_ |
# define PASSCHAR(string) string |
166 |
# define hgive hgive_ |
#else |
167 |
# define hgiven hgiven_ |
# define hlimit HLIMIT |
168 |
# define hprntu hprntu_ |
# define hropen HROPEN |
169 |
# define hgnpar hgnpar_ |
# define hrin HRIN |
170 |
# define hgnf hgnf_ |
# define hnoent HNOENT |
171 |
# define hgnt hgnt_ |
# define hgive HGIVE |
172 |
# define rzink rzink_ |
# define hgiven HGIVEN |
173 |
# define hdcofl hdcofl_ |
# define hprntu HPRNTU |
174 |
# define hmaxim hmaxim_ |
# define hgnpar HGNPAR |
175 |
# define hminim hminim_ |
# define hgnf HGNF |
176 |
# define hdelet hdelet_ |
# define hgnt HGNT |
177 |
# define hntvar2 hntvar2_ |
# define rzink RZINK |
178 |
# define hbname hbname_ |
# define hdcofl HDCOFL |
179 |
# define hbnamc hbnamc_ |
# define hmaxim HMAXIM |
180 |
# define hbnam hbnam_ |
# define hminim HMINIM |
181 |
# define hi hi_ |
# define hdelet HDELET |
182 |
# define hie hie_ |
# define hntvar2 HNTVAR2 |
183 |
# define hif hif_ |
# define hbname HBNAME |
184 |
# define hij hij_ |
# define hbnamc HBNAMC |
185 |
# define hix hix_ |
# define hbnam HBNAM |
186 |
# define hijxy hijxy_ |
# define hi HI |
187 |
# define hije hije_ |
# define hie HIE |
188 |
# define hcdir hcdir_ |
# define hif HIF |
189 |
# define zitoh zitoh_ |
# define hij HIJ |
190 |
# define uhtoc uhtoc_ |
# define hix HIX |
191 |
|
# define hijxy HIJXY |
192 |
# define type_of_call |
# define hije HIJE |
193 |
# define DEFCHAR const char* |
# define hcdir HCDIR |
194 |
# define PASSCHAR(string) string |
# define zitoh ZITOH |
195 |
#else |
# define uhtoc UHTOC |
196 |
# define hlimit HLIMIT |
# define type_of_call _stdcall |
197 |
# define hropen HROPEN |
# define DEFCHAR const char*, const int |
198 |
# define hrin HRIN |
# define PASSCHAR(string) string, strlen(string) |
199 |
# define hnoent HNOENT |
#endif |
200 |
# define hgive HGIVE |
|
201 |
# define hgiven HGIVEN |
extern "C" void type_of_call hlimit(const int&); |
202 |
# define hprntu HPRNTU |
#ifndef WIN32 |
203 |
# define hgnpar HGNPAR |
extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, |
204 |
# define hgnf HGNF |
const int&,const int&,const int,const int,const int); |
205 |
# define hgnt HGNT |
#else |
206 |
# define rzink RZINK |
extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, |
207 |
# define hdcofl HDCOFL |
const int&,const int&); |
208 |
# define hmaxim HMAXIM |
#endif |
209 |
# define hminim HMINIM |
|
210 |
# define hdelet HDELET |
extern "C" void type_of_call hrin(const int&,const int&,const int&); |
211 |
# define hntvar2 HNTVAR2 |
extern "C" void type_of_call hnoent(const int&,const int&); |
212 |
# define hbname HBNAME |
#ifndef WIN32 |
213 |
# define hbnamc HBNAMC |
extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, |
214 |
# define hbnam HBNAM |
const int&,const float&,const float&,const int&,const int&,const int); |
215 |
# define hi HI |
#else |
216 |
# define hie HIE |
extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, |
217 |
# define hif HIF |
const int&,const float&,const float&,const int&,const int&); |
218 |
# define hij HIJ |
#endif |
219 |
# define hix HIX |
|
220 |
# define hijxy HIJXY |
#ifndef WIN32 |
221 |
# define hije HIJE |
extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, |
222 |
# define hcdir HCDIR |
const float&,const float&,const int,const int); |
223 |
# define zitoh ZITOH |
#else |
224 |
# define uhtoc UHTOC |
extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, |
225 |
# define type_of_call _stdcall |
const float&,const float&); |
226 |
# define DEFCHAR const char*, const int |
#endif |
227 |
# define PASSCHAR(string) string, strlen(string) |
|
228 |
#endif |
#ifndef WIN32 |
229 |
|
extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&,const int,const int, const int); |
230 |
extern "C" void type_of_call hlimit(const int&); |
#else |
231 |
#ifndef WIN32 |
extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&); |
232 |
extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, |
#endif |
233 |
const int&,const int&,const int,const int,const int); |
|
234 |
#else |
#ifndef WIN32 |
235 |
extern "C" void type_of_call hropen(const int&,DEFCHAR,DEFCHAR,DEFCHAR, |
extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&,const int, const int); |
236 |
const int&,const int&); |
#else |
237 |
#endif |
extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&); |
238 |
|
#endif |
239 |
extern "C" void type_of_call hrin(const int&,const int&,const int&); |
|
240 |
extern "C" void type_of_call hnoent(const int&,const int&); |
extern "C" void type_of_call hprntu(const int&); |
241 |
#ifndef WIN32 |
extern "C" void type_of_call hgnpar(const int&,const char *,const int); |
242 |
extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, |
extern "C" void type_of_call hgnf(const int&,const int&,const float&,const int&); |
243 |
const int&,const float&,const float&,const int&,const int&,const int); |
extern "C" void type_of_call hgnt(const int&,const int&,const int&); |
244 |
#else |
extern "C" void type_of_call rzink(const int&,const int&,const char *,const int); |
245 |
extern "C" void type_of_call hgive(const int&,DEFCHAR,const int&,const float&,const float&, |
extern "C" void type_of_call hdcofl(); |
246 |
const int&,const float&,const float&,const int&,const int&); |
extern "C" void type_of_call hmaxim(const int&,const float&); |
247 |
#endif |
extern "C" void type_of_call hminim(const int&,const float&); |
248 |
|
extern "C" void type_of_call hdelet(const int&); |
249 |
#ifndef WIN32 |
extern "C" float type_of_call hi(const int&,const int&); |
250 |
extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, |
extern "C" float type_of_call hie(const int&,const int&); |
251 |
const float&,const float&,const int,const int); |
extern "C" float type_of_call hif(const int&,const int&); |
252 |
#else |
extern "C" float type_of_call hij(const int&,const int&,const int&); |
253 |
extern "C" void type_of_call hgiven(const int&,DEFCHAR,const int&,DEFCHAR, |
extern "C" void type_of_call hix(const int&,const int&,const float&); |
254 |
const float&,const float&); |
extern "C" void type_of_call hijxy(const int&,const int&,const int&,const float&,const float&); |
255 |
#endif |
extern "C" float type_of_call hije(const int&,const int&,const int&); |
256 |
|
#ifndef WIN32 |
257 |
#ifndef WIN32 |
extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR ,const int,const int); |
258 |
extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&,const int,const int, const int); |
#else |
259 |
#else |
extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR); |
260 |
extern "C" void type_of_call hntvar2(const int&,const int&,DEFCHAR,DEFCHAR,DEFCHAR,int&,int&,int&,int&,int&); |
#endif |
261 |
#endif |
|
262 |
|
extern "C" void type_of_call zitoh(const int&,const int&,const int&); |
263 |
#ifndef WIN32 |
#ifndef WIN32 |
264 |
extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&,const int, const int); |
extern "C" void type_of_call uhtoc(const int&,const int&,DEFCHAR,int&,const int); |
265 |
#else |
#else |
266 |
extern "C" void type_of_call hbnam(const int&,DEFCHAR,const int&,DEFCHAR,const int&); |
extern "C" void type_of_call uhtoc(const int&,const int&,DEFCHAR,int&); |
267 |
#endif |
#endif |
268 |
|
|
269 |
extern "C" void type_of_call hprntu(const int&); |
extern void convert_directory(const char*, char* file_raw); |
270 |
extern "C" void type_of_call hgnpar(const int&,const char *,const int); |
extern void convert_1d(Int_t id); |
271 |
extern "C" void type_of_call hgnf(const int&,const int&,const float&,const int&); |
extern void convert_cwn(Int_t id,char* file_raw); |
272 |
extern "C" void type_of_call hgnt(const int&,const int&,const int&); |
|
273 |
extern "C" void type_of_call rzink(const int&,const int&,const char *,const int); |
|
274 |
extern "C" void type_of_call hdcofl(); |
Int_t golower = 1; |
275 |
extern "C" void type_of_call hmaxim(const int&,const float&); |
Int_t bufsize = 64000; |
276 |
extern "C" void type_of_call hminim(const int&,const float&); |
Int_t optcwn = 1; |
277 |
extern "C" void type_of_call hdelet(const int&); |
|
278 |
extern "C" float type_of_call hi(const int&,const int&); |
|
279 |
extern "C" float type_of_call hie(const int&,const int&); |
int main(int argc, char **argv) |
280 |
extern "C" float type_of_call hif(const int&,const int&); |
|
281 |
extern "C" float type_of_call hij(const int&,const int&,const int&); |
{ |
282 |
extern "C" void type_of_call hix(const int&,const int&,const float&); |
if (argc < 2) { |
283 |
extern "C" void type_of_call hijxy(const int&,const int&,const int&,const float&,const float&); |
printf("Error: Pamelagp2Digits \n"); |
284 |
extern "C" float type_of_call hije(const int&,const int&,const int&); |
printf("Pamelagp2Digits file.hbook file.root file.pam [compress] [tolower] [lrecl] [bufsize] [optcwn] \n"); |
285 |
#ifndef WIN32 |
printf(" if file.root is not given it will be = file.root\n"); |
286 |
extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR ,const int,const int); |
printf(" compress = 1 by default (use 0 for no compression)\n"); |
287 |
#else |
printf(" tolower = 1 by default (use 0 to keep case of column names)\n"); |
288 |
extern "C" void type_of_call hcdir(DEFCHAR,DEFCHAR); |
printf(" lrecl =0 by default (must be specified if >8092)\n"); |
289 |
#endif |
printf(" bufsize = 8000 by default (branch buffer size)\n"); |
290 |
|
printf(" for cwn ntuple only: optcwn = 1 (default) 1-byte int -> char, 2-byte int -> short, (use 0 to keep 4-byte int) \n"); |
291 |
extern "C" void type_of_call zitoh(const int&,const int&,const int&); |
return 1; |
292 |
#ifndef WIN32 |
} |
293 |
extern "C" void type_of_call uhtoc(const int&,const int&,DEFCHAR,int&,const int); |
|
294 |
#else |
lq = &pawc[9]; |
295 |
extern "C" void type_of_call uhtoc(const int&,const int&,DEFCHAR,int&); |
iq = &pawc[17]; |
296 |
#endif |
void *qq = iq; |
297 |
|
q = (float*)qq; |
298 |
extern void convert_directory(const char*, char* file_raw); |
char *file_in=argv[1]; |
299 |
extern void convert_1d(Int_t id); |
char *file_out = " "; |
300 |
extern void convert_cwn(Int_t id,char* file_raw); |
char *file_raw; |
301 |
|
|
302 |
|
Int_t compress = 1; |
303 |
Int_t golower = 1; |
int ier=0, record_size=0; |
304 |
Int_t bufsize = 64000; |
|
305 |
Int_t optcwn = 1; |
if (argc > 8) { |
306 |
|
optcwn = atoi(argv[8]); |
307 |
// Usage subroutine |
} |
308 |
// |
if (argc > 7) { |
309 |
void DigitUsage(Int_t u){ |
bufsize = atoi(argv[7]); |
310 |
if (u<0) |
} |
311 |
printf("----- ERROR in input parameters! -----\n"); |
if (argc > 6) { |
312 |
printf("\nPAMELA Digitizer Usage:\n\n"); |
record_size = atoi(argv[6]); |
313 |
printf("Pamelagp2Digits file.hbook file.root file.pam [compress] [tolower] [lrecl] [bufsize] [optcwn] \n"); |
} |
314 |
printf(" if file.root is not given it will be = file.root\n"); |
if (argc > 5) { |
315 |
printf(" or: \nPamelagp2Digits [option] \n"); |
golower = atoi(argv[5]); |
316 |
printf("\n Options are:\n\n"); |
} |
317 |
printf(" --version print informations about compilation and exit\n"); |
if (argc > 4) { |
318 |
printf(" -h | --help print this help and exit \n"); |
compress = atoi(argv[4]); |
319 |
//printf(" -g | --debug set debug flag\n"); |
} |
320 |
printf("\nExamples: \n"); |
|
321 |
printf(" Pamelagp2Digits --version\n"); |
if (argc > 3) { |
322 |
printf(" Pamelagp2Digits simulatedProtons.his \n\n"); |
file_raw=argv[3]; |
323 |
|
} else { |
324 |
printf("The options [compress] [tolower] [lrecl] [bufsize] [optcwn] should be modified only for testing purposes:\n"); |
file_raw= new char[2000]; |
325 |
printf("(options to be removed in future versions)\n"); |
strcpy(file_raw,file_in); |
326 |
printf(" compress = 1 by default (use 0 for no compression)\n"); |
char *dot = strrchr(file_raw,'.'); |
327 |
printf(" tolower = 1 by default (use 0 to keep case of column names)\n"); |
if (dot) strcpy(dot+1,"pam"); |
328 |
printf(" lrecl =0 by default (must be specified if >8092)\n"); |
else strcat(file_out,".pam"); |
329 |
printf(" bufsize = 8000 by default (branch buffer size)\n"); |
} |
330 |
printf(" for cwn ntuple only: optcwn = 1 (default) 1-byte int -> char, 2-byte int -> short, (use 0 to keep 4-byte int) \n\n"); |
|
331 |
}; |
if (argc > 2) { |
332 |
|
file_out=argv[2]; |
333 |
int main(int argc, char *argv[]){ |
} else { |
334 |
// |
file_out= new char[2000]; |
335 |
// Checking input parameters |
strcpy(file_out,file_in); |
336 |
// |
char *dot = strrchr(file_out,'.'); |
337 |
if ( argc > 1 ){ |
if (dot) strcpy(dot+1,"gp.root"); //modified S.Orsi 09/'07 |
338 |
Int_t ic = 0; |
else strcat(file_out,".gp.root"); |
339 |
while ( ic < argc ){ |
} |
340 |
if ( !strcmp(argv[ic],"--version") ){ |
|
341 |
DigitizerInfo(true); |
|
342 |
exit(0); |
|
343 |
}; |
#if defined(_HIUX_SOURCE) && !defined(__GNUC__) |
344 |
if ( !strcmp(argv[ic],"-h") || !strcmp(argv[ic],"--help") ){ |
hf_fint((char *)NULL); |
345 |
DigitUsage(0); |
#endif |
346 |
exit(0); |
|
347 |
}; |
|
348 |
//if ( !strcmp(argv[ic],"-g") || !strcmp(argv[ic],"--debug") ){ |
int pawc_size = PAWC_SIZE; |
349 |
//debug = true; |
hlimit(pawc_size); |
350 |
//}; |
|
351 |
ic++; |
int lun = 10; |
352 |
}; |
#ifndef WIN32 |
353 |
} else{ |
hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("p"),record_size,ier,7,strlen(file_in),1); |
354 |
// |
#else |
355 |
// no input parameters: exit with error |
hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("p"),record_size,ier); |
356 |
// |
#endif |
357 |
DigitUsage(-2); |
|
358 |
exit(-2); |
if (ier) printf (" Error on hropen was %d \n", ier); |
359 |
}; |
if (quest[0]) { |
360 |
|
printf("Error cannot open input file: %s\n",file_in); |
361 |
lq = &pawc[9]; |
return 1; |
362 |
iq = &pawc[17]; |
} |
363 |
void *qq = iq; |
|
364 |
q = (float*)qq; |
char root_file_title[2000]; |
365 |
char *file_in=argv[1]; |
|
366 |
char *file_out = " "; |
TFile* hfile= TFile::Open(file_out,"RECREATE",root_file_title,compress); |
367 |
char *file_raw; |
|
368 |
|
if (!hfile) { |
369 |
Int_t compress = 1; |
printf("Error: can't open output file: %s \n",file_out); |
370 |
int ier=0, record_size=0; |
return 1; |
371 |
|
} |
372 |
if (argc > 8) { |
|
373 |
optcwn = atoi(argv[8]); |
convert_directory("//example",file_raw); |
374 |
} |
|
375 |
if (argc > 7) { |
//hfile->Write(); |
376 |
bufsize = atoi(argv[7]); |
//hfile->ls(); |
377 |
} |
|
378 |
if (argc > 6) { |
hfile->Close(); |
379 |
record_size = atoi(argv[6]); |
delete hfile; |
380 |
} |
return(0); |
381 |
if (argc > 5) { |
} |
382 |
golower = atoi(argv[5]); |
|
383 |
} |
|
384 |
if (argc > 4) { |
//____________________________________________________________________________ |
385 |
compress = atoi(argv[4]); |
void convert_directory(const char *dir, char* file_raw) |
386 |
} |
{ |
387 |
|
|
388 |
if (argc > 3) { |
|
389 |
file_raw=argv[3]; |
printf(" Converting directory %s\n",dir); |
390 |
} else { |
Int_t id; |
391 |
file_raw= new char[2000]; |
// Int_t nastycase=0; |
392 |
strcpy(file_raw,file_in); |
// Int_t nastyprint=0; |
393 |
char *dot = strrchr(file_raw,'.'); |
// Int_t idold = 0; |
394 |
if (dot) strcpy(dot+1,"pam"); |
for (Int_t key=1;key<1000000;key++) { |
395 |
else strcat(file_out,".pam"); |
int z0 = 0; |
396 |
} |
rzink(key,z0,"S",1); |
397 |
|
if (quest[0]) break; |
398 |
if (argc > 2) { |
if (quest[13] & 8) { |
399 |
file_out=argv[2]; |
continue; |
400 |
} else { |
// if (!nastyprint) { |
401 |
file_out= new char[2000]; |
// printf("Found nasty Hbook case!! You had an Hbook error message\n"); |
402 |
strcpy(file_out,file_in); |
// printf(" when creating the file (too many records)\n"); |
403 |
char *dot = strrchr(file_out,'.'); |
// printf(" Hbook file should have been created with a bigger LRECL\n"); |
404 |
if (dot) strcpy(dot+1,"gp.root"); //modified S.Orsi 09/'07 |
// printf(" ROOT will try to recover\n"); |
405 |
else strcat(file_out,".gp.root"); |
// nastyprint = 1; |
406 |
} |
// } |
407 |
|
// nastycase = 1; |
408 |
|
} |
409 |
|
id = quest[20]; |
410 |
#if defined(_HIUX_SOURCE) && !defined(__GNUC__) |
// if (id == idold && nastycase) continue; |
411 |
hf_fint((char *)NULL); |
// nastycase = 0; |
412 |
#endif |
// idold = id; |
413 |
|
int i999 = 999; |
414 |
|
hrin(id,i999,0); |
415 |
int pawc_size = PAWC_SIZE; |
if (quest[0]) { |
416 |
hlimit(pawc_size); |
printf("Error cannot read ID = %d\n",id); |
417 |
|
break; |
418 |
int lun = 10; |
} |
419 |
#ifndef WIN32 |
hdcofl(); |
420 |
hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("p"),record_size,ier,7,strlen(file_in),1); |
lcid = hcbook[10]; |
421 |
#else |
lcont = lq[lcid-1]; |
422 |
hropen(lun,PASSCHAR("example"),PASSCHAR(file_in),PASSCHAR("p"),record_size,ier); |
if (hcbits[3]) { |
423 |
#endif |
convert_cwn(id,file_raw); |
424 |
|
hdelet(id); |
425 |
if (ier) printf (" Error on hropen was %d \n", ier); |
continue; |
426 |
if (quest[0]) { |
} |
427 |
printf("Error cannot open input file: %s\n",file_in); |
|
428 |
return 1; |
if (hcbits[0]) { |
429 |
} |
convert_1d(id); |
430 |
|
hdelet(id); |
431 |
char root_file_title[2000]; |
continue; |
432 |
|
} |
433 |
TFile* hfile= TFile::Open(file_out,"RECREATE",root_file_title,compress); |
|
434 |
|
} |
435 |
if (!hfile) { |
|
436 |
printf("Error: can't open output file: %s \n",file_out); |
// converting subdirectories of this directory |
437 |
return 1; |
const Int_t kKLS = 26; |
438 |
} |
const Int_t kKNSD = 23; |
439 |
|
lcdir = rzcl[2]; |
440 |
convert_directory("//example",file_raw); |
Int_t ls = iq[lcdir+kKLS]; |
441 |
|
Int_t ndir = iq[lcdir+kKNSD]; |
442 |
//hfile->Write(); |
Int_t nch=16; |
443 |
//hfile->ls(); |
Int_t ihdir[4]; |
444 |
|
Int_t ncw = 4; |
445 |
hfile->Close(); |
TDirectory *cursav = gDirectory; |
446 |
delete hfile; |
Int_t i; |
447 |
return(0); |
char chdir[17]; |
448 |
} |
char hbookdir[17]; |
449 |
|
for (Int_t k=0;k<ndir;k++) { |
450 |
|
lcdir = rzcl[2]; |
451 |
//____________________________________________________________________________ |
zitoh(iq[lcdir+ls+7*k],ihdir[0],ncw); |
452 |
void convert_directory(const char *dir, char* file_raw) |
for (i=0;i<17;i++) chdir[i] = 0; |
453 |
{ |
#ifndef WIN32 |
454 |
|
uhtoc(ihdir[0],ncw,chdir,nch ,16); |
455 |
|
#else |
456 |
printf(" Converting directory %s\n",dir); |
uhtoc(ihdir[0],ncw,chdir,16,nch); |
457 |
Int_t id; |
#endif |
458 |
// Int_t nastycase=0; |
strcpy(hbookdir,chdir); |
459 |
// Int_t nastyprint=0; |
for (i=16;i>0;i--) { |
460 |
// Int_t idold = 0; |
if (chdir[i] == 0) continue; |
461 |
for (Int_t key=1;key<1000000;key++) { |
if (chdir[i] != ' ') break; |
462 |
int z0 = 0; |
chdir[i] = 0; |
463 |
rzink(key,z0,"S",1); |
} |
464 |
if (quest[0]) break; |
#ifndef WIN32 |
465 |
if (quest[13] & 8) { |
hcdir(PASSCHAR(hbookdir),PASSCHAR(" "),16,1); |
466 |
continue; |
#else |
467 |
// if (!nastyprint) { |
hcdir(PASSCHAR(hbookdir),PASSCHAR(" ")); |
468 |
// printf("Found nasty Hbook case!! You had an Hbook error message\n"); |
#endif |
469 |
// printf(" when creating the file (too many records)\n"); |
TDirectory *newdir = new TDirectory(chdir,chdir); |
470 |
// printf(" Hbook file should have been created with a bigger LRECL\n"); |
newdir->cd(); |
471 |
// printf(" ROOT will try to recover\n"); |
convert_directory(chdir, file_raw); |
472 |
// nastyprint = 1; |
#ifndef WIN32 |
473 |
// } |
hcdir(PASSCHAR("\\"),PASSCHAR(" "),1,1); |
474 |
// nastycase = 1; |
#else |
475 |
} |
hcdir(PASSCHAR("\\"),PASSCHAR(" ")); |
476 |
id = quest[20]; |
#endif |
477 |
// if (id == idold && nastycase) continue; |
newdir->Write(); |
478 |
// nastycase = 0; |
cursav->cd(); |
479 |
// idold = id; |
} |
480 |
int i999 = 999; |
} |
481 |
hrin(id,i999,0); |
|
482 |
if (quest[0]) { |
//____________________________________________________________________________ |
483 |
printf("Error cannot read ID = %d\n",id); |
void convert_1d(Int_t id) |
484 |
break; |
{ |
485 |
} |
if (id > 0) sprintf(idname,"h%d",id); |
486 |
hdcofl(); |
else sprintf(idname,"h_%d",-id); |
487 |
lcid = hcbook[10]; |
hnoent(id,nentries); |
488 |
lcont = lq[lcid-1]; |
#ifndef WIN32 |
489 |
if (hcbits[3]) { |
hgive(id,chtitl,ncx,xmin,xmax,ncy,ymin,ymax,nwt,idb,80); |
490 |
convert_cwn(id,file_raw); |
#else |
491 |
hdelet(id); |
hgive(id,chtitl,80,ncx,xmin,xmax,ncy,ymin,ymax,nwt,idb); |
492 |
continue; |
#endif |
493 |
} |
chtitl[4*nwt] = 0; |
494 |
|
TH1F *h1; |
495 |
if (hcbits[0]) { |
Int_t i; |
496 |
convert_1d(id); |
if (hcbits[5]) { |
497 |
hdelet(id); |
Int_t lbins = lq[lcid-2]; |
498 |
continue; |
Double_t *xbins = new Double_t[ncx+1]; |
499 |
} |
for (i=0;i<=ncx;i++) xbins[i] = q[lbins+i+1]; |
500 |
|
h1 = new TH1F(idname,chtitl,ncx,xbins); |
501 |
} |
delete [] xbins; |
502 |
|
} else { |
503 |
// converting subdirectories of this directory |
h1 = new TH1F(idname,chtitl,ncx,xmin,xmax); |
504 |
const Int_t kKLS = 26; |
} |
505 |
const Int_t kKNSD = 23; |
if (hcbits[8]) h1->Sumw2(); |
506 |
lcdir = rzcl[2]; |
TGraph *gr = 0; |
507 |
Int_t ls = iq[lcdir+kKLS]; |
if (hcbits[11]) { |
508 |
Int_t ndir = iq[lcdir+kKNSD]; |
gr = new TGraph(ncx); |
509 |
Int_t nch=16; |
h1->GetListOfFunctions()->Add(gr); |
510 |
Int_t ihdir[4]; |
} |
511 |
Int_t ncw = 4; |
|
512 |
TDirectory *cursav = gDirectory; |
Float_t x; |
513 |
Int_t i; |
for (i=0;i<=ncx+1;i++) { |
514 |
char chdir[17]; |
x = h1->GetBinCenter(i); |
515 |
char hbookdir[17]; |
h1->Fill(x,hi(id,i)); |
516 |
for (Int_t k=0;k<ndir;k++) { |
if (hcbits[8]) h1->SetBinError(i,hie(id,i)); |
517 |
lcdir = rzcl[2]; |
if (gr && i>0 && i<=ncx) gr->SetPoint(i,x,hif(id,i)); |
518 |
zitoh(iq[lcdir+ls+7*k],ihdir[0],ncw); |
} |
519 |
for (i=0;i<17;i++) chdir[i] = 0; |
Float_t ymin, ymax; |
520 |
#ifndef WIN32 |
if (hcbits[19]) { |
521 |
uhtoc(ihdir[0],ncw,chdir,nch ,16); |
ymax = q[lcid+kMAX1]; |
522 |
#else |
h1->SetMaximum(ymax); |
523 |
uhtoc(ihdir[0],ncw,chdir,16,nch); |
} |
524 |
#endif |
if (hcbits[20]) { |
525 |
strcpy(hbookdir,chdir); |
ymin = q[lcid+kMIN1]; |
526 |
for (i=16;i>0;i--) { |
h1->SetMinimum(ymin); |
527 |
if (chdir[i] == 0) continue; |
} |
528 |
if (chdir[i] != ' ') break; |
h1->SetEntries(nentries); |
529 |
chdir[i] = 0; |
h1->Write(); |
530 |
} |
delete h1; |
531 |
#ifndef WIN32 |
} |
532 |
hcdir(PASSCHAR(hbookdir),PASSCHAR(" "),16,1); |
//____________________________________________________________________________ |
533 |
#else |
void convert_cwn(Int_t id,char* file_raw) |
534 |
hcdir(PASSCHAR(hbookdir),PASSCHAR(" ")); |
{ |
535 |
#endif |
const int kNchar=9; |
536 |
TDirectory *newdir = new TDirectory(chdir,chdir); |
int nvar; |
537 |
newdir->cd(); |
int ier=0; |
538 |
convert_directory(chdir, file_raw); |
int i,j; |
539 |
#ifndef WIN32 |
int nsub,itype,isize,ielem; |
540 |
hcdir(PASSCHAR("\\"),PASSCHAR(" "),1,1); |
char *chtag_out; |
541 |
#else |
float *x; |
542 |
hcdir(PASSCHAR("\\"),PASSCHAR(" ")); |
float rmin[1000], rmax[1000]; |
543 |
#endif |
|
544 |
newdir->Write(); |
if (id > 0) sprintf(idname,"h%d",id); |
545 |
cursav->cd(); |
else sprintf(idname,"h_%d",-id); |
546 |
} |
hnoent(id,nentries); |
547 |
} |
printf(" Converting CWN with ID= %d, nentries = %d\n",id,nentries); |
548 |
|
nvar=0; |
549 |
//____________________________________________________________________________ |
#ifndef WIN32 |
550 |
void convert_1d(Int_t id) |
hgiven(id,chtitl,nvar,PASSCHAR(""),rmin[0],rmax[0],80,0); |
551 |
{ |
#else |
552 |
if (id > 0) sprintf(idname,"h%d",id); |
hgiven(id,chtitl,80,nvar,PASSCHAR(""),rmin[0],rmax[0]); |
553 |
else sprintf(idname,"h_%d",-id); |
#endif |
554 |
hnoent(id,nentries); |
|
555 |
#ifndef WIN32 |
|
556 |
hgive(id,chtitl,ncx,xmin,xmax,ncy,ymin,ymax,nwt,idb,80); |
chtag_out = new char[nvar*kNchar+1]; |
557 |
#else |
Int_t *charflag = new Int_t[nvar]; |
558 |
hgive(id,chtitl,80,ncx,xmin,xmax,ncy,ymin,ymax,nwt,idb); |
Int_t *lenchar = new Int_t[nvar]; |
559 |
#endif |
Int_t *boolflag = new Int_t[nvar]; |
560 |
chtitl[4*nwt] = 0; |
Int_t *lenbool = new Int_t[nvar]; |
561 |
TH1F *h1; |
UChar_t *boolarr = new UChar_t[10000]; |
562 |
Int_t i; |
x = new float[nvar]; |
563 |
if (hcbits[5]) { |
char *bigbuf = new char[2500000]; |
564 |
Int_t lbins = lq[lcid-2]; |
|
565 |
Double_t *xbins = new Double_t[ncx+1]; |
chtag_out[nvar*kNchar]=0; |
566 |
for (i=0;i<=ncx;i++) xbins[i] = q[lbins+i+1]; |
for (i=0;i<80;i++)chtitl[i]=0; |
567 |
h1 = new TH1F(idname,chtitl,ncx,xbins); |
#ifndef WIN32 |
568 |
delete [] xbins; |
hgiven(id,chtitl,nvar,chtag_out,rmin[0],rmax[0],80,kNchar); |
569 |
} else { |
#else |
570 |
h1 = new TH1F(idname,chtitl,ncx,xmin,xmax); |
hgiven(id,chtitl,80,nvar,chtag_out,kNchar,rmin[0],rmax[0]); |
571 |
} |
#endif |
572 |
if (hcbits[8]) h1->Sumw2(); |
#ifndef WIN32 |
573 |
TGraph *gr = 0; |
hbnam(id,PASSCHAR(" "),bigbuf[0],PASSCHAR("$CLEAR"),0,1,6); |
574 |
if (hcbits[11]) { |
#else |
575 |
gr = new TGraph(ncx); |
hbnam(id,PASSCHAR(" "),bigbuf[0],PASSCHAR("$CLEAR"),0); |
576 |
h1->GetListOfFunctions()->Add(gr); |
#endif |
577 |
} |
|
578 |
|
Int_t bufpos = 0; |
579 |
Float_t x; |
Int_t isachar = 0; |
580 |
for (i=0;i<=ncx+1;i++) { |
Int_t isabool = 0; |
581 |
x = h1->GetBinCenter(i); |
char fullname[1024]; |
582 |
h1->Fill(x,hi(id,i)); |
char name[512]; |
583 |
if (hcbits[8]) h1->SetBinError(i,hie(id,i)); |
char block[512]; |
584 |
if (gr && i>0 && i<=ncx) gr->SetPoint(i,x,hif(id,i)); |
char oldblock[512]; |
585 |
} |
Int_t nbits = 0; |
586 |
Float_t ymin, ymax; |
strcpy(oldblock,"OLDBLOCK"); |
587 |
if (hcbits[19]) { |
Int_t oldischar = -1; |
588 |
ymax = q[lcid+kMAX1]; |
for (i=80;i>0;i--) {if (chtitl[i] == ' ') chtitl[i] = 0; } |
589 |
h1->SetMaximum(ymax); |
TTree *tree = new TTree(idname,chtitl); |
590 |
} |
for(i=0; i<nvar;i++) { |
591 |
if (hcbits[20]) { |
memset(name,' ',sizeof(name)); |
592 |
ymin = q[lcid+kMIN1]; |
name[sizeof(name)-1] = 0; |
593 |
h1->SetMinimum(ymin); |
memset(block,' ',sizeof(block)); |
594 |
} |
block[sizeof(block)-1] = 0; |
595 |
h1->SetEntries(nentries); |
memset(fullname,' ',sizeof(fullname)); |
596 |
h1->Write(); |
fullname[sizeof(fullname)-1]=0; |
597 |
delete h1; |
#ifndef WIN32 |
598 |
} |
hntvar2(id,i+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem,512,1024,512); |
599 |
//____________________________________________________________________________ |
#else |
600 |
void convert_cwn(Int_t id,char* file_raw) |
hntvar2(id,i+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem); |
601 |
{ |
#endif |
602 |
const int kNchar=9; |
|
603 |
int nvar; |
for (j=510;j>0;j--) { |
604 |
int ier=0; |
if(golower) name[j] = tolower(name[j]); |
605 |
int i,j; |
if (name[j] == ' ') name[j] = 0; |
606 |
int nsub,itype,isize,ielem; |
} |
607 |
char *chtag_out; |
if (golower == 2) name[0] = tolower(name[0]); |
608 |
float *x; |
|
609 |
float rmin[1000], rmax[1000]; |
for (j=1022;j>0;j--) { |
610 |
|
if(golower && fullname[j-1] != '[') fullname[j] = tolower(fullname[j]); |
611 |
if (id > 0) sprintf(idname,"h%d",id); |
// convert also character after [, if golower == 2 |
612 |
else sprintf(idname,"h_%d",-id); |
if (golower == 2) fullname[j] = tolower(fullname[j]); |
613 |
hnoent(id,nentries); |
if (fullname[j] == ' ') fullname[j] = 0; |
614 |
printf(" Converting CWN with ID= %d, nentries = %d\n",id,nentries); |
} |
615 |
nvar=0; |
// convert also first character, if golower == 2 |
616 |
#ifndef WIN32 |
if (golower == 2) fullname[0] = tolower(fullname[0]); |
617 |
hgiven(id,chtitl,nvar,PASSCHAR(""),rmin[0],rmax[0],80,0); |
for (j=510;j>0;j--) { |
618 |
#else |
if (block[j] == ' ') block[j] = 0; |
619 |
hgiven(id,chtitl,80,nvar,PASSCHAR(""),rmin[0],rmax[0]); |
else break; |
620 |
#endif |
} |
621 |
|
if (itype == 1) { |
622 |
|
if( isize == 4 ) strcat(fullname,"/F"); |
623 |
chtag_out = new char[nvar*kNchar+1]; |
else if( isize == 8) strcat(fullname,"/D"); |
624 |
Int_t *charflag = new Int_t[nvar]; |
} |
625 |
Int_t *lenchar = new Int_t[nvar]; |
|
626 |
Int_t *boolflag = new Int_t[nvar]; |
|
627 |
Int_t *lenbool = new Int_t[nvar]; |
// add support for 1-byte (Char_t) and 2-byte (Short_t) integers |
628 |
UChar_t *boolarr = new UChar_t[10000]; |
Int_t nBytesUsed = 4; // default for integers |
629 |
x = new float[nvar]; |
|
630 |
char *bigbuf = new char[2500000]; |
if( itype == 2 ) |
631 |
|
{ |
632 |
chtag_out[nvar*kNchar]=0; |
if( optcwn == 1 ) |
633 |
for (i=0;i<80;i++)chtitl[i]=0; |
{ |
634 |
#ifndef WIN32 |
if( nbits > 16 ) |
635 |
hgiven(id,chtitl,nvar,chtag_out,rmin[0],rmax[0],80,kNchar); |
{ |
636 |
#else |
strcat(fullname,"/I"); |
637 |
hgiven(id,chtitl,80,nvar,chtag_out,kNchar,rmin[0],rmax[0]); |
} |
638 |
#endif |
else |
639 |
#ifndef WIN32 |
{ |
640 |
hbnam(id,PASSCHAR(" "),bigbuf[0],PASSCHAR("$CLEAR"),0,1,6); |
if( nbits > 8 ) |
641 |
#else |
{ |
642 |
hbnam(id,PASSCHAR(" "),bigbuf[0],PASSCHAR("$CLEAR"),0); |
strcat(fullname,"/S"); |
643 |
#endif |
nBytesUsed = 2; |
644 |
|
} |
645 |
Int_t bufpos = 0; |
else |
646 |
Int_t isachar = 0; |
{ |
647 |
Int_t isabool = 0; |
strcat(fullname,"/B"); |
648 |
char fullname[1024]; |
nBytesUsed = 1; |
649 |
char name[512]; |
} |
650 |
char block[512]; |
} |
651 |
char oldblock[512]; |
} |
652 |
Int_t nbits = 0; |
else |
653 |
strcpy(oldblock,"OLDBLOCK"); |
{ |
654 |
Int_t oldischar = -1; |
strcat(fullname,"/I"); |
655 |
for (i=80;i>0;i--) {if (chtitl[i] == ' ') chtitl[i] = 0; } |
} |
656 |
TTree *tree = new TTree(idname,chtitl); |
} |
657 |
for(i=0; i<nvar;i++) { |
|
658 |
memset(name,' ',sizeof(name)); |
// add support for 1-byte (UChar_t) and 2-byte (UShort_t) integers |
659 |
name[sizeof(name)-1] = 0; |
if ( itype == 3 ) |
660 |
memset(block,' ',sizeof(block)); |
{ |
661 |
block[sizeof(block)-1] = 0; |
if( optcwn == 1 ) |
662 |
memset(fullname,' ',sizeof(fullname)); |
{ |
663 |
fullname[sizeof(fullname)-1]=0; |
if( nbits > 16) |
664 |
#ifndef WIN32 |
{ |
665 |
hntvar2(id,i+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem,512,1024,512); |
strcat(fullname,"/i"); |
666 |
#else |
} |
667 |
hntvar2(id,i+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem); |
else |
668 |
#endif |
{ |
669 |
|
if( nbits > 8 ) |
670 |
for (j=510;j>0;j--) { |
{ |
671 |
if(golower) name[j] = tolower(name[j]); |
strcat(fullname,"/s"); |
672 |
if (name[j] == ' ') name[j] = 0; |
nBytesUsed = 2; |
673 |
} |
} |
674 |
if (golower == 2) name[0] = tolower(name[0]); |
else |
675 |
|
{ |
676 |
for (j=1022;j>0;j--) { |
strcat(fullname,"/b"); |
677 |
if(golower && fullname[j-1] != '[') fullname[j] = tolower(fullname[j]); |
nBytesUsed = 1; |
678 |
// convert also character after [, if golower == 2 |
} |
679 |
if (golower == 2) fullname[j] = tolower(fullname[j]); |
} |
680 |
if (fullname[j] == ' ') fullname[j] = 0; |
} |
681 |
} |
else |
682 |
// convert also first character, if golower == 2 |
{ |
683 |
if (golower == 2) fullname[0] = tolower(fullname[0]); |
strcat(fullname,"/i"); |
684 |
for (j=510;j>0;j--) { |
} |
685 |
if (block[j] == ' ') block[j] = 0; |
} |
686 |
else break; |
|
687 |
} |
|
688 |
if (itype == 1) { |
|
689 |
if( isize == 4 ) strcat(fullname,"/F"); |
|
690 |
else if( isize == 8) strcat(fullname,"/D"); |
// if (itype == 4) strcat(fullname,"/i"); |
691 |
} |
if (itype == 4) strcat(fullname,"/b"); |
692 |
|
if (itype == 5) strcat(fullname,"/C"); |
693 |
|
//printf("Creating branch:%s, block:%s, fullname:%s, nsub=%d, itype=%d, isize=%d, ielem=%d\n",name,block,fullname,nsub,itype,isize,ielem); |
694 |
// add support for 1-byte (Char_t) and 2-byte (Short_t) integers |
Int_t ischar; |
695 |
Int_t nBytesUsed = 4; // default for integers |
if (itype == 5) ischar = 1; |
696 |
|
else ischar = 0; |
697 |
if( itype == 2 ) |
if (ischar != oldischar || strcmp(oldblock,block) != 0) { |
698 |
{ |
strcpy(oldblock,block); |
699 |
if( optcwn == 1 ) |
oldischar = ischar; |
700 |
{ |
Int_t lblock = strlen(block); |
701 |
if( nbits > 16 ) |
Long_t add= (Long_t)&bigbuf[bufpos]; |
702 |
{ |
#ifndef WIN32 |
703 |
strcat(fullname,"/I"); |
hbnam(id,PASSCHAR(block),add,PASSCHAR("$SET"),ischar,lblock,4); |
704 |
} |
#else |
705 |
else |
hbnam(id,PASSCHAR(block),add,PASSCHAR("$SET"),ischar); |
706 |
{ |
#endif |
707 |
if( nbits > 8 ) |
|
708 |
{ |
} |
709 |
strcat(fullname,"/S"); |
TBranch *branch = tree->Branch(name,(void*)&bigbuf[bufpos],fullname,bufsize); |
710 |
nBytesUsed = 2; |
boolflag[i] = -10; |
711 |
} |
charflag[i] = 0; |
712 |
else |
if (itype == 4) {isabool++; boolflag[i] = bufpos; lenbool[i] = ielem;} |
713 |
{ |
bufpos += isize*ielem; |
714 |
strcat(fullname,"/B"); |
if (ischar) {isachar++; charflag[i] = bufpos-1; lenchar[i] = isize*ielem;} |
715 |
nBytesUsed = 1; |
TObjArray *ll= branch->GetListOfLeaves(); |
716 |
} |
TLeaf *leaf = (TLeaf*)ll->UncheckedAt(0); |
717 |
} |
if (!leaf) continue; |
718 |
} |
TLeafI *leafcount = (TLeafI*)leaf->GetLeafCount(); |
719 |
else |
if (leafcount) { |
720 |
{ |
if (leafcount->GetMaximum() <= 0) leafcount->SetMaximum(ielem); |
721 |
strcat(fullname,"/I"); |
} |
722 |
} |
} |
723 |
} |
Int_t cf,l; |
724 |
|
for(i=1;i<=nentries;i++) { |
725 |
// add support for 1-byte (UChar_t) and 2-byte (UShort_t) integers |
hgnt(id,i,ier); |
726 |
if ( itype == 3 ) |
if (isabool) { // if column is boolean |
727 |
{ |
for (j=0;j<nvar;j++) { |
728 |
if( optcwn == 1 ) |
cf = boolflag[j]; |
729 |
{ |
if (cf >-1) { |
730 |
if( nbits > 16) |
for (l=0;l<lenbool[j];l++) { |
731 |
{ |
#ifdef R__BYTESWAP |
732 |
strcat(fullname,"/i"); |
boolarr[l] = (UChar_t)bigbuf[cf+4*l]; |
733 |
} |
#else |
734 |
else |
boolarr[l] = (UChar_t)bigbuf[cf+4*l+3]; |
735 |
{ |
#endif |
736 |
if( nbits > 8 ) |
} |
737 |
{ |
memcpy(&bigbuf[cf],boolarr,lenbool[j]); |
738 |
strcat(fullname,"/s"); |
} |
739 |
nBytesUsed = 2; |
} |
740 |
} |
} |
741 |
else |
if (isachar) { // if column is character, set terminator |
742 |
{ |
for (j=0;j<nvar;j++) { |
743 |
strcat(fullname,"/b"); |
cf = charflag[j]; |
744 |
nBytesUsed = 1; |
if (cf) { |
745 |
} |
bigbuf[cf] = '\0'; |
746 |
} |
if (bigbuf[cf-1] != ' ') continue; |
747 |
} |
bigbuf[cf-1] = '\0'; |
748 |
else |
if (bigbuf[cf-2] != ' ') continue; |
749 |
{ |
bigbuf[cf-2] = '\0'; |
750 |
strcat(fullname,"/i"); |
} |
751 |
} |
} |
752 |
} |
} |
753 |
|
|
754 |
|
// if optimizing cwn ntuple then look up bufpos and adjust integers to be shorts or chars |
755 |
|
if( optcwn == 1 ) |
756 |
|
{ |
757 |
// if (itype == 4) strcat(fullname,"/i"); |
bufpos = 0; |
758 |
if (itype == 4) strcat(fullname,"/b"); |
for(int k=0; k<nvar;k++) |
759 |
if (itype == 5) strcat(fullname,"/C"); |
{ |
760 |
//printf("Creating branch:%s, block:%s, fullname:%s, nsub=%d, itype=%d, isize=%d, ielem=%d\n",name,block,fullname,nsub,itype,isize,ielem); |
#ifndef WIN32 |
761 |
Int_t ischar; |
hntvar2(id,k+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem,32,64,32); |
762 |
if (itype == 5) ischar = 1; |
#else |
763 |
else ischar = 0; |
hntvar2(id,k+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem); |
764 |
if (ischar != oldischar || strcmp(oldblock,block) != 0) { |
#endif |
765 |
strcpy(oldblock,block); |
|
766 |
oldischar = ischar; |
Int_t nBytesUsed = 4; // default for integers |
767 |
Int_t lblock = strlen(block); |
|
768 |
Long_t add= (Long_t)&bigbuf[bufpos]; |
if ( itype == 2 || itype == 3) |
769 |
#ifndef WIN32 |
{ |
770 |
hbnam(id,PASSCHAR(block),add,PASSCHAR("$SET"),ischar,lblock,4); |
if( nbits > 16) |
771 |
#else |
{ |
772 |
hbnam(id,PASSCHAR(block),add,PASSCHAR("$SET"),ischar); |
// do nothing for integers of 4 byte |
773 |
#endif |
} |
774 |
|
else |
775 |
} |
{ |
776 |
TBranch *branch = tree->Branch(name,(void*)&bigbuf[bufpos],fullname,bufsize); |
if( nbits > 8 ) |
777 |
boolflag[i] = -10; |
{ |
778 |
charflag[i] = 0; |
nBytesUsed = 2; |
779 |
if (itype == 4) {isabool++; boolflag[i] = bufpos; lenbool[i] = ielem;} |
} |
780 |
bufpos += isize*ielem; |
else |
781 |
if (ischar) {isachar++; charflag[i] = bufpos-1; lenchar[i] = isize*ielem;} |
{ |
782 |
TObjArray *ll= branch->GetListOfLeaves(); |
nBytesUsed = 1; |
783 |
TLeaf *leaf = (TLeaf*)ll->UncheckedAt(0); |
} |
784 |
if (!leaf) continue; |
} |
785 |
TLeafI *leafcount = (TLeafI*)leaf->GetLeafCount(); |
} |
786 |
if (leafcount) { |
|
787 |
if (leafcount->GetMaximum() <= 0) leafcount->SetMaximum(ielem); |
if(nBytesUsed == 1) |
788 |
} |
{ |
789 |
} |
|
790 |
Int_t cf,l; |
for(Int_t index = 0; index < ielem; index++) |
791 |
for(i=1;i<=nentries;i++) { |
{ |
792 |
hgnt(id,i,ier); |
// shift all chars with data to be one after another |
793 |
if (isabool) { // if column is boolean |
bigbuf[bufpos + index*nBytesUsed ] = bigbuf[bufpos + index * isize]; |
794 |
for (j=0;j<nvar;j++) { |
} |
795 |
cf = boolflag[j]; |
} |
796 |
if (cf >-1) { |
else |
797 |
for (l=0;l<lenbool[j];l++) { |
{ |
798 |
#ifdef R__BYTESWAP |
if(nBytesUsed == 2) |
799 |
boolarr[l] = (UChar_t)bigbuf[cf+4*l]; |
{ |
800 |
#else |
|
801 |
boolarr[l] = (UChar_t)bigbuf[cf+4*l+3]; |
for(Int_t index = 0; index < ielem; index++) |
802 |
#endif |
{ |
803 |
} |
// shift all shorts ( 2 chars) with data to be one after another |
804 |
memcpy(&bigbuf[cf],boolarr,lenbool[j]); |
bigbuf[bufpos + index*nBytesUsed ] = bigbuf[bufpos + index * isize]; |
805 |
} |
bigbuf[bufpos + index*nBytesUsed+1 ] = bigbuf[bufpos + index * isize+1]; |
806 |
} |
} |
807 |
} |
} |
808 |
if (isachar) { // if column is character, set terminator |
} |
809 |
for (j=0;j<nvar;j++) { |
bufpos += isize*ielem; |
810 |
cf = charflag[j]; |
} |
811 |
if (cf) { |
} |
812 |
bigbuf[cf] = '\0'; |
|
813 |
if (bigbuf[cf-1] != ' ') continue; |
tree->Fill(); |
814 |
bigbuf[cf-1] = '\0'; |
} |
815 |
if (bigbuf[cf-2] != ' ') continue; |
|
816 |
bigbuf[cf-2] = '\0'; |
tree->Write(); |
817 |
} |
|
818 |
} |
std::cout << "Invoking Digitizer" << endl << flush; |
819 |
} |
|
820 |
|
Digitizer* dig = new Digitizer(tree,file_raw); |
821 |
// if optimizing cwn ntuple then look up bufpos and adjust integers to be shorts or chars |
dig->Loop(); |
822 |
if( optcwn == 1 ) |
dig->Close(); |
823 |
{ |
|
824 |
bufpos = 0; |
std::cout << "Finished" << endl << flush; |
825 |
for(int k=0; k<nvar;k++) |
|
826 |
{ |
} |
827 |
#ifndef WIN32 |
|
828 |
hntvar2(id,k+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem,32,64,32); |
|
|
#else |
|
|
hntvar2(id,k+1,PASSCHAR(name),PASSCHAR(fullname),PASSCHAR(block),nsub,itype,isize,nbits,ielem); |
|
|
#endif |
|
|
|
|
|
Int_t nBytesUsed = 4; // default for integers |
|
|
|
|
|
if ( itype == 2 || itype == 3) |
|
|
{ |
|
|
if( nbits > 16) |
|
|
{ |
|
|
// do nothing for integers of 4 byte |
|
|
} |
|
|
else |
|
|
{ |
|
|
if( nbits > 8 ) |
|
|
{ |
|
|
nBytesUsed = 2; |
|
|
} |
|
|
else |
|
|
{ |
|
|
nBytesUsed = 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if(nBytesUsed == 1) |
|
|
{ |
|
|
|
|
|
for(Int_t index = 0; index < ielem; index++) |
|
|
{ |
|
|
// shift all chars with data to be one after another |
|
|
bigbuf[bufpos + index*nBytesUsed ] = bigbuf[bufpos + index * isize]; |
|
|
} |
|
|
} |
|
|
else |
|
|
{ |
|
|
if(nBytesUsed == 2) |
|
|
{ |
|
|
|
|
|
for(Int_t index = 0; index < ielem; index++) |
|
|
{ |
|
|
// shift all shorts ( 2 chars) with data to be one after another |
|
|
bigbuf[bufpos + index*nBytesUsed ] = bigbuf[bufpos + index * isize]; |
|
|
bigbuf[bufpos + index*nBytesUsed+1 ] = bigbuf[bufpos + index * isize+1]; |
|
|
} |
|
|
} |
|
|
} |
|
|
bufpos += isize*ielem; |
|
|
} |
|
|
} |
|
|
|
|
|
tree->Fill(); |
|
|
} |
|
|
|
|
|
tree->Write(); |
|
|
|
|
|
std::cout << "Invoking Digitizer" << endl << flush; |
|
|
|
|
|
Digitizer* dig = new Digitizer(tree,file_raw); |
|
|
dig->Loop(); |
|
|
dig->Close(); |
|
|
|
|
|
std::cout << "Finished" << endl << flush; |
|
|
|
|
|
} |
|
|
|
|
|
|
|