/[PAMELA software]/calo/ground/COMMON/inc/CaloFunctions.h
ViewVC logotype

Annotation of /calo/ground/COMMON/inc/CaloFunctions.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Tue Dec 13 13:40:15 2005 UTC (19 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +15 -1 lines
File MIME type: text/plain
Bug fixed in CaloFindCalibs

1 mocchiut 1.1 //
2     // Calorimeter useful functions and subroutines - Emiliano Mocchiutti
3     //
4 mocchiut 1.2 // CaloFunctions.h version 4.01 (2005-12-13)
5 mocchiut 1.1 //
6     // Programs in this file are called by other programs and cannot be run by hand.
7     //
8     // Changelog:
9     //
10 mocchiut 1.2 // 4.00 - 4.01 (2005-12-13): bug in CaloFindCalibs (do not search on other calibration files when fails to find any calibration): fixed.
11     //
12 mocchiut 1.1 // 3.10 - 4.00 (2005-11-29): preparing for the final release, changed checkemilib (PAM_YODALIB -> PAM_YODA).
13     //
14     // 3.09 - 3.10 (2005-11-15): changed langaupro since it did not work in the compiled version; changed WhatToDo to work in compiled version.
15     //
16     // 3.08 - 3.09 (2005-11-11): small changes to PrintFigure subroutine
17     //
18     // 3.07 - 3.08 (2005-10-13): classes are now in another file (caloclasses.h)
19     //
20     // 3.06 - 3.07 (2005-10-10): added subroutine ColorTOFMIP for TOF colors.
21     //
22     // 3.05 - 3.06 (2005-10-04): added subroutine getfileLEVname.
23     //
24     // 3.04 - 3.05 (2005-08-04): Fixed bugs when running on a 64 bit arch.
25     //
26     // 3.03 - 3.04 (2005-07-14): Bug in getLEVname, fixed.
27     //
28     // 3.02 - 3.03 (2005-07-13): Finally CaloFunctions.h can be compiled under ROOT! Added clones of routines in the yodautility file no needed anymore.
29     //
30     // 3.01 - 3.02 (2005-07-11): Some more tuning for the macro compilation.
31     //
32     // 3.00 - 3.01 (2005-07-06): changed getLEVname since it gave some problems when called more than once in a ROOT sesssion. Tracker structurs now placed in a tracker
33     // include file.
34     //
35     // 2.27 - 3.00 (2005-07-05): Started the tuning for the compilation of the macros. Changed order of functions, added include files for ROOT routines, fixed some
36     // implicit casting. Fixed redefinition of class constructors. Small change in the calib structure.
37     //
38     // 2.26 - 2.27 (2005-06-23): Changed class CalorimeterLevel2 and structures to add good, perr,swerr and crc infos.
39     //
40     // 2.25 - 2.26 (2005-06-16): Changed class CalorimeterLevel2 and structures to convert OBT, headc and evfile to integers.
41     //
42     // 2.24 - 2.25 (2005-06-07): Added subroutine checkifpretyodaversion to check if file is older than 050515_007 (since that file there is a new format in TMTC data).
43     //
44     // 2.23 - 2.24 (2005-06-06): Small changes in the struct "calib". Change type of CaloPede subroutine, now it is an integer and not void: return 3 if it doesn't find the
45     // calibration file.
46     //
47     // 2.22 - 2.23 (2005-05-30): Added checkmerging and fillmerging subroutines to avoid processing twice the same event.
48     //
49     // 2.21 - 2.22 (2005-05-19): Speed-up and better behaviour of CaloFindcalibs. No need to change calls to this subroutine, all internal changes.
50     //
51     // 2.20 - 2.21 (2005-05-17): Changed CaloFindCalibs in order to check also the calibration file provided if any but first check the current file.
52     //
53     // 2.19 - 2.20 (2005-05-06): Added mip to structure calib.
54     //
55     // 2.18 - 2.19 (2005-05-05): Added calorimeter class CalorimeterLevel2 and structures CaLevel1 CaLevel2. Changed getLEVname subroutines (still compatible with older version).
56     //
57     // 2.17 - 2.18 (2005-04-19): Added the old subroutine Calo1stcalib with the name Calo1stcalibOLD (to be used in ShowEvent.c).
58     //
59     // 2.16 - 2.17 (2005-04-14): Added classes for calorimeter ADC to MIP conversion. Bug fixed in CalorimeterCalibration class. CaloFindBaseRawNC subroutine added to
60     // calculate baseline from raw data without any compression. Added getEmiFile subroutine to find YODA files (equivalent of getFile in
61     // yodautility.c); sintax is similar to getFile but it doesn't crash after 1111 or 2222 files.
62     //
63     // 2.15 - 2.16 (2005-04-11): Bugs fixes in the CaloFindCalibs, fetchpreviousfile and whatnamewith subroutines. Consider the case of an OBT jump in data.
64     //
65     // 2.14 - 2.15 (2005-04-07): Changes in the CaloFindCalibs subroutine. Added CaloCompressData subroutine, some small bugs fixed.
66     //
67     // 2.13 - 2.14 (2005-04-06): Changes in the CaloFindCalibs subroutine. Added fetchpreviousfile and whatnamewith subroutines. Now
68     // the program looks for calorimeter calibrations also in previous files and associates them to data in
69     // a correct way.
70     //
71     // 2.12 - 2.13 (2005-03-17): Changes in the WhatToDo subroutine.
72     //
73     // 2.11 - 2.12 (2005-03-09): PrintFigure subroutine changed to accomplish the new "saveas" script style.
74     //
75     // 2.10 - 2.11 (2005-03-04): Changed structure CalorimeterCalibration to save also fit parameters.
76     //
77     // 2.09 - 2.10 (2005-03-02): Show calibration CRC errors (in CaloFindCalibs). Added langaupro subroutines.
78     //
79     // 2.08 - 2.09 (2005-02-28): Calorimeter calibration classes changed (required by the new CaloADC2MIP).
80     //
81     // 2.07 - 2.08 (2005-02-25): check the existence of calibration header file in CaloFindCalibs!
82     //
83     // 2.06 - 2.07 (2005-02-24): bug in CaloFindBase! DO NOT put to zero the ADC values if you can't determine the baseline!
84     //
85     // 2.05 - 2.06 (2005-02-24): CalorimeterLevel1 class must be cleared during initialization to avoid the so-called "gundam-bug".
86     //
87     // 2.04 - 2.05 (2005-02-24): Changed variable definition from C/C++ style to ROOT style (int->Int_t).
88     //
89     // 2.03 - 2.04 (2005-02-23): Mispelling in the WhatToDo subroutine, fixed.
90     //
91     // 2.02 - 2.03 (2005-02-18): Calo1stCalib call CaloPede also if we don't have all four the calorimeter calibrations.
92     //
93     // 2.01 - 2.02 (2005-02-10): "progressive number" instead of "event number" in WhatToDo subroutine.
94     //
95     // 2.00 - 2.01 (2005-02-07): Added langau fit subroutines and the PrintFigure subroutine (used in CaloPLANES mainly). Some bug fixed,
96     // added user interaction routine and getfilename and getlevname subroutines to retrieve file name and to give
97     // the level name correctly.
98     //
99     // 1.00 - 2.00 (2005-01-17): Cleanup of the code
100     //
101     #include <iostream>
102     #include <TSystem.h>
103     #include <TH1.h>
104     #include <TF1.h>
105     #include <TROOT.h>
106     #include <TStyle.h>
107     #include <TClassEdit.h>
108     #include <TObject.h>
109     #include <TList.h>
110     #include <TSystem.h>
111     #include <TSystemDirectory.h>
112     #include <TString.h>
113     #include <TFile.h>
114     #include <TClass.h>
115     #include <TCanvas.h>
116     #include <TKey.h>
117     #include <TClassTable.h>
118    
119     typedef struct Chmerge {
120     Int_t fromflag;
121     Int_t scanflag;
122     Int_t pscuOBT;
123     Int_t pscucount;
124     Int_t lastOBT[1000];
125     Int_t lastcount[1000];
126     } chmerge;
127    
128     typedef struct Evento {
129     Int_t iev;
130     Int_t stwerr[4];
131     Float_t emin;
132     Float_t perror[4];
133     Float_t dexy[2][22][96];
134     Float_t dexyc[2][22][96];
135     Double_t base[2][22][6];
136     Float_t calselftrig[4][7];
137     Float_t calIItrig[4];
138     Float_t calstriphit[4];
139     Float_t calDSPtaberr[4];
140     Float_t calevnum[4];
141     Float_t shift;
142     } evento;
143    
144     typedef struct Calib {
145     TString tablename;
146     TString basepath;
147     TString yodalev;
148     char *db;
149     Int_t DW;
150     Int_t mysql;
151     Int_t obtjump;
152     Int_t time[4][51];
153     Int_t ttime[4][51];
154     Int_t fcode[4][51];
155     Int_t iev;
156     Int_t cstwerr[4];
157     Float_t ispaw;
158     Float_t cperror[4];
159     Float_t mip[2][22][96];
160     Float_t calped[2][22][96];
161     Float_t calgood[2][22][96];
162     Float_t calthr[2][22][6];
163     Float_t calrms[2][22][96];
164     Float_t calbase[2][22][6];
165     Float_t calvar[2][22][6];
166     Float_t calpuls[2][22][96];
167     Double_t sbase[2][22][6];
168     Double_t al_p[5][2];
169     Int_t trkchi2;
170     Bool_t good2;
171     } calib;
172    
173     void emicheckLib(){
174     if (!TClassTable::GetDict("pamela::TmtcEvent")){
175     char *pamyodalib = gSystem->ExpandPathName("$PAM_YODA");
176     stringstream libYoda;
177     libYoda.str("");
178     libYoda << pamyodalib << "/lib/libyoda.so";
179     gSystem->Load(libYoda.str().c_str());
180     }
181     }
182    
183     void emidigForFiles(TList& out, TSystemDirectory *tsd, string defin){
184     const char *initialDir = gSystem->pwd();
185     TList *lnk = tsd->GetListOfFiles();
186     if (lnk==0) return;
187    
188     TSystemFile *file = (TSystemFile*)lnk->First();
189     if (file->IsZombie()) {
190     lnk->Delete();
191     gSystem->cd(initialDir);
192     return;
193     }
194    
195     string *fileDes = new string(file->GetName());
196     unsigned int loc = 0;
197     while(file){
198     fileDes = new string(file->GetName());
199     if(!((fileDes->compare(".") == 0) || (fileDes->compare("..") == 0))){
200     if (file->IsDirectory()){
201     emidigForFiles(out, (TSystemDirectory*)file, defin);
202     } else {
203     loc = fileDes->find(defin.c_str(), 0);
204     if (loc != string::npos){
205     out.AddLast((TObject*)file);
206     }
207     }
208    
209     }
210     file = (TSystemFile*)lnk->After(file);
211     }
212     gSystem->cd(initialDir);
213     }
214    
215     void emimakeAllFriend(TTree* out, TList* input){
216     TList *keys;
217     TKey *key;
218     TTree *tr;
219     string *base;
220     string *className;
221     unsigned int loc;
222     bool cont = false;
223     TSystemFile *tsf = (TSystemFile*)input->First();
224     if (tsf->IsZombie()) return;
225     while(tsf){
226     base = new string(tsf->GetTitle());
227     base->append("/");
228     base->append(tsf->GetName());
229     TFile *tf = new TFile(base->c_str());
230     if (tf->IsZombie()) {
231     tsf = (TSystemFile*)input->After(tsf);
232     continue;
233     }
234     keys = tf->GetListOfKeys();
235     key = (TKey*)keys->First();
236     while(key){
237     className = new string(key->GetClassName());
238     loc = className->find("Tree", 0);
239     if(loc != string::npos){
240     tr = (TTree*)key->ReadObj();
241     if (tr->GetEntries() > 0){
242     if(cont){
243     tr = (TTree*)key->ReadObj();
244     out->AddFriend(tr->GetName(), tf);
245     } else {
246     out = ((TTree*)key->ReadObj());
247     cont = true;
248     }
249     }
250     }
251     key = (TKey*)keys->After(key);
252     }
253    
254     tsf = (TSystemFile*)input->After(tsf);
255     }
256     }
257    
258     void emimakeAllChained(TChain& out, TList* input){
259     TList *keys;
260     TKey *key;
261     TTree *tr;
262     string *base;
263     string *className;
264     unsigned int loc;
265    
266     TSystemFile *tsf = (TSystemFile*)input->First();
267     if (tsf->IsZombie()) return;
268    
269     while(tsf){
270     base = new string(tsf->GetTitle());
271     base->append("/");
272     base->append(tsf->GetName());
273     TFile *tf = new TFile(base->c_str());
274     if (tf->IsZombie()) {
275     tsf = (TSystemFile*)input->After(tsf);
276     continue;
277     }
278    
279     keys = tf->GetListOfKeys();
280     key = (TKey*)keys->First();
281     while(key){
282     className = new string(key->GetClassName());
283     loc = className->find("Tree", 0);
284     if(loc != string::npos){
285     tr = (TTree*)key->ReadObj();
286     if (tr->GetEntries() > 0){
287     out.Add(base->c_str());
288     }
289     }
290     key = (TKey*)keys->After(key);
291     }
292     tsf = (TSystemFile*)input->After(tsf);
293     }
294     }
295    
296     TFile* emigetFile(TString base, TString packetType, TString subType = "Event"){
297     TSystemDirectory *targetDir = new TSystemDirectory("", base);
298     TList *filesList = new TList;
299     TSystemFile *tsf = 0;
300     string *tmpString = 0;
301     tmpString = new string(".");
302     tmpString->append(packetType);
303     tmpString->append(".");
304     tmpString->append(subType);
305     tmpString->append(".");
306     emidigForFiles(*filesList, targetDir, tmpString->c_str());
307     if ( filesList->IsEmpty() ) {
308     filesList->Delete();
309     return 0;
310     };
311     targetDir = new TSystemDirectory("", base);
312     tsf = (TSystemFile*)filesList->First();
313     tmpString = new string(tsf->GetTitle());
314     tmpString->append("/");
315     tmpString->append(tsf->GetName());
316     targetDir->Delete();
317     filesList->Delete();
318     return new TFile(tmpString->c_str());
319     }
320    
321     Int_t emigetLastNotZeroBin(TH1 *histo){
322     Int_t lastBin = 0;
323     Int_t tempBin = 0;
324     Stat_t minVal = 0;
325     Stat_t tempVal = 0;
326     Int_t range = histo->GetNbinsX();
327    
328     tempBin = histo->GetMaximumBin();
329     tempVal = histo->GetBinContent(tempBin);
330     minVal = tempVal;
331     lastBin = tempBin;
332    
333     for (Int_t i = histo->GetMaximumBin() + 1; i < range; i++){
334     tempVal = histo->GetBinContent(i);
335     if ((tempVal != 0) && (tempVal < minVal)) {
336     minVal = tempVal;
337     lastBin = i;
338     }
339     }
340     return (Int_t)(lastBin*1.10);
341     }
342    
343     Int_t emigetFirstNotZeroBin(TH1 *histo){
344     Int_t lastBin = 0;
345     Int_t tempBin = 0;
346     Stat_t minVal = 0;
347     Stat_t tempVal = 0;
348    
349     tempBin = histo->GetMaximumBin();
350     tempVal = histo->GetBinContent(tempBin);
351     minVal = tempVal;
352     lastBin = tempBin;
353    
354     for (Int_t i = histo->GetMaximumBin() - 1; i > 0; i--){
355     tempVal = histo->GetBinContent(i);
356     if ((tempVal != 0) && (tempVal < minVal)) {
357     minVal = tempVal;
358     lastBin = i;
359     }
360     }
361     return (Int_t)(lastBin*0.90);
362     }
363    
364     void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){
365     if ( to == 0 ){
366     Int_t t2length = s2.Length();
367     s1 = "";
368     to = t2length;
369     };
370     for (Int_t i = from; i<to; i++){
371     s1.Append(s2[i],1);
372     };
373     }
374    
375     void stringappend(TString& s1, const TString& s2){
376     Int_t t2length = s2.Length();
377     for (Int_t i = 0; i<t2length; i++){
378     s1.Append(s2[i],1);
379     };
380     }
381    
382     TFile* getEmiFile(TString base, TString packetType, TString subType="Event"){
383     //
384     TString newfile;
385     stringcopy(newfile,base);
386     //
387     const char *base2 = base;
388     stringstream fil;
389     fil.str("");
390     fil << base2;
391     Int_t posiz = fil.str().find("dw_");
392     Int_t upper = 0;
393     if ( posiz == -1 ) {
394     posiz = fil.str().find("DW_");
395     upper = 1;
396     };
397     if ( posiz == -1 ) return 0;
398     TString fullname;
399     stringcopy(fullname,base,posiz,posiz+15);
400     stringappend(fullname,".");
401     stringappend(fullname,packetType);
402     stringappend(fullname,".");
403     stringappend(fullname,subType);
404     stringappend(fullname,".root");
405     //
406     stringappend(newfile,"/");
407     stringappend(newfile,packetType);
408     stringappend(newfile,"/");
409     stringappend(newfile,fullname);
410     //
411     if ( !gSystem->IsFileInIncludePath(newfile) ){
412     return 0;
413     } else {
414     return new TFile(newfile);
415     };
416     }
417    
418     void CaloCompressData(Calib & calib, Evento & evento, Int_t l, Int_t m, Int_t pre){
419     Float_t minstrip = 100000.;
420     Float_t rms = 0.;
421     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
422     if ( calib.calgood[l][m][e] == 0. && evento.dexyc[l][m][e]-calib.calped[l][m][e] < minstrip && evento.dexyc[l][m][e] > 0.) {
423     minstrip = evento.dexyc[l][m][e]-calib.calped[l][m][e];
424     rms = calib.calthr[l][m][pre];
425     };
426     };
427     //
428     // compression
429     //
430     if ( minstrip < evento.base[l][m][pre] && minstrip != 100000.){
431     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
432     if ( evento.dexyc[l][m][e]-calib.calped[l][m][e] <= (minstrip+rms) ) evento.dexyc[l][m][e] = 0.;
433     };
434     };
435     }
436    
437     void CaloFindBase(Calib & calib, Evento & evento, Int_t l, Int_t m, Int_t pre){
438     Float_t ominstrip = 100000.;
439     Float_t orms = 0.;
440     Float_t minstrip = 100000.;
441     Float_t rms = 0.;
442     evento.base[l][m][pre] = 0.;
443     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
444     if ( calib.calgood[l][m][e] == 0. && evento.dexyc[l][m][e]-calib.calped[l][m][e] < minstrip && evento.dexyc[l][m][e] > 0.) {
445     ominstrip = minstrip;
446     minstrip = evento.dexyc[l][m][e]-calib.calped[l][m][e];
447     orms = rms;
448     rms = calib.calthr[l][m][pre];
449     };
450     if ( calib.calgood[l][m][e] == 0. && evento.dexyc[l][m][e]-calib.calped[l][m][e] < ominstrip && evento.dexyc[l][m][e]-calib.calped[l][m][e] >minstrip ) {
451     ominstrip = evento.dexyc[l][m][e]-calib.calped[l][m][e];
452     orms = calib.calthr[l][m][pre];
453     };
454     };
455     if ( minstrip != 100000. ) {
456     if ( ominstrip != 10000.) {
457     minstrip = ominstrip;
458     rms = orms;
459     };
460     Float_t strip6s = 0.;
461     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
462     if ( (evento.dexyc[l][m][e]-calib.calped[l][m][e]) >= minstrip && (evento.dexyc[l][m][e]-calib.calped[l][m][e]) <= (minstrip+rms) ) {
463     strip6s += 1.;
464     evento.base[l][m][pre] += (evento.dexyc[l][m][e] - calib.calped[l][m][e]);
465     };
466     //
467     // compression
468     //
469     if ( evento.dexyc[l][m][e]-calib.calped[l][m][e] <= (minstrip+rms) ) evento.dexyc[l][m][e] = 0.;
470     };
471     if ( strip6s >= 9. ){
472     Double_t arro = evento.base[l][m][pre]/strip6s;
473     Float_t deci = 1000.*((float)arro - float(int(arro)));
474     if ( deci < 500. ) {
475     arro = double(int(arro));
476     } else {
477     arro = 1. + double(int(arro));
478     };
479     evento.base[l][m][pre] = arro;
480     } else {
481     evento.base[l][m][pre] = 31000.;
482     };
483     } else {
484     evento.base[l][m][pre] = 31000.;
485     };
486     }
487    
488     void CaloFindBaseRaw(Calib & calib, Evento & evento, Int_t l, Int_t m, Int_t pre){
489     Float_t minstrip = 100000.;
490     Float_t rms = 0.;
491     evento.base[l][m][pre] = 0.;
492     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
493     if ( calib.calgood[l][m][e] == 0. && evento.dexy[l][m][e]-calib.calped[l][m][e] < minstrip && evento.dexy[l][m][e] > 0.) {
494     minstrip = evento.dexy[l][m][e]-calib.calped[l][m][e];
495     rms = calib.calthr[l][m][pre];
496     };
497     };
498     if ( minstrip != 100000. ) {
499     Float_t strip6s = 0.;
500     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
501     if ( (evento.dexy[l][m][e]-calib.calped[l][m][e]) >= minstrip && (evento.dexy[l][m][e]-calib.calped[l][m][e]) <= (minstrip+rms) ) {
502     strip6s += 1.;
503     evento.base[l][m][pre] += (evento.dexy[l][m][e] - calib.calped[l][m][e]);
504     };
505     //
506     // compression
507     //
508     if ( abs((int)(evento.dexy[l][m][e]-calib.calped[l][m][e])) <= (minstrip+rms) ) {
509     evento.dexyc[l][m][e] = 0.;
510     } else {
511     evento.dexyc[l][m][e] = evento.dexy[l][m][e];
512     };
513     };
514     if ( strip6s >= 9. ){
515     Double_t arro = evento.base[l][m][pre]/strip6s;
516     Float_t deci = 1000.*((float)arro - float(int(arro)));
517     if ( deci < 500. ) {
518     arro = double(int(arro));
519     } else {
520     arro = 1. + double(int(arro));
521     };
522     evento.base[l][m][pre] = arro;
523     } else {
524     evento.base[l][m][pre] = 31000.;
525     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
526     evento.dexyc[l][m][e] = evento.dexy[l][m][e];
527     };
528     };
529     } else {
530     evento.base[l][m][pre] = 31000.;
531     };
532     }
533    
534     void CaloFindBaseRawNC(Calib & calib, Evento & evento, Int_t l, Int_t m, Int_t pre){
535     Float_t minstrip = 100000.;
536     Float_t rms = 0.;
537     evento.base[l][m][pre] = 0.;
538     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
539     if ( calib.calgood[l][m][e] == 0. && evento.dexy[l][m][e]-calib.calped[l][m][e] < minstrip && evento.dexy[l][m][e] > 0.) {
540     minstrip = evento.dexy[l][m][e]-calib.calped[l][m][e];
541     rms = calib.calthr[l][m][pre];
542     };
543     };
544     if ( minstrip != 100000. ) {
545     Float_t strip6s = 0.;
546     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
547     if ( (evento.dexy[l][m][e]-calib.calped[l][m][e]) >= minstrip && (evento.dexy[l][m][e]-calib.calped[l][m][e]) <= (minstrip+rms) ) {
548     strip6s += 1.;
549     evento.base[l][m][pre] += (evento.dexy[l][m][e] - calib.calped[l][m][e]);
550     };
551     //
552     // compression
553     //
554     evento.dexyc[l][m][e] = evento.dexy[l][m][e];
555     };
556     if ( strip6s >= 9. ){
557     Double_t arro = evento.base[l][m][pre]/strip6s;
558     Float_t deci = 1000.*((float)arro - float(int(arro)));
559     if ( deci < 500. ) {
560     arro = double(int(arro));
561     } else {
562     arro = 1. + double(int(arro));
563     };
564     evento.base[l][m][pre] = arro;
565     } else {
566     evento.base[l][m][pre] = 31000.;
567     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
568     evento.dexyc[l][m][e] = evento.dexy[l][m][e];
569     };
570     };
571     } else {
572     evento.base[l][m][pre] = 31000.;
573     };
574     }
575    
576     int CaloPede(TString filename, Int_t s, Int_t atime, Calib & calib){
577     TFile *calheadFile = 0;
578     calheadFile = getEmiFile(filename, "CalibCalPed", "Header");
579     TFile *calcalibFile = 0;
580     calcalibFile = getEmiFile(filename, "CalibCalPed","Event");
581     //
582     const char *filen = 0;
583     filen = filename;
584     if ( !calheadFile || !calcalibFile ) {
585     if ( calheadFile ) calheadFile->Close();
586     if ( calcalibFile ) calcalibFile->Close();
587     printf("\n\nERROR: not able to open file: %s \n",filen);
588     return(3);
589     };
590     TTree *tr = (TTree*)calheadFile->Get("Pscu");
591     tr->AddFriend("CalibCalPed", calcalibFile);
592     pamela::CalibCalPedEvent *ce = 0;
593     pamela::PscuHeader *cph = 0;
594     pamela::EventHeader *ceh = 0;
595     tr->SetBranchAddress("Header", &ceh);
596     tr->SetBranchAddress("Event", &ce);
597     Long64_t ncalibs = tr->GetEntries();
598     for (Int_t ci = 0; ci < ncalibs ; ci++){
599     tr->GetEntry(ci);
600     cph = ceh->GetPscuHeader();
601     if ( atime == cph->GetOrbitalTime()){
602     calib.iev = ce->iev;
603     if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) {
604     for ( Int_t d=0 ; d<11 ;d++ ){
605     Int_t pre = -1;
606     for ( Int_t j=0; j<96 ;j++){
607     if ( j%16 == 0 ) pre++;
608     if ( s == 2 ){
609     calib.calped[0][2*d+1][j] = ce->calped[3][d][j];
610     calib.cstwerr[3] = ce->cstwerr[3];
611     calib.cperror[3] = ce->cperror[3];
612     calib.calgood[0][2*d+1][j] = ce->calgood[3][d][j];
613     calib.calthr[0][2*d+1][pre] = ce->calthr[3][d][pre];
614     calib.calrms[0][2*d+1][j] = ce->calrms[3][d][j];
615     calib.calbase[0][2*d+1][pre] = ce->calbase[3][d][pre];
616     calib.calvar[0][2*d+1][pre] = ce->calvar[3][d][pre];
617     };
618     if ( s == 3 ){
619     calib.calped[0][2*d][j] = ce->calped[1][d][j];
620     calib.cstwerr[1] = ce->cstwerr[1];
621     calib.cperror[1] = ce->cperror[1];
622     calib.calgood[0][2*d][j] = ce->calgood[1][d][j];
623     calib.calthr[0][2*d][pre] = ce->calthr[1][d][pre];
624     calib.calrms[0][2*d][j] = ce->calrms[1][d][j];
625     calib.calbase[0][2*d][pre] = ce->calbase[1][d][pre];
626     calib.calvar[0][2*d][pre] = ce->calvar[1][d][pre];
627     };
628     if ( s == 0 ){
629     calib.calped[1][2*d][j] = ce->calped[0][d][j];
630     calib.cstwerr[0] = ce->cstwerr[0];
631     calib.cperror[0] = ce->cperror[0];
632     calib.calgood[1][2*d][j] = ce->calgood[0][d][j];
633     calib.calthr[1][2*d][pre] = ce->calthr[0][d][pre];
634     calib.calrms[1][2*d][j] = ce->calrms[0][d][j];
635     calib.calbase[1][2*d][pre] = ce->calbase[0][d][pre];
636     calib.calvar[1][2*d][pre] = ce->calvar[0][d][pre];
637     };
638     if ( s == 1 ){
639     calib.calped[1][2*d+1][j] = ce->calped[2][d][j];
640     calib.cstwerr[2] = ce->cstwerr[2];
641     calib.cperror[2] = ce->cperror[2];
642     calib.calgood[1][2*d+1][j] = ce->calgood[2][d][j];
643     calib.calthr[1][2*d+1][pre] = ce->calthr[2][d][pre];
644     calib.calrms[1][2*d+1][j] = ce->calrms[2][d][j];
645     calib.calbase[1][2*d+1][pre] = ce->calbase[2][d][pre];
646     calib.calvar[1][2*d+1][pre] = ce->calvar[2][d][pre];
647     };
648     };
649     };
650     };
651     };
652     };
653     tr->Delete();
654     if ( calheadFile ) calheadFile->Close();
655     if ( calcalibFile ) calcalibFile->Close();
656     return(0);
657     }
658    
659     TString getFilename(const TString filename){
660     const string fil = (const char*)filename;
661     Int_t posiz = fil.find("dw_");
662     if ( posiz == -1 ) posiz = fil.find("DW_");
663     if ( posiz == -1 ) return 0;
664     Int_t posiz2 = posiz+13;
665     TString file2;
666     stringcopy(file2,filename,posiz,posiz2);
667     TString pdat(".dat");
668     stringappend(file2,pdat);
669     return file2;
670     }
671    
672     Int_t fetchpreviousfile(TString ffile, Int_t s){
673     const char *file = ffile;
674     stringstream fil;
675     fil.str("");
676     fil << file ;
677     Int_t posiz = fil.str().find("dw_");
678     Int_t upper = 0;
679     if ( posiz == -1 ) {
680     posiz = fil.str().find("DW_");
681     upper = 1;
682     };
683     if ( posiz == -1 ) return(1);
684     //
685     TString nomefile = getFilename(ffile);
686     const char *ufnome = nomefile;
687     stringstream nyear;
688     stringstream nmonth;
689     stringstream nday;
690     stringstream nfno;
691     TString year;
692     TString month;
693     TString day;
694     TString fno;
695     stringcopy(year, ufnome, 3, 5);
696     stringcopy(month, ufnome, 5, 7);
697     stringcopy(day, ufnome, 7, 9);
698     stringcopy(fno, ufnome, 10, 13);
699     const char *cyear = year;
700     const char *cmonth = month;
701     const char *cday = day;
702     const char *cfno = fno;
703     Int_t jy = atoi(cyear);
704     Int_t jm = atoi(cmonth);
705     Int_t jd = atoi(cday);
706     Int_t jn = atoi(cfno);
707     Int_t inter = 0;
708     char *zy;
709     char *zm;
710     char *zd;
711     char *zn = "";
712     char *zyn;
713     Int_t jyn = 0;
714     Int_t goodthis = 0;
715     Int_t onegood = 0;
716     Long64_t ncalibs;
717     TTree *tr;
718     pamela::CalibCalPedEvent *ce = 0;
719     pamela::PscuHeader *cph = 0;
720     pamela::EventHeader *ceh = 0;
721     if ( jn > 1 ) {
722     jn--;
723     } else {
724     jn = 999;
725     if ( jd > 1 ) {
726     jd--;
727     } else {
728     if ( jm > 1 ) {
729     jm--;
730     } else {
731     jm = 12;
732     if ( jy > 3 ) {
733     jy--;
734     } else {
735     return(1);
736     };
737     };
738     if ( jm==4 || jm==6 || jm==9 || jm==11 ){
739     jd = 30;
740     } else {
741     jd = 31;
742     };
743     if ( jm==2 ) jd = 29;
744     };
745     };
746     Int_t gday = 0;
747     Int_t retvar = 1;
748     stringstream nyd;
749     while ( jy>3 ) {
750     while ( jm>0 ){
751     while ( jd > 0 ){
752     while ( jn > 0 ){
753     retvar--;
754     nyear.str("");
755     nyear << jy;
756     if ( jy<10 ){
757     zy = "0";
758     } else {
759     zy = "";
760     };
761     nmonth.str("");
762     nmonth << jm;
763     if ( jm<10 ){
764     zm = "0";
765     } else {
766     zm = "";
767     };
768     nday.str("");
769     nday << jd;
770     if ( jd<10 ){
771     zd = "0";
772     } else {
773     zd = "";
774     };
775     nfno.str("");
776     nfno << jn;
777     if ( jn>99 ) zn = "";
778     if ( jn<100 && jn>9 ) zn = "0";
779     if ( jn<10 ) zn = "00";
780     jyn = 0;
781     goodthis = 0;
782     onegood = 0;
783     while ( jyn < 100 ){
784     begwhile:
785     nyd.str("");
786     nyd << jyn;
787     if ( jyn<10 ){
788     zyn = "0";
789     } else {
790     zyn = "";
791     };
792     stringstream nfile;
793     nfile.str("");
794     if ( upper ){
795     nfile << "DW_" << zy;
796     } else {
797     nfile << "dw_" << zy;
798     };
799     nfile << nyear.str().c_str();
800     nfile << zm;
801     nfile << nmonth.str().c_str();
802     nfile << zd;
803     nfile << nday.str().c_str() << "_";
804     nfile << zn;
805     nfile << nfno.str().c_str();
806     nfile << zyn;
807     nfile << nyd.str().c_str();
808     //
809     TString fgfile = "";
810     stringcopy(fgfile,ffile,0,posiz);
811     stringappend(fgfile,nfile.str().c_str());
812     TFile *calheadFile = 0;
813     calheadFile = getEmiFile(fgfile, "CalibCalPed", "Header");
814     TFile *calcalibFile = 0;
815     calcalibFile = getEmiFile(fgfile, "CalibCalPed","Event");
816     //
817     if ( !calheadFile || !calcalibFile ) {
818     if ( calheadFile ) calheadFile->Close();
819     if ( calcalibFile ) calcalibFile->Close();
820     if ( jyn > 0 && onegood ) {
821     goodthis = 1;
822     jyn--;
823     goto begwhile;
824     };
825     if ( jyn == 0 ) {
826     onegood = 0;
827     jyn = 100;
828     goto salta;
829     };
830     if ( jyn > 0 && !onegood ) {
831     onegood = 0;
832     jyn = 100;
833     goto salta;
834     };
835     goto salta;
836     } else {
837     onegood = 1;
838     if ( !goodthis ) {
839     calheadFile->Close();
840     calcalibFile->Close();
841     goto salta;
842     };
843     };
844     //Takes the tree of the header file
845     tr = (TTree*)calheadFile->Get("Pscu");
846     tr->AddFriend("CalibCalPed", calcalibFile);
847     tr->SetBranchAddress("Header", &ceh);
848     tr->SetBranchAddress("Event", &ce);
849     ncalibs = tr->GetEntries();
850     if ( ncalibs == 0 ) {
851     jyn = 100;
852     onegood = 0;
853     goodthis = 0;
854     calheadFile->Close();
855     calcalibFile->Close();
856     goto salta;
857     };
858     inter = 0;
859     for (Int_t c = 0; c < ncalibs; c++){
860     tr->GetEntry(c);
861     cph = ceh->GetPscuHeader();
862     if ( ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) {
863     inter++;
864     };
865     };
866     if ( inter ){
867     jyn = 100;
868     calheadFile->Close();
869     calcalibFile->Close();
870     return(retvar);
871     };
872     calheadFile->Close();
873     calcalibFile->Close();
874     salta:
875     jyn++;
876     };
877     jn--;
878     };
879     jn = 999;
880     jd--;
881     gday++;
882     if ( gday>1 ) return(1);
883     };
884     jm--;
885     if ( jm==4 || jm==6 || jm==9 || jm==11 ){
886     jd = 30;
887     } else {
888     jd = 31;
889     };
890     if ( jm==2 ) jd = 29;
891     };
892     jm = 12;
893     jy--;
894     };
895     return(retvar);
896     }
897    
898     TString whatnamewith(TString ffile, Int_t retvar){
899     Int_t debug = 0;
900     const char *file = ffile;
901     stringstream fil;
902     fil.str("");
903     fil << file ;
904     if ( debug ) printf("ffile %s retvar %i \n",file,retvar);
905     Int_t posiz = fil.str().find("dw_");
906     Int_t upper = 0;
907     if ( posiz == -1 ) {
908     posiz = fil.str().find("DW_");
909     upper = 1;
910     };
911     if ( posiz == -1 ) return("wrong");
912     //
913     // printf("posiz %i \n",posiz);
914     TString nomefile = getFilename(ffile);
915     const char *ufnome = nomefile;
916     stringstream nyear;
917     stringstream nmonth;
918     stringstream nday;
919     stringstream nfno;
920     TString year;
921     TString month;
922     TString day;
923     TString fno;
924     stringcopy(year, ufnome, 3, 5);
925     stringcopy(month, ufnome, 5, 7);
926     stringcopy(day, ufnome, 7, 9);
927     stringcopy(fno, ufnome, 10, 13);
928     const char *cyear = year;
929     const char *cmonth = month;
930     const char *cday = day;
931     const char *cfno = fno;
932     Int_t jy = atoi(cyear);
933     Int_t jm = atoi(cmonth);
934     Int_t jd = atoi(cday);
935     Int_t jn = atoi(cfno);
936     Int_t jyn = 0;
937     Int_t goodthis = 0;
938     Int_t onegood = 0;
939     char *zy;
940     char *zm;
941     char *zd;
942     char *zn = "";
943     char *zyn;
944     Long64_t ncalibs;
945     TString fgfile;
946     TTree *tr;
947     TFile *calheadFile = 0;
948     TFile *calcalibFile = 0;
949     if ( jn > 1 ) {
950     jn--;
951     } else {
952     jn = 999;
953     if ( jd > 1 ) {
954     jd--;
955     } else {
956     if ( jm > 1 ) {
957     jm--;
958     } else {
959     jm = 12;
960     if ( jy > 3 ) {
961     jy--;
962     } else {
963     return("wrong");
964     };
965     };
966     if ( jm==4 || jm==6 || jm==9 || jm==11 ){
967     jd = 30;
968     } else {
969     jd = 31;
970     };
971     if ( jm==2 ) jd = 29;
972     };
973     };
974     Int_t retval = 1;
975     Int_t gday = 0;
976     stringstream nyd;
977     while ( jy>3 ) {
978     while ( jm>0 ){
979     while ( jd > 0 ){
980     while ( jn > 0 ){
981     retval--;
982     if ( retval < retvar ) return("wrong");
983     nyear.str("");
984     nyear << jy;
985     if ( jy<10 ){
986     zy = "0";
987     } else {
988     zy = "";
989     };
990     nmonth.str("");
991     nmonth << jm;
992     if ( jm<10 ){
993     zm = "0";
994     } else {
995     zm = "";
996     };
997     nday.str("");
998     nday << jd;
999     if ( jd<10 ){
1000     zd = "0";
1001     } else {
1002     zd = "";
1003     };
1004     nfno.str("");
1005     nfno << jn;
1006     if ( jn>99 ) zn = "";
1007     if ( jn<100 && jn>9 ) zn = "0";
1008     if ( jn<10 ) zn = "00";
1009     jyn = 0;
1010     goodthis = 0;
1011     onegood = 0;
1012     while ( jyn < 100 ){
1013     begwhile:
1014     nyd.str("");
1015     nyd << jyn;
1016     if ( jyn<10 ){
1017     zyn = "0";
1018     } else {
1019     zyn = "";
1020     };
1021     stringstream nfile;
1022     nfile.str("");
1023     if ( upper ){
1024     nfile << "DW_" << zy;
1025     } else {
1026     nfile << "dw_" << zy;
1027     };
1028     nfile << nyear.str().c_str();
1029     nfile << zm;
1030     nfile << nmonth.str().c_str();
1031     nfile << zd;
1032     nfile << nday.str().c_str() << "_";
1033     nfile << zn;
1034     nfile << nfno.str().c_str();
1035     nfile << zyn;
1036     nfile << nyd.str().c_str();
1037     //
1038     fgfile = "";
1039     stringcopy(fgfile,ffile,0,posiz);
1040     stringappend(fgfile,nfile.str().c_str());
1041     const char *tosee = fgfile;
1042     if ( debug ) printf("file: %s retval %i retvar %i \n",tosee,retval,retvar);
1043     calheadFile = getEmiFile(fgfile, "CalibCalPed", "Header");
1044     calcalibFile = getEmiFile(fgfile, "CalibCalPed","Event");
1045     //
1046     if ( !calheadFile || !calcalibFile ) {
1047     if ( calheadFile ) calheadFile->Close();
1048     if ( calcalibFile ) calcalibFile->Close();
1049     if ( jyn > 0 && onegood ) {
1050     goodthis = 1;
1051     jyn--;
1052     goto begwhile;
1053     };
1054     if ( jyn == 0 ) {
1055     onegood = 0;
1056     jyn = 100;
1057     goto salta;
1058     };
1059     if ( jyn > 0 && !onegood ) {
1060     onegood = 0;
1061     jyn = 100;
1062     goto salta;
1063     };
1064     goto salta;
1065     } else {
1066     onegood = 1;
1067     if ( !goodthis ){
1068     calheadFile->Close();
1069     calcalibFile->Close();
1070     goto salta;
1071     };
1072     };
1073     tr = (TTree*)calheadFile->Get("Pscu");
1074     tr->AddFriend("CalibCalPed", calcalibFile);
1075     ncalibs = tr->GetEntries();
1076     if ( ncalibs == 0 ) {
1077     jyn = 100;
1078     onegood = 0;
1079     goodthis = 0;
1080     calheadFile->Close();
1081     calcalibFile->Close();
1082     goto salta;
1083     };
1084     calheadFile->Close();
1085     calcalibFile->Close();
1086     if ( retval == retvar ) return(fgfile);
1087     salta:
1088     jyn++;
1089     };
1090     jn--;
1091     };
1092     jn = 999;
1093     jd--;
1094     gday++;
1095     if ( gday>7 ) return("wrong");
1096     };
1097     jm--;
1098     if ( jm==4 || jm==6 || jm==9 || jm==11 ){
1099     jd = 30;
1100     } else {
1101     jd = 31;
1102     };
1103     if ( jm==2 ) jd = 29;
1104     };
1105     jm = 12;
1106     jy--;
1107     };
1108     return("wrong");
1109     }
1110    
1111     char *getLEVname(TString filename, TString detc, TString numb, TString frame="root"){
1112     // char *file;
1113     stringstream file;
1114     file.str("");
1115     const char *num = numb;
1116     const char *det = detc;
1117     const char *fra = frame;
1118     string fil = (const char *)filename;
1119     Int_t posiz = fil.find("dw_");
1120     if ( posiz == -1 ) posiz = fil.find("DW_");
1121     if ( posiz == -1 ) return(0);
1122     Int_t spos = posiz;
1123     Int_t epos = posiz+15;
1124     TString tmptempf;
1125     stringcopy(tmptempf,filename,spos,epos);
1126     const char *tempf = tmptempf;
1127     file << tempf << ".Physics.Level";
1128     file << num << ".";
1129     file << det << ".Event.";
1130     file << fra;
1131     const char *rfile = file.str().c_str();
1132     return((char*)rfile);
1133     };
1134    
1135     char *getfileLEVname(TString filename, TString detc, TString numb, TString frame="root"){
1136     // char *file;
1137     stringstream file;
1138     const char *num = numb;
1139     const char *det = detc;
1140     const char *fra = frame;
1141     string fil = (const char *)filename;
1142     Int_t posiz = fil.find("dw_");
1143     if ( posiz == -1 ) posiz = fil.find("DW_");
1144     if ( posiz == -1 ) return(0);
1145     Int_t spos = posiz;
1146     Int_t epos = posiz+13;
1147     TString tmptempf;
1148     stringcopy(tmptempf,filename,spos,epos);
1149     const char *tempf = tmptempf;
1150     file.str("");
1151     file << tempf << ".Physics.Level";
1152     // file << "00.Physics.Level";
1153     file << num << ".";
1154     file << det << ".Event.";
1155     file << fra;
1156     const char *rfile = file.str().c_str();
1157     return((char*)rfile);
1158     };
1159    
1160     void OLDCaloFindCalibs(TString &filename, Calib & calib){
1161     for (Int_t s = 0; s < 4; s++){
1162     for (Int_t d = 1; d<50; d++){
1163     calib.ttime[s][d] = 0;
1164     if ( d < 49 ) calib.time[s][d] = 0;
1165     };
1166     };
1167     TFile *calheadFile = 0;
1168     calheadFile = getEmiFile(filename, "CalibCalPed", "Header");
1169     TFile *calcalibFile = 0;
1170     calcalibFile = getEmiFile(filename, "CalibCalPed","Event");
1171     //
1172     if ( !calheadFile || !calcalibFile ) {
1173     if ( calheadFile ) calheadFile->Close();
1174     if ( calcalibFile ) calcalibFile->Close();
1175     printf("No calibration header file! Exiting...\n");
1176     return;
1177     };
1178     //Takes the tree of the header file
1179     TTree *tr = (TTree*)calheadFile->Get("Pscu");
1180     tr->AddFriend("CalibCalPed", calcalibFile);
1181     pamela::CalibCalPedEvent *ce = 0;
1182     pamela::PscuHeader *cph = 0;
1183     pamela::EventHeader *ceh = 0;
1184     tr->SetBranchAddress("Header", &ceh);
1185     tr->SetBranchAddress("Event", &ce);
1186     Long64_t ncalibs = tr->GetEntries();
1187     Int_t inter;
1188     for (Int_t s = 0; s < 4; s++){
1189     for (Int_t d = 1; d<50; d++){
1190     calib.ttime[s][d] = 0;
1191     if ( d < 49 ) calib.time[s][d] = 0;
1192     };
1193     };
1194     for (Int_t s = 0; s < 4; s++){
1195     inter = 0;
1196     for (Int_t c = 0; c < ncalibs; c++){
1197     tr->GetEntry(c);
1198     cph = ceh->GetPscuHeader();
1199     calib.ttime[s][inter] = 0;
1200     if ( ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) {
1201     calib.ttime[s][inter] = cph->GetOrbitalTime();
1202     inter++;
1203     } else {
1204     if ( ce->cstwerr[s] != 0 && ce->cperror[s] != 0 ) {
1205     printf(" ERROR: entry %i stwerr %X perror %f \n",c,ce->cstwerr[s],ce->cperror[s]);
1206     };
1207     };
1208     };
1209     if ( inter == 0 ){
1210     printf(" ERROR: no suitable calibration for section %i in this file!\n",s);
1211     };
1212     for (Int_t d = 1; d<50; d++){
1213     if ( calib.ttime[s][d] != 0 ) {
1214     calib.time[s][d-1] = calib.ttime[s][d-1] + (int)((calib.ttime[s][d] - calib.ttime[s][d-1])/2.);
1215     } else {
1216     if ( d == 1 ) {
1217     calib.time[s][d-1] = 0;
1218     };
1219     };
1220     };
1221     };
1222     calheadFile->Close();
1223     calcalibFile->Close();
1224     }
1225    
1226     void CaloFindCalibs(TString &filename, TString &calibfile, Int_t &wused, Calib & calib){
1227     //
1228     // First of all check if the file has a monotone growing OBT time function.
1229     //
1230     Int_t debug = 0;
1231     Int_t obtjump = 0;
1232     Int_t evjump[50];
1233     Int_t OBT = 0;
1234     Int_t OOBT = 0;
1235     Int_t OBT1 = 0;
1236     Int_t LOBT = 0;
1237     pamela::PscuHeader *ph = 0;
1238     pamela::EventHeader *eh = 0;
1239     TFile *headerF = 0;
1240     headerF = emigetFile(filename, "Physics", "Header");
1241     if ( !headerF ) {
1242     printf(" No physics file! \n ");
1243     return;
1244     };
1245     TTree *ctr = (TTree*)headerF->Get("Pscu");
1246     Long64_t nevents = ctr->GetEntries();
1247     if ( nevents == 0 ) {
1248     printf(" The file is empty! \n ");
1249     return;
1250     };
1251     for (Int_t i = 0; i < nevents; i++){
1252     ctr->SetBranchAddress("Header", &eh);
1253     ctr->GetEntry(i);
1254     ph = eh->GetPscuHeader();
1255     OBT = ph->GetOrbitalTime();
1256     if ( !i ) OBT1 = OBT;
1257     if ( i == nevents-1 ) LOBT = OBT;
1258     if ( OOBT > OBT ) {
1259     evjump[obtjump] = i;
1260     obtjump++;
1261     };
1262     OOBT = OBT;
1263     };
1264     printf("\n Obtjump = %i - FIRST OBT %i - LAST OBT %i \n\n",obtjump,OBT1,LOBT);
1265     //
1266     TTree *tr;
1267     pamela::CalibCalPedEvent *ce = 0;
1268     pamela::PscuHeader *cph = 0;
1269     pamela::EventHeader *ceh = 0;
1270     Long64_t ncalibs;
1271     //
1272     for (Int_t s = 0; s < 4; s++){
1273     for (Int_t d = 1; d<50; d++){
1274     calib.ttime[s][d] = 0;
1275     if ( d < 49 ) calib.time[s][d] = 0;
1276     };
1277     };
1278     for (Int_t s = 0; s < 4; s++){
1279     //
1280     Int_t firstlook = 0;
1281     repeatsearch:
1282     //
1283     Int_t inter = 0;
1284     TFile *calheadFile = 0;
1285     calheadFile = getEmiFile(filename, "CalibCalPed", "Header");
1286     TFile *calcalibFile = 0;
1287     calcalibFile = getEmiFile(filename, "CalibCalPed","Event");
1288     //
1289     if ( !calheadFile || !calcalibFile ) {
1290     if ( calheadFile ) calheadFile->Close();
1291     if ( calcalibFile ) calcalibFile->Close();
1292     printf(" No calibration in this file! \n");
1293     if ( !firstlook ){
1294     wused = 2;
1295     filename = calibfile;
1296     firstlook = 1;
1297     goto repeatsearch;
1298     } else {
1299     wused = 0;
1300     goto jte;
1301     };
1302     };
1303     wused = 1;
1304     //Takes the tree of the header file
1305     tr = (TTree*)calheadFile->Get("Pscu");
1306     tr->AddFriend("CalibCalPed", calcalibFile);
1307     tr->SetBranchAddress("Header", &ceh);
1308     tr->SetBranchAddress("Event", &ce);
1309     //
1310     ncalibs = tr->GetEntries();
1311     calib.obtjump = 0;
1312     inter = 0;
1313     for (Int_t c = 0; c < ncalibs; c++){
1314     tr->GetEntry(c);
1315     cph = ceh->GetPscuHeader();
1316     calib.ttime[s][inter] = 0;
1317     if ( ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) {
1318     calib.ttime[s][inter] = cph->GetOrbitalTime();
1319     inter++;
1320     } else {
1321     if ( ce->cstwerr[s] != 0 && ce->cperror[s] != 0 ) {
1322     printf(" ERROR: entry %i stwerr %X perror %f \n",c,ce->cstwerr[s],ce->cperror[s]);
1323     };
1324     };
1325     };
1326     jte:
1327     if ( inter == 0 ){
1328     printf(" WARNING: no suitable calibration for section %i in this file!\n",s);
1329     printf(" I WILL SEARCH IN PREVIOUS FILES\n");
1330 mocchiut 1.2 if ( !firstlook ){
1331     wused = 2;
1332     filename = calibfile;
1333     firstlook = 1;
1334     goto repeatsearch;
1335     };
1336 mocchiut 1.1 };
1337     if ( inter > 50 ){
1338     printf(" WARNING: cannot handle more than 50 calibrations for file!\n");
1339     printf(" I WILL SEARCH IN PREVIOUS FILES\n");
1340     inter = 0;
1341 mocchiut 1.2 if ( !firstlook ){
1342     wused = 2;
1343     filename = calibfile;
1344     firstlook = 1;
1345     goto repeatsearch;
1346     };
1347 mocchiut 1.1 };
1348     if ( obtjump ){
1349     calib.obtjump = 1;
1350     printf(" ERROR: jump in OBT! CPU restarded? \n");
1351     printf(" WARNING: I will use only the first calibration (if any)\n");
1352     };
1353     //
1354     Int_t lastcal = 0;
1355     Int_t of = 0;
1356     if ( OBT1 < calib.ttime[s][0] || !inter ) {
1357     //
1358     // here we must look for a calibration in the previous file...
1359     //
1360     TString ffile = "";
1361     stringcopy(ffile,filename);
1362     Int_t fcodep = fetchpreviousfile(ffile,s);
1363     if ( fcodep == 1 ) {
1364     if ( inter ){
1365     of = -3;
1366     printf(" WARNING: Problems to find a good calibration for section %i \n",s);
1367     } else {
1368     of = -2;
1369     printf(" ERROR: I was not able to find any good calibration for section %i \n",s);
1370     };
1371     } else {
1372     stringcopy(ffile,filename);
1373     TString pfile = whatnamewith(ffile,fcodep);
1374     struct Calib tcal;
1375     OLDCaloFindCalibs(pfile,tcal);
1376     for ( Int_t d = 0; d<51; d++ ){
1377     if ( tcal.ttime[s][d] == 0 ){
1378     lastcal = d-1;
1379     break;
1380     };
1381     };
1382     if ( !inter ){
1383     calib.ttime[s][0] = tcal.ttime[s][lastcal];
1384     calib.time[s][0] = OBT1;
1385     calib.time[s][1] = LOBT;
1386     calib.fcode[s][0] = fcodep;
1387     if ( debug ) printf("boh! %i \n",fcodep);
1388     if ( debug ) getchar();
1389     of = -1;
1390     } else {
1391     if ( obtjump ){
1392     if ( debug ) printf("boh2! %i \n",fcodep);
1393     if ( debug ) getchar();
1394     inter = 1;
1395     calib.time[s][0] = OBT1;
1396     calib.time[s][1] = LOBT;
1397     calib.fcode[s][0] = 10;
1398     of = -5;
1399     for (Int_t d = 1; d<50; d++){
1400     calib.ttime[s][d] = 0;
1401     if ( d>1 && d<49 ) calib.time[s][d] = 0;
1402     };
1403     } else {
1404     if ( lastcal >= 0 && tcal.ttime[s][lastcal]<OBT1 && (OBT1-tcal.ttime[s][lastcal])<7200000 && (OBT1-tcal.ttime[s][lastcal])>0 ){
1405     for (Int_t i = inter+1; i>0; i--){
1406     calib.ttime[s][i] = calib.ttime[s][i-1];
1407     };
1408     calib.time[s][0] = OBT1;
1409     calib.ttime[s][0] = tcal.ttime[s][lastcal];
1410     calib.fcode[s][0] = fcodep;
1411     of = 2;
1412     } else {
1413     calib.time[s][0] = OBT1;
1414     calib.fcode[s][0] = 10;
1415     of = 1;
1416     };
1417     };
1418     };
1419     };
1420     } else {
1421     of = 0;
1422     };
1423     if ( debug ) printf("boh3! %i \n",of);
1424     Int_t of1 = 0;
1425     if ( inter && of != 0 && of != 2 && of != -2 && of != -5) {
1426     for (Int_t i = inter+1; i>0; i--){
1427     calib.ttime[s][i] = calib.ttime[s][i-1];
1428     };
1429     of1 = 0;
1430     };
1431     if ( of == -2 ) of = -1;
1432     if ( of == -3 ) {
1433     of = 1;
1434     calib.fcode[s][0] = 10;
1435     };
1436     //
1437     if ( of != -1 && of != -5 ){
1438     if ( of == 2 ) of = 1;
1439     for (Int_t d = 0; d<inter+1; d++){
1440     calib.time[s][d+of] = calib.ttime[s][d+of];
1441     calib.fcode[s][d+of] = 10;
1442     if ( d == inter ){
1443     if ( debug ) printf("boh4! %i \n",of);
1444     calib.time[s][d+of1+of] = LOBT;
1445     calib.fcode[s][d+of] = 0;
1446     };
1447     };
1448     };
1449     if ( calheadFile ) calheadFile->Close();
1450     if ( calcalibFile ) calcalibFile->Close();
1451     };
1452     }
1453    
1454     void Calo1stcalib(TString filename, Calib & calib, Int_t b[4]){
1455     Float_t estrip[2][22][96];
1456     //
1457     // this is the value of the mip for each strip. To be changed when we will have the real values
1458     //
1459     for (Int_t s=0; s<4;s++){
1460     for (Int_t d = 0; d<50; d++){
1461     calib.ttime[s][d] = 0 ;
1462     if ( d < 49 ) calib.time[s][d] = 0 ;
1463     };
1464     };
1465     for (Int_t m = 0; m < 2 ; m++ ){
1466     for (Int_t k = 0; k < 22; k++ ){
1467     for (Int_t l = 0; l < 96; l++ ){
1468     calib.calped[m][k][l] = 0. ;
1469     estrip[m][k][l] = 0.;
1470     };
1471     };
1472     }
1473     //
1474     // first of all find the calibrations in the file
1475     //
1476     OLDCaloFindCalibs(filename, calib);
1477     //
1478     // print on the screen the results:
1479     //
1480     printf(" ---------------------------------------------------------- \n \n");
1481     Int_t calibex = 0;
1482     for (Int_t s=0; s<4;s++){
1483     Int_t stop = 0;
1484     for (Int_t d = 0; d<48; d++){
1485     if ( calib.ttime[s][d] != 0 ) calibex++;
1486     if ( calib.time[s][0] != 0 ){
1487     if ( d == 0 ) printf(" Section %i from time 0 to time %i use calibration at time %i \n",s,calib.time[s][d],calib.ttime[s][d]);
1488     if ( calib.time[s][d+1] != 0 ) {
1489     printf(" Section %i from time %i to time %i use calibration at time %i \n",s,calib.time[s][d],calib.time[s][d+1],calib.ttime[s][d+1]);
1490     } else {
1491     if ( !stop ){
1492     printf(" Section %i from time %i use calibration at time %i \n",s,calib.time[s][d],calib.ttime[s][d+1]);
1493     stop = 1;
1494     };
1495     };
1496     } else {
1497     if ( calib.ttime[s][d] != 0 ) printf(" Section %i from time 0 use calibration at time %i \n",s,calib.ttime[s][d]);
1498     };
1499     };
1500     printf("\n");
1501     };
1502     printf(" ---------------------------------------------------------- \n");
1503     if ( calibex < 1 ) {
1504     printf("No full calibration data in this file, sorry!\n");
1505     } else {
1506     //
1507     // calibrate before starting
1508     //
1509     for (Int_t s = 0; s < 4; s++){
1510     b[s]=0;
1511     CaloPede(filename,s,calib.ttime[s][b[s]],calib);
1512     };
1513     };
1514     }
1515    
1516    
1517     void ColorMIP(Float_t mip, int& colo){
1518     // printf("mip = %f \n",mip);
1519     if ( colo > 0 ){
1520     colo = 10;
1521     if ( mip > 0.7 ) colo = 38;
1522     if ( mip > 2. ) colo = 4;
1523     if ( mip > 10. ) colo = 3;
1524     if ( mip > 100. ) colo = 2;
1525     if ( mip > 500. ) colo = 6;
1526     } else {
1527     colo = 10;
1528     if ( mip > 0.7 ) colo = 17;
1529     if ( mip > 2. ) colo = 15;
1530     if ( mip > 10. ) colo = 14;
1531     if ( mip > 100. ) colo = 13;
1532     if ( mip > 500. ) colo = 12;
1533     };
1534     }
1535    
1536     void ColorTOFMIP(Float_t mip, int& colo){
1537     // printf("mip = %f \n",mip);
1538     if ( colo > 0 ){
1539     colo = 10;
1540     if ( mip > 0. ) colo = 38;
1541     if ( mip > 2. ) colo = 4;
1542     if ( mip > 10. ) colo = 3;
1543     if ( mip > 100. ) colo = 2;
1544     if ( mip > 500. ) colo = 6;
1545     } else {
1546     colo = 10;
1547     if ( mip > 0. ) colo = 17;
1548     if ( mip > 2. ) colo = 15;
1549     if ( mip > 10. ) colo = 14;
1550     if ( mip > 100. ) colo = 13;
1551     if ( mip > 500. ) colo = 12;
1552     };
1553     }
1554    
1555     Int_t WhatToDo(int& i, int& doflag, int& jumpto, Long64_t nevents, Float_t lastevno, Float_t firstevno, const char *file, TString outDir, TString figty, TCanvas &figure) {
1556     char *bw;
1557     if ( jumpto == -1 ){
1558     bw = "bw";
1559     } else {
1560     bw = "";
1561     };
1562     jumpto = 0;
1563     char tellme[256];
1564     stringstream input;
1565     char tellme2[256];
1566     stringstream input2;
1567     char tellme3[256];
1568     stringstream input3;
1569     stringstream out;
1570     out.str("x");
1571     input2.str("zzzzzzzzzzzzzz");
1572     input3.str("z");
1573     input << out.str().c_str();
1574     stringstream stc;
1575     stringstream stc2;
1576     while ( !strcmp(input.str().c_str(),out.str().c_str()) ) {
1577     printf("\nPress <enter> to continue, b<enter> to go backward, j<enter> to jump to a\nparticular event number, p<enter> to save the figure, q<enter> to quit: \n");
1578     cin.getline(tellme,256);
1579     //
1580     input.str("");
1581     input << tellme;
1582     out << "y";
1583     //
1584     stc.str("b");
1585     //
1586     if ( !strcmp(input.str().c_str(),stc.str().c_str()) ) {
1587     if ( i > 0 ) {
1588     printf("WARNING: going backward!\n\n");
1589     doflag = 2;
1590     } else {
1591     printf("This is the first event, you can't go backward! \n");
1592     out.str("");
1593     out << input.str().c_str();
1594     };
1595     };
1596     stc.str("j");
1597     if ( !strcmp(input.str().c_str(),stc.str().c_str()) ) {
1598     printf("\n Do you want to jump to a progressive number [p] or to an event number [e]? ");
1599     cin.getline(tellme3,256);
1600     input3.str("");
1601     input3 << tellme3;
1602     stc.str("p");
1603     if ( !strcmp(input3.str().c_str(),stc.str().c_str()) ) {
1604     printf("\n Enter the progressive number you want to jump to: ");
1605     cin.getline(tellme2,256);
1606     input2.str("");
1607     input2 << tellme2;
1608     Int_t j;
1609     j = atoi(input2.str().c_str());
1610     if ( j < 1 || j > nevents+1 ) {
1611     printf("\n You can choose between 1 and %i \n",(int)nevents+1);
1612     out.str("");
1613     out << input.str().c_str();
1614     } else {
1615     printf("\n Jumping to progressive number %i\n\n",j);
1616     i = j-2;
1617     };
1618     };
1619     stc.str("e");
1620     if ( !strcmp(input3.str().c_str(),stc.str().c_str()) ) {
1621     printf("\n Enter the event number you want to jump to: ");
1622     cin.getline(tellme2,256);
1623     input2.str("");
1624     input2 << tellme2;
1625     Int_t j;
1626     j = atoi(input2.str().c_str());
1627     if ( j < firstevno || j > lastevno ) {
1628     printf("\n You can choose between %i and %i \n",(int)firstevno,(int)lastevno);
1629     out.str("");
1630     out << input.str().c_str();
1631     } else {
1632     printf("\n Jumping to event number %i\n\n",j);
1633     jumpto = j;
1634     i = -1;
1635     };
1636     };
1637     stc.str("e");
1638     stc2.str("p");
1639     if ( strcmp(input3.str().c_str(),stc.str().c_str()) && strcmp(input3.str().c_str(),stc2.str().c_str()) ) {
1640     printf(" You must type or \"p\" or \"e\"\n");
1641     out.str("");
1642     out << input.str().c_str();
1643     };
1644     };
1645     //
1646     stc.str("q");
1647     if ( !strcmp(input.str().c_str(),stc.str().c_str()) ) {
1648     printf("Exiting...\n");
1649     return(1);
1650     };
1651     //
1652     stc.str("p");
1653     if ( !strcmp(input.str().c_str(),stc.str().c_str()) ) {
1654     printf("Enter a file extension recognized by ROOT (ps, eps, gif,...):\n");
1655     cin.getline(tellme2,256);
1656     input2.str("");
1657     input2 << tellme2;
1658     out.str("");
1659     out << input.str().c_str();
1660     //
1661     TString filename = file;
1662     const string fil = (const char*)filename;
1663     Int_t posiz = fil.find("dw_");
1664     if ( posiz == -1 ) posiz = fil.find("DW_");
1665     Int_t posiz2 = posiz+13;
1666     TString file2;
1667     stringcopy(file2,filename,posiz,posiz2);
1668     const char *figrec = file2;
1669     const char *outdir = outDir;
1670     stringstream figsave;
1671     const char *ty = figty;
1672     figsave.str("");
1673     figsave << outdir << "/";
1674     figsave << ty << "_";
1675     figsave << (i+1) << "_";
1676     figsave << figrec;
1677     figsave << bw << ".";
1678     figsave << input2.str().c_str();
1679     figure.SaveAs(figsave.str().c_str());
1680     printf("\n");
1681     };
1682     };
1683     return(0);
1684     }
1685    
1686     void PrintFigure(TString filename, TString outDir, TString figty, TString saveas, TCanvas& figure) {
1687     const string fil = (const char*)filename;
1688     Int_t posiz = fil.find("dw_");
1689     if ( posiz == -1 ) posiz = fil.find("DW_");
1690     Int_t posiz2 = posiz+13;
1691     TString file2;
1692     stringcopy(file2,filename,posiz,posiz2);
1693     //
1694     const char *figrec = file2;
1695     stringstream figsave;
1696     figsave.str("");
1697     figsave << outDir.Data() << "/";
1698     figsave << figrec << "_";
1699     figsave << figty.Data() << ".";
1700     figsave << saveas.Data();
1701     figure.SaveAs(figsave.str().c_str());
1702     return;
1703     }
1704    
1705     Double_t langaufun(Double_t *x, Double_t *par) {
1706     // Numeric constants
1707     Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
1708     Double_t mpshift = -0.22278298; // Landau maximum location
1709     // Control constants
1710     Double_t np = 100.0; // number of convolution steps
1711     Double_t sc = 3.; // convolution extends to +-sc Gaussian sigmas
1712     // Variables
1713     Double_t xx;
1714     Double_t mpc;
1715     Double_t fland;
1716     Double_t sum = 0.0;
1717     Double_t xlow,xupp;
1718     Double_t step;
1719     Double_t i;
1720     // MP shift correction
1721     mpc = par[1] - mpshift * par[0];
1722     // Range of convolution integral
1723     xlow = x[0] - sc * par[3];
1724     xupp = x[0] + sc * par[3];
1725     step = (xupp-xlow) / np;
1726     // Convolution integral of Landau and Gaussian by sum
1727     for(i=1.0; i<=np/2; i++) {
1728     xx = xlow + (i-.5) * step;
1729     fland = TMath::Landau(xx,mpc,par[0]) / par[0];
1730     sum += fland * TMath::Gaus(x[0],xx,par[3]);
1731     xx = xupp - (i-.5) * step;
1732     fland = TMath::Landau(xx,mpc,par[0]) / par[0];
1733     sum += fland * TMath::Gaus(x[0],xx,par[3]);
1734     };
1735     return (par[2] * step * sum * invsq2pi / par[3]);
1736     }
1737    
1738    
1739    
1740     TF1 *langaufit(TH1F *his, Double_t *fitrange, Double_t *startvalues, Double_t *parlimitslo, Double_t *parlimitshi, Double_t *fitparams, Double_t *fiterrors, Double_t *ChiSqr, Int_t *NDF, TString drw="QR0"){
1741     // Once again, here are the Landau * Gaussian parameters:
1742     // par[0]=Width (scale) parameter of Landau density
1743     // par[1]=Most Probable (MP, location) parameter of Landau density
1744     // par[2]=Total area (integral -inf to inf, normalization constant)
1745     // par[3]=Width (sigma) of convoluted Gaussian function
1746     //
1747     // Variables for langaufit call:
1748     // his histogram to fit
1749     // fitrange[2] lo and hi boundaries of fit range
1750     // startvalues[4] reasonable start values for the fit
1751     // parlimitslo[4] lower parameter limits
1752     // parlimitshi[4] upper parameter limits
1753     // fitparams[4] returns the final fit parameters
1754     // fiterrors[4] returns the final fit errors
1755     // ChiSqr returns the chi square
1756     // NDF returns ndf
1757     Int_t i;
1758     Char_t FunName[100];
1759     sprintf(FunName,"Fitfcn_%s",his->GetName());
1760     //
1761     TF1 *ffitold = (TF1*)gROOT->GetListOfFunctions()->FindObject(FunName);
1762     if (ffitold) delete ffitold;
1763     //
1764     TF1 *ffit = new TF1(FunName,langaufun,fitrange[0],fitrange[1],4);
1765     ffit->SetParameters(startvalues);
1766     ffit->SetParNames("Width","MP","Area","GSigma");
1767     //
1768     for (i=0; i<4; i++) {
1769     ffit->SetParLimits(i, parlimitslo[i], parlimitshi[i]);
1770     };
1771     his->Fit(FunName,drw); // fit within specified range, use ParLimits, do not plot
1772     //
1773     ffit->GetParameters(fitparams); // obtain fit parameters
1774     for (i=0; i<4; i++) {
1775     fiterrors[i] = ffit->GetParError(i); // obtain fit parameter errors
1776     }
1777     ChiSqr[0] = ffit->GetChisquare(); // obtain chi^2
1778     NDF[0] = ffit->GetNDF(); // obtain ndf
1779     //
1780     return (ffit); // return fit function
1781     }
1782    
1783    
1784     //Double_t langaupro(Double_t *params, Double_t &maxx) {
1785     Double_t langaupro(Double_t *params) {
1786     // Seaches for the location (x value) at the maximum of the
1787     // Landau-Gaussian convolute and its full width at half-maximum.
1788     //
1789     Double_t p,x;
1790     Double_t step;
1791     Double_t l,lold;
1792     Int_t i = 0;
1793     Int_t MAXCALLS = 5000;
1794     // Search for maximum
1795     p = params[1] - 0.1 * params[0];
1796     step = 0.05 * params[0];
1797     lold = -2.0;
1798     l = -1.0;
1799     // while ( (l != lold) && (i < MAXCALLS) ) {
1800     while ( fabs(l-lold)>10e-12 && (i < MAXCALLS) ) {
1801     i++;
1802     lold = l;
1803     x = p + step;
1804     l = langaufun(&x,params);
1805     if ( l < lold ) step = -step/10.;
1806     p += step;
1807     // printf(" i %i: l %.16g lold %.16g x %.16g p %.16g step %.16g \n",i,l,lold,x,p,step);
1808     // printf(" l %.16g \n",l);
1809     };
1810     // printf(" i %i: l %.16g lold %.16g x %.16g p %.16g step %.16g \n",i,l,lold,x,p,step);
1811     //printf(" l %.16g \n",l);
1812     if (i == MAXCALLS) return (-1.);
1813     //
1814     return(x);
1815     }
1816    
1817    
1818     void delay(int selftrig, int &del){
1819     int i;
1820     i = 0;
1821     del = 300;
1822     //
1823     while ((i < 16) && ((selftrig & (0x8000>>i)) == 0)) {
1824     del += 50;
1825     i++;
1826     };
1827     if (i > 15) del = 1100;
1828     }
1829    
1830     Double_t fitraw(Double_t *x, Double_t *par){
1831     //
1832     Double_t fitval = par[3] + par[0]*TMath::Exp(-par[2]*(x[0]-par[1]));
1833     //
1834     return fitval;
1835     }
1836    
1837    
1838    
1839     int checkmerging(Chmerge & chmerge){
1840     for (Int_t i = chmerge.fromflag; i<1000; i++){
1841     if ( chmerge.pscuOBT == 0 && chmerge.pscucount == 0 ) return(1);
1842     if ( chmerge.pscuOBT == chmerge.lastOBT[i] && chmerge.pscucount == chmerge.lastcount[i] ){
1843     chmerge.fromflag = i;
1844     printf("\n WARNING! %i event number %i at OBT %i already processed, skipped!\n",i,chmerge.pscucount,chmerge.pscuOBT);
1845     return(1);
1846     };
1847     };
1848     return(0);
1849     }
1850    
1851     int fillmerging(Chmerge & chmerge){
1852     chmerge.lastOBT[chmerge.scanflag] = chmerge.pscuOBT;
1853     chmerge.lastcount[chmerge.scanflag] = chmerge.pscucount;
1854     chmerge.scanflag++;
1855     if ( chmerge.scanflag > 999 ) return(0);
1856     chmerge.lastOBT[chmerge.scanflag] = 0;
1857     chmerge.lastcount[chmerge.scanflag] = 0;
1858     return(0);
1859     }
1860    
1861     //short int checkifpretyodaversion(TString filename){
1862     // string fil = (const char *)filename;
1863     // Int_t posiz = fil.find("dw_");
1864     // if ( posiz == -1 ) posiz = fil.find("DW_");
1865     // if ( posiz == -1 ) return (-1);
1866     // TString year;
1867     // stringcopy(year,filename,posiz+3,posiz+5);
1868     // const char *ye = year;
1869     // Int_t y = atoi(ye);
1870     // TString month;
1871     // stringcopy(month,filename,posiz+5,posiz+7);
1872     // const char *mo = month;
1873     // Int_t m = atoi(mo);
1874     // TString day;
1875     // stringcopy(day,filename,posiz+7,posiz+9);
1876     // const char *da = day;
1877     // Int_t d = atoi(da);
1878     // TString fno;
1879     // stringcopy(fno,filename,posiz+10,posiz+13);
1880     // const char *fn = fno;
1881     // Int_t f = atoi(fn);
1882     // if ( y >= 5 && m >= 5 && d < 15 ) return(1);
1883     // if ( y == 5 && m == 5 && d == 15 && f < 7 ) return(1);
1884     // return(0);
1885     //}
1886    
1887    

  ViewVC Help
Powered by ViewVC 1.1.23