/[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.1 - (hide annotations) (download)
Tue Dec 6 10:12:56 2005 UTC (19 years ago) by mocchiut
Branch: MAIN
Branch point for: EventViewer
File MIME type: text/plain
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.23