/[PAMELA software]/eventviewer/ground/macros/EventViewer.c
ViewVC logotype

Annotation of /eventviewer/ground/macros/EventViewer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri Jan 13 10:07:39 2006 UTC (18 years, 10 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +28 -3 lines
File MIME type: text/plain
Added tracker measured positions used to determine the track (in LEVEL2 visualization)

1 mocchiut 1.1 //-------------------------------------------------------------------------------------------------------------------------------------------------------
2     //
3 mocchiut 1.2 // EventViewer.c version 8.01 (2006-01-10)
4 mocchiut 1.1 //
5     // Shows PAMELA events - Emiliano Mocchiutti
6     //
7     //-------------------------------------------------------------------------------------------------------------------------------------------------------
8     //
9     // The only input needed is the path to the directory ("filename") created by YODA for the data file you want to analyze.
10     //
11     // Standard use:
12     //
13     // root[0] .L ShowEvent.c
14     // root[1] ShowEvent("/home/dati/filesFromYoda/DW_050112_00600/");
15     //
16     // For further informations use:
17     //
18     // root[3] ShowEvent();
19     //
20     // or
21     //
22     // root[4] ShowEvent("help");
23     //
24     //-------------------------------------------------------------------------------------------------------------------------------------------------------
25     //
26     // Changelog:
27     //
28 mocchiut 1.2 // 8.00 - 8.01 (2006-01-10): Added tracker measured positions used to determine the track.
29     //
30 mocchiut 1.1 // 7.03 - 8.00 (2005-11-24): many changes to compile the macro. The code is still very redundant and heavy but some bugs were fixed and now it should be more stable.
31     // Do not require anymore the AcFunctions.h header, a clone has been written (aclev1class.h).
32     //
33     // 7.02 - 7.03 (2005-10-14): load library containing CalorimeterLevel1 class definition.
34     //
35     // 7.01 - 7.02 (2005-10-12): changed neutron detector color scale to a more realistic one.
36     //
37     // 7.00 - 7.01 (2005-10-10): simplyfied input (less parameters), added support for TOF level1 data.
38     //
39     // 6.05 - 7.00 (2005-09-21): changes to work with tracker software version 2.00.
40     //
41     // 6.04 - 6.05 (2005-08-03): changes to fix bugs related to 64 bit arch.
42     //
43     // 6.03 - 6.04 (2005-07-22): small bug in signal visualization in TOF S11 fixed.
44     //
45     // 6.02 - 6.03 (2005-07-19): use clone routines of yodaUtility.c that can be found in CaloFunctions.h and don't load anymore yodaUtility.c
46     //
47     // 6.01 - 6.02 (2005-07-12): small changes due to correction for the compilation of CaloFunctions.h.
48     //
49     // 6.00 - 6.01 (2005-07-07): AC, now it reads LEVEL1 output (hit are shown with different colour if they are not in time with trigger). Some AC related small bugs fixed.
50     // Added synchronization routines between "YODA" output and tracker output (I am assuming that everything comes out from YODA is synchronized).
51     //
52     // 5.21 - 6.00 (2005-07-06): Now it can read tracker rootples generated by the GroundDataConvert software. Some minor bugs related to tracker visualization fixed.
53     // Notice that tracker data are not synchronized yet to the "YODA" data.
54     //
55     // 5.20 - 5.21 (2005-06-29): Added some options in the interactive menu (B/W toggling, track in S4/ND toggling). Created a new include file with structures for the
56     // event viewer, changed the WhatToDO routine, now renamed in WhatToDoEV. Bug: cannot run program twice when showing track without quitting
57     // ROOT, fixed. Changed "CALO" to "Calorimeter" and "TRK" to "Tracker" in verbose infos mode. Bug: don't show trigger configuration on the text
58     // output when no infos are shown on the figure, fixed. Increased the width of the track line.
59     //
60     // 5.19 - 5.20 (2005-06-28): Bug: S4 z dimension is wrong! corrected. New filename and changes needed to upgrade to the new software architecture.
61     //
62     // 5.18 - 5.19 (2005-06-16): Bug: S4/PULSER flag is not always correct since sometimes the trigger is given by S4 but the flag is not set. Fixed (?) with a
63     // workaround, to be checked that is the best we can do.
64     //
65     // 5.17 - 5.18 (2005-06-14): Added black and white visualization (use input variable "BW" as flag). Wrong position of S4 in level0 visualization, fixed. Saved PS files do not
66     // contain the TOF information from TDC position, fixed.
67     //
68     // 5.16 - 5.17 (2005-06-08): S4 level0 and level1 splitted. Level0 shows the patterntrig variable (NB: NOT ALWAYS CORRECT!!), Level1 shows calibrated info from S4.
69     //
70     // 5.15 - 5.16 (2005-06-07): Unload libraries when exiting and change back to the starting directory. Check if the file is older than 050515_007.
71     //
72     // 5.14 - 5.15 (2005-05-17): Crashes if ADC to MIP calorimeter conversion value is zero, fixed.
73     //
74     // 5.13 - 5.14 (2005-05-13): Force level0 visualization also for the calorimeter.
75     //
76     // 5.12 - 5.13 (2005-05-10): Calorimeter Z dimension is WRONG!!! fixed.
77     //
78     // 5.11 - 5.12 (2005-05-02): OBT is On Board Time and not Orbital Time!
79     //
80     // 5.10 - 5.11 (2005-04-19): Bug fixed in the new subroutine ShowTOFL1 and changed to the old behaviour the calorimeter calibration search (it could took long time
81     // to find a good calibration with the new method expecially in the case of a directory with a single file).
82     //
83     // 5.09 - 5.10 (2005-04-18): Added ShowTOFL1 subroutine to show TOF informations instead of trigger infos. Still it possible to see trigger infos forcing level0 data.
84     //
85     // 5.08 - 5.09 (2005-04-11): Changes in the CaloShowL0 subroutine: do not calibrate more than once if there is a jump in OBT.
86     //
87     // 5.07 - 5.08 (2005-04-07): Changes in the CaloShowL0 subroutine. Changed tree name of level1 and adc2mip calorimeter data.
88     //
89     // 5.06 - 5.07 (2005-04-05): Bug in the rigidity and chi2 report in the figure, fixed.
90     //
91     // 5.05 - 5.06 (2005-03-30): Small changes in the whattodo behaviour.
92     //
93     // 5.04 - 5.05 (2005-03-23): Introduced the input variable FORCELEV to force the data level to load. For now it is possible only to force level0 data
94     // reading of calorimeter and tracker. News: the selection file name now can be anyone and must be used as input if you want
95     // to select events. Hence the "selection" integer input has become the string "selfile".
96     //
97     // 5.03 - 5.04 (2005-03-18): Small changes in the print out.
98     //
99     // 5.02 - 5.03 (2005-03-17): Cannot go backward in selection mode, fixed. Change in ShowS4 the S4 calibration parameter.
100     // New: now it is possible to jump to a certain event number and not only to progressive number.
101     //
102     // 5.01 - 5.02 (2005-03-16): Pulser information is now printed in the INFOS and S4 MIP signal (first order calibration) is represented with colours
103     // (same palette as for calorimeter).
104     //
105     // 5.00 - 5.01 (2005-03-14): Information text size increased.
106     //
107     // 4.11 - 5.00 (2005-03-11): Track visualization offset bug fixed. Reload magnetic field maps if back to the first event, fixed.
108     // Added some comments in the code. Added level2 tracker data to filter.c.
109     //
110     // 4.10 - 4.11 (2005-03-10): Tracker LEVEL1 visualization implemented. Changed the tracker directory from "magnet" to "tracker". Show LEVEL1 information
111     // even if LEVEL2 data are not present.
112     //
113     // 4.09 - 4.10 (2005-03-08): Read the calorimeter calibration file if trying to generate level 1 data.
114     //
115     // 4.08 - 4.09 (2005-03-03): S4 always shown as hit, fixed.
116     //
117     // 4.07 - 4.08 (2005-02-25): In filter mode added a progress viewer. CAS1 plane view was filled with full red colour instead of pinkish colour, fixed.
118     //
119     // 4.06 - 4.07 (2005-02-25): crashes when exiting on empty files. Fixed.
120     //
121     // 4.05 - 4.06 (2005-02-24): Changed order of input variables.
122     //
123     // 4.04 - 4.05 (2005-02-24): Changed variable definition from C/C++ style to ROOT style (int->Int_t).
124     //
125     // 4.03 - 4.04 (2005-02-23): Added the "selection" input variable. If set greater than zero the program will look for
126     // events satisfying the condition in the filter.c program. Notice that running in this configuration
127     // will not let you to go backward with events.
128     //
129     // 4.02 - 4.03 (2005-02-23): Sometimes the calorimeter was repeating an event to infinity. Fixed.
130     //
131     // 4.01 - 4.02 (2005-02-22): ROOT 4.03/02 version bug fixed (calorimeter only).
132     //
133     // 4.00 - 4.01 (2005-02-18): Calorimeter compress/full raw mode visualization didn't work. Fixed. Neutron detector data format changed, fixed accordingly.
134     //
135     // 3.04 - 4.00 (2005-02-14): Small changes in the calorimeter x/y view and in the tracker plane view geometries.
136     // Added the track visualization code once you have tracker LEVEL2 data.
137     //
138     // 3.03 - 3.04 (2005-02-10): Show not only the YODA number (progressive number) but also the EVENT NUMBER from the packet header!
139     //
140     // 3.02 - 3.03 (2005-02-08): TOF scintillators divided into A and B PMTs. Upper triangles are A PMT, lower triangles are B PMTs. S4 readout implemented:
141     // the information comes from the trigger board and the energy level is drawn out as LEVEL0 information. Some bugs in the
142     // scintillators order fixed. Changed color of shadow hit in the tracker Y-view; added small black dot on tracker ladders to
143     // indicate the detectors edges.
144     //
145     // 3.01 - 3.02 (2005-02-04): Tracker hit shown in the plane view. CAS shown in the plane view. Level0 TOF information shown in the scintillators.
146     // Bug for which it is not possible to see only the last event, fixed.
147     //
148     // 3.00 - 3.01 (2005-01-31): AC CARD view from above added. Printing bug fixed, now it calls for the WhatToDo routine in CaloFunctions.h.
149     //
150     // 2.01 - 3.00 (2005-01-21): Major changes in the program philosophy: now it will check first for higher order LEVEL data and it will use low level data
151     // only as last resurce.
152     //
153     // 2.00 - 2.01 (2005-01-18): AC cat changed, added PMTs, AC hits out of triggers are shown now in a different colour. Added "go backward" capability.
154     //
155     // 1.01 - 2.00 (2005-01-14): many changes, some cleanup of the code, detectors are in scale.
156     //
157     // 1.00 - 1.01 (2004-12-15): Include also yodaUtility.c .
158     //
159     #include <math.h>
160     #include <stdio.h>
161     //
162     #include <fstream>
163     #include <sstream>
164     #include <iostream>
165     #include <iomanip>
166     //
167     #include <TTree.h>
168     #include <TClassEdit.h>
169     #include <TObject.h>
170     #include <TList.h>
171     #include <TSystem.h>
172     #include <TSystemDirectory.h>
173     #include <TString.h>
174     #include <TFile.h>
175     #include <TClass.h>
176     #include <TCanvas.h>
177     #include <TH1.h>
178     #include <TH1F.h>
179     #include <TH2D.h>
180     #include <TLatex.h>
181     #include <TPad.h>
182     #include <TPaveLabel.h>
183     #include <TLine.h>
184     #include <TPolyLine.h>
185     #include <TChain.h>
186     #include <TApplication.h>
187     #include <TVirtualX.h>
188     #include <TGClient.h>
189     #include <TGWindow.h>
190     #include <TEllipse.h>
191     #include <TArrow.h>
192     #include <TStyle.h>
193     //
194     #include <trklev1struct.h>
195     //
196     #if !defined (__CINT__)
197     #include <event/PamelaRun.h>
198     #include <event/physics/calorimeter/CalorimeterEvent.h>
199     #include <event/physics/trigger/TriggerEvent.h>
200     #include <event/physics/tof/TofEvent.h>
201     #include <event/physics/tracker/TrackerEvent.h>
202     #include <event/physics/anticounter/AnticounterEvent.h>
203     #include <event/physics/neutronDetector/NeutronEvent.h>
204     #include <event/physics/S4/S4Event.h>
205     #include <event/CalibCalPedEvent.h>
206     #include <event/CalibTrk1Event.h>
207     #include <event/CalibTrk2Event.h>
208     #include <caloclasses.h>
209     extern const char *pathtocalibration();
210     extern void creadB(const char []);
211     extern void projectlev1(Trklev1 &);
212     extern void ctrack(int, Double_t [], Double_t [], Double_t [], Double_t [], int &);
213     #endif
214     //
215     //
216     #include <CaloFunctions.h>
217     #include <eventviewer.h>
218     //
219     #include <ctrkstruct.h>
220     #include <ctrkinclude.h>
221     #include <ctofstruct.h>
222     #include <ctofinclude.h>
223     #include <aclev1class.h>
224     //
225    
226     void unload1(){
227     #if defined (__CINT__)
228     char *pam_lib=gSystem->Getenv("PAM_LIB");
229     stringstream libload1;
230     libload1.str("");
231     libload1 << pam_lib << "/libptlevel1_C";
232     gSystem->Unload(libload1.str().c_str());
233     char *pam_lib=gSystem->Getenv("PAM_LIB");
234     stringstream libload1;
235     libload1.str("");
236     libload1 << pam_lib << "/libptlevel1";
237     gSystem->Unload(libload1.str().c_str());
238     #endif
239     }
240    
241     void unload2(){
242     #if defined (__CINT__)
243     char *pam_lib=gSystem->Getenv("PAM_LIB");
244     stringstream libload;
245     libload.str("");
246     libload << pam_lib << "/libreadb2maps_C";
247     gSystem->Unload(libload.str().c_str());
248     libload.str("");
249     char *pam_lib=gSystem->Getenv("PAM_LIB");
250     libload << pam_lib << "/libreadb2maps";
251     gSystem->Unload(libload.str().c_str());
252     libload.str("");
253     char *pam_lib=gSystem->Getenv("PAM_LIB");
254     libload << pam_lib << "/libtrack_C";
255     gSystem->Unload(libload.str().c_str());
256     stringstream libload;
257     libload.str("");
258     char *pam_lib=gSystem->Getenv("PAM_LIB");
259     libload << pam_lib << "/libtrack";
260     gSystem->Unload(libload.str().c_str());
261     #endif
262     }
263     //**********************************************************************************
264     // LEVEL0 SUBROUTINES //
265     //**********************************************************************************
266    
267     void ShowCaloRAW(Int_t i, TTree *otr, Variables & var){
268    
269     pamela::calorimeter::CalorimeterEvent *de = 0;
270     otr->SetBranchAddress("Calorimeter.Event", &de);
271     if ( !var.nosig ) otr->GetEntry(i);
272    
273     //
274     // Book the histograms:
275     //
276     //
277     stringstream delex;
278     delex.str("");
279     delex << "x-view event " << (i+1);
280     stringstream deley;
281     deley.str("");
282     deley << "y-view event " << (i+1);
283     gDirectory->Delete(delex.str().c_str());
284     gDirectory->Delete(deley.str().c_str());
285     TH2F *Xview = new TH2F(delex.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
286     TH2F *Yview = new TH2F(deley.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
287     Xview->GetYaxis()->SetLabelColor(10);
288     Yview->GetYaxis()->SetLabelColor(10);
289     //
290     // figures:
291     //
292     Int_t bgcolor = 10;
293     TPad *pd1 = new TPad("calox","This is pad1",var.xxvc-0.154*var.sfx,var.yxvc-0.3645*var.sfy,var.xxvc+0.154*var.sfx,var.yxvc-0.1200*var.sfy,bgcolor);
294     TPad *pd2 = new TPad("caloy","This is pad2",var.xyvc-0.154*var.sfx,var.yyvc-0.3645*var.sfy,var.xyvc+0.154*var.sfx,var.yyvc-0.1200*var.sfy,bgcolor);
295    
296     pd1->SetFillStyle(4000);
297     pd1->SetFillColor(0);
298     pd1->SetFrameFillStyle(4000);
299     pd2->SetFillStyle(4000);
300     pd2->SetFillColor(0);
301     pd2->SetFrameFillStyle(4000);
302    
303     TLatex *t=new TLatex();
304     t->SetTextFont(32);
305     t->SetTextColor(1);
306     t->SetTextSize(0.03);
307     t->SetTextAlign(12);
308     pd1->Range(0.,0.,1.,1.);
309     pd2->Range(0.,0.,1.,1.);
310     pd1->SetTicks();
311     pd2->SetTicks();
312     pd1->Draw();
313     pd2->Draw();
314    
315     pd1->cd();
316     gStyle->SetOptStat(0);
317     Xview->GetYaxis()->SetTitleOffset(0.5);
318     Xview->SetFillColor(bgcolor);
319     Xview->Fill(1.,1.,1.);
320     Xview->Draw("box");
321     pd1->Update();
322     pd2->cd();
323     gStyle->SetOptStat(0);
324     Yview->GetYaxis()->SetTitleOffset(0.5);
325     Yview->SetFillColor(bgcolor);
326     Yview->Fill(1.,1.,1.);
327     Yview->Draw("box");
328     pd2->Update();
329    
330     //
331     // run over views and planes
332     //
333     stringstream xevent;
334     stringstream yevent;
335     for (Int_t m = 0; m < 22; m++){
336     for (Int_t l = 0; l < 2; l++){
337     //
338     // determine the section number
339     //
340     Int_t se = 5;
341     if ( !l && m%2 == 0 ){
342     se = 3;
343     };
344     if ( !l && m%2 != 0 ){
345     se = 2;
346     };
347     if ( l && m%2 == 0 ){
348     se = 1;
349     };
350     if ( l && m%2 != 0 ){
351     se = 0;
352     };
353     //
354     // determine what kind of event we are going to analyze
355     //
356     bool isCOMP = 0;
357     bool isFULL = 0;
358     if ( de->stwerr[se] & (1 << 16) ) isCOMP = 1;
359     if ( de->stwerr[se] & (1 << 17) ) isFULL = 1;
360     //
361     // run over strips
362     //
363     if ( isCOMP || isFULL ) {
364     for (Int_t n = 0; n < 96; n++){
365     if ( de->dexyc[l][m][n] > 0. && !var.nosig ){
366     xevent.str("");
367     yevent.str("");
368     xevent << "x-view event " << n;
369     xevent << " " << m;
370     xevent << " " << l;
371     yevent << "y-view event " << n;
372     yevent << " " << m;
373     yevent << " " << l;
374     gDirectory->Delete(xevent.str().c_str());
375     gDirectory->Delete(yevent.str().c_str());
376     TH2F *Xview = new TH2F(xevent.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
377     TH2F *Yview = new TH2F(yevent.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
378     Int_t colo = 38;
379     Xview->SetFillColor(colo);
380     Yview->SetFillColor(colo);
381     if ( l == 0 ) {
382     Xview->Fill(n,21-m,1.);
383     pd1->cd();
384     Xview->Draw("box same");
385     };
386     if ( l == 1 ) {
387     Yview->Fill(95-n,21-m,1.);
388     pd2->cd();
389     Yview->Draw("box same");
390     };
391     };
392     };
393     };
394     };
395     };
396     pd1->Update();
397     pd2->Update();
398     var.qtot=0;
399     var.nstrip=0;
400     }
401    
402     void ShowND(Int_t evno, TTree *otr, Variables & var){
403     Int_t tmpSize;
404     Int_t yUpperTrig = 0;
405     Int_t yUpperBk = 0;
406     Int_t yBottomBk = 0;
407     pamela::neutron::NeutronEvent *ne = 0;
408     pamela::neutron::NeutronRecord *nr = 0;
409     otr->SetBranchAddress("Neutron.Event", &ne);
410     //
411     if ( !var.nosig ) otr->GetEntry(evno);
412     //
413     tmpSize = ne->Records->GetEntries();
414     for (Int_t j = 0; j < tmpSize; j++){
415     nr = (pamela::neutron::NeutronRecord*)ne->Records->At(j);
416     yUpperTrig += (int)nr->trigPhysics;
417     yUpperBk += (int)nr->upperBack;
418     yBottomBk += (int)nr->bottomBack;
419     }
420    
421     var.trup = yUpperTrig;
422     var.bkup = yUpperBk;
423     var.bkbo = yBottomBk;
424    
425     if ( var.nosig ){
426     yUpperTrig = 0;
427     yUpperBk = 0;
428     yBottomBk = 0;
429     }
430     Int_t ucolo = 10;
431     if ( var.bw ){
432     if ( yUpperTrig == 1 ){
433     ucolo = 17;
434     }
435     if ( yUpperTrig == 2 ){
436     ucolo = 15;
437     }
438     if ( yUpperTrig > 2 && yUpperTrig < 7 ){
439     ucolo = 14;
440     }
441     if ( yUpperTrig > 6 && yUpperTrig < 15 ){
442     ucolo = 13;
443     }
444     if ( yUpperTrig >= 14 ){
445     ucolo = 12;
446     };
447     } else {
448     if ( yUpperTrig == 1 ){
449     ucolo = 38;
450     }
451     if ( yUpperTrig == 2 ){
452     ucolo = 4;
453     }
454     if ( yUpperTrig > 2 && yUpperTrig < 7 ){
455     ucolo = 3;
456     }
457     if ( yUpperTrig > 6 && yUpperTrig < 15 ){
458     ucolo = 2;
459     }
460     if ( yUpperTrig >= 14 ){
461     ucolo = 6;
462     };
463     };
464     //
465     // figures:
466     //
467     if ( true ){
468     Float_t xc1[5]={ -0.300, 0.300, 0.300, -0.300, -0.300 };
469     Float_t yc1[5]={ -0.47-0.04, -0.47-0.04, -0.47+2.*0.075-0.04, -0.47+2.*0.075-0.04, -0.47-0.04};
470     //
471     // Upper X-view
472     //
473     Float_t xc[5];
474     Float_t yc[5];
475     for (Int_t i = 0; i<5 ; i++) {
476     xc[i]= var.xxvc + xc1[i]*var.nds4;
477     yc[i] = var.yxvc + yc1[i]*var.sfy;
478     };
479     TPolyLine *fnd2x = new TPolyLine(5,xc,yc);
480     fnd2x->SetLineColor(1);
481     fnd2x->SetFillColor(ucolo);
482     fnd2x->SetLineWidth(1);
483     fnd2x->Draw("f");
484     fnd2x->Draw();
485     };
486     if ( true ){
487     Float_t xc1[5]={ -0.275, 0.275, 0.275, -0.275, -0.275 };
488     Float_t yc1[5]={ -0.47-0.04-0.075, -0.47-0.04-0.075, -0.47+0.075-0.04, -0.47+0.075-0.04, -0.47-0.04-0.075};
489     //
490     // Upper Y-view
491     //
492     Float_t xc[5];
493     Float_t yc[5];
494     for (Int_t i = 0; i<5 ; i++) {
495     xc[i]= var.xyvc + xc1[i]*var.nds4;
496     yc[i] = var.yyvc + (yc1[i]+0.075)*var.sfy;
497     };
498     TPolyLine *fnd2y = new TPolyLine(5,xc,yc);
499     fnd2y->SetLineColor(1);
500     fnd2y->SetFillColor(ucolo);
501     fnd2y->SetLineWidth(1);
502     fnd2y->Draw("f");
503     fnd2y->Draw();
504     };
505     }
506    
507     void ShowTRKL0(Int_t evno, TTree *otr, Variables & var){
508     //
509     pamela::tracker::TrackerEvent *trk = 0;
510     otr->SetBranchAddress("Tracker.Event", &trk);
511     if ( !var.nosig ) otr->GetEntry(evno);
512     //
513     // a matrix of pads for each view x and y
514     //
515     TPad *trkpad[12];
516     for (Int_t n = 0; n<12; n++){
517     stringstream spd;
518     spd.str("");
519     spd << "pd1" << n;
520     gDirectory->Delete(spd.str().c_str());
521     spd.str("");
522     spd << "pd2" << n;
523     gDirectory->Delete(spd.str().c_str());
524     spd.str("");
525     spd << "pd3" << n;
526     gDirectory->Delete(spd.str().c_str());
527     spd.str("");
528     spd << "pd4" << n;
529     gDirectory->Delete(spd.str().c_str());
530     spd.str("");
531     spd << "pd5" << n;
532     gDirectory->Delete(spd.str().c_str());
533     spd.str("");
534     spd << "pd6" << n;
535     gDirectory->Delete(spd.str().c_str());
536     spd.str("");
537     stringstream sbd;
538     sbd.str("");
539     Int_t magcol = 0;
540     TPad *mag1 = 0;
541     TPad *mag2 = 0;
542     if ( n%2 ) {
543     Float_t posx = var.xxvc;
544     Float_t posy = var.yxvc + (0.29 - 0.089*((n/2.)-1.))*var.sfy;
545     spd.str("");
546     sbd.str("");
547     spd << "pd1" << n;
548     sbd << "bd1" << n;
549     trkpad[n] = new TPad(spd.str().c_str(),sbd.str().c_str(),posx-0.081*var.sfx,posy,posx+0.081*var.sfx,posy+0.089*var.sfy,10);
550     trkpad[n]->SetFillStyle(4000);
551     trkpad[n]->SetFillColor(0);
552     trkpad[n]->SetFrameFillStyle(4000);
553     trkpad[n]->Draw();
554     if ( n != 1 ) {
555     if ( var.bw ) {
556     magcol = 1;
557     } else {
558     magcol = 45;
559     };
560     spd.str("");
561     sbd.str("");
562     spd << "pd2" << n;
563     sbd << "bd2" << n;
564     mag1 = new TPad(spd.str().c_str(),sbd.str().c_str(),posx-(0.039+0.081)*var.sfx,posy+0.004*var.sfy,posx-0.081*var.sfx,posy+0.088*var.sfy,magcol);
565     if ( var.bw ) mag1->SetFillStyle(3001);
566     mag1->Draw();
567     spd.str("");
568     sbd.str("");
569     spd << "pd3" << n;
570     sbd << "bd3" << n;
571     mag2 = new TPad(spd.str().c_str(),sbd.str().c_str(),posx+0.081*var.sfx,posy+0.004*var.sfy,posx+(0.081+0.039)*var.sfx,posy+0.088*var.sfy,magcol);
572     if ( var.bw ) mag2->SetFillStyle(3001);
573     mag2->Draw();
574     };
575     } else {
576     Float_t posx = var.xyvc;
577     Float_t posy = var.yyvc + (0.29 - 0.089 * (((n+1.)/2.)-1.))*var.sfy;
578     spd.str("");
579     sbd.str("");
580     spd << "pd4" << n;
581     sbd << "bd4" << n;
582     trkpad[n] = new TPad(spd.str().c_str(),sbd.str().c_str(),posx-0.07*var.sfx,posy,posx+0.07*var.sfx,posy+0.089*var.sfy,10);
583     trkpad[n]->SetFillStyle(4000);
584     trkpad[n]->SetFillColor(0);
585     trkpad[n]->SetFrameFillStyle(4000);
586     trkpad[n]->Draw();
587     if ( n != 0 ) {
588     if ( var.bw ) {
589     magcol = 1;
590     } else {
591     magcol = 45;
592     };
593     spd.str("");
594     sbd.str("");
595     spd << "pd5" << n;
596     sbd << "bd5" << n;
597     mag1 = new TPad(spd.str().c_str(),sbd.str().c_str(),posx-(0.048+0.066)*var.sfx,posy+0.004*var.sfy,posx-0.066*var.sfx,posy+0.088*var.sfy,magcol);
598     if ( var.bw ) mag1->SetFillStyle(3001);
599     mag1->Draw();
600     spd.str("");
601     sbd.str("");
602     spd << "pd6" << n;
603     sbd << "bd6" << n;
604     mag2 = new TPad(spd.str().c_str(),sbd.str().c_str(),posx+0.066*var.sfx,posy+0.004*var.sfy,posx+(0.066+0.048)*var.sfx,posy+0.088*var.sfy,magcol);
605     if ( var.bw ) mag2->SetFillStyle(3001);
606     mag2->Draw();
607     };
608     };
609     };
610     TPad *trplv;
611     gDirectory->Delete("trkplv");
612     trplv = new TPad("trkplv","trkplv",var.xcat-0.066*var.sfx,var.ycat-0.081*var.sfy,var.xcat+0.066*var.sfx,var.ycat+0.081*var.sfy,10);
613     trplv->SetFillStyle(4000);
614     trplv->SetFillColor(0);
615     trplv->SetFrameFillStyle(4000);
616     trplv->Draw();
617     //
618     Int_t sigcol1 = 17;
619     Int_t sigcol2 = 15;
620     Int_t linecol = 13;
621     if ( var.bw ) {
622     sigcol1 = 17;
623     sigcol2 = 15;
624     linecol = 13;
625     } else {
626     sigcol1 = 32;
627     sigcol2 = 38;
628     linecol = 42;
629     };
630     TLine *linea = 0;
631     TLine *linea1x = 0;
632     TLine *linea2x = 0;
633     TLine *linea1y = 0;
634     Float_t x = 0.;
635     for (Int_t l = 0; l<12; l++){
636     trkpad[l]->cd();
637     if ( l%2 ) {
638     trkpad[l]->Range(0.,0.,3100.,1.);
639     linea = new TLine(0.,0.01,3100.,0.01);
640     linea1x = new TLine(1033.,0.01,1033,0.030);
641     linea2x = new TLine(2066.,0.01,2066,0.030);
642     } else {
643     trkpad[l]->Range(0.,0.,2076.,1.);
644     linea = new TLine(0.,0.01,2076.,0.01);
645     linea1y = new TLine(1038.,0.01,1038,0.030);
646     };
647     linea->SetLineWidth(2);
648     linea->SetLineColor(linecol);
649     linea->Draw();
650     if ( l%2 ) {
651     linea1x->SetLineWidth(1);
652     linea1x->SetLineColor(1);
653     linea1x->Draw();
654     linea2x->SetLineWidth(1);
655     linea2x->SetLineColor(1);
656     linea2x->Draw();
657     } else {
658     linea1y->SetLineWidth(1);
659     linea1y->SetLineColor(1);
660     linea1y->Draw();
661     };
662     //
663     Int_t planeno = trk->DSPnumber[l]-1;
664     if ( planeno < 0 || planeno > 11 ) planeno = 0;
665     if ( planeno >= 0 && !var.nosig ) {
666     if ( (planeno+1)%2 ){
667     trkpad[planeno]->cd();
668     trkpad[planeno]->Range(0.,0.,2076.,1.);
669     for (Int_t m = 0; m<3; m++){
670     if ( trk->signcluster[l][m] != 0. ){
671     if ( planeno == 10 ) {
672     x = 1024 - trk->addrcluster[l][m];
673     } else {
674     x = trk->addrcluster[l][m];
675     };
676     linea = new TLine(14.+x,0.01,14.+x,0.3);
677     linea->SetLineWidth(2);
678     linea->SetLineColor(sigcol1);
679     linea->Draw();
680     x += 1024.;
681     linea = new TLine(14.+x,0.01,14.+x,0.3);
682     linea->SetLineWidth(2);
683     linea->SetLineColor(sigcol2);
684     linea->Draw();
685     var.ncly++;
686     };
687     };
688     } else {
689     trkpad[planeno]->cd();
690     trkpad[planeno]->Range(0.,0.,3100.,1.);
691     for (Int_t m = 0; m<3; m++){
692     if ( trk->signcluster[l][m] != 0. ){
693     x = trk->addrcluster[l][m] + 1024. * m;
694     linea = new TLine(14.+x,0.01,14.+x,0.3);
695     linea->SetLineWidth(2);
696     linea->SetLineColor(sigcol2);
697     linea->Draw();
698     var.nclx++;
699     };
700     };
701     };
702     };
703     };
704     //
705     // Show track in the plane view!
706     //
707     Float_t xh[6];
708     Float_t yh1[6];
709     Float_t yh2[6];
710     Float_t mag[6];
711     for (Int_t l = 0; l<6; l++ ){
712     xh[l] = 0.;
713     yh1[l] = 0.;
714     yh2[l] = 0.;
715     mag[l] = 0.;
716     };
717     Int_t ncro = 0;
718     //
719     for (Int_t l = 0; l<12; l++ ){
720     Float_t xsig = 0.;
721     Float_t ysig = 0.;
722     Int_t planeno = trk->DSPnumber[l]-1;
723     for (Int_t e = 0; e<12;e++){
724     Int_t planeno2 = trk->DSPnumber[e]-1;
725     if ( planeno == planeno2-1 ){
726     if ( planeno < 0 || planeno > 11 ) planeno = 0;
727     if ( planeno >= 0 && !var.nosig ) {
728     mag[ncro] = ((float)planeno+1.)/5.;
729     if ( (planeno+1)%2 ){
730     for (Int_t m = 0; m<3; m++){
731     if ( trk->signcluster[l][m] != 0. ){
732     if ( planeno == 10 ) {
733     x = 1024 - trk->addrcluster[l][m];
734     } else {
735     x = trk->addrcluster[l][m];
736     };
737     x += 1024.;
738     if ( trk->signcluster[l][m]> ysig ){
739     ysig = trk->signcluster[l][m];
740     yh1[ncro] = x-1024.;
741     yh2[ncro] = x;
742     };
743     };
744     };
745     for (Int_t m = 0; m<3; m++){
746     if ( trk->signcluster[e][m] != 0. ){
747     x = trk->addrcluster[e][m] + 1024. * m;
748     if ( trk->signcluster[e][m]> xsig && !( planeno == 0 && x > 2800) ){
749     xsig = trk->signcluster[e][m];
750     xh[ncro] = x;
751     };
752     };
753     };
754     } else {
755     for (Int_t m = 0; m<3; m++){
756     if ( trk->signcluster[l][m] != 0. ){
757     x = trk->addrcluster[l][m] + 1024. * m;
758     if ( trk->signcluster[l][m]> xsig && !( planeno == 0 && x > 2800) ){
759     xsig = trk->signcluster[l][m];
760     xh[ncro] = x;
761     };
762     };
763     };
764     if ( (planeno+1)%2 ){
765     for (Int_t m = 0; m<3; m++){
766     if ( trk->signcluster[e][m] != 0. ){
767     if ( planeno == 10 ) {
768     x = 1024 - trk->addrcluster[e][m];
769     } else {
770     x = trk->addrcluster[e][m];
771     };
772     x += 1024.;
773     if ( trk->signcluster[e][m]> ysig ){
774     ysig = trk->signcluster[e][m];
775     yh1[ncro] = x-1024.;
776     yh2[ncro] = x;
777     };
778     };
779     };
780     };
781     };
782     if ( ysig > 0. && xsig > 0. ) {
783     ncro++;
784     };
785     };
786     };
787     };
788     };
789     //
790     // Draw crosses
791     //
792     if ( ncro ) {
793     trplv->cd();
794     trplv->Range(0.,0.,2076.,3100.);
795     for ( Int_t i = 0; i<ncro; i++){
796     //
797     Float_t cdx = (55./mag[i])*var.sfx;
798     Float_t cdy = (55./mag[i])*var.sfy;
799     Float_t lwx = (1.9)*var.sfy;
800     Float_t lwy = (1.9)*var.sfx;
801     //
802     linea = new TLine(yh1[i]-lwx/2.,xh[i]-cdy,yh1[i]-lwx/2.,xh[i]+cdy);
803     linea->SetLineWidth((int)lwx);
804     linea->SetLineColor(sigcol1);
805     linea->Draw();
806     linea = new TLine(yh1[i]-cdx,xh[i]-lwy/2.,yh1[i]+cdx,xh[i]-lwy/2.);
807     linea->SetLineWidth((int)lwy);
808     linea->SetLineColor(sigcol1);
809     linea->Draw();
810     //
811     linea = new TLine(yh2[i]-lwx/2.,xh[i]-cdy,yh2[i]-lwx/2.,xh[i]+cdy);
812     linea->SetLineWidth((int)lwx);
813     linea->SetLineColor(sigcol2);
814     linea->Draw();
815     linea = new TLine(yh2[i]-cdy,xh[i]-lwy/2.,yh2[i]+cdx,xh[i]-lwy/2.);
816     linea->SetLineWidth((int)lwy);
817     linea->SetLineColor(sigcol2);
818     linea->Draw();
819     };
820     };
821     }
822    
823     void ShowAC(Int_t i, TTree *otr, Variables & var, Int_t lev){
824     //
825     Int_t hitmapA = 0;
826     Int_t hitmapB = 0;
827     Int_t hitstatusA = 0;
828     Int_t hitstatusB = 0;
829     if ( lev == 0 ){
830     pamela::anticounter::AnticounterEvent *ace = 0;
831     otr->SetBranchAddress("Anticounter.Event", &ace);
832     if ( !var.nosig ) otr->GetEntry(i);
833     hitmapA = ace->hitmap[0];
834     hitmapB = ace->hitmap[1];
835     if ( lev == 0 ){
836     hitstatusA = 65535;
837     hitstatusB = 65535;
838     } else {
839     hitstatusA = ace->status[0];
840     hitstatusB = ace->status[1];
841     };
842     };
843     if ( lev == 1 ){
844     AnticounterLevel1 *ace1 = new AnticounterLevel1();
845     otr->SetBranchAddress("AcLevel1.Event", &ace1);
846     if ( !var.nosig ) otr->GetEntry(i);
847     hitmapA = ace1->hitmap[0];
848     hitmapB = ace1->hitmap[1];
849     if ( lev == 0 ){
850     hitstatusA = 65535;
851     hitstatusB = 65535;
852     } else {
853     hitstatusA = ace1->hitstatus[0];
854     hitstatusB = ace1->hitstatus[1];
855     };
856     };
857     //
858     if ( var.nosig ){
859     hitmapA = 0;
860     hitmapB = 0;
861     hitstatusA = 0;
862     hitstatusB = 0;
863     };
864     //
865     Float_t cas1 = 0.;
866     Float_t cas2 = 0.;
867     Float_t cas3 = 0.;
868     Float_t cas4 = 0.;
869     Float_t cas1b = 0.;
870     Float_t cas2b = 0.;
871     Float_t cas3b = 0.;
872     Float_t cas4b = 0.;
873     //
874     Float_t cat1 = 0.;
875     Float_t cat2 = 0.;
876     Float_t cat3 = 0.;
877     Float_t cat4 = 0.;
878     Float_t cat1b = 0.;
879     Float_t cat2b = 0.;
880     Float_t cat3b = 0.;
881     Float_t cat4b = 0.;
882     //
883     Float_t card1 = 0.;
884     Float_t card2 = 0.;
885     Float_t card3 = 0.;
886     Float_t card4 = 0.;
887     Float_t card1b = 0.;
888     Float_t card2b = 0.;
889     Float_t card3b = 0.;
890     Float_t card4b = 0.;
891     //
892     Float_t intime = -0.25;
893     Float_t outtime = -0.375;
894     if ( var.bw ){
895     intime = -0.25;
896     outtime = -0.375;
897     } else {
898     intime = 1.;
899     outtime = -4.;
900     };
901     //
902     // main board
903     //
904     if ( hitmapA & (1<<0) ) {
905     card4 = intime;
906     if ( !(hitstatusA & (1<<0)) ) card4 = outtime ;
907     var.hcard++;
908     }
909     if ( hitmapA & (1<<1) ) {
910     cat2 = intime;
911     if ( !(hitstatusA & (1<<1)) ) cat2 = outtime ;
912     var.hcat++;
913     }
914     if ( hitmapA & (1<<2) ) {
915     cas1 = intime;
916     if ( !(hitstatusA & (1<<2)) ) cas1 = outtime ;
917     var.hcas++;
918     }
919     //
920     if ( hitmapA & (1<<4) ) {
921     card2 = intime;
922     if ( !(hitstatusA & (1<<4)) ) card2 = outtime ;
923     var.hcard++;
924     }
925     if ( hitmapA & (1<<5) ) {
926     cat4 = intime;
927     if ( !(hitstatusA & (1<<5)) ) cat4 = outtime ;
928     var.hcat++;
929     }
930     if ( hitmapA & (1<<6) ) {
931     cas4 = intime;
932     if ( !(hitstatusA & (1<<6)) ) cas4 = outtime ;
933     var.hcas++;
934     }
935     //
936     if ( hitmapA & (1<<8) ) {
937     card3 = intime;
938     if ( !(hitstatusA & (1<<8)) ) card3 = outtime ;
939     var.hcard++;
940     }
941     if ( hitmapA & (1<<9) ) {
942     cat3 = intime;
943     if ( !(hitstatusA & (1<<9)) ) cat3 = outtime ;
944     var.hcat++;
945     }
946     if ( hitmapA & (1<<10) ) {
947     cas3 = intime;
948     if ( !(hitstatusA & (1<<10)) ) cas3 = outtime ;
949     var.hcas++;
950     }
951     //
952     if ( hitmapA & (1<<12) ) {
953     card1 = intime;
954     if ( !(hitstatusA & (1<<12)) ) card1 = outtime ;
955     var.hcard++;
956     }
957     if ( hitmapA & (1<<13) ) {
958     cat1 = intime;
959     if ( !(hitstatusA & (1<<13)) ) cat1 = outtime ;
960     var.hcat++;
961     }
962     if ( hitmapA & (1<<14) ) {
963     cas2 = intime;
964     if ( !(hitstatusA & (1<<14)) ) cas2 = outtime ;
965     var.hcas++;
966     }
967    
968     //
969     // extra board
970     //
971     if ( hitmapB & (1<<0) ) {
972     card4b = intime;
973     if ( !(hitstatusB & (1<<0)) ) card4b = outtime ;
974     var.hcard++;
975     }
976     if ( hitmapB & (1<<1) ) {
977     cat2b = intime;
978     if ( !(hitstatusB & (1<<1)) ) cat2b = outtime ;
979     var.hcat++;
980     }
981     if ( hitmapB & (1<<2) ) {
982     cas1b = intime;
983     if ( !(hitstatusB & (1<<2)) ) cas1b = outtime;
984     var.hcas++;
985     }
986     //
987     if ( hitmapB & (1<<4) ) {
988     card2b = intime;
989     if ( !(hitstatusB & (1<<4)) ) card2b = outtime ;
990     var.hcard++;
991     }
992     if ( hitmapB & (1<<5) ) {
993     cat4b = intime;
994     if ( !(hitstatusB & (1<<5)) ) cat4b = outtime ;
995     var.hcat++;
996     }
997     if ( hitmapB & (1<<6) ) {
998     cas4b = intime;
999     if ( !(hitstatusB & (1<<6)) ) cas4b = outtime ;
1000     var.hcas++;
1001     }
1002     //
1003     if ( hitmapB & (1<<8) ) {
1004     card3b = intime;
1005     if ( !(hitstatusB & (1<<8)) ) card3b = outtime ;
1006     var.hcard++;
1007     }
1008     if ( hitmapB & (1<<9) ) {
1009     cat3b = intime;
1010     if ( !(hitstatusB & (1<<9)) ) cat3b = outtime ;
1011     var.hcat++;
1012     }
1013     if ( hitmapB & (1<<10) ) {
1014     cas3b = intime;
1015     if ( !(hitstatusB & (1<<10)) ) cas3b = outtime ;
1016     var.hcas++;
1017     }
1018     //
1019     if ( hitmapB & (1<<12) ) {
1020     card1b = intime;
1021     if ( !(hitstatusB & (1<<12)) ) card1b = outtime ;
1022     var.hcard++;
1023     }
1024     if ( hitmapB & (1<<13) ) {
1025     cat1b = intime;
1026     if ( !(hitstatusB & (1<<13)) ) cat1b = outtime ;
1027     var.hcat++;
1028     }
1029     if ( hitmapB & (1<<14) ) {
1030     cas2b = intime;
1031     if ( !(hitstatusB & (1<<14)) ) cas2b = outtime ;
1032     var.hcas++;
1033     };
1034     Int_t colo = 0;
1035     //
1036     // CAS height and width
1037     //
1038     Float_t csh = 0.194*var.sfy;
1039     Float_t csw = 0.008*var.sfx;
1040     Float_t ctw = 0.008;
1041    
1042     //
1043     // CAS2 -0.039-0.081 |TRX TRY
1044     //
1045     if ( true ){
1046     Float_t xofs = var.xxvc -(0.039+0.081+0.0273)*var.sfx;
1047     Float_t yofs = var.yxvc + 0.09*var.sfy ;
1048     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
1049     Double_t y[4] = {yofs-csh,yofs-csh,yofs+csh,yofs-csh};
1050     TPolyLine *fcas2 = new TPolyLine(4,x,y);
1051     fcas2->SetLineColor(1);
1052     colo = (int)(10. - cas2 * 8.);
1053     fcas2->SetFillColor(colo);
1054     fcas2->SetLineWidth(1);
1055     fcas2->Draw("f");
1056     fcas2->Draw();
1057     };
1058     if ( true ){
1059     Float_t xofs = var.xxvc -(0.039 +0.081 +0.0273)*var.sfx;
1060     Float_t yofs = var.yxvc + 0.09*var.sfy ;
1061     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
1062     Double_t y[4] = {yofs+csh,yofs-csh,yofs+csh,yofs+csh};
1063     TPolyLine *fcas2b = new TPolyLine(4,x,y);
1064     fcas2b->SetLineColor(1);
1065     colo = (int)(10. - cas2b * 8.);
1066     fcas2b->SetFillColor(colo);
1067     fcas2b->SetLineWidth(1);
1068     fcas2b->Draw("f");
1069     fcas2b->Draw();
1070     };
1071     //
1072     // CAS1 -0.039+0.081 TRX| TRY
1073     //
1074     if ( true ){
1075     Float_t xofs = var.xxvc + (0.039 +0.081+0.0273)*var.sfx +csw;
1076     Float_t yofs = var.yxvc + 0.09*var.sfy ;
1077     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
1078     Double_t y[4] = {yofs-csh,yofs+csh,yofs-csh,yofs-csh};
1079     TPolyLine *fcas1 = new TPolyLine(4,x,y);
1080     fcas1->SetLineColor(1);
1081     colo = (int)(10. - cas1 * 8.);
1082     fcas1->SetFillColor(colo);
1083     fcas1->SetLineWidth(1);
1084     fcas1->Draw("f");
1085     fcas1->Draw();
1086     };
1087     if ( true ){
1088     Float_t xofs = var.xxvc + (0.039 +0.081+0.0273)*var.sfx +csw;
1089     Float_t yofs = var.yxvc + 0.09*var.sfy ;
1090     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
1091     Double_t y[4] = {yofs+csh,yofs+csh,yofs-csh,yofs+csh};
1092     TPolyLine *fcas1b = new TPolyLine(4,x,y);
1093     fcas1b->SetLineColor(1);
1094     colo = (int)(10. - cas1b * 8.);
1095     fcas1b->SetFillColor(colo);
1096     fcas1b->SetLineWidth(1);
1097     fcas1b->Draw("f");
1098     fcas1b->Draw();
1099     };
1100     //
1101     // CAS4 -0.039-0.081 TRX |TRY
1102     //
1103     if ( true ){
1104     Float_t xofs = var.xyvc - (0.048 +0.066 +0.0273)*var.sfx;
1105     Float_t yofs = var.yyvc + 0.09*var.sfy ;
1106     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
1107     Double_t y[4] = {yofs-csh,yofs-csh,yofs+csh,yofs-csh};
1108     TPolyLine *fcas4 = new TPolyLine(4,x,y);
1109     fcas4->SetLineColor(1);
1110     colo = (int)(10. - cas4 * 8.);
1111     fcas4->SetFillColor(colo);
1112     fcas4->SetLineWidth(1);
1113     fcas4->Draw("f");
1114     fcas4->Draw();
1115     };
1116     if ( true ){
1117     Float_t xofs = var.xyvc - (0.048 +0.066 +0.0273)*var.sfx;
1118     Float_t yofs = var.yyvc + 0.09*var.sfy ;
1119     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
1120     Double_t y[4] = {yofs+csh,yofs-csh,yofs+csh,yofs+csh};
1121     TPolyLine *fcas4b = new TPolyLine(4,x,y);
1122     fcas4b->SetLineColor(1);
1123     colo = (int)(10. - cas4b * 8.);
1124     fcas4b->SetFillColor(colo);
1125     fcas4b->SetLineWidth(1);
1126     fcas4b->Draw("f");
1127     fcas4b->Draw();
1128     };
1129    
1130     //
1131     // CAS3 -0.039+0.081 TRX TRY|
1132     //
1133     if ( true ){
1134     Float_t xofs = var.xyvc + (0.048 +0.066+0.0273)*var.sfx +csw;
1135     Float_t yofs = var.yyvc + 0.09*var.sfy ;
1136     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
1137     Double_t y[4] = {yofs-csh,yofs+csh,yofs-csh,yofs-csh};
1138     TPolyLine *fcas3 = new TPolyLine(4,x,y);
1139     fcas3->SetLineColor(1);
1140     colo = (int)(10. - cas3 * 8.);
1141     fcas3->SetFillColor(colo);
1142     fcas3->SetLineWidth(1);
1143     fcas3->Draw("f");
1144     fcas3->Draw();
1145     };
1146     if ( true ){
1147     Float_t xofs = var.xyvc + (0.048 +0.066+0.0273)*var.sfx +csw;
1148     Float_t yofs = var.yyvc + 0.09*var.sfy ;
1149     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
1150     Double_t y[4] = {yofs+csh,yofs+csh,yofs-csh,yofs+csh};
1151     TPolyLine *fcas3b = new TPolyLine(4,x,y);
1152     fcas3b->SetLineColor(1);
1153     colo = (int)(10. - cas3b * 8.);
1154     fcas3b->SetFillColor(colo);
1155     fcas3b->SetLineWidth(1);
1156     fcas3b->Draw("f");
1157     fcas3b->Draw();
1158     };
1159    
1160     //
1161     // CAT coordinate system
1162     //
1163     Float_t xcat = var.xcat;
1164     Float_t ycat = var.ycat;
1165     Float_t pmt1 = 0.0356;
1166     Float_t pmt2 = 0.038;
1167     Float_t xpmt1 = -0.149*var.sfx;
1168     Float_t ypmt1 = 0.251*var.sfy;
1169     Float_t apmt1 = atan((11.*var.sfy)/(14.*var.sfx));
1170     Float_t xpmt2 = -0.257*var.sfx;
1171     Float_t ypmt2 = 0.158*var.sfy;
1172     Float_t apmt2 = atan((11.*var.sfx)/(15.*var.sfy));
1173     //
1174     Int_t cattime = 13;
1175     Int_t catnoti = 12;
1176     if ( var.bw ){
1177     cattime = 13;
1178     catnoti = 12;
1179     } else {
1180     cattime = 2;
1181     catnoti = 42;
1182     };
1183     //
1184     if ( true ){
1185     // PMTs
1186     Float_t xc1[5]={ 0., 0.014*var.sfx, 0.014*var.sfx-var.sfx*var.sfx*pmt1*cos(apmt1), -var.sfx*var.sfx*pmt1*cos(apmt1), 0.};
1187     Float_t yc1[5]={ 0., 0.011*var.sfy, 0.011*var.sfy+var.sfy*var.sfy*pmt1*sin(apmt1), var.sfy*var.sfy*pmt1*sin(apmt1), 0.};
1188     Float_t xc2[5]={ 0., 0.011*var.sfx, 0.011*var.sfx-pmt2*var.sfx*var.sfx*cos(apmt2), -pmt2*var.sfx*var.sfx*cos(apmt2), 0.};
1189     Float_t yc2[5]={ 0., 0.015*var.sfy, 0.015*var.sfy+var.sfy*pmt2*var.sfy*sin(apmt2), var.sfy*pmt2*var.sfy*sin(apmt2), 0.};
1190     // SCINTs
1191     Float_t xcc1[10]={-0.149, -0.090165, -0.090165, -0.149, -0.242, -0.257, -0.212, -0.257, -0.242, -0.149};
1192     Float_t ycc1[10]={ 0.169, 0.108165, -0.108165, -0.169, -0.169, -0.158, 0., 0.158, 0.169, 0.169};
1193     Float_t xcc2[10]={-0.149, -0.149, -0.138, 0., 0.138, 0.149, 0.149, 0.090165, -0.090165, -0.149};
1194     Float_t ycc2[10]={ 0.169, 0.251, 0.265, 0.220, 0.265, 0.251, 0.169, 0.108165, 0.108165, 0.169};
1195     //
1196     // CAT sections
1197     //
1198     if ( true ){
1199     Float_t xofs = var.xxvc -0.108165*var.sfx;
1200     Float_t yofs = var.yxvc + 0.3725*var.sfy ;
1201     Double_t xx[5] = {xofs,xofs-0.112*var.sfx,xofs-0.112*var.sfx,xofs,xofs};
1202     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
1203     TPolyLine *fcat3 = new TPolyLine(5,xx,yy);
1204     fcat3->SetLineColor(1);
1205     if ( cat3 != 0. || cat3b != 0. ){
1206     if ( cat3 > 0 || cat3b > 0 || cat3 == -0.25 || cat3b == -0.25 ){
1207     colo = cattime;
1208     } else {
1209     colo = catnoti;
1210     };
1211     } else {
1212     colo = 10;
1213     };
1214     fcat3->SetFillColor(colo);
1215     fcat3->SetLineWidth(1);
1216     fcat3->Draw("f");
1217     fcat3->Draw();
1218     };
1219     if ( true ){
1220     Float_t xofs = var.xxvc +0.108165*var.sfx;
1221     Float_t yofs = var.yxvc + 0.3725 *var.sfy;
1222     Double_t xx[5] = {xofs,xofs+0.112*var.sfx,xofs+0.112*var.sfx,xofs,xofs};
1223     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
1224     TPolyLine *fcat4 = new TPolyLine(5,xx,yy);
1225     fcat4->SetLineColor(1);
1226     if ( cat4 != 0. || cat4b != 0. ){
1227     if ( cat4 > 0 || cat4b > 0 || cat4 == -.25 || cat4b == -.25 ){
1228     colo = cattime;
1229     } else {
1230     colo = catnoti;
1231     };
1232     } else {
1233     colo = 10;
1234     };
1235     fcat4->SetFillColor(colo);
1236     fcat4->SetLineWidth(1);
1237     fcat4->Draw("f");
1238     fcat4->Draw();
1239     };
1240     if ( true ){
1241     Float_t xofs = var.xyvc + 0.090165*var.sfx;
1242     Float_t yofs = var.yyvc + 0.3725*var.sfy ;
1243     Double_t xx[5] = {xofs,xofs+0.122*var.sfx,xofs+0.122*var.sfx,xofs,xofs};
1244     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
1245     TPolyLine *fcat1 = new TPolyLine(5,xx,yy);
1246     fcat1->SetLineColor(1);
1247     if ( cat1 != 0. || cat1b != 0. ){
1248     if ( cat1 > 0 || cat1b > 0 || cat1 ==-.25 || cat1b ==-.25 ){
1249     colo = cattime;
1250     } else {
1251     colo = catnoti;
1252     };
1253     } else {
1254     colo = 10;
1255     };
1256     fcat1->SetFillColor(colo);
1257     fcat1->SetLineWidth(1);
1258     fcat1->Draw("f");
1259     fcat1->Draw();
1260     };
1261     if ( true ){
1262     Float_t xofs = var.xyvc - 0.090165*var.sfx;
1263     Float_t yofs = var.yyvc + 0.3725*var.sfy ;
1264     Double_t xx[5] = {xofs,xofs-0.122*var.sfx,xofs-0.122*var.sfx,xofs,xofs};
1265     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
1266     TPolyLine *fcat2 = new TPolyLine(5,xx,yy);
1267     fcat2->SetLineColor(1);
1268     if ( cat2 != 0. || cat2b != 0. ){
1269     if ( cat2 > 0 || cat2b > 0 || cat2 ==-.25 || cat2b ==-.25 ){
1270     colo = cattime;
1271     } else {
1272     colo = catnoti;
1273     };
1274     } else {
1275     colo = 10;
1276     };
1277     fcat2->SetFillColor(colo);
1278     fcat2->SetLineWidth(1);
1279     fcat2->Draw("f");
1280     fcat2->Draw();
1281     };
1282     //
1283     // CAT1
1284     //
1285     Float_t xcc[10];
1286     Float_t ycc[10];
1287     if ( true ){
1288     for (Int_t i = 0; i<10 ; i++) {
1289     xcc[i]= xcat - xcc1[i]*var.sfx;
1290     ycc[i] = ycat + ycc1[i]*var.sfy;
1291     };
1292     TPolyLine *fcat1 = new TPolyLine(10,xcc,ycc);
1293     fcat1->SetLineColor(1);
1294     colo = 10;
1295     if ( cat1 != 0. || cat1b != 0. ) {
1296     if ( cat1 > 0 || cat1b > 0 || cat1 ==-.25 || cat1b ==-.25 ){
1297     colo = cattime;
1298     } else {
1299     colo = catnoti;
1300     };
1301     };
1302     fcat1->SetFillColor(colo);
1303     fcat1->SetLineWidth(1);
1304     fcat1->Draw("f");
1305     fcat1->Draw();
1306     };
1307     //
1308     // CAT2
1309     //
1310     if ( true ){
1311     for (Int_t i = 0; i<10 ; i++) {
1312     xcc[i]= xcat + xcc1[i]*var.sfx;
1313     ycc[i] = ycat + ycc1[i]*var.sfy;
1314     };
1315     TPolyLine *fcat2 = new TPolyLine(10,xcc,ycc);
1316     fcat2->SetLineColor(1);
1317     colo = 10;
1318     if ( cat2 != 0. || cat2b != 0. ) {
1319     if ( cat2 > 0 || cat2b > 0 || cat2 ==-.25 || cat2b ==-.25 ){
1320     colo = cattime;
1321     } else {
1322     colo = catnoti;
1323     };
1324     };
1325     fcat2->SetFillColor(colo);
1326     fcat2->SetLineWidth(1);
1327     fcat2->Draw("f");
1328     fcat2->Draw();
1329     };
1330     //
1331     // CAT3
1332     //
1333     if ( true ){
1334     for (Int_t i = 0; i<10 ; i++) {
1335     xcc[i]= xcat + xcc2[i]*var.sfx;
1336     ycc[i] = ycat - ycc2[i]*var.sfy;
1337     };
1338     TPolyLine *fcat3 = new TPolyLine(10,xcc,ycc);
1339     fcat3->SetLineColor(1);
1340     colo = 10;
1341     if ( cat3 != 0. || cat3b != 0. ) {
1342     if ( cat3 > 0 || cat3b > 0 || cat3 == -.25 || cat3b ==-.25 ){
1343     colo = cattime;
1344     } else {
1345     colo = catnoti;
1346     };
1347     };
1348     fcat3->SetFillColor(colo);
1349     fcat3->SetLineWidth(1);
1350     fcat3->Draw("f");
1351     fcat3->Draw();
1352     };
1353     //
1354     // CAT4
1355     //
1356     if ( true ){
1357     for (Int_t i = 0; i<10 ; i++) {
1358     xcc[i]= xcat + xcc2[i]*var.sfx;
1359     ycc[i] = ycat + ycc2[i]*var.sfy;
1360     };
1361     TPolyLine *fcat4 = new TPolyLine(10,xcc,ycc);
1362     fcat4->SetLineColor(1);
1363     colo = 10;
1364     if ( cat4 != 0. || cat4b != 0. ) {
1365     if ( cat4 > 0 || cat4b > 0 || cat4 == -.25 || cat4b ==-.25 ){
1366     colo = cattime;
1367     } else {
1368     colo = catnoti;
1369     };
1370     };
1371     fcat4->SetFillColor(colo);
1372     fcat4->SetLineWidth(1);
1373     fcat4->Draw("f");
1374     fcat4->Draw();
1375     };
1376     //
1377     // CAT1 PMTs
1378     //
1379     Float_t xc[5];
1380     Float_t yc[5];
1381     if ( true ){
1382     for (Int_t i = 0; i<5 ; i++) {
1383     xc[i]= xcat - xpmt2 - xc1[i];
1384     yc[i] = ycat + ypmt2 + yc1[i];
1385     };
1386     TPolyLine *fcat1 = new TPolyLine(5,xc,yc);
1387     fcat1->SetLineColor(1);
1388     colo = (int)(10. - cat1 * 8.);
1389     fcat1->SetFillColor(colo);
1390     fcat1->SetLineWidth(1);
1391     fcat1->Draw("f");
1392     fcat1->Draw();
1393     };
1394     if ( true ){
1395     for (Int_t i = 0; i<5 ; i++) {
1396     xc[i]= xcat - xpmt2 - xc1[i];
1397     yc[i] = ycat - ypmt2 - yc1[i];
1398     };
1399     TPolyLine *fcat1b = new TPolyLine(5,xc,yc);
1400     fcat1b->SetLineColor(1);
1401     colo = (int)(10. - cat1b * 8.);
1402     fcat1b->SetFillColor(colo);
1403     fcat1b->SetLineWidth(1);
1404     fcat1b->Draw("f");
1405     fcat1b->Draw();
1406     };
1407     //
1408     // CAT2 PMTs
1409     //
1410     if ( true ){
1411     for (Int_t i = 0; i<5 ; i++) {
1412     xc[i]= xcat + xpmt2 + xc1[i];
1413     yc[i] = ycat + ypmt2 + yc1[i];
1414     };
1415     TPolyLine *fcat2 = new TPolyLine(5,xc,yc);
1416     fcat2->SetLineColor(1);
1417     colo = (int)(10. - cat2 * 8.);
1418     fcat2->SetFillColor(colo);
1419     fcat2->SetLineWidth(1);
1420     fcat2->Draw("f");
1421     fcat2->Draw();
1422     };
1423     if ( true ){
1424     for (Int_t i = 0; i<5 ; i++) {
1425     xc[i]= xcat + xpmt2 + xc1[i];
1426     yc[i] = ycat - ypmt2 - yc1[i];
1427     };
1428     TPolyLine *fcat2b = new TPolyLine(5,xc,yc);
1429     fcat2b->SetLineColor(1);
1430     colo = (int)(10. - cat2b * 8.);
1431     fcat2b->SetFillColor(colo);
1432     fcat2b->SetLineWidth(1);
1433     fcat2b->Draw("f");
1434     fcat2b->Draw();
1435     };
1436     //
1437     // CAT3 PMTs
1438     //
1439     if ( true ){
1440     for (Int_t i = 0; i<5 ; i++) {
1441     xc[i]= xcat + xpmt1 + xc2[i];
1442     yc[i] = ycat - ypmt1 - yc2[i];
1443     };
1444     TPolyLine *fcat3b = new TPolyLine(5,xc,yc);
1445     fcat3b->SetLineColor(1);
1446     colo = (int)(10. - cat3b * 8.);
1447     fcat3b->SetFillColor(colo);
1448     fcat3b->SetLineWidth(1);
1449     fcat3b->Draw("f");
1450     fcat3b->Draw();
1451     };
1452     if ( true ){
1453     for (Int_t i = 0; i<5 ; i++) {
1454     xc[i]= xcat - xpmt1 - xc2[i];
1455     yc[i] = ycat - ypmt1 - yc2[i];
1456     };
1457     TPolyLine *fcat3 = new TPolyLine(5,xc,yc);
1458     fcat3->SetLineColor(1);
1459     colo = (int)(10. - cat3 * 8.);
1460     fcat3->SetFillColor(colo);
1461     fcat3->SetLineWidth(1);
1462     fcat3->Draw("f");
1463     fcat3->Draw();
1464     };
1465     //
1466     // CAT4 PMTs
1467     //
1468     if ( true ){
1469     for (Int_t i = 0; i<5 ; i++) {
1470     xc[i]= xcat + xpmt1 + xc2[i];
1471     yc[i] = ycat + ypmt1 + yc2[i];
1472     };
1473     TPolyLine *fcat4b = new TPolyLine(5,xc,yc);
1474     fcat4b->SetLineColor(1);
1475     colo = (int)(10. - cat4b * 8.);
1476     fcat4b->SetFillColor(colo);
1477     fcat4b->SetLineWidth(1);
1478     fcat4b->Draw("f");
1479     fcat4b->Draw();
1480     };
1481     if ( true ){
1482     for (Int_t i = 0; i<5 ; i++) {
1483     xc[i]= xcat - xpmt1 - xc2[i];
1484     yc[i] = ycat + ypmt1 + yc2[i];
1485     };
1486     TPolyLine *fcat4 = new TPolyLine(5,xc,yc);
1487     fcat4->SetLineColor(1);
1488     colo = (int)(10. - cat4 * 8.);
1489     fcat4->SetFillColor(colo);
1490     fcat4->SetLineWidth(1);
1491     fcat4->Draw("f");
1492     fcat4->Draw();
1493     };
1494     };
1495     if ( true ){
1496     //
1497     // CAS plane view:
1498     //
1499     Float_t xofs = -0.025;
1500     Float_t yofs = 0.039 +0.081+0.0273;
1501     Float_t csy = 0.33/2.;
1502     Float_t pmofs = 0.004;
1503     Float_t csw2 = 0.008;
1504     Float_t xc1[5] = { xofs-csy, xofs-csy, xofs+csy, xofs+csy, xofs-csy};
1505     Float_t yc1[5] = { yofs, yofs+csw2, yofs+csw2, yofs, yofs};
1506    
1507     Float_t xc2[5] = { xofs-csy-csw2, xofs-csy-csw2, xofs-csy, xofs-csy, xofs-csy-csw2};
1508     Float_t yc2[5] = { yofs+pmofs, yofs+pmofs+csw2, yofs+pmofs+csw2, yofs+pmofs, yofs+pmofs};
1509     Float_t xc3[5] = { xofs-csy-csw2, xofs-csy-csw2, xofs-csy, xofs-csy, xofs-csy-csw2};
1510     Float_t yc3[5] = { yofs+pmofs, yofs+pmofs-csw2, yofs+pmofs-csw2, yofs+pmofs, yofs+pmofs};
1511    
1512     //
1513     // CAS1
1514     //
1515     Float_t xc[5];
1516     Float_t yc[5];
1517     for (Int_t i = 0; i<5 ; i++) {
1518     xc[i]= xcat + xc1[i]*var.sfx;
1519     yc[i] = ycat + yc1[i]*var.sfy;
1520     };
1521     TPolyLine *pcass1 = new TPolyLine(5,xc,yc);
1522     pcass1->SetLineColor(1);
1523     colo = 10;
1524     if ( cas1 != 0. || cas1b != 0. ) {
1525     if ( cas1 > 0 || cas1b > 0 || cas1 ==-.25 || cas1b ==-.25){
1526     colo = cattime;
1527     } else {
1528     colo = catnoti;
1529     };
1530     };
1531     if ( colo != 10 ) pcass1->SetFillStyle(3001);
1532     pcass1->SetFillColor(colo);
1533     pcass1->SetLineWidth(1);
1534     pcass1->SetLineStyle(2);
1535     pcass1->Draw("f");
1536     pcass1->Draw();
1537     //
1538     for (Int_t i = 0; i<5 ; i++) {
1539     xc[i]= xcat + xc2[i]*var.sfx;
1540     yc[i] = ycat + yc2[i]*var.sfy;
1541     };
1542     TPolyLine *pcasp1b = new TPolyLine(5,xc,yc);
1543     pcasp1b->SetLineColor(1);
1544     colo = (int)(10. - cas1b * 8.);
1545     if ( colo != 10 ) pcasp1b->SetFillStyle(3001);
1546     pcasp1b->SetFillColor(colo);
1547     pcasp1b->SetLineWidth(1);
1548     pcasp1b->SetLineStyle(2);
1549     pcasp1b->Draw("f");
1550     pcasp1b->Draw();
1551     //
1552     for (Int_t i = 0; i<5 ; i++) {
1553     xc[i]= xcat + xc3[i]*var.sfx;
1554     yc[i] = ycat + yc3[i]*var.sfy;
1555     };
1556     TPolyLine *pcasp1 = new TPolyLine(5,xc,yc);
1557     pcasp1->SetLineColor(1);
1558     colo = (int)(10. - cas1 * 8.);
1559     if ( colo != 10 ) pcasp1->SetFillStyle(3001);
1560     pcasp1->SetFillColor(colo);
1561     pcasp1->SetLineWidth(1);
1562     pcasp1->SetLineStyle(2);
1563     pcasp1->Draw("f");
1564     pcasp1->Draw();
1565     //
1566     // CAS2
1567     //
1568     for (Int_t i = 0; i<5 ; i++) {
1569     xc[i]= xcat - xc1[i]*var.sfx;
1570     yc[i] = ycat - yc1[i]*var.sfy;
1571     };
1572     TPolyLine *pcass2 = new TPolyLine(5,xc,yc);
1573     pcass2->SetLineColor(1);
1574     colo = 10;
1575     if ( cas2 != 0. || cas2b != 0. ) {
1576     if ( cas2 > 0 || cas2b > 0 || cas2 ==-.25 || cas2b ==-.25 ){
1577     colo = cattime;
1578     } else {
1579     colo = catnoti;
1580     };
1581     };
1582     if ( colo != 10 ) pcass2->SetFillStyle(3001);
1583     pcass2->SetFillColor(colo);
1584     pcass2->SetLineWidth(1);
1585     pcass2->SetLineStyle(2);
1586     pcass2->Draw("f");
1587     pcass2->Draw();
1588     //
1589     for (Int_t i = 0; i<5 ; i++) {
1590     xc[i]= xcat - xc2[i]*var.sfx;
1591     yc[i] = ycat - yc2[i]*var.sfy;
1592     };
1593     TPolyLine *pcasp2b = new TPolyLine(5,xc,yc);
1594     pcasp2b->SetLineColor(1);
1595     colo = (int)(10. - cas2b * 8.);
1596     if ( colo != 10 ) pcasp2b->SetFillStyle(3001);
1597     pcasp2b->SetFillColor(colo);
1598     pcasp2b->SetLineWidth(1);
1599     pcasp2b->SetLineStyle(2);
1600     pcasp2b->Draw("f");
1601     pcasp2b->Draw();
1602     //
1603     for (Int_t i = 0; i<5 ; i++) {
1604     xc[i]= xcat - xc3[i]*var.sfx;
1605     yc[i] = ycat - yc3[i]*var.sfy;
1606     };
1607     TPolyLine *pcasp2 = new TPolyLine(5,xc,yc);
1608     pcasp2->SetLineColor(1);
1609     colo = (int)(10. - cas2 * 8.);
1610     pcasp2->SetFillColor(colo);
1611     if ( colo != 10 ) pcasp2->SetFillStyle(3001);
1612     pcasp2->SetLineWidth(1);
1613     pcasp2->SetLineStyle(2);
1614     pcasp2->Draw("f");
1615     pcasp2->Draw();
1616    
1617     };
1618     if ( true ){
1619     Float_t xofs = 0.048 +0.066+0.0273;
1620     Float_t yofs = 0.02;
1621     Float_t csy = 0.33/2.;
1622     Float_t pmofs = 0.004;
1623     Float_t csw2 = 0.008;
1624     Float_t xc1[5] = { xofs, xofs+csw2, xofs+csw2, xofs, xofs};
1625     Float_t yc1[5] = { yofs-csy, yofs-csy, yofs+csy, yofs+csy, yofs-csy};
1626     Float_t xc2[5] = { xofs+pmofs, xofs+pmofs+csw2, xofs+pmofs+csw2, xofs+pmofs, xofs+pmofs};
1627     Float_t yc2[5] = { yofs+csy+csw2, yofs+csy+csw2, yofs+csy, yofs+csy, yofs+csy+csw2};
1628     Float_t xc3[5] = { xofs+pmofs, xofs+pmofs-csw2, xofs+pmofs-csw2, xofs+pmofs, xofs+pmofs};
1629     Float_t yc3[5] = { yofs+csy+csw2, yofs+csy+csw2, yofs+csy, yofs+csy, yofs+csy+csw2};
1630     //
1631     // CAS3
1632     //
1633     Float_t xc[5];
1634     Float_t yc[5];
1635     for (Int_t i = 0; i<5 ; i++) {
1636     xc[i]= xcat + xc1[i]*var.sfx;
1637     yc[i] = ycat + yc1[i]*var.sfy;
1638     };
1639     TPolyLine *pcass3 = new TPolyLine(5,xc,yc);
1640     pcass3->SetLineColor(1);
1641     colo = 10;
1642     if ( cas3 != 0. || cas3b != 0. ) {
1643     if ( cas3 > 0 || cas3b > 0 || cas3 ==-.25 || cas3b ==-.25){
1644     colo = cattime;
1645     } else {
1646     colo = catnoti;
1647     };
1648     };
1649     if ( colo != 10 ) pcass3->SetFillStyle(3001);
1650     pcass3->SetFillColor(colo);
1651     pcass3->SetLineWidth(1);
1652     pcass3->SetLineStyle(2);
1653     pcass3->Draw("f");
1654     pcass3->Draw();
1655     //
1656     for (Int_t i = 0; i<5 ; i++) {
1657     xc[i]= xcat + xc2[i]*var.sfx;
1658     yc[i] = ycat + yc2[i]*var.sfy;
1659     };
1660     TPolyLine *pcasp3b = new TPolyLine(5,xc,yc);
1661     pcasp3b->SetLineColor(1);
1662     colo = (int)(10. - cas3b * 8.);
1663     if ( colo != 10 ) pcasp3b->SetFillStyle(3001);
1664     pcasp3b->SetFillColor(colo);
1665     pcasp3b->SetLineWidth(1);
1666     pcasp3b->SetLineStyle(2);
1667     pcasp3b->Draw("f");
1668     pcasp3b->Draw();
1669     //
1670     for (Int_t i = 0; i<5 ; i++) {
1671     xc[i]= xcat + xc3[i]*var.sfx;
1672     yc[i] = ycat + yc3[i]*var.sfy;
1673     };
1674     TPolyLine *pcasp3 = new TPolyLine(5,xc,yc);
1675     pcasp3->SetLineColor(1);
1676     colo = (int)(10. - cas3 * 8.);
1677     pcasp3->SetFillColor(colo);
1678     if ( colo != 10 ) pcasp3->SetFillStyle(3001);
1679     pcasp3->SetLineWidth(1);
1680     pcasp3->SetLineStyle(2);
1681     pcasp3->Draw("f");
1682     pcasp3->Draw();
1683     //
1684     // CAS4
1685     //
1686     for (Int_t i = 0; i<5 ; i++) {
1687     xc[i]= xcat - xc1[i]*var.sfx;
1688     yc[i] = ycat - yc1[i]*var.sfy;
1689     };
1690     TPolyLine *pcass4 = new TPolyLine(5,xc,yc);
1691     pcass4->SetLineColor(1);
1692     colo = 10;
1693     if ( cas4 != 0. || cas4b != 0. ) {
1694     if ( cas4 > 0 || cas4b > 0 || cas4 ==-.25 || cas4b ==-.25 ){
1695     colo = cattime;
1696     } else {
1697     colo = catnoti;
1698     };
1699     };
1700     pcass4->SetFillColor(colo);
1701     if ( colo != 10 ) pcass4->SetFillStyle(3001);
1702     pcass4->SetLineWidth(1);
1703     pcass4->SetLineStyle(2);
1704     pcass4->Draw("f");
1705     pcass4->Draw();
1706     //
1707     for (Int_t i = 0; i<5 ; i++) {
1708     xc[i]= xcat - xc2[i]*var.sfx;
1709     yc[i] = ycat - yc2[i]*var.sfy;
1710     };
1711     TPolyLine *pcasp4 = new TPolyLine(5,xc,yc);
1712     pcasp4->SetLineColor(1);
1713     colo = (int)(10. - cas4 * 8.);
1714     pcasp4->SetFillColor(colo);
1715     if ( colo != 10 ) pcasp4->SetFillStyle(3001);
1716     pcasp4->SetLineWidth(1);
1717     pcasp4->SetLineStyle(2);
1718     pcasp4->Draw("f");
1719     pcasp4->Draw();
1720     //
1721     for (Int_t i = 0; i<5 ; i++) {
1722     xc[i]= xcat - xc3[i]*var.sfx;
1723     yc[i] = ycat - yc3[i]*var.sfy;
1724     };
1725     TPolyLine *pcasp4b = new TPolyLine(5,xc,yc);
1726     pcasp4b->SetLineColor(1);
1727     colo = (int)(10. - cas4b * 8.);
1728     pcasp4b->SetFillColor(colo);
1729     if ( colo != 10 ) pcasp4b->SetFillStyle(3001);
1730     pcasp4b->SetLineWidth(1);
1731     pcasp4b->SetLineStyle(2);
1732     pcasp4b->Draw("f");
1733     pcasp4b->Draw();
1734     };
1735     Float_t alfa = 1.2020334;
1736     Float_t lcrd = 0.1815/2.;
1737     Float_t wcrd = 0.008;
1738     if ( true ){
1739     //
1740     // CARD plane view:
1741     //
1742     Float_t xc1[5] = { -0.090165, -0.090165, -0.082165, -0.082165, -0.090165};
1743     Float_t yc1[5] = { -0.100, 0.092, 0.092, -0.100, -0.100};
1744     Float_t xc2[5] = { -0.094165, -0.094165, -0.086165, -0.086165, -0.094165};
1745     Float_t yc2[5] = { 0.092, 0.100, 0.100, 0.092, 0.092};
1746     Float_t xc3[5] = { -0.086165, -0.086165, -0.078165, -0.078165, -0.086165};
1747     Float_t yc3[5] = { 0.092, 0.100, 0.100, 0.092, 0.092};
1748     //
1749     // CARD1
1750     //
1751     Float_t xc[5];
1752     Float_t yc[5];
1753     for (Int_t i = 0; i<5 ; i++) {
1754     xc[i]= xcat + xc1[i]*var.sfx;
1755     yc[i] = ycat + yc1[i]*var.sfy;
1756     };
1757     TPolyLine *pcars1 = new TPolyLine(5,xc,yc);
1758     pcars1->SetLineColor(1);
1759     colo = 10;
1760     if ( card1 != 0. || card1b != 0. ) {
1761     if ( card1 > 0 || card1b > 0 || card1 ==-.25 || card1b ==-.25 ){
1762     colo = cattime;
1763     } else {
1764     colo = catnoti;
1765     };
1766     };
1767     pcars1->SetFillColor(colo);
1768     pcars1->SetLineWidth(1);
1769     pcars1->Draw("f");
1770     pcars1->Draw();
1771     //
1772     for (Int_t i = 0; i<5 ; i++) {
1773     xc[i]= xcat + xc2[i]*var.sfx;
1774     yc[i] = ycat + yc2[i]*var.sfy;
1775     };
1776     TPolyLine *pcarp1b = new TPolyLine(5,xc,yc);
1777     pcarp1b->SetLineColor(1);
1778     colo = (int)(10. - card1b * 8.);
1779     pcarp1b->SetFillColor(colo);
1780     pcarp1b->SetLineWidth(1);
1781     pcarp1b->Draw("f");
1782     pcarp1b->Draw();
1783     //
1784     for (Int_t i = 0; i<5 ; i++) {
1785     xc[i] = xcat + xc3[i]*var.sfx;
1786     yc[i] = ycat + yc3[i]*var.sfy;
1787     };
1788     TPolyLine *pcarp1 = new TPolyLine(5,xc,yc);
1789     pcarp1->SetLineColor(1);
1790     colo = (int)(10. - card1 * 8.);
1791     pcarp1->SetFillColor(colo);
1792     pcarp1->SetLineWidth(1);
1793     pcarp1->Draw("f");
1794     pcarp1->Draw();
1795     //
1796     // CARD4
1797     //
1798     for (Int_t i = 0; i<5 ; i++) {
1799     xc[i]= xcat - xc1[i]*var.sfx;
1800     yc[i] = ycat - yc1[i]*var.sfy;
1801     };
1802     TPolyLine *pcars4 = new TPolyLine(5,xc,yc);
1803     pcars4->SetLineColor(1);
1804     colo = 10;
1805     if ( card4 != 0. || card4b != 0. ) {
1806     if ( card4 > 0 || card4b > 0 || card4 ==-.25 || card4b ==-.25){
1807     colo = cattime;
1808     } else {
1809     colo = catnoti;
1810     };
1811     };
1812     pcars4->SetFillColor(colo);
1813     pcars4->SetLineWidth(1);
1814     pcars4->Draw("f");
1815     pcars4->Draw();
1816     //
1817     for (Int_t i = 0; i<5 ; i++) {
1818     xc[i]= xcat - xc2[i]*var.sfx;
1819     yc[i] = ycat - yc2[i]*var.sfy;
1820     };
1821     TPolyLine *pcarp4b = new TPolyLine(5,xc,yc);
1822     pcarp4b->SetLineColor(1);
1823     colo = (int)(10. - card4b * 8.);
1824     pcarp4b->SetFillColor(colo);
1825     pcarp4b->SetLineWidth(1);
1826     pcarp4b->Draw("f");
1827     pcarp4b->Draw();
1828     //
1829     for (Int_t i = 0; i<5 ; i++) {
1830     xc[i]= xcat - xc3[i]*var.sfx;
1831     yc[i] = ycat - yc3[i]*var.sfy;
1832     };
1833     TPolyLine *pcarp4 = new TPolyLine(5,xc,yc);
1834     pcarp4->SetLineColor(1);
1835     colo = (int)(10. - card4 * 8.);
1836     pcarp4->SetFillColor(colo);
1837     pcarp4->SetLineWidth(1);
1838     pcarp4->Draw("f");
1839     pcarp4->Draw();
1840     };
1841     if ( true ){
1842     Float_t xc1[5] = { -0.074, 0.074, 0.074, -0.074, -0.074};
1843     Float_t yc1[5] = { 0.108165, 0.108165, 0.100165, 0.100165, 0.108165};
1844     Float_t xc2[5] = { 0.074, 0.082, 0.082, 0.074, 0.074};
1845     Float_t yc2[5] = { 0.112165, 0.112165, 0.104165, 0.104165, 0.112165};
1846     Float_t xc3[5] = { 0.074, 0.082, 0.082, 0.074, 0.074};
1847     Float_t yc3[5] = { 0.104165, 0.104165, 0.096165, 0.096165, 0.104165};
1848     //
1849     // CARD2
1850     //
1851     Float_t xc[5];
1852     Float_t yc[5];
1853     for (Int_t i = 0; i<5 ; i++) {
1854     xc[i]= xcat - (xc1[i]-0.0025)*var.sfx;
1855     yc[i] = ycat - yc1[i]*var.sfy;
1856     };
1857     TPolyLine *pcars2 = new TPolyLine(5,xc,yc);
1858     pcars2->SetLineColor(1);
1859     colo = 10;
1860     if ( card2 != 0. || card2b != 0.) {
1861     if ( card2 > 0 || card2b > 0 || card2 ==-.25 || card2b ==-.25 ){
1862     colo = cattime;
1863     } else {
1864     colo = catnoti;
1865     };
1866     };
1867     pcars2->SetFillColor(colo);
1868     pcars2->SetLineWidth(1);
1869     pcars2->Draw("f");
1870     pcars2->Draw();
1871     //
1872     for (Int_t i = 0; i<5 ; i++) {
1873     xc[i]= xcat - (xc2[i]-0.0025)*var.sfx;
1874     yc[i] = ycat - yc2[i]*var.sfy;
1875     };
1876     TPolyLine *pcarp2 = new TPolyLine(5,xc,yc);
1877     pcarp2->SetLineColor(1);
1878     colo = (int)(10. - card2 * 8.);
1879     pcarp2->SetFillColor(colo);
1880     pcarp2->SetLineWidth(1);
1881     pcarp2->Draw("f");
1882     pcarp2->Draw();
1883     //
1884     for (Int_t i = 0; i<5 ; i++) {
1885     xc[i]= xcat - (xc3[i]-0.0025)*var.sfx;
1886     yc[i] = ycat - yc3[i]*var.sfy;
1887     };
1888     TPolyLine *pcarp2b = new TPolyLine(5,xc,yc);
1889     pcarp2b->SetLineColor(1);
1890     colo = (int)(10. - card2b * 8.);
1891     pcarp2b->SetFillColor(colo);
1892     pcarp2b->SetLineWidth(1);
1893     pcarp2b->Draw("f");
1894     pcarp2b->Draw();
1895     //
1896     // CARD3
1897     //
1898     for (Int_t i = 0; i<5 ; i++) {
1899     xc[i]= xcat + (xc1[i]-0.0025)*var.sfx;
1900     yc[i] = ycat + yc1[i]*var.sfy;
1901     };
1902     TPolyLine *pcars3 = new TPolyLine(5,xc,yc);
1903     pcars3->SetLineColor(1);
1904     colo = 10;
1905     if ( card3 != 0. || card3b != 0. ) {
1906     if ( card3 > 0 || card3b > 0 || card3==-.25 || card3b ==-.25){
1907     colo = cattime;
1908     } else {
1909     colo = catnoti;
1910     };
1911     };
1912     pcars3->SetFillColor(colo);
1913     pcars3->SetLineWidth(1);
1914     pcars3->Draw("f");
1915     pcars3->Draw();
1916     //
1917     for (Int_t i = 0; i<5 ; i++) {
1918     xc[i]= xcat + (xc2[i]-0.0025)*var.sfx;
1919     yc[i] = ycat + yc2[i]*var.sfy;
1920     };
1921     TPolyLine *pcarp3 = new TPolyLine(5,xc,yc);
1922     pcarp3->SetLineColor(1);
1923     colo = (int)(10. - card3 * 8.);
1924     pcarp3->SetFillColor(colo);
1925     pcarp3->SetLineWidth(1);
1926     pcarp3->Draw("f");
1927     pcarp3->Draw();
1928     //
1929     for (Int_t i = 0; i<5 ; i++) {
1930     xc[i]= xcat + (xc3[i]-0.0025)*var.sfx;
1931     yc[i] = ycat + yc3[i]*var.sfy;
1932     };
1933     TPolyLine *pcarp3b = new TPolyLine(5,xc,yc);
1934     pcarp3b->SetLineColor(1);
1935     colo = (int)(10. - card3b * 8.);
1936     pcarp3b->SetFillColor(colo);
1937     pcarp3b->SetLineWidth(1);
1938     pcarp3b->Draw("f");
1939     pcarp3b->Draw();
1940    
1941     //
1942     // CARD - X-view
1943     //
1944     Float_t cardcx = 0.143168*var.sfx;
1945     Float_t cardcy = 0.1475*var.sfy;
1946     Float_t acrdx[4] = {-lcrd*cos(alfa), lcrd*cos(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)};
1947     Float_t acrdy[4] = {-lcrd*sin(alfa), lcrd*sin(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)};
1948     Float_t bcrdx[4] = { lcrd*cos(alfa), lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), lcrd*cos(alfa)};
1949     Float_t bcrdy[4] = { lcrd*sin(alfa), lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), lcrd*sin(alfa)};
1950    
1951     //
1952     // CARD3 X/ Y
1953     //
1954     Float_t xcc[4];
1955     Float_t ycc[4];
1956     for (Int_t i = 0; i<4 ; i++) {
1957     xcc[i] = cardcx + var.xxvc + acrdx[i]*var.sfx;
1958     ycc[i] = cardcy + var.yxvc + (0.36 + acrdy[i])*var.sfy;
1959     };
1960     TPolyLine *fcard3 = new TPolyLine(4,xcc,ycc);
1961     fcard3->SetLineColor(1);
1962     colo = (int)(10. - card3 * 8.);
1963     fcard3->SetFillColor(colo);
1964     fcard3->SetLineWidth(1);
1965     fcard3->Draw("f");
1966     fcard3->Draw();
1967     //
1968     for (Int_t i = 0; i<4 ; i++) {
1969     xcc[i] = cardcx + var.xxvc + bcrdx[i]*var.sfx;
1970     ycc[i] = cardcy + var.yxvc + (0.36 + bcrdy[i])*var.sfy;
1971     };
1972     TPolyLine *fcard3b = new TPolyLine(4,xcc,ycc);
1973     fcard3b->SetLineColor(1);
1974     colo = (int)(10. - card3b * 8.);
1975     fcard3b->SetFillColor(colo);
1976     fcard3b->SetLineWidth(1);
1977     fcard3b->Draw("f");
1978     fcard3b->Draw();
1979    
1980     //
1981     // CARD2 \X Y
1982     //
1983     for (Int_t i = 0; i<4 ; i++) {
1984     xcc[i] = -cardcx + var.xxvc - acrdx[i]*var.sfx;
1985     ycc[i] = cardcy + var.yxvc + (0.36 + acrdy[i])*var.sfy;
1986     };
1987     TPolyLine *fcard2 = new TPolyLine(4,xcc,ycc);
1988     fcard2->SetLineColor(1);
1989     colo = (int)(10. - card2 * 8.);
1990     fcard2->SetFillColor(colo);
1991     fcard2->SetLineWidth(1);
1992     fcard2->Draw("f");
1993     fcard2->Draw();
1994     //
1995     for (Int_t i = 0; i<4 ; i++) {
1996     xcc[i] = -cardcx + var.xxvc - bcrdx[i]*var.sfx;
1997     ycc[i] = cardcy + var.yxvc + (0.36 + bcrdy[i])*var.sfy;
1998     };
1999     TPolyLine *fcard2b = new TPolyLine(4,xcc,ycc);
2000     fcard2b->SetLineColor(1);
2001     colo = (int)(10. - card2b * 8.);
2002     fcard2b->SetFillColor(colo);
2003     fcard2b->SetLineWidth(1);
2004     fcard2b->Draw("f");
2005     fcard2b->Draw();
2006     };
2007    
2008     if ( true ){
2009     Float_t acrdx[4] = {-lcrd*cos(alfa), lcrd*cos(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)};
2010     Float_t acrdy[4] = {-lcrd*sin(alfa), lcrd*sin(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)};
2011     Float_t bcrdx[4] = { lcrd*cos(alfa), lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), lcrd*cos(alfa)};
2012     Float_t bcrdy[4] = { lcrd*sin(alfa), lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), lcrd*sin(alfa)};
2013     //
2014     // CARD - Y-view
2015     //
2016     Float_t cardcx = 0.12*var.sfx;
2017     Float_t cardcy = 0.1475*var.sfy;
2018     //
2019     // CARD4 X Y/
2020     //
2021     Float_t xcc[4];
2022     Float_t ycc[4];
2023     for (Int_t i = 0; i<4 ; i++) {
2024     xcc[i] = cardcx + var.xyvc + acrdx[i]*var.sfx;
2025     ycc[i] = cardcy + var.yyvc + (0.36 + acrdy[i])*var.sfy;
2026     };
2027     TPolyLine *fcard4 = new TPolyLine(4,xcc,ycc);
2028     fcard4->SetLineColor(1);
2029     colo = (int)(10. - card4 * 8.);
2030     fcard4->SetFillColor(colo);
2031     fcard4->SetLineWidth(1);
2032     fcard4->Draw("f");
2033     fcard4->Draw();
2034     //
2035     for (Int_t i = 0; i<4 ; i++) {
2036     xcc[i] = cardcx + var.xyvc + bcrdx[i]*var.sfx;
2037     ycc[i] = cardcy + var.yyvc + (0.36 + bcrdy[i])*var.sfy;
2038     };
2039     TPolyLine *fcard4b = new TPolyLine(4,xcc,ycc);
2040     fcard4b->SetLineColor(1);
2041     colo = (int)(10. - card4b * 8.);
2042     fcard4b->SetFillColor(colo);
2043     fcard4b->SetLineWidth(1);
2044     fcard4b->Draw("f");
2045     fcard4b->Draw();
2046    
2047     //
2048     // CARD1 X \Y
2049     //
2050     for (Int_t i = 0; i<4 ; i++) {
2051     xcc[i] = -cardcx + var.xyvc - acrdx[i]*var.sfx;
2052     ycc[i] = cardcy + var.yyvc + (0.36 + acrdy[i])*var.sfy;
2053     };
2054     TPolyLine *fcard1 = new TPolyLine(4,xcc,ycc);
2055     fcard1->SetLineColor(1);
2056     colo = (int)(10. - card1 * 8.);
2057     fcard1->SetFillColor(colo);
2058     fcard1->SetLineWidth(1);
2059     fcard1->Draw("f");
2060     fcard1->Draw();
2061     //
2062     for (Int_t i = 0; i<4 ; i++) {
2063     xcc[i] = -cardcx + var.xyvc - bcrdx[i]*var.sfx;
2064     ycc[i] = cardcy + var.yyvc + (0.36 + bcrdy[i])*var.sfy;
2065     };
2066     TPolyLine *fcard1b = new TPolyLine(4,xcc,ycc);
2067     fcard1b->SetLineColor(1);
2068     colo = (int)(10. - card1b * 8.);
2069     fcard1b->SetFillColor(colo);
2070     fcard1b->SetLineWidth(1);
2071     fcard1b->Draw("f");
2072     fcard1b->Draw();
2073     };
2074     }
2075    
2076     void ShowTOF(Int_t j, TTree *otr, Variables & var){
2077     //
2078     // get the trigger infos
2079     //
2080     pamela::trigger::TriggerEvent *trigger = 0;
2081     otr->SetBranchAddress("Trigger.Event", &trigger);
2082     if ( !var.nosig ) otr->GetEntry(j);
2083     //
2084    
2085     //
2086     // on day these variables will contain the MIP value for each paddle
2087     //
2088     Float_t ms11a[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
2089     Float_t ms12a[6] = {0.,0.,0.,0.,0.,0.};
2090     Float_t ms21a[2] = {0.,0.};
2091     Float_t ms22a[2] = {0.,0.};
2092     Float_t ms31a[3] = {0.,0.,0.};
2093     Float_t ms32a[3] = {0.,0.,0.};
2094     Float_t ms11b[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
2095     Float_t ms12b[6] = {0.,0.,0.,0.,0.,0.};
2096     Float_t ms21b[2] = {0.,0.};
2097     Float_t ms22b[2] = {0.,0.};
2098     Float_t ms31b[3] = {0.,0.,0.};
2099     Float_t ms32b[3] = {0.,0.,0.};
2100     //
2101     // TDC info for each PMT
2102     //
2103     Float_t mt11[2][8];
2104     Float_t mt12[2][6];
2105     Float_t mt21[2][2];
2106     Float_t mt22[2][2];
2107     Float_t mt31[2][3];
2108     Float_t mt32[2][3];
2109     //
2110     Int_t S3 = 0;
2111     Int_t S2 = 0;
2112     Int_t S12 = 0;
2113     Int_t S11 = 0;
2114     if ( !var.nosig ) {
2115     S3 = trigger->patterntrig[2];
2116     S2 = trigger->patterntrig[3];
2117     S12 = trigger->patterntrig[4];
2118     S11 = trigger->patterntrig[5];
2119     };
2120     //
2121     for ( Int_t i = 0; i<8; i++ ) {
2122     if ( S11 & (1<<i) ){
2123     ms11a[i] = 1.;
2124     }
2125     if ( S11 & (1<<(i+8) ) ){
2126     ms11b[i] = 1.;
2127     }
2128     };
2129     for ( Int_t i = 0; i<6; i++ ) {
2130     if ( S12 & (1<<i) ) {
2131     ms12a[i] = 1.;
2132     }
2133     if ( S12 & (1<<(i+6)) ) {
2134     ms12b[i] = 1.;
2135     }
2136     };
2137     Int_t ii = 2;
2138     for ( Int_t i = 0; i<2; i++ ) {
2139     ii--;
2140     if ( S2 & (1<<i) ) {
2141     ms21a[ii] = 1.;
2142     }
2143     if ( S2 & (1<<(i+2)) ) {
2144     ms21b[ii] = 1.;
2145     }
2146     };
2147     for ( Int_t i = 4; i<6; i++ ) {
2148     if ( S2 & (1<<i) ) {
2149     ms22a[i-4] = 1.;
2150     }
2151     if ( S2 & (1<<(i+2)) ) {
2152     ms22b[i-4] = 1.;
2153     }
2154     };
2155     for ( Int_t i = 0; i<3; i++ ) {
2156     if ( S3 & (1<<i) ) {
2157     ms31a[i] = 1.;
2158     }
2159     if ( S3 & (1<<(i+3)) ) {
2160     ms31b[i] = 1.;
2161     }
2162     };
2163     for ( Int_t i = 6; i<9; i++ ) {
2164     if ( S3 & (1<<i) ) {
2165     ms32a[i-6] = 1.;
2166     }
2167     if ( S3 & (1<<(i+3)) ) {
2168     ms32b[i-6] = 1.;
2169     }
2170     };
2171     //
2172     Int_t colo;
2173     Int_t ocolo;
2174     Float_t xs2x = var.xxvc;
2175     Float_t ys2x = var.yxvc + 0.36*var.sfy;
2176     Float_t xs2y = var.xyvc;
2177     Float_t ys2y = var.yyvc + 0.36*var.sfy;
2178     Float_t ws2 = 0.005;
2179     Float_t ws13 = 0.007;
2180     Int_t noadc = 12;
2181     if ( var.bw ){
2182     noadc=12;
2183     } else {
2184     noadc=41;
2185     };
2186     //
2187     // S11 X-view
2188     //
2189     // A
2190     Float_t s11p = 0.051;
2191     ocolo = 10;
2192     TPolyLine *ftof11xa[8];
2193     for ( Int_t j=0; j<8; j++){
2194     Float_t xc1[4]={ (s11p*j), (s11p*j), s11p*(j+1), (s11p*j)};
2195     Float_t yc1[4]={ 0., ws13, ws13, 0.};
2196     Float_t xc[4];
2197     Float_t yc[4];
2198     for (Int_t i = 0; i<4 ; i++) {
2199     xc[i]= xs2x + (-0.204+xc1[i])*var.sfx;
2200     yc[i] = ys2x + (0.295+yc1[i])*var.sfy;
2201     };
2202     ftof11xa[j] = new TPolyLine(4,xc,yc);
2203     ftof11xa[j]->SetLineColor(1);
2204     if ( var.bw ){
2205     colo = -1;
2206     } else {
2207     colo = 1;
2208     };
2209     ColorMIP(ms11a[j],colo);
2210     //
2211     if ( colo != 10 ) ocolo = colo;
2212     if ( mt11[0][j] == 4095. ) colo = noadc;
2213     //
2214     ftof11xa[j]->SetFillColor(colo);
2215     ftof11xa[j]->SetLineWidth(1);
2216     ftof11xa[j]->Draw("f");
2217     ftof11xa[j]->Draw();
2218     };
2219     // B
2220     s11p = 0.051;
2221     TPolyLine *ftof11xb[8];
2222     for ( Int_t j=0; j<8; j++){
2223     Float_t xc1[4]={ (s11p*j), s11p*(j+1), s11p*(j+1), (s11p*j)};
2224     Float_t yc1[4]={ 0., 0., ws13, 0.};
2225     Float_t xc[4];
2226     Float_t yc[4];
2227     for (Int_t i = 0; i<4 ; i++) {
2228     xc[i]= xs2x + (-0.204+xc1[i])*var.sfx;
2229     yc[i] = ys2x + (0.295+yc1[i])*var.sfy;
2230     };
2231     ftof11xb[j] = new TPolyLine(4,xc,yc);
2232     ftof11xb[j]->SetLineColor(1);
2233     if ( var.bw ){
2234     colo = -1;
2235     } else {
2236     colo = 1;
2237     };
2238     ColorMIP(ms11b[j],colo);
2239     //
2240     if ( colo != 10 ) ocolo = colo;
2241     if ( mt11[1][j] == 4095. ) colo = noadc;
2242     //
2243     ftof11xb[j]->SetFillColor(colo);
2244     ftof11xb[j]->SetLineWidth(1);
2245     ftof11xb[j]->Draw("f");
2246     ftof11xb[j]->Draw();
2247     };
2248    
2249     //
2250     // S11 Y-view
2251     //
2252     if ( true ){
2253     Float_t nxc1[5]={ -0.165, 0.165, 0.165, -0.165, -0.165};
2254     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
2255     Float_t nxc[5];
2256     Float_t nyc[5];
2257     for (Int_t i = 0; i<5 ; i++) {
2258     nxc[i]= xs2y + nxc1[i]*var.sfx;
2259     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
2260     };
2261     TPolyLine *ftof11y = new TPolyLine(5,nxc,nyc);
2262     ftof11y->SetLineColor(1);
2263     ftof11y->SetFillColor(ocolo);
2264     ftof11y->SetLineWidth(1);
2265     ftof11y->Draw("f");
2266     ftof11y->Draw();
2267     };
2268    
2269     //
2270     // S12 Y-view
2271     //
2272     // A
2273     Float_t s12p = 0.055;
2274     ocolo = 10;
2275     TPolyLine *ftof12ya[6];
2276     for ( Int_t j=0; j<6; j++){
2277     Float_t xc1[4]={ (s12p*j), s12p*(j), s12p*(j+1), (s12p*j)};
2278     Float_t yc1[4]={ -ws13, 0., 0., -ws13};
2279     Float_t xc[4];
2280     Float_t yc[4];
2281     for (Int_t i = 0; i<4 ; i++) {
2282     xc[i]= xs2y + (-0.165+xc1[i])*var.sfx;
2283     yc[i] = ys2y + (0.295+yc1[i])*var.sfy;
2284     };
2285     ftof12ya[j] = new TPolyLine(4,xc,yc);
2286     ftof12ya[j]->SetLineColor(1);
2287     if ( var.bw ){
2288     colo = -1;
2289     } else {
2290     colo = 1;
2291     };
2292     ColorMIP(ms12a[j],colo);
2293     //
2294     if ( colo != 10 ) ocolo = colo;
2295     if ( mt12[0][j] == 4095. ) colo = noadc;
2296     //
2297     ftof12ya[j]->SetFillColor(colo);
2298     ftof12ya[j]->SetLineWidth(1);
2299     ftof12ya[j]->Draw("f");
2300     ftof12ya[j]->Draw();
2301     };
2302     // B
2303     s12p = 0.055;
2304     TPolyLine *ftof12yb[6];
2305     for ( Int_t j=0; j<6; j++){
2306     Float_t xc1[4]={ (s12p*j), s12p*(j+1), s12p*(j+1), (s12p*j)};
2307     Float_t yc1[4]={ -ws13, -ws13, 0., -ws13};
2308     Float_t xc[4];
2309     Float_t yc[4];
2310     for (Int_t i = 0; i<4 ; i++) {
2311     xc[i]= xs2y + (-0.165+xc1[i])*var.sfx;
2312     yc[i] = ys2y + (0.295+yc1[i])*var.sfy;
2313     };
2314     ftof12yb[j] = new TPolyLine(4,xc,yc);
2315     ftof12yb[j]->SetLineColor(1);
2316     if ( var.bw ){
2317     colo = -1;
2318     } else {
2319     colo = 1;
2320     };
2321     ColorMIP(ms12b[j],colo);
2322     //
2323     if ( colo != 10 ) ocolo = colo;
2324     if ( mt12[1][j] == 4095. ) colo = noadc;
2325     //
2326     ftof12yb[j]->SetFillColor(colo);
2327     ftof12yb[j]->SetLineWidth(1);
2328     ftof12yb[j]->Draw("f");
2329     ftof12yb[j]->Draw();
2330     };
2331     //
2332     // S12 X-view
2333     //
2334     if ( true ){
2335     Float_t nxc1[5]={ -0.204, 0.204, 0.204, -0.204, -0.204};
2336     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
2337     Float_t nxc[5];
2338     Float_t nyc[5];
2339     for (Int_t i = 0; i<5 ; i++) {
2340     nxc[i]= xs2x + nxc1[i]*var.sfx;
2341     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
2342     };
2343     TPolyLine *ftof12x = new TPolyLine(5,nxc,nyc);
2344     ftof12x->SetLineColor(1);
2345     ftof12x->SetFillColor(ocolo);
2346     ftof12x->SetLineWidth(1);
2347     ftof12x->Draw("f");
2348     ftof12x->Draw();
2349     };
2350    
2351     //
2352     // S21 Y-view
2353     //
2354     // A
2355     Float_t s21p = 0.075;
2356     ocolo = 10;
2357     TPolyLine *ftof21ya[2];
2358     for ( Int_t j=0; j<2; j++){
2359     Float_t xc1[4]={ s21p*(j-1), s21p*(j-1), s21p*j, s21p*(j-1)};
2360     Float_t yc1[4]={ 0., ws2, ws2, 0.};
2361     Float_t xc[4];
2362     Float_t yc[4];
2363     for (Int_t i = 0; i<4 ; i++) {
2364     xc[i]= xs2y + xc1[i]*var.sfx;
2365     yc[i] = ys2y + yc1[i]*var.sfy;
2366     };
2367     ftof21ya[j] = new TPolyLine(4,xc,yc);
2368     ftof21ya[j]->SetLineColor(1);
2369     if ( var.bw ){
2370     colo = -1;
2371     } else {
2372     colo = 1;
2373     };
2374     ColorMIP(ms21a[j],colo);
2375     //
2376     if ( colo != 10 ) ocolo = colo;
2377     if ( mt21[0][j] == 4095. ) colo = noadc;
2378     //
2379     ftof21ya[j]->SetFillColor(colo);
2380     ftof21ya[j]->SetLineWidth(1);
2381     ftof21ya[j]->Draw("f");
2382     ftof21ya[j]->Draw();
2383     };
2384     // B
2385     s21p = 0.075;
2386     TPolyLine *ftof21yb[2];
2387     for ( Int_t j=0; j<2; j++){
2388     Float_t xc1[4]={ s21p*(j-1), s21p*j, s21p*j, s21p*(j-1)};
2389     Float_t yc1[4]={ 0., 0., ws2, 0.};
2390     Float_t xc[4];
2391     Float_t yc[4];
2392     for (Int_t i = 0; i<4 ; i++) {
2393     xc[i]= xs2y + xc1[i]*var.sfx;
2394     yc[i] = ys2y + yc1[i]*var.sfy;
2395     };
2396     ftof21yb[j] = new TPolyLine(4,xc,yc);
2397     ftof21yb[j]->SetLineColor(1);
2398     if ( var.bw ){
2399     colo = -1;
2400     } else {
2401     colo = 1;
2402     };
2403     ColorMIP(ms21b[j],colo);
2404     //
2405     if ( colo != 10 ) ocolo = colo;
2406     if ( mt21[1][j] == 4095. ) colo = noadc;
2407     //
2408     ftof21yb[j]->SetFillColor(colo);
2409     ftof21yb[j]->SetLineWidth(1);
2410     ftof21yb[j]->Draw("f");
2411     ftof21yb[j]->Draw();
2412     };
2413     //
2414     // S21 X-view
2415     //
2416     if ( true ){
2417     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
2418     Float_t nyc1[5]={ 0., 0., ws2, ws2, 0.};
2419     Float_t nxc[5];
2420     Float_t nyc[5];
2421     for (Int_t i = 0; i<5 ; i++) {
2422     nxc[i]= xs2x + nxc1[i]*var.sfx;
2423     nyc[i] = ys2x + nyc1[i]*var.sfy;
2424     };
2425     TPolyLine *ftof21x = new TPolyLine(5,nxc,nyc);
2426     ftof21x->SetLineColor(1);
2427     ftof21x->SetFillColor(ocolo);
2428     ftof21x->SetLineWidth(1);
2429     ftof21x->Draw("f");
2430     ftof21x->Draw();
2431     };
2432     //
2433     // S22 X-view
2434     //
2435     // A
2436     Float_t s22p = 0.090;
2437     ocolo = 10;
2438     TPolyLine *ftof22xa[2];
2439     for ( Int_t j=0; j<2; j++){
2440     Float_t xc1[4]={ s22p*(j-1), s22p*(j-1), s22p*j, s22p*(j-1)};
2441     Float_t yc1[4]={ -ws2, 0., 0., -ws2};
2442     Float_t xc[4];
2443     Float_t yc[4];
2444     for (Int_t i = 0; i<4 ; i++) {
2445     xc[i]= xs2x + xc1[i]*var.sfx;
2446     yc[i] = ys2x + yc1[i]*var.sfy;
2447     };
2448     ftof22xa[j] = new TPolyLine(4,xc,yc);
2449     ftof22xa[j]->SetLineColor(1);
2450     if ( var.bw ){
2451     colo = -1;
2452     } else {
2453     colo = 1;
2454     };
2455     ColorMIP(ms22a[j],colo);
2456     //
2457     if ( colo != 10 ) ocolo = colo;
2458     if ( mt22[0][j] == 4095. ) colo = noadc;
2459     //
2460     ftof22xa[j]->SetFillColor(colo);
2461     ftof22xa[j]->SetLineWidth(1);
2462     ftof22xa[j]->Draw("f");
2463     ftof22xa[j]->Draw();
2464     };
2465     // B
2466     s22p = 0.090;
2467     TPolyLine *ftof22xb[2];
2468     for ( Int_t j=0; j<2; j++){
2469     Float_t xc1[4]={ s22p*(j-1), s22p*j, s22p*j, s22p*(j-1)};
2470     Float_t yc1[4]={ -ws2, -ws2, 0., -ws2};
2471     Float_t xc[4];
2472     Float_t yc[4];
2473     for (Int_t i = 0; i<4 ; i++) {
2474     xc[i]= xs2x + xc1[i]*var.sfx;
2475     yc[i] = ys2x + yc1[i]*var.sfy;
2476     };
2477     ftof22xb[j] = new TPolyLine(4,xc,yc);
2478     ftof22xb[j]->SetLineColor(1);
2479     if ( var.bw ){
2480     colo = -1;
2481     } else {
2482     colo = 1;
2483     };
2484     ColorMIP(ms22b[j],colo);
2485     //
2486     if ( colo != 10 ) ocolo = colo;
2487     if ( mt22[1][j] == 4095. ) colo = noadc;
2488     //
2489     ftof22xb[j]->SetFillColor(colo);
2490     ftof22xb[j]->SetLineWidth(1);
2491     ftof22xb[j]->Draw("f");
2492     ftof22xb[j]->Draw();
2493     };
2494     //
2495     // S22 Y-view
2496     //
2497     if ( true ){
2498     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
2499     Float_t nyc1[5]={ 0., 0., -ws2, -ws2, 0.};
2500     Float_t nxc[5];
2501     Float_t nyc[5];
2502     for (Int_t i = 0; i<5 ; i++) {
2503     nxc[i]= xs2y + nxc1[i]*var.sfx;
2504     nyc[i] = ys2y + nyc1[i]*var.sfy;
2505     };
2506     TPolyLine *ftof22y = new TPolyLine(5,nxc,nyc);
2507     ftof22y->SetLineColor(1);
2508     ftof22y->SetFillColor(ocolo);
2509     ftof22y->SetLineWidth(1);
2510     ftof22y->Draw("f");
2511     ftof22y->Draw();
2512     };
2513    
2514     //
2515     // S31 X-view
2516     //
2517     // A
2518     Float_t s31p = 0.060;
2519     ocolo = 10;
2520     TPolyLine *ftof31xa[3];
2521     for ( Int_t j=0; j<3; j++){
2522     Float_t xc1[4]={ (s31p*j), (s31p*j), s31p*(j+1), (s31p*j)};
2523     Float_t yc1[4]={ 0., ws13, ws13, 0.};
2524     Float_t xc[4];
2525     Float_t yc[4];
2526     for (Int_t i = 0; i<4 ; i++) {
2527     xc[i]= xs2x + (-0.090+xc1[i])*var.sfx;
2528     yc[i] = ys2x + (-0.488+yc1[i])*var.sfy;
2529     };
2530     ftof31xa[j] = new TPolyLine(4,xc,yc);
2531     ftof31xa[j]->SetLineColor(1);
2532     if ( var.bw ){
2533     colo = -1;
2534     } else {
2535     colo = 1;
2536     };
2537     ColorMIP(ms31a[j],colo);
2538     //
2539     if ( colo != 10 ) ocolo = colo;
2540     if ( mt31[0][j] == 4095. ) colo = noadc;
2541     //
2542     ftof31xa[j]->SetFillColor(colo);
2543     ftof31xa[j]->SetLineWidth(1);
2544     ftof31xa[j]->Draw("f");
2545     ftof31xa[j]->Draw();
2546     };
2547     // B
2548     s31p = 0.060;
2549     TPolyLine *ftof31xb[3];
2550     for ( Int_t j=0; j<3; j++){
2551     Float_t xc1[4]={ (s31p*j), s31p*(j+1), s31p*(j+1), (s31p*j)};
2552     Float_t yc1[4]={ 0., 0., ws13, 0.};
2553     Float_t xc[4];
2554     Float_t yc[4];
2555     for (Int_t i = 0; i<4 ; i++) {
2556     xc[i]= xs2x + (-0.090+xc1[i])*var.sfx;
2557     yc[i] = ys2x + (-0.488+yc1[i])*var.sfy;
2558     };
2559     ftof31xb[j] = new TPolyLine(4,xc,yc);
2560     ftof31xb[j]->SetLineColor(1);
2561     if ( var.bw ){
2562     colo = -1;
2563     } else {
2564     colo = 1;
2565     };
2566     ColorMIP(ms31b[j],colo);
2567     //
2568     if ( colo != 10 ) ocolo = colo;
2569     if ( mt31[1][j] == 4095. ) colo = noadc;
2570     //
2571     ftof31xb[j]->SetFillColor(colo);
2572     ftof31xb[j]->SetLineWidth(1);
2573     ftof31xb[j]->Draw("f");
2574     ftof31xb[j]->Draw();
2575     };
2576     //
2577     // S31 Y-view
2578     //
2579     if ( true ){
2580     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
2581     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
2582     Float_t nxc[5];
2583     Float_t nyc[5];
2584     for (Int_t i = 0; i<5 ; i++) {
2585     nxc[i]= xs2y + nxc1[i]*var.sfx;
2586     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
2587     };
2588     TPolyLine *ftof31y = new TPolyLine(5,nxc,nyc);
2589     ftof31y->SetLineColor(1);
2590     ftof31y->SetFillColor(ocolo);
2591     ftof31y->SetLineWidth(1);
2592     ftof31y->Draw("f");
2593     ftof31y->Draw();
2594     };
2595     //
2596     // S32 Y-view
2597     //
2598     Float_t s32p = 0.050;
2599     ocolo = 10;
2600     TPolyLine *ftof32ya[3];
2601     for ( Int_t j=0; j<3; j++){
2602     Float_t xc1[4]={ (s32p*j), (s32p*j), s32p*(j+1), (s32p*j)};
2603     Float_t yc1[4]={ -ws13, 0., 0., -ws13};
2604     Float_t xc[4];
2605     Float_t yc[4];
2606     for (Int_t i = 0; i<4 ; i++) {
2607     xc[i]= xs2y + (-0.075+xc1[i])*var.sfx;
2608     yc[i] = ys2y + (-0.488+yc1[i])*var.sfy;
2609     };
2610     ftof32ya[j] = new TPolyLine(4,xc,yc);
2611     ftof32ya[j]->SetLineColor(1);
2612     if ( var.bw ){
2613     colo = -1;
2614     } else {
2615     colo = 1;
2616     };
2617     ColorMIP(ms32a[j],colo);
2618     //
2619     if ( colo != 10 ) ocolo = colo;
2620     if ( mt32[0][j] == 4095. ) colo = noadc;
2621     //
2622     ftof32ya[j]->SetFillColor(colo);
2623     ftof32ya[j]->SetLineWidth(1);
2624     ftof32ya[j]->Draw("f");
2625     ftof32ya[j]->Draw();
2626     };
2627     s32p = 0.050;
2628     TPolyLine *ftof32yb[3];
2629     for ( Int_t j=0; j<3; j++){
2630     Float_t xc1[4]={ (s32p*j), s32p*(j+1), s32p*(j+1), (s32p*j)};
2631     Float_t yc1[4]={ -ws13, -ws13, 0., -ws13};
2632     Float_t xc[4];
2633     Float_t yc[4];
2634     for (Int_t i = 0; i<4 ; i++) {
2635     xc[i]= xs2y + (-0.075+xc1[i])*var.sfx;
2636     yc[i] = ys2y + (-0.488+yc1[i])*var.sfy;
2637     };
2638     ftof32yb[j] = new TPolyLine(4,xc,yc);
2639     ftof32yb[j]->SetLineColor(1);
2640     if ( var.bw ){
2641     colo = -1;
2642     } else {
2643     colo = 1;
2644     };
2645     ColorMIP(ms32b[j],colo);
2646     //
2647     if ( colo != 10 ) ocolo = colo;
2648     if ( mt32[1][j] == 4095. ) colo = noadc;
2649     //
2650     ftof32yb[j]->SetFillColor(colo);
2651     ftof32yb[j]->SetLineWidth(1);
2652     ftof32yb[j]->Draw("f");
2653     ftof32yb[j]->Draw();
2654     };
2655     //
2656     // S32 X-view
2657     //
2658     if ( true ){
2659     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
2660     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
2661     Float_t nxc[5];
2662     Float_t nyc[5];
2663     for (Int_t i = 0; i<5 ; i++) {
2664     nxc[i]= xs2x + nxc1[i]*var.sfx;
2665     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
2666     };
2667     TPolyLine *ftof32x = new TPolyLine(5,nxc,nyc);
2668     ftof32x->SetLineColor(1);
2669     ftof32x->SetFillColor(ocolo);
2670     ftof32x->SetLineWidth(1);
2671     ftof32x->Draw("f");
2672     ftof32x->Draw();
2673     };
2674     }
2675    
2676     void ShowS4L0(Int_t i, TTree *otr, Variables & var){
2677    
2678     pamela::trigger::TriggerEvent *trigger = 0;
2679     otr->SetBranchAddress("Trigger.Event", &trigger);
2680     if ( !var.nosig ) otr->GetEntry(i);
2681    
2682     Float_t ms4[3] = {0.,0.,0.};
2683     Int_t S4 = 0;
2684     if ( !var.nosig ) {
2685     S4 = trigger->patterntrig[1];
2686     };
2687     //
2688     for ( Int_t i = 0; i<3; i++ ) {
2689     if ( S4 & (1<<0) ) ms4[i] = 1.;
2690     };
2691     //
2692     Int_t colo;
2693     Float_t xs4x = var.xxvc;
2694     Float_t ys4x = var.yxvc - 0.3250*var.sfy; //25
2695     Float_t xs4y = var.xyvc;
2696     Float_t ys4y = var.yyvc - 0.3250*var.sfy;
2697     Float_t ws4 = 0.010;
2698    
2699     //
2700     // Y-view
2701     //
2702     Float_t s4p = 0.1606667;
2703     Int_t ocolo = 0;
2704     TPolyLine *fs4y[3];
2705     for ( Int_t j=0; j<3; j++){
2706     Float_t xc1[5]={ (s4p*j), s4p*(j+1), s4p*(j+1), (s4p*j), (s4p*j)};
2707     Float_t yc1[5]={ 0., 0., ws4, ws4, 0.};
2708     Float_t xc[5];
2709     Float_t yc[5];
2710     for (Int_t i = 0; i<5 ; i++) {
2711     xc[i]= xs4y + (-0.241+xc1[i])*var.nds4;
2712     yc[i] = ys4y + (yc1[i]-0.03)*var.sfy;
2713     };
2714     fs4y[j] = new TPolyLine(5,xc,yc);
2715     fs4y[j]->SetLineColor(1);
2716     if ( var.bw ){
2717     colo = -1;
2718     } else {
2719     colo = 1;
2720     };
2721     ColorMIP(ms4[j],colo);
2722     //
2723     if ( colo != 10 ) ocolo = colo;
2724     //
2725     fs4y[j]->SetFillColor(colo);
2726     fs4y[j]->SetLineWidth(1);
2727     fs4y[j]->Draw("f");
2728     fs4y[j]->Draw();
2729     };
2730     //
2731     // X-view
2732     //
2733     Float_t xc1[5]={ -0.241, 0.241, 0.241, -0.241, -0.241};
2734     Float_t yc1[5]={ 0., 0., ws4, ws4, 0.};
2735     Float_t xc[5];
2736     Float_t yc[5];
2737     for (Int_t i = 0; i<5 ; i++) {
2738     xc[i]= xs4x + xc1[i]*var.nds4;
2739     yc[i] = ys4x + (yc1[i]-0.03)*var.sfy;
2740     };
2741     TPolyLine *fs4x = new TPolyLine(5,xc,yc);
2742     fs4x->SetLineColor(1);
2743     fs4x->SetFillColor(ocolo);
2744     fs4x->SetLineWidth(1);
2745     fs4x->Draw("f");
2746     fs4x->Draw();
2747     }
2748    
2749     //**********************************************************************************
2750     // LEVEL1 SUBROUTINES //
2751     //**********************************************************************************
2752    
2753     void ShowS4L1(Int_t i, TTree *otr, Variables & var){
2754    
2755     pamela::S4::S4Event *s4 = 0;
2756     otr->SetBranchAddress("S4.Event", &s4);
2757     if ( !var.nosig ) otr->GetEntry(i);
2758    
2759     Float_t ms4[3] = {0.,0.,0.};
2760     Int_t data = 0;
2761     if ( !var.nosig ) {
2762     data = s4->S4_DATA;
2763     };
2764     //
2765     Float_t calibdata;
2766     if ( !s4->unpackError && data > 31 ){
2767     calibdata = ((Float_t)data - 32.) * 0.5;
2768     } else {
2769     calibdata = 0.;
2770     };
2771     var.s4sig = calibdata;
2772     //
2773     for ( Int_t j = 0; j<3; j++ ) {
2774     ms4[j] = calibdata;
2775     };
2776     Int_t colo;
2777     Float_t xs4x = var.xxvc;
2778     Float_t ys4x = var.yxvc - 0.3250*var.sfy;
2779     Float_t xs4y = var.xyvc;
2780     Float_t ys4y = var.yyvc - 0.3250*var.sfy;
2781     Float_t ws4 = 0.010;
2782     //
2783     // Y-view
2784     //
2785     Float_t s4p = 0.1606667;
2786     Int_t ocolo = 0;
2787     TPolyLine *fs4y[3];
2788     for ( Int_t j=0; j<3; j++){
2789     Float_t xc1[5]={ (s4p*j), s4p*(j+1), s4p*(j+1), (s4p*j), (s4p*j)};
2790     Float_t yc1[5]={ 0., 0., ws4, ws4, 0.};
2791     Float_t xc[5];
2792     Float_t yc[5];
2793     for (Int_t i = 0; i<5 ; i++) {
2794     xc[i]= xs4y + (-0.241+xc1[i])*var.nds4;
2795     yc[i] = ys4y + (yc1[i]-0.03)*var.sfy;
2796     };
2797     fs4y[j] = new TPolyLine(5,xc,yc);
2798     fs4y[j]->SetLineColor(1);
2799     if ( var.bw ){
2800     colo = -1;
2801     } else {
2802     colo = 1;
2803     };
2804     ColorMIP(ms4[j],colo);
2805     //
2806     if ( colo != 10 ) ocolo = colo;
2807     //
2808     fs4y[j]->SetFillColor(colo);
2809     fs4y[j]->SetLineWidth(1);
2810     fs4y[j]->Draw("f");
2811     fs4y[j]->Draw();
2812     };
2813     //
2814     // X-view
2815     //
2816     Float_t xc1[5]={ -0.241, 0.241, 0.241, -0.241, -0.241};
2817     Float_t yc1[5]={ 0., 0., ws4, ws4, 0.};
2818     Float_t xc[5];
2819     Float_t yc[5];
2820     for (Int_t i = 0; i<5 ; i++) {
2821     xc[i]= xs4x + xc1[i]*var.nds4;
2822     yc[i] = ys4x + (yc1[i]-0.03)*var.sfy;
2823     };
2824     TPolyLine *fs4x = new TPolyLine(5,xc,yc);
2825     fs4x->SetLineColor(1);
2826     fs4x->SetFillColor(ocolo);
2827     fs4x->SetLineWidth(1);
2828     fs4x->Draw("f");
2829     fs4x->Draw();
2830     }
2831    
2832     void ShowCaloL1(Int_t i, TTree *otr, Variables & var){
2833     //
2834     CalorimeterLevel1 *calo = new CalorimeterLevel1();
2835     otr->SetBranchAddress("CaloLevel1.Event", &calo);
2836     if ( !var.nosig ) otr->GetEntry(i);
2837     //
2838     // Book the histograms:
2839     //
2840     //
2841     stringstream xview;
2842     stringstream yview;
2843     xview.str("");
2844     yview.str("");
2845     xview << "x-view event " << (i+1);
2846     yview << "y-view event " << (i+1);
2847     gDirectory->Delete(xview.str().c_str());
2848     gDirectory->Delete(yview.str().c_str());
2849     TH2F *Xview = new TH2F(xview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
2850     TH2F *Yview = new TH2F(yview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
2851     Xview->GetYaxis()->SetLabelColor(10);
2852     Yview->GetYaxis()->SetLabelColor(10);
2853     //
2854     // figures:
2855     //
2856     Int_t bgcolor = 10;
2857     TPad *pd1 = new TPad("calox","This is pad1",var.xxvc-0.154*var.sfx,var.yxvc-0.3645*var.sfy,var.xxvc+0.154*var.sfx,var.yxvc-0.1200*var.sfy,bgcolor);
2858     TPad *pd2 = new TPad("caloy","This is pad2",var.xyvc-0.154*var.sfx,var.yyvc-0.3645*var.sfy,var.xyvc+0.154*var.sfx,var.yyvc-0.1200*var.sfy,bgcolor);
2859    
2860     pd1->SetFillStyle(4000);
2861     pd1->SetFillColor(0);
2862     pd1->SetFrameFillStyle(4000);
2863     pd2->SetFillStyle(4000);
2864     pd2->SetFillColor(0);
2865     pd2->SetFrameFillStyle(4000);
2866    
2867     TLatex *t=new TLatex();
2868     t->SetTextFont(32);
2869     t->SetTextColor(1);
2870     t->SetTextSize(0.03);
2871     t->SetTextAlign(12);
2872     pd1->Range(0.,0.,1.,1.);
2873     pd2->Range(0.,0.,1.,1.);
2874     pd1->SetTicks();
2875     pd2->SetTicks();
2876     pd1->Draw();
2877     pd2->Draw();
2878    
2879     pd1->cd();
2880     gStyle->SetOptStat(0);
2881     Xview->GetYaxis()->SetTitleOffset(0.5);
2882     Xview->SetFillColor(bgcolor);
2883     Xview->Fill(1.,1.,1.);
2884     Xview->Draw("box");
2885     pd1->Update();
2886     pd2->cd();
2887     gStyle->SetOptStat(0);
2888     Yview->GetYaxis()->SetTitleOffset(0.5);
2889     Yview->SetFillColor(bgcolor);
2890     Yview->Fill(1.,1.,1.);
2891     Yview->Draw("box");
2892     pd2->Update();
2893    
2894     //
2895     // run over views and planes
2896     //
2897     stringstream xvev;
2898     stringstream yvev;
2899     for (Int_t m = 0; m < 22; m++){
2900     for (Int_t l = 0; l < 2; l++){
2901     for (Int_t n = 0; n < 96; n++){
2902     if ( calo->estrip[l][m][n] > 0.7 ) {
2903     //
2904     // OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course)
2905     //
2906     // if ( l == 0 && m == 21 ) printf(" xpos n=%i calo bottom: %f \n",n,(n*2.44-117.12)/10.);
2907     Int_t colo;
2908     if ( var.bw ){
2909     colo = -1;
2910     } else {
2911     colo = 1;
2912     };
2913     ColorMIP(calo->estrip[l][m][n],colo);
2914     if ( l == 0 && !var.nosig ) {
2915     xvev.str("");
2916     xvev << "x-view event " << n;
2917     xvev << " " << m;
2918     xvev << " " << l;
2919     gDirectory->Delete(xvev.str().c_str());
2920     TH2F *Xview = new TH2F(xvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
2921     Xview->SetFillColor(colo);
2922     Xview->Fill(n,21-m,1.);
2923     pd1->cd();
2924     Xview->Draw("box same");
2925     };
2926     if ( l == 1 && !var.nosig ) {
2927     yvev.str("");
2928     yvev << "y-view event " << n;
2929     yvev << " " << m;
2930     yvev << " " << l;
2931     gDirectory->Delete(yvev.str().c_str());
2932     TH2F *Yview = new TH2F(yvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
2933     Yview->SetFillColor(colo);
2934     Yview->Fill(95-n,21-m,1.);
2935     pd2->cd();
2936     Yview->Draw("box same");
2937     };
2938     };
2939     };
2940     };
2941     };
2942     pd1->Update();
2943     pd2->Update();
2944     var.qtot=(int)calo->qtot;
2945     var.nstrip=(int)calo->nstrip;
2946     }
2947    
2948     void ShowTRKL1(Int_t evno, TTree *ttr1, Variables & var){
2949     //
2950     Int_t syncro = 1;
2951     Int_t itr = evno;
2952     Int_t trnevents = ttr1->GetEntries();
2953     Int_t nodata = 0;
2954     Int_t pktnum = 0;
2955     Int_t obt = 0;
2956     trkcalosync: struct Tracklev1 trk;
2957     struct CTracklev1 ev2;
2958     settrklev1(ttr1,trk);
2959     if ( itr >= trnevents ){
2960     printf(" WARNING: no more tracker level1 data.\n");
2961     nodata = 1;
2962     goto goon;
2963     };
2964     if ( !var.nosig ) ttr1->GetEntry(itr);
2965     accesstrklev1(trk,ev2);
2966     pktnum = var.headc;
2967     obt = var.etime;
2968     if ( pktnum != ev2.pkt_num1 || obt != ev2.obt1 ){
2969     if ( pktnum > ev2.pkt_num1 || obt > ev2.obt1 ){
2970     itr++;
2971     if ( syncro ) printf(" WARNING: lost sync! try to recover... \n");
2972     syncro = 0;
2973     goto trkcalosync;
2974     };
2975     if ( pktnum < ev2.pkt_num1 || obt < ev2.obt1 ){
2976     printf(" WARNING: no tracker level2 data. \n");
2977     nodata = 1;
2978     goto goon;
2979     };
2980     };
2981     //
2982     if ( !syncro ) printf(" ...synchronization recovered! \n");
2983     syncro = 1;
2984     //
2985     goon: struct Trklev1 ev;
2986     ev.good1 = (Bool_t)ev2.good1;
2987     ev.nev1 = ev2.nev1;
2988     ev.pkt_type1 = ev2.pkt_type1;
2989     ev.pkt_num1 = ev2.pkt_num1;
2990     ev.obt1 = ev2.obt1;
2991     ev.which_calib1 = ev2.which_calib1;
2992     ev.nclstr1 = ev2.nclstr1;
2993     ev.totcllength = ev2.totcllength;
2994     for ( Int_t ii = 0 ; ii<8500; ii++){
2995     ev.clsignal[ii] = ev2.clsignal[ii];
2996     };
2997     for ( Int_t ii = 0 ; ii<500 ; ii++){
2998     ev.view[ii] = (Int_t)ev2.view[ii];
2999     ev.ladder[ii] = (Int_t)ev2.ladder[ii];
3000     ev.maxs[ii] = (Int_t)ev2.maxs[ii];
3001     ev.mult[ii] = (Int_t)ev2.mult[ii];
3002     ev.dedx[ii] = (Float_t)ev2.dedx[ii];
3003     ev.indstart[ii] = (Int_t)ev2.indstart[ii];
3004     ev.indmax[ii] = (Int_t)ev2.indmax[ii];
3005     };
3006     for ( Int_t ii = 0 ; ii<12 ; ii++){
3007     for ( Int_t ij = 0 ; ij<24 ; ij++){
3008     ev.cnev[ij][ii] = ev2.cnev[ii][ij];
3009     };
3010     };
3011     for ( Int_t ii = 0 ; ii<12 ; ii++){
3012     for ( Int_t ij = 0 ; ij<3072 ; ij++){
3013     ev.sigma_matrix[ij][ii] = var.DSPsig_par[ii][ij];
3014     };
3015     };
3016     //
3017     // find the cluster, position and signal with the external fortran routine. We must pass the common.
3018     //
3019     if ( !nodata ){
3020     projectlev1(ev);
3021     } else {
3022     ev.nclstr1 = 0;
3023     };
3024     //
3025     // a matrix of pads for each view x and y
3026     //
3027     TPad *trkpad[12];
3028     Int_t magcol = 0;
3029     TPad *mag1 = 0;
3030     TPad *mag2 = 0;
3031     for (Int_t n = 0; n<12; n++){
3032     stringstream spd;
3033     spd.str("");
3034     spd << "pd1" << n;
3035     gDirectory->Delete(spd.str().c_str());
3036     spd.str("");
3037     spd << "pd2" << n;
3038     gDirectory->Delete(spd.str().c_str());
3039     spd.str("");
3040     spd << "pd3" << n;
3041     gDirectory->Delete(spd.str().c_str());
3042     spd.str("");
3043     spd << "pd4" << n;
3044     gDirectory->Delete(spd.str().c_str());
3045     spd.str("");
3046     spd << "pd5" << n;
3047     gDirectory->Delete(spd.str().c_str());
3048     spd.str("");
3049     spd << "pd6" << n;
3050     gDirectory->Delete(spd.str().c_str());
3051     stringstream bpd;
3052     bpd.str("");
3053     if ( n%2 ) {
3054     Float_t posx = var.xxvc;
3055     Float_t posy = var.yxvc + (0.29 - 0.089*((n/2.)-1.))*var.sfy;
3056     spd.str("");
3057     spd << "pd1" << n;
3058     bpd.str("");
3059     bpd << "bd1" << n;
3060     trkpad[n] = new TPad(spd.str().c_str(),bpd.str().c_str(),posx-0.081*var.sfx,posy,posx+0.081*var.sfx,posy+0.089*var.sfy,10);
3061     trkpad[n]->SetFillStyle(4000);
3062     trkpad[n]->SetFillColor(0);
3063     trkpad[n]->SetFrameFillStyle(4000);
3064     trkpad[n]->Draw();
3065     if ( n != 1 ) {
3066     if ( var.bw ) {
3067     magcol = 1;
3068     } else {
3069     magcol = 45;
3070     };
3071     spd.str("");
3072     spd << "pd2" << n;
3073     bpd.str("");
3074     bpd << "bd2" << n;
3075     mag1 = new TPad(spd.str().c_str(),bpd.str().c_str(),posx-(0.039+0.081)*var.sfx,posy+0.004*var.sfy,posx-0.081*var.sfx,posy+0.088*var.sfy,magcol);
3076     if ( var.bw ) mag1->SetFillStyle(3001);
3077     mag1->Draw();
3078     spd.str("");
3079     spd << "pd3" << n;
3080     bpd.str("");
3081     bpd << "bd3" << n;
3082     mag2 = new TPad(spd.str().c_str(),bpd.str().c_str(),posx+0.081*var.sfx,posy+0.004*var.sfy,posx+(0.081+0.039)*var.sfx,posy+0.088*var.sfy,magcol);
3083     if ( var.bw ) mag2->SetFillStyle(3001);
3084     mag2->Draw();
3085     };
3086     } else {
3087     Float_t posx = var.xyvc;
3088     Float_t posy = var.yyvc + (0.29 - 0.089 * (((n+1.)/2.)-1.))*var.sfy;
3089     spd.str("");
3090     spd << "pd4" << n;
3091     bpd.str("");
3092     bpd << "bd4" << n;
3093     trkpad[n] = new TPad(spd.str().c_str(),bpd.str().c_str(),posx-0.07*var.sfx,posy,posx+0.07*var.sfx,posy+0.089*var.sfy,10);
3094     trkpad[n]->SetFillStyle(4000);
3095     trkpad[n]->SetFillColor(0);
3096     trkpad[n]->SetFrameFillStyle(4000);
3097     trkpad[n]->Draw();
3098     if ( n != 0 ) {
3099     if ( var.bw ) {
3100     magcol = 1;
3101     } else {
3102     magcol = 45;
3103     };
3104     spd.str("");
3105     spd << "pd5" << n;
3106     bpd.str("");
3107     bpd << "bd5" << n;
3108     mag1 = new TPad(spd.str().c_str(),bpd.str().c_str(),posx-(0.048+0.066)*var.sfx,posy+0.004*var.sfy,posx-0.066*var.sfx,posy+0.088*var.sfy,magcol);
3109     if ( var.bw ) mag1->SetFillStyle(3001);
3110     mag1->Draw();
3111     spd.str("");
3112     spd << "pd6" << n;
3113     bpd.str("");
3114     bpd << "bd6" << n;
3115     mag2 = new TPad(spd.str().c_str(),bpd.str().c_str(),posx+0.066*var.sfx,posy+0.004*var.sfy,posx+(0.066+0.048)*var.sfx,posy+0.088*var.sfy,magcol);
3116     if ( var.bw ) mag2->SetFillStyle(3001);
3117     mag2->Draw();
3118     };
3119     };
3120     };
3121     TPad *trplv;
3122     gDirectory->Delete("trkplv");
3123     trplv = new TPad("trkplv","trkplv",var.xcat-0.07*var.sfx,var.ycat-0.081*var.sfy,var.xcat+0.07*var.sfx,var.ycat+0.081*var.sfy,10);
3124     trplv->SetFillStyle(4000);
3125     trplv->SetFillColor(0);
3126     trplv->SetFrameFillStyle(4000);
3127     trplv->Draw();
3128     Int_t sigcol1 = 17;
3129     Int_t sigcol2 = 15;
3130     Int_t linecol = 13;
3131     if ( var.bw ) {
3132     sigcol1 = 17;
3133     sigcol2 = 15;
3134     linecol = 13;
3135     } else {
3136     sigcol1 = 32;
3137     sigcol2 = 38;
3138     linecol = 42;
3139     };
3140     //
3141     TLine *linea = 0;
3142     TLine *linea1x = 0;
3143     TLine *linea2x = 0;
3144     TLine *linea1y = 0;
3145     for (Int_t l = 0; l<12; l++){
3146     trkpad[l]->cd();
3147     if ( l%2 ) {
3148     trkpad[l]->Range(-8.1,0.,8.1,1000.);
3149     linea = new TLine(-8.1,10.,8.1,10.);
3150     linea1x = new TLine(-2.7,10.,-2.7,30.);
3151     linea2x = new TLine(2.7,10.,2.7,30.);
3152     } else {
3153     trkpad[l]->Range(-7.05,0.,7.05,1000.);
3154     linea = new TLine(-7.05,10.,7.05,10.);
3155     linea1y = new TLine(0.,10.,0.,30.);
3156     };
3157 mocchiut 1.2 linea->SetLineWidth(2);
3158 mocchiut 1.1 linea->SetLineColor(linecol);
3159     linea->Draw();
3160     if ( l%2 ) {
3161     linea1x->SetLineWidth(1);
3162     linea1x->SetLineColor(1);
3163     linea1x->Draw();
3164     linea2x->SetLineWidth(1);
3165     linea2x->SetLineColor(1);
3166     linea2x->Draw();
3167     } else {
3168     linea1y->SetLineWidth(1);
3169     linea1y->SetLineColor(1);
3170     linea1y->Draw();
3171     };
3172     //
3173     };
3174     Int_t planeno = 0;
3175     if ( !var.nosig ){
3176     planeno = 0;
3177     Float_t x = 0.;
3178     Float_t y = 0.;
3179     for (Int_t l = 0; l<ev.nclstr1; l++){
3180     for (Int_t m = 0; m<2; m++){
3181     if ( ev.clz[l][m] != 0. ){
3182     if ( ev.clz[l][m] > 20. ) planeno = 1 - m;
3183     if ( ev.clz[l][m] < 20. && ev.clz[l][m] > 10. ) planeno = 3 - m;
3184     if ( ev.clz[l][m] < 10. && ev.clz[l][m] > 0. ) planeno = 5 - m;
3185     if ( ev.clz[l][m] < 0. && ev.clz[l][m] > -10. ) planeno = 7 - m;
3186     if ( ev.clz[l][m] <-10. && ev.clz[l][m] >-20. ) planeno = 9 - m;
3187     if ( ev.clz[l][m] < -20. ) planeno = 11 - m;
3188     //
3189     if ( (planeno+1)%2 ){
3190     trkpad[planeno]->cd();
3191     trkpad[planeno]->Range(-7.05,0.,7.05,1000.);
3192     if ( ev.cls[l][m] != 0. ){
3193     x = ev.clp[l][1];
3194     y = ev.cls[l][m];
3195     linea = new TLine(x,0.,x,y);
3196     linea->SetLineWidth(3);
3197     linea->SetLineColor(sigcol1);
3198     linea->Draw();
3199     //
3200     x = ev.clp[l][2];
3201     linea = new TLine(x,0.,x,y);
3202     linea->SetLineWidth(3);
3203     linea->SetLineColor(sigcol2);
3204     linea->Draw();
3205     var.ncly++;
3206     };
3207     } else {
3208     trkpad[planeno]->cd();
3209     trkpad[planeno]->Range(-8.1,0.,8.1,1000.);
3210     if ( ev.cls[l][m] != 0. ){
3211     x = ev.clp[l][0];
3212     y = ev.cls[l][m];
3213     linea = new TLine(x,0.,x,y);
3214     linea->SetLineWidth(3);
3215     linea->SetLineColor(sigcol2);
3216     linea->Draw();
3217     var.nclx++;
3218     };
3219     };
3220     };
3221     };
3222     };
3223     };
3224     //
3225     // Show track in the plane view!
3226     //
3227     Float_t xh[6];
3228     Float_t yh1[6];
3229     Float_t yh2[6];
3230     Float_t mag[6];
3231     Float_t xsig[6];
3232     Float_t ysig[6];
3233     Int_t mask[6];
3234     for (Int_t l = 0; l<6; l++ ){
3235     xh[l] = 0.;
3236     yh1[l] = 0.;
3237     yh2[l] = 0.;
3238     mag[l] = 0.;
3239     xsig[l] = 0.;
3240     ysig[l] = 0.;
3241     mask[l] = 0;
3242     };
3243     Int_t ncro = 0;
3244     //
3245     // return;
3246     //
3247     for (Int_t l = 0; l<ev.nclstr1; l++){
3248     for (Int_t m = 0; m<2; m++){
3249     if ( ev.clz[l][m] != 0. ){
3250     if ( ev.clz[l][m] > 20. ) {
3251     planeno = 1 - m;
3252     ncro = 0;
3253     };
3254     if ( ev.clz[l][m] < 20. && ev.clz[l][m] > 10. ) {
3255     planeno = 3 - m;
3256     ncro = 1;
3257     };
3258     if ( ev.clz[l][m] < 10. && ev.clz[l][m] > 0. ) {
3259     planeno = 5 - m;
3260     ncro = 2;
3261     };
3262     if ( ev.clz[l][m] < 0. && ev.clz[l][m] > -10. ) {
3263     planeno = 7 - m;
3264     ncro = 3;
3265     };
3266     if ( ev.clz[l][m] <-10. && ev.clz[l][m] >-20. ) {
3267     planeno = 9 - m;
3268     ncro = 4;
3269     };
3270     if ( ev.clz[l][m] < -20. ) {
3271     planeno = 11 - m;
3272     ncro = 5;
3273     }
3274     //
3275     mag[ncro] = ((float)planeno+1.)/5.;
3276     if ( (planeno+1)%2 ){
3277     if ( ev.cls[l][m] > ysig[ncro] ){
3278     ysig[ncro] = ev.cls[l][m];
3279     yh1[ncro] = ev.clp[l][1];
3280     yh2[ncro] = ev.clp[l][2];
3281     };
3282     } else {
3283     if ( ev.cls[l][m] > xsig[ncro] ){
3284     xsig[ncro] = ev.cls[l][m];
3285     xh[ncro] = ev.clp[l][0];
3286     };
3287     };
3288     if ( ysig[ncro] > 0. && xsig[ncro] > 0. ) {
3289     mask[ncro] = 1;
3290     };
3291     };
3292     };
3293     };
3294     //
3295     // Draw crosses
3296     //
3297     trplv->cd();
3298     trplv->Range(-7.05,-8.1,7.05,8.1);
3299     for ( Int_t i = 0; i<6; i++){
3300     if ( mask[i] ){
3301     //
3302     Float_t cdx = (0.55/mag[i])*var.sfx;
3303     Float_t cdy = (0.55/mag[i])*var.sfy;
3304     Float_t lwx = (0.019)*var.sfy;
3305     Float_t lwy = (0.019)*var.sfx;
3306     //
3307     linea = new TLine(yh1[i]-lwx/2.,xh[i]-cdy,yh1[i]-lwx/2.,xh[i]+cdy);
3308     linea->SetLineWidth((int)lwx);
3309     linea->SetLineColor(sigcol1);
3310     linea->Draw();
3311     linea = new TLine(yh1[i]-cdx,xh[i]-lwy/2.,yh1[i]+cdx,xh[i]-lwy/2.);
3312     linea->SetLineWidth((int)lwy);
3313     linea->SetLineColor(sigcol1);
3314     linea->Draw();
3315     //
3316     linea = new TLine(yh2[i]-lwx/2.,xh[i]-cdy,yh2[i]-lwx/2.,xh[i]+cdy);
3317     linea->SetLineWidth((int)lwx);
3318     linea->SetLineColor(sigcol2);
3319     linea->Draw();
3320     linea = new TLine(yh2[i]-cdy,xh[i]-lwy/2.,yh2[i]+cdx,xh[i]-lwy/2.);
3321     linea->SetLineWidth((int)lwy);
3322     linea->SetLineColor(sigcol2);
3323     linea->Draw();
3324     };
3325     };
3326     }
3327    
3328     void ShowTOFGENL1(Int_t j, TTree *otr, Variables & var){
3329     //
3330     // the channels MAP:
3331     //
3332     Int_t ch11a[8] = { 3, 3, 3, 3, 0, 0, 1, 1};
3333     Int_t hb11a[8] = { 0, 2, 4, 6, 9, 11, 1, 3};
3334     Int_t ch11b[8] = { 1, 1, 1, 1, 0, 0, 0, 0};
3335     Int_t hb11b[8] = { 5, 7, 11, 9, 7, 5, 3, 1};
3336    
3337     Int_t ch12a[6] = { 2, 2, 2, 2, 2, 2};
3338     Int_t hb12a[6] = { 1, 3, 5, 7, 9, 11};
3339     Int_t ch12b[6] = { 3, 3, 3, 3, 3, 3};
3340     Int_t hb12b[6] = { 11, 9, 7, 5, 3, 1};
3341    
3342     Int_t ch21a[2] = { 0, 0};
3343     Int_t hb21a[2] = { 0, 4};
3344     Int_t ch21b[2] = { 1, 0};
3345     Int_t hb21b[2] = { 8, 6};
3346    
3347     Int_t ch22a[2] = { 0, 0};
3348     Int_t hb22a[2] = { 2, 8};
3349     Int_t ch22b[2] = { 1, 0};
3350     Int_t hb22b[2] = { 10, 10};
3351    
3352     Int_t ch31a[3] = { 1, 2, 2};
3353     Int_t hb31a[3] = { 6, 8, 10};
3354     Int_t ch31b[3] = { 1, 1, 1};
3355     Int_t hb31b[3] = { 4, 2, 0};
3356    
3357     Int_t ch32a[3] = { 2, 2, 3};
3358     Int_t hb32a[3] = { 0, 4, 8};
3359     Int_t ch32b[3] = { 2, 2, 3};
3360     Int_t hb32b[3] = { 2, 6, 10};
3361    
3362     //
3363     pamela::tof::TofEvent *tof = 0;
3364     otr->SetBranchAddress("Tof.Event", &tof);
3365     if ( !var.nosig ) otr->GetEntry(j);
3366     //
3367     // ADC values
3368     //
3369     Float_t ms11a[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
3370     Float_t ms12a[6] = {0.,0.,0.,0.,0.,0.};
3371     Float_t ms21a[2] = {0.,0.};
3372     Float_t ms22a[2] = {0.,0.};
3373     Float_t ms31a[3] = {0.,0.,0.};
3374     Float_t ms32a[3] = {0.,0.,0.};
3375     Float_t ms11b[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
3376     Float_t ms12b[6] = {0.,0.,0.,0.,0.,0.};
3377     Float_t ms21b[2] = {0.,0.};
3378     Float_t ms22b[2] = {0.,0.};
3379     Float_t ms31b[3] = {0.,0.,0.};
3380     Float_t ms32b[3] = {0.,0.,0.};
3381     //
3382     Float_t xp11[8];
3383     Float_t A11[8] = {-19.,-9.6,-25.7,-13.1,-30.9,-21.1,-11.7,-15.9};
3384     Float_t B11[8] = {-2.6,-2.6,-2.3,-2.4,-2.4,-2.8,-2.75,-2.5};
3385     Float_t E11[8] = {2.6,2.6,2.6,2.6,2.6,2.6,2.6,2.6};
3386     Float_t xp12[6];
3387     Float_t A12[6] = {11.6,16.6,5.9,-22.2,-18.0,-14.2};
3388     Float_t B12[6] = {-2.309,-2.424,-1.958,-2.092,-2.241,-2.144};
3389     Float_t E12[6] = {2.6,2.6,2.6,2.6,2.6,2.6};
3390     Float_t xp21[2];
3391     Float_t A21[2] = {12.5, 21.7};
3392     Float_t B21[2] = {-1.492,-1.519};
3393     Float_t E21[2] = {2.2,2.2};
3394     Float_t xp22[2];
3395     Float_t A22[2] = {-27.0, -45.8};
3396     Float_t B22[2] = {-1.897,-1.477};
3397     Float_t E22[2] = {2.9,2.9};
3398     Float_t xp31[3];
3399     Float_t A31[3] = {-25.1, -41.4, -33.9};
3400     Float_t B31[3] = {-3.374,-3.793,-3.495};
3401     Float_t E31[3] = {1.2,1.2,1.2};
3402     Float_t xp32[3];
3403     Float_t A32[3] = {1.3, 3.9, -22.0};
3404     Float_t B32[3] = {-3.134,-3.526,-3.417};
3405     Float_t E32[3] = {2.3,2.3,2.3};
3406     //
3407     // TDC info for each PMT
3408     //
3409     Float_t mt11[2][8];
3410     Float_t mt12[2][6];
3411     Float_t mt21[2][2];
3412     Float_t mt22[2][2];
3413     Float_t mt31[2][3];
3414     Float_t mt32[2][3];
3415     Int_t noadc = 12;
3416     if ( var.bw ){
3417     noadc = 12;
3418     } else {
3419     noadc = 41;
3420     };
3421     //
3422     Int_t ii = 0;
3423     if ( var.nosig ) goto draw;
3424     for ( Int_t i = 0; i<8; i++ ) {
3425     mt11[0][i] = tof->tdc[ch11a[i]][hb11a[i]];
3426     mt11[1][i] = tof->tdc[ch11b[i]][hb11b[i]];
3427     ms11a[i] = tof->adc[ch11a[i]][hb11a[i]];
3428     ms11b[i] = tof->adc[ch11b[i]][hb11b[i]];
3429     xp11[i] = ( -A11[i] + (mt11[0][i]-mt11[1][i]) / 2. ) / B11[i] ;
3430     if ( ms11a[i] == 4095. ) {
3431     ms11a[i] = 0.;
3432     } else {
3433     ms11a[i] = 1.;
3434     };
3435     if ( ms11b[i] == 4095. ) {
3436     ms11b[i] = 0.;
3437     } else {
3438     ms11b[i] = 1.;
3439     };
3440     };
3441     for ( Int_t i = 0; i<6; i++ ) {
3442     mt12[0][i] = tof->tdc[ch12a[i]][hb12a[i]];
3443     mt12[1][i] = tof->tdc[ch12b[i]][hb12b[i]];
3444     ms12a[i] = tof->adc[ch12a[i]][hb12a[i]];
3445     ms12b[i] = tof->adc[ch12b[i]][hb12b[i]];
3446     xp12[i] = ( -A12[i] + (mt12[0][i]-mt12[1][i]) / 2. ) / B12[i] ;
3447     if ( ms12a[i] == 4095. ){
3448     ms12a[i] = 0.;
3449     } else {
3450     ms12a[i] = 1.;
3451     };
3452     if ( ms12b[i] == 4095. ){
3453     ms12b[i] = 0.;
3454     } else {
3455     ms12b[i] = 1.;
3456     };
3457     };
3458     ii = 2;
3459     for ( Int_t i = 0; i<2; i++ ) {
3460     ii--;
3461     mt21[0][ii] = tof->tdc[ch21a[i]][hb21a[i]];
3462     mt21[1][ii] = tof->tdc[ch21b[i]][hb21b[i]];
3463     ms21a[ii] = tof->adc[ch21a[i]][hb21a[i]];
3464     ms21b[ii] = tof->adc[ch21b[i]][hb21b[i]];
3465     xp21[ii] = ( -A21[ii] + (mt21[0][ii]-mt21[1][ii]) / 2. ) / B21[ii] ;
3466     if ( ms21a[ii] == 4095. ){
3467     ms21a[ii] = 0.;
3468     } else {
3469     ms21a[ii] = 1.;
3470     };
3471     if ( ms21b[ii] == 4095. ){
3472     ms21b[ii] = 0.;
3473     } else {
3474     ms21b[ii] = 1.;
3475     };
3476     };
3477     for ( Int_t i = 0; i<2; i++ ) {
3478     mt22[0][i] = tof->tdc[ch22a[i]][hb22a[i]];
3479     mt22[1][i] = tof->tdc[ch22b[i]][hb22b[i]];
3480     ms22a[i] = tof->adc[ch22a[i]][hb22a[i]];
3481     ms22b[i] = tof->adc[ch22b[i]][hb22b[i]];
3482     xp22[i] = ( -A22[i] + (mt22[0][i]-mt22[1][i]) / 2. ) / B22[i] ;
3483     if ( ms22a[i] == 4095. ){
3484     ms22a[i] = 0.;
3485     } else {
3486     ms22a[i] = 1.;
3487     };
3488     if ( ms22b[i] == 4095. ){
3489     ms22b[i] = 0.;
3490     } else {
3491     ms22b[i] = 1.;
3492     };
3493     };
3494     for ( Int_t i = 0; i<3; i++ ) {
3495     mt31[0][i] = tof->tdc[ch31a[i]][hb31a[i]];
3496     mt31[1][i] = tof->tdc[ch31b[i]][hb31b[i]];
3497     ms31a[i] = tof->adc[ch31a[i]][hb31a[i]];
3498     ms31b[i] = tof->adc[ch31b[i]][hb31b[i]];
3499     xp31[i] = ( -A31[i] + (mt31[0][i]-mt31[1][i]) / 2. ) / B31[i] ;
3500     if ( ms31a[i] == 4095. ){
3501     ms31a[i] = 0.;
3502     } else {
3503     ms31a[i] = 1.;
3504     };
3505     if ( ms31b[i] == 4095. ){
3506     ms31b[i] = 0.;
3507     } else {
3508     ms31b[i] = 1.;
3509     };
3510     };
3511     for ( Int_t i = 0; i<3; i++ ) {
3512     mt32[0][i] = tof->tdc[ch32a[i]][hb32a[i]];
3513     mt32[1][i] = tof->tdc[ch32b[i]][hb32b[i]];
3514     ms32a[i] = tof->adc[ch32a[i]][hb32a[i]];
3515     ms32b[i] = tof->adc[ch32b[i]][hb32b[i]];
3516     xp32[i] = ( -A32[i] + (mt32[0][i]-mt32[1][i]) / 2. ) / B32[i] ;
3517     if ( ms32a[i] == 4095. ){
3518     ms32a[i] = 0.;
3519     } else {
3520     ms32a[i] = 1.;
3521     };
3522     if ( ms32b[i] == 4095. ){
3523     ms32b[i] = 0.;
3524     } else {
3525     ms32b[i] = 1.;
3526     };
3527     };
3528     //
3529     draw: Int_t colo = 0;
3530     Int_t ocolo = 0;
3531     Float_t xs2x = var.xxvc;
3532     Float_t ys2x = var.yxvc + 0.36*var.sfy;
3533     Float_t xs2y = var.xyvc;
3534     Float_t ys2y = var.yyvc + 0.36*var.sfy;
3535     Float_t ws2 = 0.005;
3536     Float_t ws13 = 0.007;
3537     //
3538     // S11 X-view
3539     //
3540     Float_t s11p = 0.051;
3541     ocolo = 10;
3542     TPolyLine *ftof11x[8];
3543     for ( Int_t j=0; j<8; j++){
3544     Float_t nxc1[5]={ (s11p*j), (s11p*j), s11p*(j+1), s11p*(j+1), (s11p*j)};
3545     Float_t nyc1[5]={ 0., ws13, ws13, 0., 0.};
3546     Float_t nxc[5];
3547     Float_t nyc[5];
3548     for (Int_t i = 0; i<5 ; i++) {
3549     nxc[i]= xs2x + (-0.204+nxc1[i])*var.sfx;
3550     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
3551     };
3552     ftof11x[j] = new TPolyLine(5,nxc,nyc);
3553     ftof11x[j]->SetLineColor(1);
3554     if ( var.bw ){
3555     colo = -1;
3556     } else {
3557     colo = 1;
3558     };
3559     ColorMIP(ms11a[j]+ms11b[j],colo);
3560     //
3561     if ( colo != 10 ) ocolo = colo;
3562     //
3563     ftof11x[j]->SetFillColor(colo);
3564     ftof11x[j]->SetLineWidth(1);
3565     ftof11x[j]->Draw("f");
3566     ftof11x[j]->Draw();
3567     };
3568     //
3569     // S11 Y-view
3570     //
3571     Float_t nxc1[5]={ -0.165, 0.165, 0.165, -0.165, -0.165};
3572     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
3573     Float_t nxc[5];
3574     Float_t nyc[5];
3575     for (Int_t i = 0; i<5 ; i++) {
3576     nxc[i]= xs2y + nxc1[i]*var.sfx;
3577     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
3578     };
3579     TPolyLine *ftof11y = new TPolyLine(5,nxc,nyc);
3580     ftof11y->SetFillStyle(4000);
3581     ftof11y->SetFillColor(0);
3582     ftof11y->SetLineColor(1);
3583     ftof11y->SetLineWidth(1);
3584     ftof11y->Draw("f");
3585     ftof11y->Draw();
3586     TPolyLine *sftof11[8];
3587     for ( Int_t j=0; j<8; j++){
3588     if ( (mt11[0][j]<4095. || mt11[1][j]<4095.) && !var.nosig ){
3589     if ( ocolo == 10 ) ocolo = noadc;
3590     Float_t lowp = (xp11[j]-E11[j])/100.;
3591     Float_t higp = (xp11[j]+E11[j])/100.;
3592     if ( lowp < -0.164 ) lowp = -0.164;
3593     if ( higp > 0.164 ) higp = 0.164;
3594     if ( lowp < higp ){
3595     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3596     Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015};
3597     Float_t nxc[5];
3598     Float_t nyc[5];
3599     for (Int_t i = 0; i<5 ; i++) {
3600     nxc[i]= xs2y + nxc1[i]*var.sfx;
3601     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
3602     };
3603     sftof11[j] = new TPolyLine(5,nxc,nyc);
3604     sftof11[j]->SetLineColor(ocolo);
3605     sftof11[j]->SetFillColor(ocolo);
3606     sftof11[j]->SetLineWidth(1);
3607     sftof11[j]->Draw("f");
3608     sftof11[j]->Draw();
3609     };
3610     };
3611     };
3612    
3613     //
3614     // S12 Y-view
3615     //
3616     Float_t s12p = 0.055;
3617     ocolo = 10;
3618     TPolyLine *ftof12y[6];
3619     for ( Int_t j=0; j<6; j++){
3620     Float_t nxc1[5]={ (s12p*j), (s12p*j), s12p*(j+1), s12p*(j+1), (s12p*j)};
3621     Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13};
3622     Float_t nxc[5];
3623     Float_t nyc[5];
3624     for (Int_t i = 0; i<5 ; i++) {
3625     nxc[i]= xs2y + (-0.165+nxc1[i])*var.sfx;
3626     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
3627     };
3628     ftof12y[j] = new TPolyLine(5,nxc,nyc);
3629     ftof12y[j]->SetLineColor(1);
3630     if ( var.bw ){
3631     colo = -1;
3632     } else {
3633     colo = 1;
3634     };
3635     ColorMIP(ms12a[j]+ms12b[j],colo);
3636     //
3637     if ( colo != 10 ) ocolo = colo;
3638     //
3639     ftof12y[j]->SetFillColor(colo);
3640     ftof12y[j]->SetLineWidth(1);
3641     ftof12y[j]->Draw("f");
3642     ftof12y[j]->Draw();
3643     };
3644     //
3645     // S12 X-view
3646     //
3647     if ( true ){
3648     Float_t nxc1[5]={ -0.204, 0.204, 0.204, -0.204, -0.204};
3649     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
3650     Float_t nxc[5];
3651     Float_t nyc[5];
3652     for (Int_t i = 0; i<5 ; i++) {
3653     nxc[i]= xs2x + nxc1[i]*var.sfx;
3654     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
3655     };
3656     TPolyLine *ftof12x = new TPolyLine(5,nxc,nyc);
3657     ftof12x->SetLineColor(1);
3658     ftof12x->SetFillStyle(4000);
3659     ftof12x->SetFillColor(0);
3660     ftof12x->SetLineWidth(1);
3661     ftof12x->Draw("f");
3662     ftof12x->Draw();
3663     TPolyLine *sftof12[6];
3664     for ( Int_t j=0; j<6; j++){
3665     if ( (mt12[0][j]<4095. || mt12[1][j]<4095.) && !var.nosig ){
3666     if ( ocolo == 10 ) ocolo = noadc;
3667     Float_t lowp = (xp12[j]-E12[j])/100.;
3668     Float_t higp = (xp12[j]+E12[j])/100.;
3669     if ( lowp < -0.203 ) lowp = -0.203;
3670     if ( higp > 0.203 ) higp = 0.203;
3671     if ( lowp < higp ){
3672     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3673     Float_t nyc1[5]={ -0.0015, -0.0015, -ws13+0.0015, -ws13+0.0015, -0.0015};
3674     Float_t nxc[5];
3675     Float_t nyc[5];
3676     for (Int_t i = 0; i<5 ; i++) {
3677     nxc[i]= xs2x + nxc1[i]*var.sfx;
3678     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
3679     };
3680     sftof12[j] = new TPolyLine(5,nxc,nyc);
3681     sftof12[j]->SetLineColor(ocolo);
3682     sftof12[j]->SetFillColor(ocolo);
3683     sftof12[j]->SetLineWidth(1);
3684     sftof12[j]->Draw("f");
3685     sftof12[j]->Draw();
3686     };
3687     };
3688     };
3689     };
3690     //
3691    
3692     //
3693     // S21 Y-view
3694     //
3695     Float_t s21p = 0.075;
3696     ocolo = 10;
3697     TPolyLine *ftof21y[2];
3698     for ( Int_t j=0; j<2; j++){
3699     Float_t nxc1[5]={ s21p*(j-1), s21p*(j-1), s21p*j,s21p*j, s21p*(j-1)};
3700     Float_t nyc1[5]={ 0., ws2, ws2, 0., 0.};
3701     Float_t nxc[5];
3702     Float_t nyc[5];
3703     for (Int_t i = 0; i<5 ; i++) {
3704     nxc[i]= xs2y + nxc1[i]*var.sfx;
3705     nyc[i] = ys2y + nyc1[i]*var.sfy;
3706     };
3707     ftof21y[j] = new TPolyLine(5,nxc,nyc);
3708     ftof21y[j]->SetLineColor(1);
3709     if ( var.bw ){
3710     colo = -1;
3711     } else {
3712     colo = 1;
3713     };
3714     ColorMIP(ms21a[j]+ms21b[j],colo);
3715     //
3716     if ( colo != 10 ) ocolo = colo;
3717     //
3718     ftof21y[j]->SetFillColor(colo);
3719     ftof21y[j]->SetLineWidth(1);
3720     ftof21y[j]->Draw("f");
3721     ftof21y[j]->Draw();
3722     };
3723     //
3724     // S21 X-view
3725     //
3726     if ( true ){
3727     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
3728     Float_t nyc1[5]={ 0., 0., ws2, ws2, 0.};
3729     Float_t nxc[5];
3730     Float_t nyc[5];
3731     for (Int_t i = 0; i<5 ; i++) {
3732     nxc[i]= xs2x + nxc1[i]*var.sfx;
3733     nyc[i] = ys2x + nyc1[i]*var.sfy;
3734     };
3735     TPolyLine *ftof21x = new TPolyLine(5,nxc,nyc);
3736     ftof21x->SetLineColor(1);
3737     ftof21x->SetFillStyle(4000);
3738     ftof21x->SetFillColor(0);
3739     ftof21x->SetLineWidth(1);
3740     ftof21x->Draw("f");
3741     ftof21x->Draw();
3742     TPolyLine *sftof21[2];
3743     for ( Int_t j=0; j<2; j++){
3744     if ( (mt21[0][j]<4095. || mt21[1][j]<4095.) && !var.nosig ){
3745     if ( ocolo == 10 ) ocolo = noadc;
3746     Float_t lowp = (xp21[j]-E21[j])/100.;
3747     Float_t higp = (xp21[j]+E21[j])/100.;
3748     if ( lowp < -0.089 ) lowp = -0.089;
3749     if ( higp > 0.089 ) higp = 0.089;
3750     if ( lowp < higp ){
3751     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3752     Float_t nyc1[5]={ 0.0015, 0.0015, ws2-0.0015, ws2-0.0015, 0.};
3753     Float_t nxc[5];
3754     Float_t nyc[5];
3755     for (Int_t i = 0; i<5 ; i++) {
3756     nxc[i]= xs2x + nxc1[i]*var.sfx;
3757     nyc[i] = ys2x + nyc1[i]*var.sfy;
3758     };
3759     sftof21[j] = new TPolyLine(5,nxc,nyc);
3760     sftof21[j]->SetLineColor(ocolo);
3761     sftof21[j]->SetFillColor(ocolo);
3762     sftof21[j]->SetLineWidth(1);
3763     sftof21[j]->Draw("f");
3764     sftof21[j]->Draw();
3765     };
3766     };
3767     };
3768     };
3769     //
3770    
3771     //
3772     // S22 X-view
3773     //
3774     Float_t s22p = 0.090;
3775     ocolo = 10;
3776     TPolyLine *ftof22x[2];
3777     for ( Int_t j=0; j<2; j++){
3778     Float_t nxc1[5]={ s22p*(j-1), s22p*(j-1), s22p*j, s22p*j, s22p*(j-1)};
3779     Float_t nyc1[5]={ -ws2, 0., 0., -ws2, -ws2};
3780     Float_t nxc[5];
3781     Float_t nyc[5];
3782     for (Int_t i = 0; i<5 ; i++) {
3783     nxc[i]= xs2x + nxc1[i]*var.sfx;
3784     nyc[i] = ys2x + nyc1[i]*var.sfy;
3785     };
3786     ftof22x[j] = new TPolyLine(5,nxc,nyc);
3787     ftof22x[j]->SetLineColor(1);
3788     if ( var.bw ){
3789     colo = -1;
3790     } else {
3791     colo = 1;
3792     };
3793     ColorMIP(ms22a[j]+ms22b[j],colo);
3794     //
3795     if ( colo != 10 ) ocolo = colo;
3796     //
3797     ftof22x[j]->SetFillColor(colo);
3798     ftof22x[j]->SetLineWidth(1);
3799     ftof22x[j]->Draw("f");
3800     ftof22x[j]->Draw();
3801     };
3802     //
3803     // S22 Y-view
3804     //
3805     if ( true ){
3806     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
3807     Float_t nyc1[5]={ 0., 0., -ws2, -ws2, 0.};
3808     Float_t nxc[5];
3809     Float_t nyc[5];
3810     for (Int_t i = 0; i<5 ; i++) {
3811     nxc[i]= xs2y + nxc1[i]*var.sfx;
3812     nyc[i] = ys2y + nyc1[i]*var.sfy;
3813     };
3814     TPolyLine *ftof22y = new TPolyLine(5,nxc,nyc);
3815     ftof22y->SetLineColor(1);
3816     ftof22y->SetFillStyle(4000);
3817     ftof22y->SetFillColor(0);
3818     ftof22y->SetLineWidth(1);
3819     ftof22y->Draw("f");
3820     ftof22y->Draw();
3821     TPolyLine *sftof22[2];
3822     for ( Int_t j=0; j<2; j++){
3823     if ( (mt22[0][j]<4095. || mt22[1][j]<4095.) && !var.nosig ){
3824     if ( ocolo == 10 ) ocolo = noadc;
3825     Float_t lowp = (xp22[j]-E22[j])/100.;
3826     Float_t higp = (xp22[j]+E22[j])/100.;
3827     if ( lowp < -0.074 ) lowp = -0.074;
3828     if ( higp > 0.074 ) higp = 0.074;
3829     if ( lowp < higp ){
3830     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3831     Float_t nyc1[5]={ -0.0015, -0.0015, -ws2+0.0015, -ws2+0.0015, -0.0015};
3832     Float_t nxc[5];
3833     Float_t nyc[5];
3834     for (Int_t i = 0; i<5 ; i++) {
3835     nxc[i]= xs2y + nxc1[i]*var.sfx;
3836     nyc[i] = ys2y + nyc1[i]*var.sfy;
3837     };
3838     sftof22[j] = new TPolyLine(5,nxc,nyc);
3839     sftof22[j]->SetLineColor(ocolo);
3840     sftof22[j]->SetFillColor(ocolo);
3841     sftof22[j]->SetLineWidth(1);
3842     sftof22[j]->Draw("f");
3843     sftof22[j]->Draw();
3844     };
3845     };
3846     };
3847     };
3848     //
3849    
3850     //
3851     // S31 X-view
3852     //
3853     Float_t s31p = 0.060;
3854     ocolo = 10;
3855     TPolyLine *ftof31x[3];
3856     for ( Int_t j=0; j<3; j++){
3857     Float_t nxc1[5]={ (s31p*j), (s31p*j), s31p*(j+1), s31p*(j+1), (s31p*j)};
3858     Float_t nyc1[5]={ 0., ws13, ws13, 0., 0.};
3859     Float_t nxc[5];
3860     Float_t nyc[5];
3861     for (Int_t i = 0; i<5 ; i++) {
3862     nxc[i]= xs2x + (-0.090+nxc1[i])*var.sfx;
3863     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
3864     };
3865     ftof31x[j] = new TPolyLine(5,nxc,nyc);
3866     ftof31x[j]->SetLineColor(1);
3867     if ( var.bw ){
3868     colo = -1;
3869     } else {
3870     colo = 1;
3871     };
3872     ColorMIP(ms31a[j]+ms31b[j],colo);
3873     //
3874     if ( colo != 10 ) ocolo = colo;
3875     //
3876     ftof31x[j]->SetFillColor(colo);
3877     ftof31x[j]->SetLineWidth(1);
3878     ftof31x[j]->Draw("f");
3879     ftof31x[j]->Draw();
3880     };
3881     //
3882     // S31 Y-view
3883     //
3884     if ( true ){
3885     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
3886     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
3887     Float_t nxc[5];
3888     Float_t nyc[5];
3889     for (Int_t i = 0; i<5 ; i++) {
3890     nxc[i]= xs2y + nxc1[i]*var.sfx;
3891     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
3892     };
3893     TPolyLine *ftof31y = new TPolyLine(5,nxc,nyc);
3894     ftof31y->SetLineColor(1);
3895     ftof31y->SetFillStyle(4000);
3896     ftof31y->SetFillColor(0);
3897     ftof31y->SetLineWidth(1);
3898     ftof31y->Draw("f");
3899     ftof31y->Draw();
3900     TPolyLine *sftof31[3];
3901     for ( Int_t j=0; j<3; j++){
3902     if ( (mt31[0][j]<4095. || mt31[1][j]<4095.) && !var.nosig){
3903     if ( ocolo == 10 ) ocolo = noadc;
3904     Float_t lowp = (xp31[j]-E31[j])/100.;
3905     Float_t higp = (xp31[j]+E31[j])/100.;
3906     if ( lowp < -0.074 ) lowp = -0.074;
3907     if ( higp > 0.074 ) higp = 0.074;
3908     if ( lowp < higp ){
3909     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3910     Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015};
3911     Float_t nxc[5];
3912     Float_t nyc[5];
3913     for (Int_t i = 0; i<5 ; i++) {
3914     nxc[i]= xs2y + nxc1[i]*var.sfx;
3915     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
3916     };
3917     sftof31[j] = new TPolyLine(5,nxc,nyc);
3918     sftof31[j]->SetLineColor(ocolo);
3919     sftof31[j]->SetFillColor(ocolo);
3920     sftof31[j]->SetLineWidth(1);
3921     sftof31[j]->Draw("f");
3922     sftof31[j]->Draw();
3923     };
3924     };
3925     };
3926     };
3927     //
3928    
3929     //
3930     // S32 Y-view
3931     //
3932     Float_t s32p = 0.050;
3933     ocolo = 10;
3934     TPolyLine *ftof32y[3];
3935     for ( Int_t j=0; j<3; j++){
3936     Float_t nxc1[5]={ (s32p*j), (s32p*j), s32p*(j+1),s32p*(j+1), (s32p*j)};
3937     Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13};
3938     Float_t nxc[5];
3939     Float_t nyc[5];
3940     for (Int_t i = 0; i<5 ; i++) {
3941     nxc[i]= xs2y + (-0.075+nxc1[i])*var.sfx;
3942     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
3943     };
3944     ftof32y[j] = new TPolyLine(5,nxc,nyc);
3945     ftof32y[j]->SetLineColor(1);
3946     if ( var.bw ){
3947     colo = -1;
3948     } else {
3949     colo = 1;
3950     };
3951     ColorMIP(ms32a[j]+ms32b[j],colo);
3952     //
3953     if ( colo != 10 ) ocolo = colo;
3954     //
3955     ftof32y[j]->SetFillColor(colo);
3956     ftof32y[j]->SetLineWidth(1);
3957     ftof32y[j]->Draw("f");
3958     ftof32y[j]->Draw();
3959     };
3960     //
3961     // S32 X-view
3962     //
3963     if ( true ){
3964     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
3965     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
3966     Float_t nxc[5];
3967     Float_t nyc[5];
3968     for (Int_t i = 0; i<5 ; i++) {
3969     nxc[i]= xs2x + nxc1[i]*var.sfx;
3970     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
3971     };
3972     TPolyLine *ftof32x = new TPolyLine(5,nxc,nyc);
3973     ftof32x->SetLineColor(1);
3974     ftof32x->SetLineWidth(1);
3975     ftof32x->SetFillStyle(4000);
3976     ftof32x->SetFillColor(0);
3977     ftof32x->Draw("f");
3978     ftof32x->Draw();
3979     TPolyLine *sftof32[3];
3980     for ( Int_t j=0; j<3; j++){
3981     if ( (mt32[0][j]<4095. || mt32[1][j]<4095.) && !var.nosig ){
3982     if ( ocolo == 10 ) ocolo = noadc;
3983     Float_t lowp = (xp32[j]-E32[j])/100.;
3984     Float_t higp = (xp32[j]+E32[j])/100.;
3985     if ( lowp < -0.089 ) lowp = -0.089;
3986     if ( higp > 0.089 ) higp = 0.089;
3987     if ( lowp < higp ){
3988     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3989     Float_t nyc1[5]={ -0.0015, -0.0015, -ws13+0.0015, -ws13+0.0015, -0.0015};
3990     Float_t nxc[5];
3991     Float_t nyc[5];
3992     for (Int_t i = 0; i<5 ; i++) {
3993     nxc[i]= xs2x + nxc1[i]*var.sfx;
3994     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
3995     };
3996     sftof32[j] = new TPolyLine(5,nxc,nyc);
3997     sftof32[j]->SetLineColor(ocolo);
3998     sftof32[j]->SetFillColor(ocolo);
3999     sftof32[j]->SetLineWidth(1);
4000     sftof32[j]->Draw("f");
4001     sftof32[j]->Draw();
4002     };
4003     };
4004     };
4005     };
4006     //
4007     }
4008    
4009     void ShowTOFL1(Int_t j, TTree *toftr, Variables & var){
4010     //
4011     for (Int_t i=0 ; i<5; i++){
4012     var.beta[i] = 0.;
4013     };
4014     //
4015     struct Toflev1 ntof;
4016     settoflev1(toftr,ntof);
4017     //
4018     Int_t syncro = 1;
4019     Int_t itr = j;
4020     Int_t trnevents = toftr->GetEntries();
4021     Int_t pktnum = 0;
4022     Int_t obt = 0;
4023     trkcalosync: if ( itr >= trnevents ){
4024     printf(" WARNING: no more tof level1 data.\n");
4025     return;
4026     };
4027     if ( !var.nosig ) toftr->GetEntry(itr);
4028     pktnum = var.headc;
4029     obt = var.etime;
4030     if ( pktnum != ntof.pkt_num || obt != ntof.obt ){
4031     if ( pktnum > ntof.pkt_num || obt > ntof.obt ){
4032     itr++;
4033     if ( syncro ) printf(" WARNING: lost sync! try to recover... \n");
4034     syncro = 0;
4035     goto trkcalosync;
4036     };
4037     if ( pktnum < ntof.pkt_num || obt < ntof.obt ){
4038     printf(" WARNING: no tof level1 data. \n");
4039     return;
4040     };
4041     };
4042     //
4043     if ( !syncro ) printf(" ...synchronization recovered! \n");
4044     syncro = 1;
4045     //
4046     if ( !var.nosig ) {
4047     for (Int_t i=0 ; i<5; i++){
4048     if ( ntof.beta[i] < 100.) var.beta[i] = ntof.beta[i];
4049     };
4050     };
4051     struct CToflev1 tof;
4052     accesstoflev1(ntof,tof);
4053     //
4054     // the channels MAP:
4055     //
4056     Int_t ch11a[8] = { 3, 3, 3, 3, 0, 0, 1, 1};
4057     Int_t hb11a[8] = { 0, 2, 4, 6, 9, 11, 1, 3};
4058     Int_t ch11b[8] = { 1, 1, 1, 1, 0, 0, 0, 0};
4059     Int_t hb11b[8] = { 5, 7, 11, 9, 7, 5, 3, 1};
4060    
4061     Int_t ch12a[6] = { 2, 2, 2, 2, 2, 2};
4062     Int_t hb12a[6] = { 1, 3, 5, 7, 9, 11};
4063     Int_t ch12b[6] = { 3, 3, 3, 3, 3, 3};
4064     Int_t hb12b[6] = { 11, 9, 7, 5, 3, 1};
4065    
4066     Int_t ch21a[2] = { 0, 0};
4067     Int_t hb21a[2] = { 0, 4};
4068     Int_t ch21b[2] = { 1, 0};
4069     Int_t hb21b[2] = { 8, 6};
4070    
4071     Int_t ch22a[2] = { 0, 0};
4072     Int_t hb22a[2] = { 2, 8};
4073     Int_t ch22b[2] = { 1, 0};
4074     Int_t hb22b[2] = { 10, 10};
4075    
4076     Int_t ch31a[3] = { 1, 2, 2};
4077     Int_t hb31a[3] = { 6, 8, 10};
4078     Int_t ch31b[3] = { 1, 1, 1};
4079     Int_t hb31b[3] = { 4, 2, 0};
4080    
4081     Int_t ch32a[3] = { 2, 2, 3};
4082     Int_t hb32a[3] = { 0, 4, 8};
4083     Int_t ch32b[3] = { 2, 2, 3};
4084     Int_t hb32b[3] = { 2, 6, 10};
4085    
4086     //
4087     Float_t E11 = 2.6;
4088     Float_t E12 = 2.6;
4089     Float_t E21 = 2.2;
4090     Float_t E22 = 2.9;
4091     Float_t E31 = 1.2;
4092     Float_t E32 = 2.3;
4093    
4094     //
4095     // ADC values
4096     //
4097     Float_t ms11a[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
4098     Float_t ms12a[6] = {0.,0.,0.,0.,0.,0.};
4099     Float_t ms21a[2] = {0.,0.};
4100     Float_t ms22a[2] = {0.,0.};
4101     Float_t ms31a[3] = {0.,0.,0.};
4102     Float_t ms32a[3] = {0.,0.,0.};
4103     Float_t ms11b[8] = {0.,0.,0.,0.,0.,0.,0.,0.};
4104     Float_t ms12b[6] = {0.,0.,0.,0.,0.,0.};
4105     Float_t ms21b[2] = {0.,0.};
4106     Float_t ms22b[2] = {0.,0.};
4107     Float_t ms31b[3] = {0.,0.,0.};
4108     Float_t ms32b[3] = {0.,0.,0.};
4109     //
4110     Float_t xp11 = 0.;
4111     Float_t xp12 = 0.;
4112     Float_t xp21 = 0.;
4113     Float_t xp22 = 0.;
4114     Float_t xp31 = 0.;
4115     Float_t xp32 = 0.;
4116     //
4117     Int_t noadc = 12;
4118     if ( var.bw ){
4119     noadc = 12;
4120     } else {
4121     noadc = 41;
4122     };
4123     //
4124     Int_t ii = 2;
4125     //
4126     if ( var.nosig ) goto draw;
4127     xp11 = tof.ytof[0];
4128     for ( Int_t i = 0; i<8; i++ ) {
4129     if ( tof.adc_c[ch11a[i]][hb11a[i]] < 1000. ){
4130     ms11a[i] = tof.adc_c[ch11a[i]][hb11a[i]]/2.;
4131     };
4132     if ( tof.adc_c[ch11b[i]][hb11b[i]] < 1000. ){
4133     ms11b[i] = tof.adc_c[ch11b[i]][hb11b[i]]/2.;
4134     };
4135     };
4136     xp12 = tof.xtof[0];
4137     for ( Int_t i = 0; i<6; i++ ) {
4138     if ( tof.adc_c[ch12a[i]][hb12a[i]] < 1000. ) ms12a[i] = tof.adc_c[ch12a[i]][hb12a[i]]/2.;
4139     if ( tof.adc_c[ch12b[i]][hb12b[i]] < 1000. ) ms12b[i] = tof.adc_c[ch12b[i]][hb12b[i]]/2.;
4140     };
4141     xp21 = tof.xtof[1];
4142     ii = 2;
4143     for ( Int_t i = 0; i<2; i++ ) {
4144     ii--;
4145     if ( tof.adc_c[ch21a[i]][hb21a[i]] < 1000. ) ms21a[ii] = tof.adc_c[ch21a[i]][hb21a[i]]/2.;
4146     if ( tof.adc_c[ch21b[i]][hb21b[i]] < 1000. ) ms21b[ii] = tof.adc_c[ch21b[i]][hb21b[i]]/2.;
4147     };
4148     xp22 = tof.ytof[1];
4149     for ( Int_t i = 0; i<2; i++ ) {
4150     if ( tof.adc_c[ch22a[i]][hb22a[i]] < 1000. ) ms22a[i] = tof.adc_c[ch22a[i]][hb22a[i]]/2.;
4151     if ( tof.adc_c[ch22b[i]][hb22b[i]] < 1000. ) ms22b[i] = tof.adc_c[ch22b[i]][hb22b[i]]/2.;
4152     };
4153     xp31 = tof.ytof[2];
4154     for ( Int_t i = 0; i<3; i++ ) {
4155     if ( tof.adc_c[ch31a[i]][hb31a[i]] < 1000. ) ms31a[i] = tof.adc_c[ch31a[i]][hb31a[i]]/2.;
4156     if ( tof.adc_c[ch31b[i]][hb31b[i]] < 1000. ) ms31b[i] = tof.adc_c[ch31b[i]][hb31b[i]]/2.;
4157     };
4158     xp32 = tof.xtof[2];
4159     for ( Int_t i = 0; i<3; i++ ) {
4160     if ( tof.adc_c[ch32a[i]][hb32a[i]] < 1000. ) ms32a[i] = tof.adc_c[ch32a[i]][hb32a[i]]/2.;
4161     if ( tof.adc_c[ch32b[i]][hb32b[i]] < 1000. ) ms32b[i] = tof.adc_c[ch32b[i]][hb32b[i]]/2.;
4162     };
4163     //
4164     draw:
4165     //
4166     Int_t colo;
4167     Int_t ocolo;
4168     Float_t xs2x = var.xxvc;
4169     Float_t ys2x = var.yxvc + 0.36*var.sfy;
4170     Float_t xs2y = var.xyvc;
4171     Float_t ys2y = var.yyvc + 0.36*var.sfy;
4172     Float_t ws2 = 0.005;
4173     Float_t ws13 = 0.007;
4174     //
4175     // S11 X-view
4176     //
4177     Float_t s11p = 0.051;
4178     ocolo = 10;
4179     TPolyLine *ftof11x[8];
4180     for ( Int_t j=0; j<8; j++){
4181     Float_t nxc1[5]={ (s11p*j), (s11p*j), s11p*(j+1), s11p*(j+1), (s11p*j)};
4182     Float_t nyc1[5]={ 0., ws13, ws13, 0., 0.};
4183     Float_t nxc[5];
4184     Float_t nyc[5];
4185     for (Int_t i = 0; i<5 ; i++) {
4186     nxc[i]= xs2x + (-0.204+nxc1[i])*var.sfx;
4187     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
4188     };
4189     ftof11x[j] = new TPolyLine(5,nxc,nyc);
4190     ftof11x[j]->SetLineColor(1);
4191     if ( var.bw ){
4192     colo = -1;
4193     } else {
4194     colo = 1;
4195     };
4196     ColorTOFMIP(ms11a[j]+ms11b[j],colo);
4197     //
4198     if ( colo != 10 ) ocolo = colo;
4199     //
4200     ftof11x[j]->SetFillColor(colo);
4201     ftof11x[j]->SetLineWidth(1);
4202     ftof11x[j]->Draw("f");
4203     ftof11x[j]->Draw();
4204     };
4205     //
4206     // S11 Y-view
4207     //
4208     if ( true ){
4209     Float_t nxc1[5]={ -0.165, 0.165, 0.165, -0.165, -0.165};
4210     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
4211     Float_t nxc[5];
4212     Float_t nyc[5];
4213     for (Int_t i = 0; i<5 ; i++) {
4214     nxc[i]= xs2y + nxc1[i]*var.sfx;
4215     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
4216     };
4217     TPolyLine *ftof11y = new TPolyLine(5,nxc,nyc);
4218     ftof11y->SetFillStyle(4000);
4219     ftof11y->SetFillColor(0);
4220     ftof11y->SetLineColor(1);
4221     ftof11y->SetLineWidth(1);
4222     ftof11y->Draw("f");
4223     ftof11y->Draw();
4224     TPolyLine *sftof11;
4225     if ( !var.nosig ){
4226     if ( ocolo == 10 ) ocolo = noadc;
4227     Float_t lowp = (xp11-E11)/100.;
4228     Float_t higp = (xp11+E11)/100.;
4229     if ( lowp < -0.164 ) lowp = -0.164;
4230     if ( higp > 0.164 ) higp = 0.164;
4231     if ( lowp < higp ){
4232     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
4233     Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015};
4234     Float_t nxc[5];
4235     Float_t nyc[5];
4236     for (Int_t i = 0; i<5 ; i++) {
4237     nxc[i]= xs2y + nxc1[i]*var.sfx;
4238     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
4239     };
4240     sftof11 = new TPolyLine(5,nxc,nyc);
4241     sftof11->SetLineColor(ocolo);
4242     sftof11->SetFillColor(ocolo);
4243     sftof11->SetLineWidth(1);
4244     sftof11->Draw("f");
4245     sftof11->Draw();
4246     };
4247     };
4248     };
4249    
4250     //
4251     // S12 Y-view
4252     //
4253     Float_t s12p = 0.055;
4254     ocolo = 10;
4255     TPolyLine *ftof12y[6];
4256     for ( Int_t j=0; j<6; j++){
4257     Float_t nxc1[5]={ (s12p*j), (s12p*j), s12p*(j+1), s12p*(j+1), (s12p*j)};
4258     Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13};
4259     Float_t nxc[5];
4260     Float_t nyc[5];
4261     for (Int_t i = 0; i<5 ; i++) {
4262     nxc[i]= xs2y + (-0.165+nxc1[i])*var.sfx;
4263     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
4264     };
4265     ftof12y[j] = new TPolyLine(5,nxc,nyc);
4266     ftof12y[j]->SetLineColor(1);
4267     if ( var.bw ){
4268     colo = -1;
4269     } else {
4270     colo = 1;
4271     };
4272     ColorTOFMIP(ms12a[j]+ms12b[j],colo);
4273     //
4274     if ( colo != 10 ) ocolo = colo;
4275     //
4276     ftof12y[j]->SetFillColor(colo);
4277     ftof12y[j]->SetLineWidth(1);
4278     ftof12y[j]->Draw("f");
4279     ftof12y[j]->Draw();
4280     };
4281     //
4282     // S12 X-view
4283     //
4284     if ( true ){
4285     Float_t nxc1[5]={ -0.204, 0.204, 0.204, -0.204, -0.204};
4286     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
4287     Float_t nxc[5];
4288     Float_t nyc[5];
4289     for (Int_t i = 0; i<5 ; i++) {
4290     nxc[i]= xs2x + nxc1[i]*var.sfx;
4291     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
4292     };
4293     TPolyLine *ftof12x = new TPolyLine(5,nxc,nyc);
4294     ftof12x->SetLineColor(1);
4295     ftof12x->SetFillStyle(4000);
4296     ftof12x->SetFillColor(0);
4297     ftof12x->SetLineWidth(1);
4298     ftof12x->Draw("f");
4299     ftof12x->Draw();
4300     TPolyLine *sftof12;
4301     if ( !var.nosig ){
4302     if ( ocolo == 10 ) ocolo = noadc;
4303     Float_t lowp = (xp12-E12)/100.;
4304     Float_t higp = (xp12+E12)/100.;
4305     if ( lowp < -0.203 ) lowp = -0.203;
4306     if ( higp > 0.203 ) higp = 0.203;
4307     if ( lowp < higp ){
4308     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
4309     Float_t nyc1[5]={ -0.0015, -0.0015, -ws13+0.0015, -ws13+0.0015, -0.0015};
4310     Float_t nxc[5];
4311     Float_t nyc[5];
4312     for (Int_t i = 0; i<5 ; i++) {
4313     nxc[i]= xs2x + nxc1[i]*var.sfx;
4314     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
4315     };
4316     sftof12 = new TPolyLine(5,nxc,nyc);
4317     sftof12->SetLineColor(ocolo);
4318     sftof12->SetFillColor(ocolo);
4319     sftof12->SetLineWidth(1);
4320     sftof12->Draw("f");
4321     sftof12->Draw();
4322     };
4323     };
4324     };
4325     //
4326    
4327     //
4328     // S21 Y-view
4329     //
4330     Float_t s21p = 0.075;
4331     ocolo = 10;
4332     TPolyLine *ftof21y[2];
4333     for ( Int_t j=0; j<2; j++){
4334     Float_t nxc1[5]={ s21p*(j-1), s21p*(j-1), s21p*j,s21p*j, s21p*(j-1)};
4335     Float_t nyc1[5]={ 0., ws2, ws2, 0., 0.};
4336     Float_t nxc[5];
4337     Float_t nyc[5];
4338     for (Int_t i = 0; i<5 ; i++) {
4339     nxc[i]= xs2y + nxc1[i]*var.sfx;
4340     nyc[i] = ys2y + nyc1[i]*var.sfy;
4341     };
4342     ftof21y[j] = new TPolyLine(5,nxc,nyc);
4343     ftof21y[j]->SetLineColor(1);
4344     if ( var.bw ){
4345     colo = -1;
4346     } else {
4347     colo = 1;
4348     };
4349     ColorTOFMIP(ms21a[j]+ms21b[j],colo);
4350     //
4351     if ( colo != 10 ) ocolo = colo;
4352     //
4353     ftof21y[j]->SetFillColor(colo);
4354     ftof21y[j]->SetLineWidth(1);
4355     ftof21y[j]->Draw("f");
4356     ftof21y[j]->Draw();
4357     };
4358     //
4359     // S21 X-view
4360     //
4361     if ( true ){
4362     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
4363     Float_t nyc1[5]={ 0., 0., ws2, ws2, 0.};
4364     Float_t nxc[5];
4365     Float_t nyc[5];
4366     for (Int_t i = 0; i<5 ; i++) {
4367     nxc[i]= xs2x + nxc1[i]*var.sfx;
4368     nyc[i] = ys2x + (0.0+nyc1[i])*var.sfy;
4369     };
4370     TPolyLine *ftof21x = new TPolyLine(5,nxc,nyc);
4371     ftof21x->SetLineColor(1);
4372     ftof21x->SetFillStyle(4000);
4373     ftof21x->SetFillColor(0);
4374     ftof21x->SetLineWidth(1);
4375     ftof21x->Draw("f");
4376     ftof21x->Draw();
4377     TPolyLine *sftof21;
4378     if ( !var.nosig ){
4379     if ( ocolo == 10 ) ocolo = noadc;
4380     Float_t lowp = (xp21-E21)/100.;
4381     Float_t higp = (xp21+E21)/100.;
4382     if ( lowp < -0.089 ) lowp = -0.089;
4383     if ( higp > 0.089 ) higp = 0.089;
4384     if ( lowp < higp ){
4385     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
4386     Float_t nyc1[5]={ 0.0015, 0.0015, ws2-0.0015, ws2-0.0015, 0.};
4387     Float_t nxc[5];
4388     Float_t nyc[5];
4389     for (Int_t i = 0; i<5 ; i++) {
4390     nxc[i]= xs2x + nxc1[i]*var.sfx;
4391     nyc[i] = ys2x + (0.0+nyc1[i])*var.sfy;
4392     };
4393     sftof21 = new TPolyLine(5,nxc,nyc);
4394     sftof21->SetLineColor(ocolo);
4395     sftof21->SetFillColor(ocolo);
4396     sftof21->SetLineWidth(1);
4397     sftof21->Draw("f");
4398     sftof21->Draw();
4399     };
4400     };
4401     };
4402     //
4403    
4404     //
4405     // S22 X-view
4406     //
4407     Float_t s22p = 0.090;
4408     ocolo = 10;
4409     TPolyLine *ftof22x[2];
4410     for ( Int_t j=0; j<2; j++){
4411     Float_t nxc1[5]={ s22p*(j-1), s22p*(j-1), s22p*j, s22p*j, s22p*(j-1)};
4412     Float_t nyc1[5]={ -ws2, 0., 0., -ws2, -ws2};
4413     Float_t nxc[5];
4414     Float_t nyc[5];
4415     for (Int_t i = 0; i<5 ; i++) {
4416     nxc[i]= xs2x + nxc1[i]*var.sfx;
4417     nyc[i] = ys2x + (0.0+nyc1[i])*var.sfy;
4418     };
4419     ftof22x[j] = new TPolyLine(5,nxc,nyc);
4420     ftof22x[j]->SetLineColor(1);
4421     if ( var.bw ){
4422     colo = -1;
4423     } else {
4424     colo = 1;
4425     };
4426     ColorTOFMIP(ms22a[j]+ms22b[j],colo);
4427     //
4428     if ( colo != 10 ) ocolo = colo;
4429     //
4430     ftof22x[j]->SetFillColor(colo);
4431     ftof22x[j]->SetLineWidth(1);
4432     ftof22x[j]->Draw("f");
4433     ftof22x[j]->Draw();
4434     };
4435     //
4436     // S22 Y-view
4437     //
4438     if ( true ){
4439     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
4440     Float_t nyc1[5]={ 0., 0., -ws2, -ws2, 0.};
4441     Float_t nxc[5];
4442     Float_t nyc[5];
4443     for (Int_t i = 0; i<5 ; i++) {
4444     nxc[i]= xs2y + nxc1[i]*var.sfx;
4445     nyc[i] = ys2y + (0.0+nyc1[i])*var.sfy;
4446     };
4447     TPolyLine *ftof22y = new TPolyLine(5,nxc,nyc);
4448     ftof22y->SetLineColor(1);
4449     ftof22y->SetFillStyle(4000);
4450     ftof22y->SetFillColor(0);
4451     ftof22y->SetLineWidth(1);
4452     ftof22y->Draw("f");
4453     ftof22y->Draw();
4454     TPolyLine *sftof22;
4455     if ( !var.nosig ){
4456     if ( ocolo == 10 ) ocolo = noadc;
4457     Float_t lowp = (xp22-E22)/100.;
4458     Float_t higp = (xp22+E22)/100.;
4459     if ( lowp < -0.074 ) lowp = -0.074;
4460     if ( higp > 0.074 ) higp = 0.074;
4461     if ( lowp < higp ){
4462     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
4463     Float_t nyc1[5]={ -0.0015, -0.0015, -ws2+0.0015, -ws2+0.0015, -0.0015};
4464     Float_t nxc[5];
4465     Float_t nyc[5];
4466     for (Int_t i = 0; i<5 ; i++) {
4467     nxc[i]= xs2y + nxc1[i]*var.sfx;
4468     nyc[i] = ys2y + (0.0+nyc1[i])*var.sfy;
4469     };
4470     sftof22 = new TPolyLine(5,nxc,nyc);
4471     sftof22->SetLineColor(ocolo);
4472     sftof22->SetFillColor(ocolo);
4473     sftof22->SetLineWidth(1);
4474     sftof22->Draw("f");
4475     sftof22->Draw();
4476     };
4477     };
4478     };
4479     //
4480    
4481     //
4482     // S31 X-view
4483     //
4484     Float_t s31p = 0.060;
4485     ocolo = 10;
4486     TPolyLine *ftof31x[3];
4487     for ( Int_t j=0; j<3; j++){
4488     Float_t nxc1[5]={ (s31p*j), (s31p*j), s31p*(j+1), s31p*(j+1), (s31p*j)};
4489     Float_t nyc1[5]={ 0., ws13, ws13, 0., 0.};
4490     Float_t nxc[5];
4491     Float_t nyc[5];
4492     for (Int_t i = 0; i<5 ; i++) {
4493     nxc[i]= xs2x + (-0.090+nxc1[i])*var.sfx;
4494     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
4495     };
4496     ftof31x[j] = new TPolyLine(5,nxc,nyc);
4497     ftof31x[j]->SetLineColor(1);
4498     if ( var.bw ){
4499     colo = -1;
4500     } else {
4501     colo = 1;
4502     };
4503     ColorTOFMIP(ms31a[j]+ms31b[j],colo);
4504     //
4505     if ( colo != 10 ) ocolo = colo;
4506     //
4507     ftof31x[j]->SetFillColor(colo);
4508     ftof31x[j]->SetLineWidth(1);
4509     ftof31x[j]->Draw("f");
4510     ftof31x[j]->Draw();
4511     };
4512     //
4513     // S31 Y-view
4514     //
4515     if ( true ){
4516     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
4517     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
4518     Float_t nxc[5];
4519     Float_t nyc[5];
4520     for (Int_t i = 0; i<5 ; i++) {
4521     nxc[i]= xs2y + nxc1[i]*var.sfx;
4522     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
4523     };
4524     TPolyLine *ftof31y = new TPolyLine(5,nxc,nyc);
4525     ftof31y->SetLineColor(1);
4526     ftof31y->SetFillStyle(4000);
4527     ftof31y->SetFillColor(0);
4528     ftof31y->SetLineWidth(1);
4529     ftof31y->Draw("f");
4530     ftof31y->Draw();
4531     TPolyLine *sftof31;
4532     if ( !var.nosig ){
4533     if ( ocolo == 10 ) ocolo = noadc;
4534     Float_t lowp = (xp31-E31)/100.;
4535     Float_t higp = (xp31+E31)/100.;
4536     if ( lowp < -0.074 ) lowp = -0.074;
4537     if ( higp > 0.074 ) higp = 0.074;
4538     if ( lowp < higp ){
4539     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
4540     Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015};
4541     Float_t nxc[5];
4542     Float_t nyc[5];
4543     for (Int_t i = 0; i<5 ; i++) {
4544     nxc[i]= xs2y + nxc1[i]*var.sfx;
4545     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
4546     };
4547     sftof31 = new TPolyLine(5,nxc,nyc);
4548     sftof31->SetLineColor(ocolo);
4549     sftof31->SetFillColor(ocolo);
4550     sftof31->SetLineWidth(1);
4551     sftof31->Draw("f");
4552     sftof31->Draw();
4553     };
4554     };
4555     };
4556     //
4557    
4558     //
4559     // S32 Y-view
4560     //
4561     Float_t s32p = 0.050;
4562     ocolo = 10;
4563     TPolyLine *ftof32y[3];
4564     for ( Int_t j=0; j<3; j++){
4565     Float_t nxc1[5]={ (s32p*j), (s32p*j), s32p*(j+1),s32p*(j+1), (s32p*j)};
4566     Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13};
4567     Float_t nxc[5];
4568     Float_t nyc[5];
4569     for (Int_t i = 0; i<5 ; i++) {
4570     nxc[i]= xs2y + (-0.075+nxc1[i])*var.sfx;
4571     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
4572     };
4573     ftof32y[j] = new TPolyLine(5,nxc,nyc);
4574     ftof32y[j]->SetLineColor(1);
4575     if ( var.bw ){
4576     colo = -1;
4577     } else {
4578     colo = 1;
4579     };
4580     ColorTOFMIP(ms32a[j]+ms32b[j],colo);
4581     //
4582     if ( colo != 10 ) ocolo = colo;
4583     //
4584     ftof32y[j]->SetFillColor(colo);
4585     ftof32y[j]->SetLineWidth(1);
4586     ftof32y[j]->Draw("f");
4587     ftof32y[j]->Draw();
4588     };
4589     //
4590     // S32 X-view
4591     //
4592     if ( true ){
4593     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
4594     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
4595     Float_t nxc[5];
4596     Float_t nyc[5];
4597     for (Int_t i = 0; i<5 ; i++) {
4598     nxc[i]= xs2x + nxc1[i]*var.sfx;
4599     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
4600     };
4601     TPolyLine *ftof32x = new TPolyLine(5,nxc,nyc);
4602     ftof32x->SetLineColor(1);
4603     ftof32x->SetLineWidth(1);
4604     ftof32x->SetFillStyle(4000);
4605     ftof32x->SetFillColor(0);
4606     ftof32x->Draw("f");
4607     ftof32x->Draw();
4608     TPolyLine *sftof32;
4609     if ( !var.nosig ){
4610     if ( ocolo == 10 ) ocolo = noadc;
4611     Float_t lowp = (xp32-E32)/100.;
4612     Float_t higp = (xp32+E32)/100.;
4613     if ( lowp < -0.089 ) lowp = -0.089;
4614     if ( higp > 0.089 ) higp = 0.089;
4615     if ( lowp < higp ){
4616     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
4617     Float_t nyc1[5]={ -0.0015, -0.0015, -ws13+0.0015, -ws13+0.0015, -0.0015};
4618     Float_t nxc[5];
4619     Float_t nyc[5];
4620     for (Int_t i = 0; i<5 ; i++) {
4621     nxc[i]= xs2x + nxc1[i]*var.sfx;
4622     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
4623     };
4624     sftof32 = new TPolyLine(5,nxc,nyc);
4625     sftof32->SetLineColor(ocolo);
4626     sftof32->SetFillColor(ocolo);
4627     sftof32->SetLineWidth(1);
4628     sftof32->Draw("f");
4629     sftof32->Draw();
4630     };
4631     };
4632     };
4633     //
4634     }
4635    
4636     //**********************************************************************************
4637     // LEVEL2 SUBROUTINES //
4638     //**********************************************************************************
4639    
4640     void ShowTRACK(Int_t evno, TTree *ttr, Variables & var){
4641     //
4642     var.rig = 0.;
4643     var.chi2 = 0.;
4644     struct Tracklev2 trk;
4645     settrklev2(ttr,trk);
4646     //
4647     Int_t trcol = 10;
4648     Int_t syncro = 1;
4649     Int_t itr = evno;
4650     Int_t trnevents = ttr->GetEntries();
4651     Int_t pktnum = 0;
4652     Int_t obt = 0;
4653     trkcalosync: if ( itr >= trnevents ){
4654     printf(" WARNING: no more tracker level2 data.\n");
4655     return;
4656     };
4657     if ( !var.nosig ) ttr->GetEntry(itr);
4658     pktnum = var.headc;
4659     obt = var.etime;
4660     if ( pktnum != trk.pkt_num || obt != trk.obt ){
4661     if ( pktnum > trk.pkt_num || obt > trk.obt ){
4662     itr++;
4663     if ( syncro ) printf(" WARNING: lost sync! try to recover... \n");
4664     syncro = 0;
4665     goto trkcalosync;
4666     };
4667     if ( pktnum < trk.pkt_num || obt < trk.obt ){
4668     printf(" WARNING: no tracker level2 data. \n");
4669     return;
4670     };
4671     };
4672     //
4673     if ( !syncro ) printf(" ...synchronization recovered! \n");
4674     //
4675     if ( trk.ntrk > 0 ){
4676     Int_t l = 0;
4677     Int_t tobeinc = 0;
4678     while ( l<trk.ntrk ) {
4679     //
4680     Int_t npoint = 100;
4681     Double_t zin[100];
4682     Double_t xout[100];
4683     Double_t yout[100];
4684     Double_t al_p[5];
4685     Int_t ifail = 0;
4686     //
4687     Float_t tx[100];
4688     Float_t ty[100];
4689     Float_t ptx1[50];
4690     Float_t pty1[50];
4691     Float_t ptx2[50];
4692     Float_t pty2[50];
4693     Float_t tx1[15];
4694     Float_t ty1[15];
4695     Float_t tzx[100];
4696     Float_t tzy[100];
4697     Float_t tzx1[15];
4698     Float_t tzy1[15];
4699     //
4700     // if there is track ambiguity in y choose the track with the smaller chi2
4701     //
4702     if ( trk.image[l] != 0 ){
4703     Float_t chiA = trk.chi2[l];
4704     Float_t chiB = trk.chi2[trk.image[l]-1];
4705     if ( chiA > chiB ) {
4706     l = trk.image[l]-1;
4707     tobeinc = 2;
4708     };
4709     tobeinc = 1;
4710     };
4711     for ( Int_t e = 0; e < 100 ; e++) {
4712     xout[e] = 0.;
4713     yout[e] = 0.;
4714     //
4715     tx[e] = 0.;
4716     ty[e] = 0.;
4717     tzx[e] = 0.;
4718     tzy[e] = 0.;
4719     if ( e < 50 ){
4720     ptx1[e] = 0.;
4721     pty1[e] = 0.;
4722     ptx2[e] = 0.;
4723     pty2[e] = 0.;
4724     if ( e < 15 ){
4725     tx1[e] = 0.;
4726     ty1[e] = 0.;
4727     tzx1[e] = 0.;
4728     tzy1[e] = 0.;
4729     };
4730     };
4731     //
4732     if ( e < 5 ) {
4733     al_p[e] = (Double_t)trk.al[l][e];
4734     };
4735     zin[e] = 60. - (124./99.)*(float)e;
4736     };
4737     //
4738     zin[85] = -45.5;
4739     //
4740     ctrack(npoint,zin,xout,yout,al_p,ifail);
4741     //
4742     //
4743     if ( !ifail ){
4744     if ( l == 0 || ( l == 1 && tobeinc ==2 ) ){
4745     if ( trk.al[l][4] != 0. ) {
4746     var.rig = 1./trk.al[l][4];
4747     var.chi2 = trk.chi2[l];
4748     } else {
4749     var.rig = 0.;
4750     var.chi2 = 0.;
4751     };
4752     };
4753     //
4754     for ( Int_t e = 0; e < npoint ; e++) {
4755     tx[e] = ((float)xout[e]/100.)*var.sfx + var.xxvc;
4756     ty[e] = ((float)yout[e]/100.)*var.sfx + var.xyvc;
4757     // printf("tx %i %f \n",e,tx[e]);
4758     //printf("xout %i %f \n",e,xout[e]);
4759     if ( e < 50 ) {
4760     ptx1[e] = ((float)yout[e]/100.)*var.sfx + var.xcat;
4761     pty1[e] = ((float)xout[e]/100.)*var.sfy + var.ycat;
4762     } else {
4763     ptx2[e-50] = ((float)yout[e]/100.)*var.sfx + var.xcat;
4764     pty2[e-50] = ((float)xout[e]/100.)*var.sfy + var.ycat;
4765     };
4766     if ( e > 84 ) {
4767     tx1[e-85] = ((float)xout[e]/100.)*var.nds4 + var.xxvc;
4768     ty1[e-85] = ((float)yout[e]/100.)*var.nds4 + var.xyvc;
4769     tzx1[e-85] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yxvc;
4770     tzy1[e-85] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yyvc;
4771     };
4772     tzx[e] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yxvc;
4773     tzy[e] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yyvc;
4774     };
4775     //
4776     // From S1 to CALO
4777     //
4778     if ( var.bw ){
4779     trcol = 17-l;
4780     } else {
4781     trcol = 50-l;
4782     };
4783     TPolyLine *trackx = new TPolyLine(86,tx,tzx);
4784     trackx->SetLineColor(trcol);
4785     trackx->SetLineWidth(1);
4786     trackx->Draw();
4787     TPolyLine *tracky = new TPolyLine(86,ty,tzy);
4788     tracky->SetLineColor(trcol);
4789     tracky->SetLineWidth(1);
4790     tracky->Draw();
4791     //
4792     // ND and S4
4793     //
4794     if ( var.tracknds4 ){
4795     TPolyLine *trackx1 = new TPolyLine(15,tx1,tzx1);
4796     trackx1->SetLineColor(trcol);
4797     trackx1->SetLineWidth(1);
4798     trackx1->Draw();
4799     TPolyLine *tracky1 = new TPolyLine(15,ty1,tzy1);
4800     tracky1->SetLineColor(trcol);
4801     tracky1->SetLineWidth(1);
4802     tracky1->Draw();
4803     };
4804     //
4805     // Plane View
4806     //
4807     TPolyLine *trackp1 = new TPolyLine(50,ptx1,pty1);
4808     trackp1->SetLineColor(trcol);
4809     trackp1->SetLineWidth(1);
4810     trackp1->Draw();
4811     TPolyLine *trackp2 = new TPolyLine(50,ptx2,pty2);
4812     trackp2->SetLineColor(trcol);
4813     trackp2->SetLineWidth(1);
4814     trackp2->SetLineStyle(3);
4815     trackp2->Draw();
4816 mocchiut 1.2 //
4817     // Dots on measured points
4818     //
4819     TEllipse *elli;
4820     Float_t x;
4821     Float_t y;
4822     Float_t z1;
4823     Float_t z2;
4824     for (Int_t g = 0; g<6; g++){
4825     x = trk.xm[l][g]*var.sfx/100. + var.xxvc;
4826     y = trk.ym[l][g]*var.sfx/100. + var.xyvc;
4827     z1 = (trk.zm[l][g]+11.2)*var.sfy/100. + var.yxvc;
4828     z2 = (trk.zm[l][g]+11.2)*var.sfy/100. + var.yyvc;
4829     elli = new TEllipse(x,z1,0.004,0.004,0.,-180.);
4830     elli->SetFillStyle(1001);
4831     elli->SetFillColor(2);
4832     elli->Draw();
4833     elli = new TEllipse(y,z2,0.004,0.004,0.,-180.);
4834     elli->SetFillStyle(1001);
4835     elli->SetFillColor(2);
4836     elli->Draw();
4837     };
4838     //
4839     //
4840 mocchiut 1.1 } else {
4841     printf(" WARNING: failed in determining the track! \n");
4842     };
4843     l++;
4844     if ( tobeinc ) {
4845     l++;
4846     tobeinc = 0;
4847     };
4848     };
4849     };
4850     }
4851    
4852     //**********************************************************************************
4853     // OTHER SUBROUTINES **
4854     //**********************************************************************************
4855    
4856     void ShowCaloL0(TString filename, Int_t i, Calib & calib, Int_t b[4], Float_t mip[2][22][96], TTree *otr, Variables & var){
4857     struct Evento evento;
4858     Int_t tot0 = 0;
4859     Int_t tot1 = 0;
4860     Int_t tot2 = 0;
4861     Int_t nstrip = 0;
4862     Float_t qtot = 0.;
4863     pamela::calorimeter::CalorimeterEvent *de = 0;
4864     otr->SetBranchAddress("Calorimeter.Event", &de);
4865     if ( !var.nosig ) otr->GetEntry(i);
4866     //
4867     // Define variables
4868     //
4869     Int_t etime = var.etime;
4870     Float_t estrip[2][22][96], ener, basel,sdexy[2][22][96],sdexyc[2][22][96];
4871     Int_t badstrip = 0;
4872     qtot = 0.;
4873     nstrip = 0;
4874     //
4875     // Book the histograms:
4876     //
4877     //
4878     stringstream xvev;
4879     stringstream yvev;
4880     xvev.str("");
4881     yvev.str("");
4882     xvev << "x-view event " << (i+1);
4883     yvev << "y-view event " << (i+1);
4884     gDirectory->Delete(xvev.str().c_str());
4885     gDirectory->Delete(yvev.str().c_str());
4886     TH2F *Xview = new TH2F(xvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
4887     TH2F *Yview = new TH2F(yvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
4888     Xview->GetYaxis()->SetLabelColor(10);
4889     Yview->GetYaxis()->SetLabelColor(10);
4890     //
4891     // figures:
4892     //
4893     Int_t bgcolor = 10;
4894     TPad *pd1 = new TPad("calox","This is pad1",var.xxvc-0.154*var.sfx,var.yxvc-0.3645*var.sfy,var.xxvc+0.154*var.sfx,var.yxvc-0.1200*var.sfy,bgcolor);
4895     TPad *pd2 = new TPad("caloy","This is pad2",var.xyvc-0.154*var.sfx,var.yyvc-0.3645*var.sfy,var.xyvc+0.154*var.sfx,var.yyvc-0.1200*var.sfy,bgcolor);
4896    
4897     pd1->SetFillStyle(4000);
4898     pd1->SetFillColor(0);
4899     pd1->SetFrameFillStyle(4000);
4900     pd2->SetFillStyle(4000);
4901     pd2->SetFillColor(0);
4902     pd2->SetFrameFillStyle(4000);
4903    
4904     TLatex *t=new TLatex();
4905     t->SetTextFont(32);
4906     t->SetTextColor(1);
4907     t->SetTextSize(0.03);
4908     t->SetTextAlign(12);
4909     pd1->Range(0.,0.,1.,1.);
4910     pd2->Range(0.,0.,1.,1.);
4911     pd1->SetTicks();
4912     pd2->SetTicks();
4913     pd1->Draw();
4914     pd2->Draw();
4915    
4916     pd1->cd();
4917     gStyle->SetOptStat(0);
4918     Xview->GetYaxis()->SetTitleOffset(0.5);
4919     Xview->SetFillColor(bgcolor);
4920     Xview->Fill(1.,1.,1.);
4921     Xview->Draw("box");
4922     pd1->Update();
4923     pd2->cd();
4924     gStyle->SetOptStat(0);
4925     Yview->GetYaxis()->SetTitleOffset(0.5);
4926     Yview->SetFillColor(bgcolor);
4927     Yview->Fill(1.,1.,1.);
4928     Yview->Draw("box");
4929     pd2->Update();
4930     //
4931     // for each event check that the calibration we are using are still within calibration limits, if not call the next calibration
4932     //
4933     for (Int_t s = 0; s < 4; s++){
4934     if ( calib.ttime[s][b[s]+1] && calib.time[s][b[s]] ){
4935     while ( etime > calib.time[s][b[s]] && calib.time[s][b[s]] != 0 ){
4936     printf(" CALORIMETER: \n" );
4937     printf(" - Section %i, event at time %i while old calibration time limit at %i. Use new calibration at time %i -\n",s,etime,calib.time[s][b[s]],calib.ttime[s][b[s]+1]);
4938     printf(" END CALORIMETER. \n\n" );
4939     b[s]++;
4940     CaloPede(filename,s,calib.ttime[s][b[s]],calib);
4941     };
4942     };
4943     };
4944     //
4945     // do whatever you want with data
4946     //
4947     evento.iev = de->iev;
4948     //
4949     // run over views and planes
4950     //
4951     stringstream xve;
4952     stringstream yve;
4953     for (Int_t l = 0; l < 2; l++){
4954     for (Int_t m = 0; m < 22; m++){
4955     //
4956     // determine the section number
4957     //
4958     Int_t se = 5;
4959     if (l == 0 && m%2 == 0) se = 3;
4960     if (l == 0 && m%2 != 0) se = 2;
4961     if (l == 1 && m%2 == 0) se = 1;
4962     if (l == 1 && m%2 != 0) se = 0;
4963     //
4964     // determine what kind of event we are going to analyze
4965     //
4966     bool isCOMP = 0;
4967     bool isFULL = 0;
4968     bool isRAW = 0;
4969     if ( de->stwerr[se] & (1 << 16) ) isCOMP = 1;
4970     if ( de->stwerr[se] & (1 << 17) ) isFULL = 1;
4971     if ( de->stwerr[se] & (1 << 3) ) isRAW = 1;
4972     //
4973     // save the prevoius energy deposit and calibration in sbase, sdexy, sdexyc
4974     //
4975     Int_t pre = -1;
4976     if ( isRAW ){
4977     for (Int_t nn = 0; nn < 96; nn++){
4978     if ( nn%16 == 0 ) pre++;
4979     evento.base[l][m][pre] = calib.calbase[l][m][pre];
4980     sdexy[l][m][nn] = evento.dexy[l][m][nn];
4981     evento.dexy[l][m][nn] = de->dexy[l][m][nn] ;
4982     sdexyc[l][m][nn] = evento.dexyc[l][m][nn];
4983     evento.dexyc[l][m][nn] = de->dexyc[l][m][nn] ;
4984     };
4985     };
4986     //
4987     // run over strips
4988     //
4989     Int_t done = 0;
4990     Int_t rdone = 0;
4991     Int_t fdone = 0;
4992     pre = -1;
4993     for (Int_t n =0 ; n < 96; n++){
4994     if ( n%16 == 0 ) {
4995     pre++;
4996     done = 0;
4997     rdone = 0;
4998     fdone = 0;
4999     };
5000     //
5001     // baseline check and calculation
5002     //
5003     if ( !isRAW ) {
5004     //
5005     // if it isn't raw and we haven't checked yet, check that the baseline is fine, if not calculate it with a relaxed algorithm.
5006     //
5007     if ( !done ){
5008     evento.base[l][m][pre] = de->base[l][m][pre] ;
5009     evento.dexyc[l][m][n] = de->dexyc[l][m][n] ;
5010     };
5011     } else {
5012     //
5013     // if it is a raw event and we haven't checked yet, calculate the baseline. Then check that the baseline is fine,
5014     // if not calculate it with relaxed algorithm.
5015     //
5016     if ( !rdone ){
5017     CaloFindBaseRaw(calib,evento,l,m,pre);
5018     tot1++;
5019     rdone = 1;
5020     };
5021     };
5022     //
5023     // no suitable new baseline, use old ones
5024     //
5025     if ( !done && (evento.base[l][m][pre] == 31000. || evento.base[l][m][pre] == 0.) ){
5026     tot0++;
5027     evento.base[l][m][pre] = calib.sbase[l][m][pre];
5028     Int_t upnn = n+16;
5029     if ( upnn > 96 ) upnn = 96;
5030     for ( Int_t nn = n; nn<upnn; nn++ ){
5031     evento.dexyc[l][m][nn] = de->dexyc[l][m][nn] ;
5032     };
5033     CaloCompressData(calib,evento,l,m,pre);
5034     done = 1;
5035     };
5036     //
5037     // if here we don't have a valid baseline we will skip the event.
5038     //
5039     if ( evento.base[l][m][pre] == 31000. ) tot2++;
5040     //
5041     // CALIBRATION ALGORITHM
5042     //
5043     basel = evento.base[l][m][pre];
5044     ener = evento.dexyc[l][m][n];
5045     estrip[l][m][n] = 0.;
5046     if ( basel>0 && basel < 30000. && ener > 0. ){
5047     estrip[l][m][n] = (ener - calib.calped[l][m][n] - basel)/mip[l][m][n] ;
5048     //
5049     // OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course)
5050     //
5051     xve.str("");
5052     yve.str("");
5053     xve << "x-view event " << n;
5054     xve << " " << m;
5055     xve << " " << l;
5056     yve << "y-view event " << n;
5057     yve << " " << m;
5058     yve << " " << l;
5059     gDirectory->Delete(xve.str().c_str());
5060     gDirectory->Delete(yve.str().c_str());
5061     TH2F *Xview = new TH2F(xve.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
5062     TH2F *Yview = new TH2F(yve.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
5063     if ( estrip[l][m][n] > 0.7 && !var.nosig ){
5064     Int_t colo;
5065     if ( var.bw ){
5066     colo = -1;
5067     } else {
5068     colo = 1;
5069     };
5070     ColorMIP(estrip[l][m][n],colo);
5071     Xview->SetFillColor(colo);
5072     Yview->SetFillColor(colo);
5073     if ( l == 0 ) {
5074     Xview->Fill(n,21-m,1.);
5075     pd1->cd();
5076     Xview->Draw("box same");
5077     };
5078     if ( l == 1 ) {
5079     Yview->Fill(95-n,21-m,1.);
5080     pd2->cd();
5081     Yview->Draw("box same");
5082     };
5083     };
5084     if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] != 0 ) badstrip++;
5085     if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] == 0 ) {
5086     qtot += estrip[l][m][n];
5087     nstrip++;
5088     };
5089     };
5090     calib.sbase[l][m][pre] = evento.base[l][m][pre];
5091     };
5092     };
5093     };
5094     pd1->Update();
5095     pd2->Update();
5096     var.qtot=(int)qtot;
5097     var.nstrip=nstrip;
5098     }
5099    
5100    
5101     void ShowPalette(Int_t bw){
5102     Float_t xp = 0.33;
5103     Float_t yp = 0.02;
5104     Float_t xw = 0.35;
5105     Float_t yh = 0.19;
5106     Double_t xx[5] = {xp, xp+xw, xp+xw, xp, xp};
5107     Double_t yy[5] = {yp, yp, yp+yh, yp+yh, yp};
5108     TPolyLine *fpale = new TPolyLine(5,xx,yy);
5109     fpale->SetLineColor(1);
5110     fpale->SetLineWidth(1);
5111     fpale->Draw();
5112     TLatex *txt=new TLatex();
5113     txt->SetTextSize(0.01);
5114     txt->DrawLatex(xp+0.005,yp+yh-0.015,"PALETTE");
5115     txt->DrawLatex(xp+0.005,yp+yh-0.04,"TOF, CALO, S4 [MIP]:");
5116     Float_t xwc = (xp+0.01)/6.;
5117     Float_t yhc = 0.03;
5118     Int_t colo = 0;
5119     Float_t yc = 0.135;
5120     TPolyLine *fc1[6];
5121     if ( bw ){
5122     for ( Int_t j=0; j<6; j++){
5123     Float_t xc = 0.335+(j*xwc);
5124     Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc};
5125     Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc};
5126     fc1[j] = new TPolyLine(5,xx,yy);
5127     fc1[j]->SetLineColor(1);
5128     if ( j == 0 ) {
5129     colo = 10;
5130     };
5131     if ( j == 1 ) {
5132     colo = 17;
5133     };
5134     if ( j == 2 ) {
5135     colo = 15;
5136     };
5137     if ( j == 3 ) {
5138     colo = 14;
5139     };
5140     if ( j == 4 ) {
5141     colo = 13;
5142     };
5143     if ( j == 5 ) {
5144     colo = 12;
5145     };
5146     fc1[j]->SetFillColor(colo);
5147     fc1[j]->SetLineWidth(1);
5148     fc1[j]->Draw("f");
5149     fc1[j]->Draw();
5150     if ( j == 0 ) {
5151     txt->DrawLatex(xc+0.005,yc+0.01,"0");
5152     };
5153     if ( j == 1 ) {
5154     txt->DrawLatex(xc+0.005,yc+0.01,"0 - 2");
5155     };
5156     if ( j == 2 ) {
5157     txt->DrawLatex(xc+0.005,yc+0.01,"2 - 10");
5158     };
5159     if ( j == 3 ) {
5160     txt->DrawLatex(xc+0.005,yc+0.01,"10 - 100");
5161     };
5162     if ( j == 4 ) {
5163     txt->DrawLatex(xc+0.005,yc+0.01,"100 - 500");
5164     };
5165     if ( j == 5 ) {
5166     txt->DrawLatex(xc+0.005,yc+0.01,"> 500");
5167     };
5168     };
5169    
5170     txt->DrawLatex(xp+0.005,yp+yh-0.095,"ND [neutrons]:");
5171     Float_t yc = 0.08;
5172     TPolyLine *fc2[6];
5173     for ( Int_t j=0; j<6; j++){
5174     Float_t xc = 0.335+(j*xwc);
5175     Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc};
5176     Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc};
5177     fc2[j] = new TPolyLine(5,xx,yy);
5178     fc2[j]->SetLineColor(1);
5179     if ( j == 0 ) {
5180     colo = 10;
5181     };
5182     if ( j == 1 ) {
5183     colo = 17;
5184     };
5185     if ( j == 2 ) {
5186     colo = 15;
5187     };
5188     if ( j == 3 ) {
5189     colo = 14;
5190     };
5191     if ( j == 4 ) {
5192     colo = 13;
5193     };
5194     if ( j == 5 ) {
5195     colo = 12;
5196     };
5197     fc2[j]->SetFillColor(colo);
5198     fc2[j]->SetLineWidth(1);
5199     fc2[j]->Draw("f");
5200     fc2[j]->Draw();
5201     if ( j == 0 ) {
5202     txt->DrawLatex(xc+0.005,yc+0.01,"0");
5203     };
5204     if ( j == 1 ) {
5205     txt->DrawLatex(xc+0.005,yc+0.01," 1 ");
5206     };
5207     if ( j == 2 ) {
5208     txt->DrawLatex(xc+0.005,yc+0.01," 2 ");
5209     };
5210     if ( j == 3 ) {
5211     txt->DrawLatex(xc+0.005,yc+0.01," 3 - 6 ");
5212     };
5213     if ( j == 4 ) {
5214     txt->DrawLatex(xc+0.005,yc+0.01," 7 - 14 ");
5215     };
5216     if ( j == 5 ) {
5217     txt->DrawLatex(xc+0.005,yc+0.01,"> 14");
5218     };
5219     };
5220     //
5221     txt->DrawLatex(xp+0.005,yp+yh-0.15,"AC:");
5222     yc = 0.025;
5223     TPolyLine *fc3[3];
5224     for ( Int_t j=0; j<3; j++){
5225     Float_t xc = 0.335+(j*xwc);
5226     Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc};
5227     Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc};
5228     fc3[j] = new TPolyLine(5,xx,yy);
5229     fc3[j]->SetLineColor(1);
5230     if ( j == 0 ) {
5231     colo = 10;
5232     };
5233     if ( j == 1 ) {
5234     colo = 13;
5235     };
5236     if ( j == 2 ) {
5237     colo = 12;
5238     };
5239     fc3[j]->SetFillColor(colo);
5240     fc3[j]->SetLineWidth(1);
5241     fc3[j]->Draw("f");
5242     fc3[j]->Draw();
5243     if ( j == 0 ) {
5244     txt->DrawLatex(xc+0.005,yc+0.01," NOT HIT ");
5245     };
5246     if ( j == 1 ) {
5247     txt->DrawLatex(xc+0.005,yc+0.01," HIT trigger");
5248     };
5249     if ( j == 2 ) {
5250     txt->SetTextSize(0.0095);
5251     txt->DrawLatex(xc+0.001,yc+0.011," HIT background");
5252     txt->SetTextSize(0.01);
5253     };
5254     };
5255     } else {
5256     for ( Int_t j=0; j<6; j++){
5257     Float_t xc = 0.335+(j*xwc);
5258     Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc};
5259     Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc};
5260     fc1[j] = new TPolyLine(5,xx,yy);
5261     fc1[j]->SetLineColor(1);
5262     if ( j == 0 ) {
5263     colo = 10;
5264     };
5265     if ( j == 1 ) {
5266     colo = 38;
5267     };
5268     if ( j == 2 ) {
5269     colo = 4;
5270     };
5271     if ( j == 3 ) {
5272     colo = 3;
5273     };
5274     if ( j == 4 ) {
5275     colo = 2;
5276     };
5277     if ( j == 5 ) {
5278     colo = 6;
5279     };
5280     fc1[j]->SetFillColor(colo);
5281     fc1[j]->SetLineWidth(1);
5282     fc1[j]->Draw("f");
5283     fc1[j]->Draw();
5284     if ( j == 0 ) {
5285     txt->DrawLatex(xc+0.005,yc+0.01,"0");
5286     };
5287     if ( j == 1 ) {
5288     txt->DrawLatex(xc+0.005,yc+0.01,"0 - 2");
5289     };
5290     if ( j == 2 ) {
5291     txt->DrawLatex(xc+0.005,yc+0.01,"2 - 10");
5292     };
5293     if ( j == 3 ) {
5294     txt->DrawLatex(xc+0.005,yc+0.01,"10 - 100");
5295     };
5296     if ( j == 4 ) {
5297     txt->DrawLatex(xc+0.005,yc+0.01,"100 - 500");
5298     };
5299     if ( j == 5 ) {
5300     txt->DrawLatex(xc+0.005,yc+0.01,"> 500");
5301     };
5302     };
5303    
5304     txt->DrawLatex(xp+0.005,yp+yh-0.095,"ND [neutrons]:");
5305     Float_t yc = 0.08;
5306     TPolyLine *fc2[6];
5307     for ( Int_t j=0; j<6; j++){
5308     Float_t xc = 0.335+(j*xwc);
5309     Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc};
5310     Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc};
5311     fc2[j] = new TPolyLine(5,xx,yy);
5312     fc2[j]->SetLineColor(1);
5313     if ( j == 0 ) {
5314     colo = 10;
5315     };
5316     if ( j == 1 ) {
5317     colo = 38;
5318     };
5319     if ( j == 2 ) {
5320     colo = 4;
5321     };
5322     if ( j == 3 ) {
5323     colo = 3;
5324     };
5325     if ( j == 4 ) {
5326     colo = 2;
5327     };
5328     if ( j == 5 ) {
5329     colo = 6;
5330     };
5331     fc2[j]->SetFillColor(colo);
5332     fc2[j]->SetLineWidth(1);
5333     fc2[j]->Draw("f");
5334     fc2[j]->Draw();
5335     if ( j == 0 ) {
5336     txt->DrawLatex(xc+0.005,yc+0.01,"0");
5337     };
5338     if ( j == 1 ) {
5339     txt->DrawLatex(xc+0.005,yc+0.01," 1 ");
5340     };
5341     if ( j == 2 ) {
5342     txt->DrawLatex(xc+0.005,yc+0.01," 2 ");
5343     };
5344     if ( j == 3 ) {
5345     txt->DrawLatex(xc+0.005,yc+0.01," 3 - 6 ");
5346     };
5347     if ( j == 4 ) {
5348     txt->DrawLatex(xc+0.005,yc+0.01," 7 - 14 ");
5349     };
5350     if ( j == 5 ) {
5351     txt->DrawLatex(xc+0.005,yc+0.01,"> 14");
5352     };
5353     };
5354     //
5355     txt->DrawLatex(xp+0.005,yp+yh-0.15,"AC:");
5356     yc = 0.025;
5357     TPolyLine *fc3[3];
5358     for ( Int_t j=0; j<3; j++){
5359     Float_t xc = 0.335+(j*xwc);
5360     Double_t xx[5] = {xc, xc+xwc, xc+xwc, xc, xc};
5361     Double_t yy[5] = {yc, yc, yc+yhc, yc+yhc, yc};
5362     fc3[j] = new TPolyLine(5,xx,yy);
5363     fc3[j]->SetLineColor(1);
5364     if ( j == 0 ) {
5365     colo = 10;
5366     };
5367     if ( j == 1 ) {
5368     colo = 2;
5369     };
5370     if ( j == 2 ) {
5371     colo = 42;
5372     };
5373     fc3[j]->SetFillColor(colo);
5374     fc3[j]->SetLineWidth(1);
5375     fc3[j]->Draw("f");
5376     fc3[j]->Draw();
5377     if ( j == 0 ) {
5378     txt->DrawLatex(xc+0.005,yc+0.01," NOT HIT ");
5379     };
5380     if ( j == 1 ) {
5381     txt->DrawLatex(xc+0.005,yc+0.01," HIT trigger");
5382     };
5383     if ( j == 2 ) {
5384     txt->SetTextSize(0.0095);
5385     txt->DrawLatex(xc+0.001,yc+0.011," HIT background");
5386     txt->SetTextSize(0.01);
5387     };
5388     };
5389     };
5390     }
5391    
5392     void DrawX(Float_t cx, Float_t cy, Float_t si, Variables & var){
5393     if ( true ){
5394     Float_t x[2] = {-si*var.sfx,si*var.sfx};
5395     Float_t y[2] = {-si*var.sfy,si*var.sfy};
5396     Float_t xb[2];
5397     Float_t yb[2];
5398     for (Int_t i = 0; i<2 ; i++){
5399     xb[i] = x[i]+cx;
5400     yb[i] = y[i]+cy;
5401     };
5402     TLine *x2 = new TLine(xb[0],yb[0],xb[1],yb[1]);
5403     x2->SetLineColor(1);
5404     x2->SetLineWidth(1);
5405     x2->Draw();
5406     };
5407     if ( true ){
5408     Float_t x[2] = {-si*var.sfx,si*var.sfx};
5409     Float_t y[2] = {si*var.sfy,-si*var.sfy};
5410     Float_t xa[2];
5411     Float_t ya[2];
5412     for (Int_t i = 0; i<2 ; i++){
5413     xa[i] = x[i]+cx;
5414     ya[i] = y[i]+cy;
5415     };
5416     TLine *x1 = new TLine(xa[0],ya[0],xa[1],ya[1]);
5417     x1->SetLineColor(1);
5418     x1->SetLineWidth(1);
5419     x1->Draw();
5420     };
5421     }
5422     //
5423     //
5424     //
5425     void ShowHelp(){
5426     char input[256];
5427     printf("\n USE:\n\n The only input needed is the path to the directory (\"filename\") created by YODA\n for the data file you want to analyze.\n Standard use:\n root[0] .L ShowEvent.c\n root[1] ShowEvent(\"/home/dati/filesFromYoda/DW_050112_00600/\");\n \n\n\n\n\n\n");
5428     printf("Press <enter> to continue\n");
5429     cin.getline(input,256);
5430     printf(" FEATURES:\n\n ShowEvent(TString filename, Int_t fromevent = 0, Int_t toevent = 0,\n TString selfile = \"\", Int_t FORCELEVEL = -1,\n Int_t ctrlword = 509, Int_t BW=0, TString outDir = \"\",\n TString calcalibfile = \"\")\n Input variables\n * fromevent = the first event to be shown (0 means \"show all\")\n");
5431     printf(" * toevent = the last event to be shown (NB: if fromevent differs from zero\n and toevent is equal zero only one event will be shown,\n number \"fromevent\")\n\n\n\n");
5432     printf("Press <enter> to continue\n");
5433     cin.getline(input,256);
5434     printf(" * ctrword is an integer which can be used as a mask to customize the figure:\n ctrword bit: 10 9 8 7 6 5 4 3 2 1 \n detector : special TOF AC TRK CALO S4 ND infos names legenda\n Examples:\n ctrword = 509 = 0111111101 : all detectors+infos are printed(DEFAULT)\n ctrword = 511 = 0111111111 : show all\n ctrword = 505 = 0111111001 : don't print infos on figure\n ctrword = 507 = 0111111011 : show detector names+legenda (no infos)\n ctrword = 8 = 0000001000 : show only ND\n ctrword = 1019 = 1111111011 : show all but infos without signals\n\n");
5435     printf("Press <enter> to continue\n");
5436     cin.getline(input,256);
5437     printf("\n\n When the \"special\" bit is set NO SIGNAL will be shown in the detectors.\n It can be used to draw a draft of the PAMELA apparatus without any event.\n ");
5438     printf(" * selfile = selection file. Can be used to select events.\n Default is \"\" that is no selection applied.\n");
5439     printf(" * FORCELEVEL = to force a certain level visualization.\n For the moment only level0 can be forced.\n");
5440     printf(" * BW = 0 flag to display black and white figures.\n Default is 0, colours, set it to 1 to have BW visualization.\n");
5441     printf(" * outDir = directory where to place figures (if you want to print them).\n Default is \"filename\".\n\n");
5442     printf("Press <enter> to continue\n");
5443     cin.getline(input,256);
5444     printf(" * calcalibfile = the calorimeter needs a calibration to display events. If a\n calibration is not in the file you want to analylze put \n here the path to a directory created by YODA for a data \n file with calorimeter calibration. Default is \"filename\".\n");
5445     printf("\n\n For further informations read the README.ShowEvent file.\n");
5446     return;
5447     }
5448    
5449     //
5450     // MAIN ROUTINE
5451     //
5452     void ShowEvent(TString filename="help", TString selfile="", Int_t ctrlword = 509, Int_t FORCELEV = -1, Int_t fromevent = 0, Int_t toevent = 0, TString outDir = ""){
5453     gROOT->GetListOfCanvases()->Delete();
5454     gDirectory->GetList()->Delete();
5455     TString calcalibfile = "";
5456     TString startingdir = gSystem->WorkingDirectory();
5457     const char* startingdir2 = gSystem->WorkingDirectory();
5458     TString path;
5459     stringcopy(path,startingdir2);
5460     Int_t BW = 0;
5461     #if defined (__CINT__)
5462     emicheckLib();
5463     const char *pamlib=gSystem->Getenv("PAM_LIB");
5464     stringstream lolib;
5465     lolib.str("");
5466     lolib << pamlib << "/EVpathtoc_c.so";
5467     gSystem->Load(lolib.str().c_str());
5468     //
5469     if (!TClassTable::GetDict("CalorimeterLevel1")){
5470     const char *pamlib2 = gSystem->ExpandPathName("$PAM_LIB");
5471     stringstream liblo;
5472     liblo.str("");
5473     liblo << pamlib2 << "/caloclasses_h.so";
5474     gSystem->Load(liblo.str().c_str());
5475     }
5476     #endif
5477     #if !defined (__CINT__)
5478     TApplication app("app",0,0);
5479     #endif
5480     const char *pam_calib = pathtocalibration();
5481     stringstream calfile;
5482     calfile.str("");
5483     calfile << pam_calib << "/CaloADC2MIP.root";
5484     struct Levels level;
5485     //
5486     const char *name= filename;
5487     if ( filename == "" || !strcmp(name,"help") ){
5488     ShowHelp();
5489     return;
5490     };
5491     //
5492     //
5493     //
5494     if ( FORCELEV != -1 ) printf("\n WARNING: FORCING LEVEL%i DATA \n\n",FORCELEV);
5495     //
5496     // LOAD SELECTION FILE
5497     //
5498     Int_t selection = 0;
5499     if ( selfile == "" ){
5500     selection = 0;
5501     } else {
5502     #if !defined (__CINT__)
5503     //
5504     // if running the compiled program we must load header files for the selection macros!
5505     //
5506     gROOT->Reset();
5507     stringstream paminc;
5508     paminc.str("");
5509     const char *testinc = gSystem->Getenv("PAM_INC");
5510     if ( testinc == "" ){
5511     const char *pam_calib = pathtocalibration();
5512     paminc << pam_calib << "../include/";
5513     } else {
5514     paminc << testinc;
5515     };
5516     stringstream carica;
5517     carica.str("");
5518     carica << paminc.str().c_str() << "/eventviewer.h";
5519     gROOT->LoadMacro(carica.str().c_str());
5520     carica.str("");
5521     carica << paminc.str().c_str() << "/trklev1struct.h";
5522     gROOT->LoadMacro(carica.str().c_str());
5523     carica.str("");
5524     carica << paminc.str().c_str() << "/ctrkstruct.h";
5525     gROOT->LoadMacro(carica.str().c_str());
5526     carica.str("");
5527     carica << paminc.str().c_str() << "/ctrkinclude.h";
5528     gROOT->LoadMacro(carica.str().c_str());
5529     carica.str("");
5530     carica << paminc.str().c_str() << "/ctofstruct.h";
5531     gROOT->LoadMacro(carica.str().c_str());
5532     carica.str("");
5533     carica << paminc.str().c_str() << "/ctofinclude.h";
5534     gROOT->LoadMacro(carica.str().c_str());
5535     #endif
5536     //
5537     // load the selection macro
5538     //
5539     selection = gROOT->LoadMacro(selfile);
5540     if ( selection ){
5541     printf("\n\n ERROR! cannot read the selection file you give me as input! \n");
5542     selection = 0;
5543     printf("\n WARNING! no selection file loaded! \n\n");
5544     } else {
5545     printf("\n\n Selection file loaded \n\n The first event will be shown anyway. \n\n");
5546     selection = 1;
5547     };
5548     };
5549     //
5550     //
5551     // LOAD FILES
5552     //
5553     Int_t SHOWDEC = 0;
5554     Int_t TOF = 0;
5555     Int_t AC = 0;
5556     Int_t TRK = 0;
5557     Int_t CALO = 0;
5558     Int_t S4 = 0;
5559     Int_t ND = 0;
5560     Int_t INFOS = 0;
5561     Int_t VINFOS = 0;
5562     Int_t PALETTE = 0;
5563     //
5564     if ( ctrlword & (1<<0) ) {
5565     PALETTE = 1;
5566     printf("Show Palette\n");
5567     };
5568     if ( BW ) printf(" --> Black and White visualization! \n");
5569     if ( ctrlword & (1<<1) ) {
5570     VINFOS = 1;
5571     printf("Show Verbose Text Informations\n");
5572     };
5573     if ( ctrlword & (1<<2) ) {
5574     INFOS = 1;
5575     printf("Show Text Informations\n");
5576     };
5577     if ( ctrlword & (1<<3) ) {
5578     ND = 1;
5579     };
5580     if ( ctrlword & (1<<4) ) {
5581     S4 = 1;
5582     };
5583     if ( ctrlword & (1<<5) ) {
5584     CALO = 1;
5585     };
5586     if ( ctrlword & (1<<6) ) {
5587     TRK = 1;
5588     };
5589     if ( ctrlword & (1<<7) ) {
5590     AC = 1;
5591     };
5592     if ( ctrlword & (1<<8) ) {
5593     TOF = 1;
5594     };
5595     if ( ctrlword & (1<<9) ) {
5596     SHOWDEC = 1;
5597     fromevent = 1;
5598     toevent = 1;
5599     printf("\n ** WARNING! YOU HAVE CHOSEN TO SHOW ONLY DETECTORS AND NO SIGNALS! **\n\n");
5600     gSystem->Exec("sleep 5");
5601     };
5602     //
5603     TString fififile = getFilename(filename);
5604     const char *file = fififile;
5605     //
5606     Int_t trk1noev = 0;
5607     Int_t trk2noev = 0;
5608     Int_t tofnoev = 0;
5609     // open files
5610     TFile *headerFile = 0;
5611     TFile *triggerFile = 0;
5612     TFile *caloFile = 0;
5613     TFile *trackerFile = 0;
5614     TFile *trackerFile2 = 0;
5615     TFile *neutronFile = 0;
5616     TFile *acFile = 0;
5617     TFile *s4File = 0;
5618     TFile *tofFile = 0;
5619     TFile *tofFileL1 = 0;
5620     TTree *toftr = 0;
5621     //
5622     headerFile = emigetFile(filename, "Physics", "Header");
5623     if ( !headerFile ){
5624     printf("ERROR: no Header file, exiting...\n");
5625     return;
5626     };
5627     TTree *otr = (TTree*)headerFile->Get("Pscu");
5628     printf("Get the Header informations\n");
5629     //
5630     triggerFile = emigetFile(filename, "Trigger");
5631     if ( !triggerFile ){
5632     printf("ERROR: no Trigger file, exiting...\n");
5633     return;
5634     };
5635     otr->AddFriend("Trigger", triggerFile);
5636     printf("Get the Trigger informations\n");
5637     //
5638     TTree *ttr = 0;
5639     TTree *ttr1 = 0;
5640     Int_t STRACK = 0;
5641     Int_t TRKLEV = 0;
5642     Int_t ACLEV = 0;
5643     TFile *trackhead = 0;
5644     TFile *trackcalibFile1 = 0;
5645     TTree *ctrk = 0;
5646     TFile *trackcalibFile2 = 0;
5647     TFile *trackerFile2b = 0;
5648     if ( TRK ) {
5649     if ( FORCELEV == 0 ){
5650     trackerFile2 = emigetFile(filename, "Tracker");
5651     if ( !trackerFile2 ){
5652     printf("WARNING: no Tracker file! \n");
5653     TRK = 0;
5654     } else {
5655     otr->AddFriend("Tracker", trackerFile2);
5656     printf("Show the Tracker detector, LEVEL0 data \n");
5657     TRKLEV = 0;
5658     };
5659     } else {
5660     trackerFile = emigetFile(filename, "Physics.Level2", "Tracker");
5661     if ( !trackerFile ){
5662     //
5663     trackhead = emigetFile(filename, "CalibTrk1", "Header");
5664     ctrk = (TTree*)trackhead->Get("Pscu");
5665     //
5666     trackerFile = emigetFile(filename, "Physics.Level1", "Tracker");
5667     trackcalibFile1 = emigetFile(filename, "CalibTrk1");
5668     trackcalibFile2 = emigetFile(filename, "CalibTrk2");
5669     //
5670     if ( !trackerFile || !trackcalibFile1 || !trackcalibFile2 || !trackhead ){
5671     trackerFile = emigetFile(filename, "Tracker");
5672     if ( !trackerFile ){
5673     printf("WARNING: no Tracker file! \n");
5674     TRK = 0;
5675     } else {
5676     otr->AddFriend("Tracker", trackerFile);
5677     printf("Show the Tracker detector, LEVEL0 data \n");
5678     TRKLEV = 0;
5679     };
5680     } else {
5681     ttr1 = (TTree*)trackerFile->Get("TrkLevel1");
5682     ctrk->AddFriend("CalibTrk1", trackcalibFile1);
5683     ctrk->AddFriend("CalibTrk2", trackcalibFile2);
5684     printf("Show the Tracker detector, LEVEL1 data \n");
5685     TRKLEV = 1;
5686     trk1noev = ttr1->GetEntries();
5687     };
5688     } else {
5689     ttr = (TTree*)trackerFile->Get("TrkLevel2");
5690     trk2noev = ttr->GetEntries();
5691     printf("Get the track informations (LEVEL2 Tracker data!)\n");
5692     STRACK = 1;
5693     //
5694     trackhead = emigetFile(filename, "CalibTrk2", "Header");
5695     ctrk = (TTree*)trackhead->Get("Pscu");
5696     //
5697     trackerFile2b = emigetFile(filename, "Physics.Level1", "Tracker");
5698     trackcalibFile1 = emigetFile(filename, "CalibTrk1");
5699     trackcalibFile2 = emigetFile(filename, "CalibTrk2");
5700     //
5701     if ( !trackerFile2b || !trackcalibFile1 || !trackcalibFile2 || !trackhead ){
5702     printf(" WARNING: no LEVEL1 Tracker data, load LEVEL0 data \n");
5703     trackerFile2b = emigetFile(filename, "Tracker");
5704     if ( !trackerFile2b ){
5705     printf("WARNING: no Tracker file! \n");
5706     TRK = 0;
5707     } else {
5708     otr->AddFriend("Tracker", trackerFile2b);
5709     printf("Show the Tracker detector, LEVEL0 data \n");
5710     TRKLEV = 0;
5711     };
5712     } else {
5713     ttr1 = (TTree*)trackerFile2b->Get("TrkLevel1");
5714     ctrk->AddFriend("CalibTrk1", trackcalibFile1);
5715     ctrk->AddFriend("CalibTrk2", trackcalibFile2);
5716     printf("Show the Tracker detector, LEVEL1 data \n");
5717     TRKLEV = 1;
5718     trk1noev = ttr1->GetEntries();
5719     };
5720     };
5721     };
5722     };
5723     //
5724     Int_t CALOLEV = 0;
5725     if ( CALO ) {
5726     if ( FORCELEV == 0 ){
5727     caloFile = emigetFile(filename, "Calorimeter");
5728     if ( !caloFile ){
5729     printf("WARNING: no calorimeter file! \n");
5730     CALO = 0;
5731     } else {
5732     otr->AddFriend("Calorimeter", caloFile);
5733     printf("Show the Calorimeter detector, LEVEL0 data \n");
5734     };
5735     CALOLEV = -1;
5736     } else {
5737     caloFile = emigetFile(filename, "Physics.Level1", "Calorimeter");
5738     if ( !caloFile ){
5739     caloFile = emigetFile(filename, "Calorimeter");
5740     if ( !caloFile ){
5741     printf("WARNING: no calorimeter file! \n");
5742     CALO = 0;
5743     } else {
5744     otr->AddFriend("Calorimeter", caloFile);
5745     printf("Show the Calorimeter detector, try to generate LEVEL1 data \n");
5746     };
5747     CALOLEV = 0;
5748     } else {
5749     otr->AddFriend("CaloLevel1", caloFile);
5750     printf("Show the Calorimeter detector, LEVEL1 data \n");
5751     CALOLEV = 1;
5752     };
5753     };
5754     };
5755     //
5756     if ( ND ) {
5757     neutronFile = emigetFile(filename, "Neutron");
5758     if ( !neutronFile ){
5759     printf("WARNING: no neutron detector file! \n");
5760     ND = 0;
5761     } else {
5762     otr->AddFriend("Neutron", neutronFile);
5763     printf("Show the Neutron detector, LEVEL0 data \n");
5764     };
5765     };
5766     //
5767     if ( AC ) {
5768     if ( FORCELEV == 0 ){
5769     acFile = emigetFile(filename, "Anticounter");
5770     if ( !acFile ){
5771     printf("WARNING: no AC file! \n");
5772     AC = 0;
5773     } else {
5774     otr->AddFriend("Anticounter", acFile);
5775     printf("Show the Anticoincidence detector, LEVEL 0 data\n");
5776     ACLEV = 0;
5777     };
5778     } else {
5779     acFile = emigetFile(filename, "Physics.Level1", "Anticounter");
5780     if ( !acFile ){
5781     acFile = emigetFile(filename, "Anticounter");
5782     if ( !acFile ){
5783     printf("WARNING: no AC file! \n");
5784     AC = 0;
5785     } else {
5786     otr->AddFriend("Anticounter", acFile);
5787     printf("Show the Anticoincidence detector, LEVEL 0 data\n");
5788     ACLEV = 0;
5789     };
5790     } else {
5791     otr->AddFriend("AcLevel1", acFile);
5792     printf("Show the Anticoincidence detector, LEVEL 1 data\n");
5793     ACLEV = 1;
5794     };
5795     };
5796     };
5797     Int_t S4LEV = 0;
5798     if ( S4 ) {
5799     s4File = emigetFile(filename, "S4");
5800     if ( !s4File ){
5801     printf("WARNING: no S4 file! \n");
5802     S4 = 0;
5803     } else {
5804     otr->AddFriend("S4", s4File);
5805     if ( FORCELEV != 0 ){
5806     printf("Show the S4 detector, try to generate LEVEL1 data \n");
5807     S4LEV = 1;
5808     } else {
5809     printf("Show the S4 detector, LEVEL0 data \n");
5810     S4LEV = 0;
5811     };
5812     };
5813     };
5814     //
5815     Int_t TOFLEV = 0;
5816     if ( TOF ) {
5817     if ( FORCELEV != 0 ){
5818     tofFileL1 = emigetFile(filename, "Physics.Level1","TofTrigger");
5819     if ( !tofFileL1 ){
5820     tofFile = emigetFile(filename, "Tof");
5821     if ( !tofFile ){
5822     printf("WARNING: no TOF file! \n");
5823     printf("Show the Time of Flight detector, LEVEL0 (trigger board) data\n");
5824     // TOF = 0;
5825     TOFLEV = 0;
5826     } else {
5827     otr->AddFriend("Tof", tofFile);
5828     printf("Show the Time of Flight, try to generate LEVEL1 data \n");
5829     TOFLEV = 10;
5830     };
5831     } else {
5832     toftr = (TTree*)tofFileL1->Get("TofLevel1");
5833     printf("Show the Time of Flight, LEVEL1 data \n");
5834     TOFLEV = 1;
5835     tofnoev = toftr->GetEntries();
5836     };
5837     } else {
5838     printf("Show the Time of Flight detector, LEVEL0 data\n");
5839     TOFLEV = 0;
5840     };
5841     };
5842     //
5843     printf("\n");
5844     //
5845     pamela::PscuHeader *ph = 0;
5846     pamela::EventHeader *eh = 0;
5847     pamela::trigger::TriggerEvent *trig = 0;
5848     Long64_t nevents = otr->GetEntries();
5849     //
5850     printf(" The file contains %i physics events \n",(int)nevents);
5851     //
5852     if (nevents<=0) {
5853     headerFile->Close();
5854     triggerFile->Close();
5855     if ( TRK ) trackerFile->Close();
5856     if ( CALO )caloFile->Close();
5857     if ( ND ) neutronFile->Close();
5858     if ( AC ) acFile->Close();
5859     if ( TOF ) tofFile->Close();
5860     if ( S4 ) s4File->Close();
5861     printf("The file is empty, exiting...\n");
5862     return;
5863     }
5864     //
5865     // Define some variables
5866     //
5867     Int_t OBT = 0;
5868     Int_t DOBT = 0;
5869     Int_t ifout = 0;
5870     Int_t OOBT = 0;
5871     //
5872     if ( calcalibfile == "" ) calcalibfile = filename;
5873     if ( outDir == "" ) outDir = filename;
5874     //
5875     struct Variables var;
5876     //
5877     if ( SHOWDEC ){
5878     var.nosig = 1;
5879     } else {
5880     var.nosig = 0;
5881     };
5882     //
5883     // here windows dimension (based on the computer screen size) and position and dimension of figures
5884     //
5885     Int_t xw, yw;
5886     UInt_t ww, hw;
5887     gVirtualX->GetWindowSize(gClient->GetRoot()->GetId(),xw,yw,ww,hw);
5888     Float_t winx = (float)ww*0.95;
5889     Float_t winy = (float)hw*0.95;
5890     Float_t winrap = winx/winy;
5891     var.bw = 0;
5892     if ( BW ) var.bw = 1;
5893     var.xxvc = 0.17;
5894     var.yxvc = 0.44;
5895     var.xyvc = 0.83;
5896     var.yyvc = 0.44;
5897     //
5898     var.sfx = 0.82/winrap;
5899     var.sfy = 0.82;
5900     //
5901     var.nds4 = 0.4;
5902     //var.nds4 = 0.85/winrap;
5903     var.xcat = 0.5;
5904     var.ycat = 0.74;
5905     //
5906     var.tracknds4 = 1;
5907     //
5908     // READ the CALORIMETER ADC to MIP conversion table (if trying to generate level1 data)
5909     //
5910     Float_t mip[2][22][96];
5911     Int_t okcalo = 0;
5912     TTree *ctree = 0;
5913     TFile *chfile;
5914     CalorimeterCalibration *ccalo = 0;
5915     Long64_t cnevents = 0;
5916     if ( !CALOLEV && CALO ){
5917     chfile = new TFile(calfile.str().c_str(),"READ","Calorimeter CALIBRATION data");
5918     if ( chfile->IsZombie() ){
5919     printf(" WARNING: no calorimeter calibration file! \n Using 26 as conversion factor for all strips. \n");
5920     okcalo = 0;
5921     } else {
5922     okcalo = 1;
5923     ctree = (TTree*)chfile->Get("CaloADC");
5924     ctree->SetBranchAddress("Event", &ccalo);
5925     //
5926     cnevents = ctree->GetEntries();
5927     ctree->GetEntry(cnevents-1);
5928     };
5929     //
5930     if ( okcalo ) {
5931     for (Int_t m = 0; m < 2 ; m++ ){
5932     for (Int_t k = 0; k < 22; k++ ){
5933     for (Int_t l = 0; l < 96; l++ ){
5934     if ( (ccalo->fp[1][m][k][l] > 20. && ccalo->fp[1][m][k][l] < 32.) || ccalo->mask[m][k][l] == 1. ) {
5935     if ( ccalo->mip[m][k][l] != 0. ){
5936     mip[m][k][l] = ccalo->mip[m][k][l];
5937     } else {
5938     mip[m][k][l] = 26. ;
5939     };
5940     } else {
5941     mip[m][k][l] = 26. ;
5942     };
5943     };
5944     };
5945     };
5946     } else {
5947     for (Int_t m = 0; m < 2 ; m++ ){
5948     for (Int_t k = 0; k < 22; k++ ){
5949     for (Int_t l = 0; l < 96; l++ ){
5950     mip[m][k][l] = 26. ;
5951     };
5952     };
5953     };
5954     };
5955     chfile->Close();
5956     };
5957     //
5958     // Check that given input are inside the boundary conditions
5959     //
5960     if ( fromevent > toevent && toevent ){
5961     printf("It must be fromevent < toevent \n");
5962     return;
5963     };
5964     if ( fromevent > nevents+1 || fromevent < 0 ) {
5965     printf("You can choose fromevent between 0 (all) and %i \n",(int)nevents+1);
5966     return;
5967     };
5968     if ( toevent > nevents+1 || toevent < 0 ) {
5969     printf("You can choose toevent between 0 (all) and %i \n",(int)nevents+1);
5970     return;
5971     };
5972     Int_t minevent = 0;
5973     Int_t maxevent = nevents - 1;
5974     if ( fromevent == 0 ) {
5975     minevent = 0;
5976     maxevent = nevents - 1;
5977     } else {
5978     minevent = fromevent - 1;
5979     if ( toevent > 0 ){
5980     maxevent = toevent-1;
5981     } else {
5982     maxevent = fromevent-1;
5983     };
5984     };
5985     //
5986     // book the canvas
5987     //
5988     TCanvas *figure = new TCanvas("PAMELA event viewer", "PAMELA event viewer",(int)winx,(int)winy);
5989     TLatex *text=new TLatex();
5990     stringstream testo;
5991     stringstream testo2;
5992     stringstream testo3;
5993     figure->Range(0.,0.,1.,1.);
5994     gStyle->SetOptDate(0);
5995     gStyle->SetOptStat(0);
5996     gStyle->SetLabelSize(0);
5997     gStyle->SetNdivisions(1,"X");
5998     gStyle->SetNdivisions(1,"Y");
5999     //
6000     stringstream libload;
6001     Int_t doflag = 1;
6002     Int_t thefirst = 1;
6003     Int_t trackdone1 = 0;
6004     Int_t trackdone2 = 0;
6005     Int_t seldone = 0;
6006     Float_t headc = 0.;
6007     Float_t headcold = 0.;
6008     Int_t i = minevent;
6009     Int_t OK = 0;
6010     Int_t jumpto = 0;
6011     //
6012     otr->SetBranchAddress("Header", &eh);
6013     otr->GetEntry(maxevent);
6014     ph = eh->GetPscuHeader();
6015     Int_t lastevno = (int)ph->GetCounter();
6016     otr->GetEntry(minevent);
6017     ph = eh->GetPscuHeader();
6018     Int_t firstevno = (int)ph->GetCounter();
6019     struct Calib calib;
6020     Int_t b[4];
6021     Int_t si = 0;
6022     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6023     // MAIN LOOP STARTS HERE: run over all the events
6024     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6025     while ( i < maxevent+1 ){
6026     //
6027     // clear canvas and variables
6028     //
6029     var.beta[0] = 0.;
6030     var.beta[1] = 0.;
6031     var.beta[2] = 0.;
6032     var.beta[3] = 0.;
6033     var.beta[4] = 0.;
6034     var.s4sig = 0.;
6035     var.nstrip = 0;
6036     var.qtot = 0;
6037     var.nclx = 0;
6038     var.ncly = 0;
6039     var.trup = 0;
6040     var.bkup = 0;
6041     var.bkbo = 0;
6042     var.hcas = 0;
6043     var.hcat = 0;
6044     var.hcard = 0;
6045     //
6046     // call the filter to select events (if filter file is given)
6047     //
6048     if ( jumpto ){
6049     otr->SetBranchAddress("Header", &eh);
6050     otr->GetEntry(i);
6051     ph = eh->GetPscuHeader();
6052     Int_t cjumpto = (int)ph->GetCounter();
6053     if ( cjumpto == jumpto ) jumpto = 0;
6054     if ( jumpto && i == maxevent ) {
6055     i = si;
6056     printf(" WARNING: NO EVENT WITH EVENT NUMBER %i \n",jumpto);
6057     jumpto = 0;
6058     };
6059     };
6060     //
6061     OK = 0;
6062     if ( !selection || ( i == minevent && !seldone) ){
6063     OK = 1;
6064     seldone = 1;
6065     } else {
6066     OK = 0;
6067     #if defined (__CINT__)
6068     OK = filter(i,otr,ttr,level);
6069     #endif
6070     #if !defined (__CINT__)
6071     stringstream cintcom;
6072     cintcom.str("");
6073     cintcom << "Int_t *i = (Int_t*)0x" << hex;
6074     cintcom << &i;
6075     gROOT->ProcessLine(cintcom.str().c_str());
6076     gROOT->ProcessLine("Int_t a = *i;");
6077     cintcom.str("");
6078     cintcom << "TTree *otr = (TTree*)0x" << hex;
6079     cintcom << otr;
6080     gROOT->ProcessLine(cintcom.str().c_str());
6081     cintcom.str("");
6082     cintcom << "TTree *ttr = (TTree*)0x" << hex;
6083     cintcom << ttr;
6084     gROOT->ProcessLine(cintcom.str().c_str());
6085     cintcom.str("");
6086     cintcom << "struct Levels &level = (struct Levels &)0x" << hex;
6087     cintcom << &level;
6088     gROOT->ProcessLine(cintcom.str().c_str());
6089     OK = gApplication->ProcessLine("filter((Int_t)a,(TTree *)otr,(TTree *)ttr,(Levels &)level);");
6090     #endif
6091     seldone = 1;
6092     printf("Scanning data: %d%c done",100*(i-minevent)/(maxevent-minevent),37);
6093     fflush(stdout);
6094     };
6095     //
6096     // if the event is selected go on
6097     //
6098     if ( OK && !jumpto ) {
6099     printf("\n");
6100     figure->Clear();
6101     figure->SetFillColor(10);
6102     figure->cd();
6103     //
6104     // Get Orbital Time information and header event number
6105     //
6106     otr->SetBranchAddress("Header", &eh);
6107     if ( !var.nosig) otr->GetEntry(i);
6108     ph = eh->GetPscuHeader();
6109     headcold = headc;
6110     headc = ph->GetCounter();
6111     var.headc = (int)ph->GetCounter();
6112     OBT = ph->GetOrbitalTime();
6113     DOBT = OBT - OOBT;
6114     OOBT = OBT;
6115     if ( i == minevent || DOBT < 0 || (headc-headcold-1)!=0 ) DOBT = 0;
6116     var.etime = OBT;
6117     //
6118     // who gave the trigger?
6119     //
6120     otr->SetBranchAddress("Trigger.Event", &trig);
6121     if ( !var.nosig) otr->GetEntry(i);
6122     Int_t calotrig = 0;
6123     if ( trig->patterntrig[0] ) calotrig = 1;
6124     Int_t toftrig = 0;
6125     if ( trig->patterntrig[2] || trig->patterntrig[3] || trig->patterntrig[4] || trig->patterntrig[5] ) toftrig = 1;
6126     Int_t s4pulser = 0;
6127     if ( trig->patterntrig[1] & (1<<0) ) s4pulser = 1;
6128     //
6129     // TOF and calorimeter when giving a trigger will always set this flag since the time window of the signal is greater than 100 ns.
6130     // S4 sometimes could not set the flag even if the trigger is given. This is a workaround to fix this "bug":
6131     //
6132     if ( !calotrig && !toftrig ) s4pulser = 1;
6133     //
6134     Int_t trigconf = trig->trigconf;
6135     stringstream trc;
6136     trc.str("");
6137     if ( trigconf & (1<<0) ) trc << "TOF1";
6138     if ( trigconf & (1<<1) ) trc << " TOF2";
6139     if ( trigconf & (1<<2) ) trc << " TOF3";
6140     if ( trigconf & (1<<3) ) trc << " TOF4";
6141     if ( trigconf & (1<<4) ) trc << " TOF5";
6142     if ( trigconf & (1<<5) ) trc << " TOF6";
6143     if ( trigconf & (1<<6) ) trc << " TOF7";
6144     if ( trigconf & (1<<7) ) trc << " S4";
6145     if ( trigconf & (1<<8) ) trc << " CALO";
6146     if ( trigconf & (1<<9) ) trc << " CALIB_ON";
6147     TString trcs(trc.str().c_str());
6148     //
6149     // show TOF
6150     //
6151     if ( TOF ){
6152     figure->cd();
6153     if ( TOFLEV == 0 ){
6154     ShowTOF(i,otr,var);
6155     level.tof = 0;
6156     };
6157     if ( TOFLEV == 10 ){
6158     ShowTOFGENL1(i,otr,var);
6159     level.tof = 0;
6160     };
6161     if ( TOFLEV == 1 ){
6162     ShowTOFL1(i,toftr,var);
6163     level.tof = 1;
6164     };
6165     };
6166     //
6167     // show anticounters
6168     //
6169     if ( AC ){
6170     figure->cd();
6171     if ( ACLEV == 0 ){
6172     ShowAC(i,otr,var,0);
6173     level.ac = 0;
6174     };
6175     if ( ACLEV == 1 ){
6176     ShowAC(i,otr,var,1);
6177     level.ac = 1;
6178     };
6179     };
6180     //
6181     // show S4
6182     //
6183     if ( S4 ){
6184     figure->cd();
6185     if ( S4LEV == 0 ){
6186     ShowS4L0(i,otr,var);
6187     level.s4 = 0;
6188     };
6189     if ( S4LEV == 1 ){
6190     ShowS4L1(i,otr,var);
6191     level.s4 = 1;
6192     };
6193     };
6194     //
6195     //
6196     // show neutron detector
6197     //
6198     if ( ND ){
6199     figure->cd();
6200     ShowND(i,otr,var);
6201     level.nd = 0;
6202     };
6203     //
6204     // show tracker
6205     //
6206     if ( TRK ){
6207     //
6208     // if we have level2 data show the track
6209     //
6210     if ( STRACK == 1 ) {
6211     if ( i == minevent && !trackdone1 ) {
6212     //
6213     // Load tracker libraries to read the magnetic field and compute the paritcle trajectory
6214     //
6215     trackdone1 = 1;
6216     #if defined (__CINT__)
6217     printf("\n\n TRACKER: loading shared libraries...\n");
6218     const char *pam_lib=gSystem->Getenv("PAM_LIB");
6219     libload.str("");
6220     libload << pam_lib << "/libtrack";
6221     gSystem->Load(libload.str().c_str());
6222     libload.str("");
6223     libload << pam_lib << "/libtrack_C";
6224     gSystem->Load(libload.str().c_str());
6225     libload.str("");
6226     libload << pam_lib << "/libreadb2maps";
6227     gSystem->Load(libload.str().c_str());
6228     libload.str("");
6229     libload << pam_lib << "/libreadb2maps_C";
6230     gSystem->Load(libload.str().c_str());
6231     libload.str("");
6232     printf(" ...done!\n\n");
6233     #endif
6234     //
6235     // Read the magnetic field map (two files), here it goes the path AND name of one of them.
6236     //
6237     printf("\n\n TRACKER: loading the magnetic field maps...\n\n\n");
6238     const char *pam_calib = pathtocalibration();
6239     stringstream bdir;
6240     bdir.str("");
6241     bdir << pam_calib << ".";
6242     creadB(bdir.str().c_str());
6243     //
6244     printf(" ...done! \n");
6245     };
6246     level.track2 = 1;
6247     figure->cd();
6248     ShowTRACK(i,ttr,var);
6249     };
6250     //
6251     // show level1 data
6252     //
6253     figure->cd();
6254     if ( TRKLEV == 1 ) {
6255     if ( i == minevent && !trackdone2 ) {
6256     trackdone2 = 1;
6257     #if defined (__CINT__)
6258     printf("\n\n TRACKER: loading level1 libraries...\n");
6259     const char *pam_lib=gSystem->Getenv("PAM_LIB");
6260     printf("\n Opening libptlev1.so \n");
6261     libload.str("");
6262     libload << pam_lib << "/libptlevel1";
6263     gSystem->Load(libload.str().c_str());
6264     libload.str("");
6265     printf("\n Opening libptlev1_C.so \n\n");
6266     libload.str("");
6267     libload << pam_lib << "/libptlevel1_C";
6268     gSystem->Load(libload.str().c_str());
6269     libload.str("");
6270     printf(" ...done! \n\n");
6271     #endif
6272     //
6273     pamela::CalibTrk1Event *te1 = 0;
6274     ctrk->SetBranchAddress("CalibTrk1.Event", &te1);
6275     if ( ctrk->GetEntries() > 0 ){
6276     ctrk->GetEntry(0);
6277     for ( Int_t ii = 0 ; ii<6 ; ii++){
6278     for ( Int_t ij = 0 ; ij<3072 ; ij++){
6279     var.DSPsig_par[ii][ij] = te1->DSPsig_par[ii][ij];
6280     };
6281     };
6282     pamela::CalibTrk2Event *te2 = 0;
6283     ctrk->SetBranchAddress("CalibTrk2.Event", &te2);
6284     ctrk->GetEntry(0);
6285     for ( Int_t ii = 6 ; ii<12 ; ii++){
6286     for ( Int_t ij = 0 ; ij<3072 ; ij++){
6287     var.DSPsig_par[ii][ij] = te2->DSPsig_par[ii-6][ij];
6288     };
6289     };
6290     } else {
6291     for ( Int_t ii = 0 ; ii<12 ; ii++){
6292     for ( Int_t ij = 0 ; ij<3072 ; ij++){
6293     if ( ii > 5 ) var.DSPsig_par[ii][ij] = 8.;
6294     if ( ii < 6 ) var.DSPsig_par[ii][ij] = 3.;
6295     };
6296     };
6297     };
6298     };
6299     ShowTRKL1(i,ttr1,var);
6300     };
6301     //
6302     // if everything fails, show at least level0 data
6303     //
6304     if ( TRKLEV == 0 ) ShowTRKL0(i,otr,var);
6305     figure->Modified();
6306     figure->Update();
6307     level.track = TRKLEV;
6308     };
6309     //
6310     // show calorimeter
6311     //
6312     if ( CALO ){
6313     figure->cd();
6314     //
6315     // if we have LEVEL1 data
6316     //
6317     if ( CALOLEV == 1 ) ShowCaloL1(i,otr,var);
6318     //
6319     // if we have only LEVEL0 data try to generate event by event LEVEL1 data
6320     //
6321     if ( CALOLEV == 0 ) {
6322     if ( !thefirst ) {
6323     ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var);
6324     } else {
6325     printf("\n\n CALORIMETER: looking for calibration data...\n");
6326     thefirst = 0;
6327     Calo1stcalib(calcalibfile,calib,b);
6328     //
6329     // check calibration
6330     //
6331     Int_t calibex = 0;
6332     Int_t stop = 0;
6333     for (Int_t s=0; s<4;s++){
6334     if ( b[s] > 4 ) b[s] = 0;
6335     stop = 0;
6336     for (Int_t d = 0; d<48; d++){
6337     if ( calib.ttime[s][d] != 0 ) calibex++;
6338     if ( calib.time[s][0] != 0 ){
6339     if ( calib.time[s][d+1] == 0 ) {
6340     if ( !stop ){
6341     stop = 1;
6342     };
6343     };
6344     };
6345     };
6346     };
6347     printf(" ...done! \n\n\n");
6348     if ( calibex < 1 ) {
6349     printf(" No calorimeter calibrations! Switching to raw mode visualitation \n Only COMPRESS and FULL mode acquisition are supported \n\n");
6350     CALOLEV = -1;
6351     } else {
6352     ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var);
6353     };
6354     };
6355     };
6356     //
6357     // if everything fail, show level0 data
6358     //
6359     if ( CALOLEV == -1 ) {
6360     ShowCaloRAW(i,otr,var);
6361     };
6362     if ( var.nosig ){
6363     var.qtot = 0;
6364     var.nstrip = 0;
6365     };
6366     level.calo = CALOLEV;
6367     };
6368     figure->cd();
6369     //
6370     // SHOW INFOS
6371     //
6372     if ( INFOS ){
6373     figure->cd();
6374     text->SetTextAngle(0);
6375     text->SetTextFont(32);
6376     text->SetTextColor(1);
6377     text->SetTextSize(0.025); // 0.02
6378     text->SetTextAlign(12);
6379     Float_t txthi = 0.47;
6380     testo.str("");
6381     testo << "File: " << file;
6382     testo << " - Event number: " << (int)headc;
6383     text->DrawLatex(0.33,txthi,testo.str().c_str());
6384     txthi -= 0.03;
6385     testo.str("");
6386     testo << "Progressive number: " << (i+1);
6387     if ( s4pulser ){
6388     testo << " - S4 trigger - ";
6389     };
6390     if ( calotrig ){
6391     testo << " - CALO trigger - ";
6392     };
6393     text->DrawLatex(0.33,txthi,testo.str().c_str());
6394     txthi -= 0.03;
6395     testo2.str("");
6396     testo2 << "On Board Time: " << (int)OBT;
6397     if ( DOBT > 0 ) {
6398     testo2 << " (delta: " << (int)DOBT;
6399     testo2 << ")";
6400     };
6401     testo2 << " [ms]";
6402     text->DrawLatex(0.33,txthi,testo2.str().c_str());
6403     txthi -= 0.03;
6404     text->SetTextSize(0.020); // 0.015
6405     const char *trc2 = trcs;
6406     testo3.str("");
6407     testo3 << "TRIGGER: " << trc2;
6408     text->DrawLatex(0.33,txthi,testo3.str().c_str());
6409     txthi -= 0.03;
6410     testo3.str("");
6411     testo3 << "AC: CARD hit = " << var.hcard;
6412     testo3 << " CAT hit = " << var.hcat;
6413     testo3 << " CAS hit = " << var.hcas;
6414     text->DrawLatex(0.33,txthi,testo3.str().c_str());
6415     txthi -= 0.03;
6416     testo3.str("");
6417     if ( STRACK ){
6418     testo3 << "TRK: RIG = " << setprecision(3) << var.rig;
6419     testo3 << " [GV] CHI2 = " << setprecision(3) << var.chi2;
6420     } else {
6421     testo3 << "TRK: NCLX = "<< var.nclx;
6422     testo3 << " NCLY = "<<var.ncly;
6423     };
6424     text->DrawLatex(0.33,txthi,testo3.str().c_str());
6425     txthi -= 0.03;
6426     testo3.str("");
6427     testo3 << "CALO: NSTRIP = " << var.nstrip;
6428     testo3 << " QTOT = "<<var.qtot << " [MIP]";
6429     text->DrawLatex(0.33,txthi,testo3.str().c_str());
6430     txthi -= 0.03;
6431     testo3.str("");
6432     testo3 << "S4: " << setprecision(2);
6433     testo3 << var.s4sig << " [MIP] TOF: #beta(1,...,5) = (";
6434     testo3 << setprecision(3) << var.beta[0];
6435     testo3 << ",";
6436     testo3 << setprecision(3) << var.beta[1];
6437     testo3 << ",";
6438     testo3 << setprecision(3) << var.beta[2];
6439     testo3 << ",";
6440     testo3 << setprecision(3) << var.beta[3];
6441     testo3 << ",";
6442     testo3 << setprecision(3) << var.beta[4];
6443     testo3 << ")";
6444     text->DrawLatex(0.33,txthi,testo3.str().c_str());
6445     txthi -= 0.03;
6446     testo3.str("");
6447     testo3 << "ND: Trigger: neutrons = " << var.trup;
6448     testo3 << " - Background: upper = " << var.bkup;
6449     testo3 << " lower = " << var.bkbo;
6450     text->DrawLatex(0.33,txthi,testo3.str().c_str());
6451     txthi -= 0.03;
6452     text->SetTextSize(0.01);
6453     text->DrawLatex(var.xxvc-0.025*var.sfx,var.yxvc-0.519*var.sfy,"CPU SIDE");
6454     text->SetTextAngle(90);
6455     text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc+0.075*var.sfy,"CPU SIDE");
6456     text->DrawLatex(var.xyvc-0.17*var.sfx,var.yyvc+0.075*var.sfy,"VME SIDE");
6457     if ( AC || TRK ){
6458     text->SetTextAngle(90);
6459     text->DrawLatex(var.xcat-0.235*var.sfx,var.ycat-0.025*var.sfy,"VME SIDE");
6460     text->DrawLatex(var.xcat+0.235*var.sfx,var.ycat-0.025*var.sfy,"CPU SIDE");
6461     //
6462     text->SetTextAngle(0);
6463     text->SetTextSize(0.015);
6464     TEllipse *elli = new TEllipse(var.xcat+0.219*var.sfx,var.ycat-0.249*var.sfy,0.003,0.003);
6465     elli->Draw();
6466     text->DrawLatex(var.xcat+0.229*var.sfx,var.ycat-0.261*var.sfy,"z");
6467     TArrow *arr;
6468     arr = new TArrow(var.xcat+0.22*var.sfx,var.ycat-0.25*var.sfy,var.xcat+0.22*var.sfx,var.ycat-0.21*var.sfy);
6469     arr->SetArrowSize(0.005);
6470     arr->Draw();
6471     text->DrawLatex(var.xcat+0.229*var.sfx,var.ycat-0.21*var.sfy,"x");
6472     arr = new TArrow(var.xcat+0.22*var.sfx,var.ycat-0.25*var.sfy,var.xcat+0.18*var.sfx,var.ycat-0.25*var.sfy);
6473     arr->SetArrowSize(0.005);
6474     arr->Draw();
6475     text->DrawLatex(var.xcat+0.18*var.sfx,var.ycat-0.261*var.sfy,"y");
6476     text->SetTextSize(0.01);
6477     };
6478     //
6479     // coordinates systems and x/y view labels
6480     //
6481     figure->cd();
6482     text->SetTextAngle(0);
6483     text->SetTextFont(32);
6484     text->SetTextColor(1);
6485     text->SetTextAlign(12);
6486     text->SetTextSize(0.01);
6487     text->DrawLatex(var.xxvc-0.025*var.sfx,var.yxvc+0.67*var.sfy,"X VIEW");
6488     text->DrawLatex(var.xyvc-0.025*var.sfx,var.yyvc+0.67*var.sfy,"Y VIEW");
6489     //
6490     text->SetTextSize(0.015);
6491     text->SetTextFont(2);
6492     DrawX(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,0.005,var);
6493     text->SetTextFont(32);
6494     text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.508*var.sfy,"y");
6495     TArrow *arr;
6496     arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.19*var.sfx,var.yxvc-0.508*var.sfy);
6497     arr->SetArrowSize(0.005);
6498     arr->Draw();
6499     text->DrawLatex(var.xxvc-0.19*var.sfx,var.yxvc-0.515*var.sfy,"x");
6500     arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.23*var.sfx,var.yxvc-0.468*var.sfy);
6501     arr->SetArrowSize(0.005);
6502     arr->Draw();
6503     text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.468*var.sfy,"z");
6504     //
6505     text->SetTextSize(0.015);
6506     text->SetTextFont(2);
6507     DrawX(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,0.005,var);
6508     text->SetTextFont(32);
6509     text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.508*var.sfy,"x");
6510     arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.18*var.sfx,var.yyvc-0.508*var.sfy);
6511     arr->SetArrowSize(0.005);
6512     arr->Draw();
6513     text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc-0.511*var.sfy,"y");
6514     arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.22*var.sfx,var.yyvc-0.468*var.sfy);
6515     arr->SetArrowSize(0.005);
6516     arr->Draw();
6517     text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.468*var.sfy,"z");
6518     text->SetTextSize(0.01);
6519     };
6520     //
6521     // SHOW PALETTE
6522     //
6523     if ( PALETTE ) ShowPalette(var.bw);
6524     //
6525     // SHOW VERBOSE INFOS
6526     //
6527     if ( VINFOS ){
6528     figure->cd();
6529     text->SetTextAngle(0);
6530     text->SetTextFont(32);
6531     text->SetTextColor(1);
6532     text->SetTextSize(0.01);
6533     text->SetTextAlign(12);
6534     if ( AC ){
6535     //
6536     // Plane view
6537     //
6538     text->SetTextAngle(90);
6539     text->DrawLatex(var.xcat+0.1*var.sfx,var.ycat-0.015*var.sfy,"CARD4");
6540     text->SetTextAngle(-90);
6541     text->DrawLatex(var.xcat-0.1*var.sfx,var.ycat+0.015*var.sfy,"CARD1");
6542     text->SetTextAngle(0);
6543     text->DrawLatex(var.xcat-0.015*var.sfx,var.ycat-0.116*var.sfy,"CARD2");
6544     text->DrawLatex(var.xcat-0.015*var.sfx,var.ycat+0.116*var.sfy,"CARD3");
6545     text->SetTextAngle(90);
6546     text->DrawLatex(var.xcat+0.13*var.sfx,var.ycat-0.015*var.sfy,"CAS3");
6547     text->SetTextAngle(-90);
6548     text->DrawLatex(var.xcat-0.13*var.sfx,var.ycat+0.015*var.sfy,"CAS4");
6549     text->SetTextAngle(0);
6550     text->DrawLatex(var.xcat-0.015*var.sfx,var.ycat-0.140*var.sfy,"CAS2");
6551     text->DrawLatex(var.xcat-0.015*var.sfx,var.ycat+0.140*var.sfy,"CAS1");
6552     text->DrawLatex(var.xcat+0.17*var.sfx,var.ycat,"CAT1");
6553     text->DrawLatex(var.xcat-0.2*var.sfx,var.ycat,"CAT2");
6554     text->DrawLatex(var.xcat-0.015*var.sfx,var.ycat-0.198*var.sfy,"CAT3");
6555     text->DrawLatex(var.xcat-0.015*var.sfx,var.ycat+0.198*var.sfy,"CAT4");
6556     //
6557     // X and Y views
6558     //
6559     text->DrawLatex(var.xxvc-0.192*var.sfx,var.yxvc-0.08*var.sfy,"CAS2");
6560     text->DrawLatex(var.xxvc+0.17*var.sfx,var.yxvc-0.08*var.sfy,"CAS1");
6561     text->DrawLatex(var.xyvc-0.192*var.sfx,var.yyvc-0.08*var.sfy,"CAS4");
6562     text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc-0.08*var.sfy,"CAS3");
6563     text->DrawLatex(var.xxvc-0.192*var.sfx,var.yxvc+0.48*var.sfy,"CARD2");
6564     text->DrawLatex(var.xxvc+0.155*var.sfx,var.yxvc+0.48*var.sfy,"CARD3");
6565     text->DrawLatex(var.xyvc-0.170*var.sfx,var.yyvc+0.48*var.sfy,"CARD1");
6566     text->DrawLatex(var.xyvc+0.13*var.sfx,var.yyvc+0.48*var.sfy,"CARD4");
6567     text->DrawLatex(var.xxvc-0.192*var.sfx,var.yxvc+0.39*var.sfy,"CAT3");
6568     text->DrawLatex(var.xxvc+0.155*var.sfx,var.yxvc+0.39*var.sfy,"CAT4");
6569     text->DrawLatex(var.xyvc-0.170*var.sfx,var.yyvc+0.39*var.sfy,"CAT2");
6570     text->DrawLatex(var.xyvc+0.13*var.sfx,var.yyvc+0.39*var.sfy,"CAT1");
6571     };
6572     if ( CALO ){
6573     text->SetTextSize(0.020);
6574     text->SetTextAngle(90);
6575     text->DrawLatex(var.xxvc-0.22*var.sfx,var.yxvc-0.290*var.sfy,"Calorimeter");
6576     text->DrawLatex(var.xyvc+0.22*var.sfx,var.yyvc-0.290*var.sfy,"Calorimeter");
6577     text->SetTextSize(0.01);
6578     text->SetTextAngle(0);
6579     };
6580     if ( TRK ){
6581     text->SetTextSize(0.020);
6582     text->SetTextAngle(90);
6583     text->DrawLatex(var.xxvc-0.22*var.sfx,var.yxvc+0.080*var.sfy,"Tracker");
6584     text->DrawLatex(var.xyvc+0.22*var.sfx,var.yyvc+0.080*var.sfy,"Tracker");
6585     text->SetTextSize(0.01);
6586     text->SetTextAngle(0);
6587     };
6588     if ( ND ){
6589     text->SetTextSize(0.020);
6590     text->SetTextAngle(90);
6591     text->DrawLatex(var.xxvc-0.22*var.sfx,var.yxvc-0.430*var.sfy,"ND");
6592     text->DrawLatex(var.xyvc+0.22*var.sfx,var.yyvc-0.430*var.sfy,"ND");
6593     text->SetTextSize(0.01);
6594     text->SetTextAngle(0);
6595     };
6596     if ( TOF ){
6597     text->SetTextSize(0.020);
6598     text->DrawLatex(var.xxvc-0.24*var.sfx,var.yxvc-0.130*var.sfy,"S3");
6599     text->DrawLatex(var.xxvc-0.24*var.sfx,var.yxvc+0.350*var.sfy,"S2");
6600     text->DrawLatex(var.xxvc-0.24*var.sfx,var.yxvc+0.653*var.sfy,"S1");
6601     text->DrawLatex(var.xyvc+0.21*var.sfx,var.yyvc-0.130*var.sfy,"S3");
6602     text->DrawLatex(var.xyvc+0.21*var.sfx,var.yyvc+0.350*var.sfy,"S2");
6603     text->DrawLatex(var.xyvc+0.21*var.sfx,var.yyvc+0.653*var.sfy,"S1");
6604     text->SetTextSize(0.01);
6605     };
6606     if ( S4 ){
6607     text->SetTextSize(0.020);
6608     text->DrawLatex(var.xxvc-0.24*var.sfx,var.yxvc-0.350*var.sfy,"S4");
6609     text->DrawLatex(var.xyvc+0.21*var.sfx,var.yyvc-0.350*var.sfy,"S4");
6610     text->SetTextSize(0.01);
6611     };
6612     if ( !INFOS ){
6613     text->SetTextSize(0.01);
6614     text->DrawLatex(var.xxvc-0.025*var.sfx,var.yxvc-0.520*var.sfy,"CPU SIDE");
6615     text->SetTextAngle(90);
6616     text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc+0.075*var.sfy,"CPU SIDE");
6617     text->DrawLatex(var.xyvc-0.17*var.sfx,var.yyvc+0.075*var.sfy,"VME SIDE");
6618     if ( AC || TRK ){
6619     text->SetTextAngle(90);
6620     text->DrawLatex(var.xcat-0.235*var.sfx,var.ycat-0.025*var.sfy,"VME SIDE");
6621     text->DrawLatex(var.xcat+0.235*var.sfx,var.ycat-0.025*var.sfy,"CPU SIDE");
6622     //
6623     text->SetTextAngle(0);
6624     text->SetTextSize(0.015);
6625     TEllipse *elli = new TEllipse(var.xcat+0.219*var.sfx,var.ycat-0.249*var.sfy,0.003,0.003);
6626     elli->Draw();
6627     text->DrawLatex(var.xcat+0.229*var.sfx,var.ycat-0.261*var.sfy,"z");
6628     TArrow *arr;
6629     arr = new TArrow(var.xcat+0.22*var.sfx,var.ycat-0.25*var.sfy,var.xcat+0.22*var.sfx,var.ycat-0.21*var.sfy);
6630     arr->SetArrowSize(0.005);
6631     arr->Draw();
6632     text->DrawLatex(var.xcat+0.229*var.sfx,var.ycat-0.21*var.sfy,"x");
6633     arr = new TArrow(var.xcat+0.22*var.sfx,var.ycat-0.25*var.sfy,var.xcat+0.18*var.sfx,var.ycat-0.25*var.sfy);
6634     arr->SetArrowSize(0.005);
6635     arr->Draw();
6636     text->DrawLatex(var.xcat+0.18*var.sfx,var.ycat-0.261*var.sfy,"y");
6637     text->SetTextSize(0.01);
6638     };
6639     //
6640     // coordinates systems and x/y view labels
6641     //
6642     figure->cd();
6643     text->SetTextAngle(0);
6644     text->SetTextFont(32);
6645     text->SetTextColor(1);
6646     text->SetTextAlign(12);
6647     text->SetTextSize(0.01);
6648     text->DrawLatex(var.xxvc-0.025*var.sfx,var.yxvc+0.67*var.sfy,"X VIEW");
6649     text->DrawLatex(var.xyvc-0.025*var.sfx,var.yyvc+0.67*var.sfy,"Y VIEW");
6650     //
6651     text->SetTextSize(0.015);
6652     text->SetTextFont(2);
6653     DrawX(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,0.005,var);
6654     text->SetTextFont(32);
6655     text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.508*var.sfy,"y");
6656     TArrow *arr;
6657     arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.19*var.sfx,var.yxvc-0.508*var.sfy);
6658     arr->SetArrowSize(0.005);
6659     arr->Draw();
6660     text->DrawLatex(var.xxvc-0.19*var.sfx,var.yxvc-0.515*var.sfy,"x");
6661     arr = new TArrow(var.xxvc-0.23*var.sfx,var.yxvc-0.508*var.sfy,var.xxvc-0.23*var.sfx,var.yxvc-0.468*var.sfy);
6662     arr->SetArrowSize(0.005);
6663     arr->Draw();
6664     text->DrawLatex(var.xxvc-0.246*var.sfx,var.yxvc-0.468*var.sfy,"z");
6665     //
6666     text->SetTextSize(0.015);
6667     text->SetTextFont(2);
6668     DrawX(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,0.005,var);
6669     text->SetTextFont(32);
6670     text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.508*var.sfy,"x");
6671     arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.18*var.sfx,var.yyvc-0.508*var.sfy);
6672     arr->SetArrowSize(0.005);
6673     arr->Draw();
6674     text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc-0.511*var.sfy,"y");
6675     arr = new TArrow(var.xyvc+0.22*var.sfx,var.yyvc-0.508*var.sfy,var.xyvc+0.22*var.sfx,var.yyvc-0.468*var.sfy);
6676     arr->SetArrowSize(0.005);
6677     arr->Draw();
6678     text->DrawLatex(var.xyvc+0.23*var.sfx,var.yyvc-0.468*var.sfy,"z");
6679     text->SetTextSize(0.01);
6680     };
6681     };
6682     //
6683     // update figure
6684     //
6685     figure->Modified();
6686     figure->Update();
6687     figure->cd();
6688     //
6689     // print infos on terminal
6690     //
6691     printf(" File: %s \n",name);
6692     if ( !s4pulser && !calotrig ){
6693     printf(" Event number: %i - Progressive number: %i \n",(int)headc,i+1);
6694     };
6695     if ( s4pulser ){
6696     printf(" Event number: %i - Progressive number: %i - S4 trigger -\n",(int)headc,i+1);
6697     };
6698     if ( calotrig ){
6699     printf(" Event number: %i - Progressive number: %i - CALO trigger -\n",(int)headc,i+1);
6700     };
6701     printf(" On Board Time: %i (delta %i) [ms]\n",OBT,DOBT);
6702     const char *trc2 = trcs;
6703     printf(" TRIGGER: %s \n",trc2);
6704     printf(" AC: CARD hit = %i CAT hit = %i CAS hit = %i \n",var.hcard,var.hcat,var.hcas);
6705     if ( STRACK ){
6706     printf(" TRK: NCLX = %i NCLY = %i RIG = %f [GV] CHI2 = %f \n",var.nclx,var.ncly,var.rig,var.chi2);
6707     } else {
6708     printf(" TRK: NCLX = %i NCLY = %i \n ",var.nclx,var.ncly);
6709     };
6710     printf(" CALO: NSTRIP = %i QTOT = %i [MIP]\n",var.nstrip,var.qtot);
6711     printf(" S4: %.2f [MIP] TOF: beta(1,...,5) = (%.2f,%.2f,%.2f,%.2f,%.2f) \n",var.s4sig,var.beta[0],var.beta[1],var.beta[2],var.beta[3],var.beta[4]);
6712     printf(" ND: Trigger: neutrons = %i - Background: upper = %i lower = %i \n",var.trup,var.bkup,var.bkbo);
6713     //
6714     // Interact with user: do you want to continue, go backward, exit or print the figure?
6715     //
6716     printf("\n\n\n\n\n\n\n\n\n\n");
6717     if ( i != maxevent ) {
6718     si = i;
6719     doflag = 1;
6720     jumpto = 0;
6721     TString figty = "ev";
6722     var.i = i;
6723     var.doflag = doflag;
6724     var.jumpto = jumpto;
6725     var.nevents = nevents;
6726     var.lastevno = lastevno;
6727     var.firstevno = firstevno;
6728     Int_t ifout = WhatToDoEV(var,file,outDir,figty,*figure);
6729     i = var.i;
6730     doflag = var.doflag;
6731     jumpto = var.jumpto;
6732     if ( i != si ) OOBT = 1000000000;
6733     if ( maxevent < i+1 ) {
6734     maxevent = nevents;
6735     printf("WARNING: you have chosen an event number out of the starting range.\n Range extended to %i\n\n",maxevent);
6736     };
6737     if ( ifout ) goto theend;
6738     } else {
6739     printf("\n\n");
6740     };
6741     };
6742     if ( doflag == 2 && i == 0 ) {
6743     printf("\n WARNING: Cannot go backward! Going forward. \n");
6744     doflag = 1;
6745     };
6746     if ( doflag == 2 && i>0 ) i--;
6747     if ( doflag == 1 ) i++;
6748     //
6749     // if in selection mode, print out a event progress bar:
6750     //
6751     if ( !selection || i == minevent ){
6752     // do nothing
6753     } else {
6754     if ( (maxevent-minevent) != 0 ){
6755     if((100*(i-minevent)/(maxevent-minevent))<10.){
6756     printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8);
6757     } else {
6758     printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8);
6759     };
6760     };
6761     };
6762    
6763     };
6764     //
6765     // END OF THE MAIN LOOP AND OF THE MAIN PROGRAM
6766     //
6767     printf("\n");
6768     theend: if ( !ifout ) printf("\nFinished, exiting... \n\n");
6769     #if defined (__CINT__)
6770     gSystem->ChangeDirectory(path);
6771     if ( trackdone2 ){
6772     unload1();
6773     };
6774     if ( trackdone1 ){
6775     unload2();
6776     };
6777     #endif
6778     printf(" ...done! \n\n");
6779     return;
6780     }

  ViewVC Help
Powered by ViewVC 1.1.23