/[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.3 - (hide annotations) (download)
Thu Mar 9 15:50:53 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.2: +1573 -474 lines
File MIME type: text/plain
Added GUI, read tracker output from software v3r02, S4/ND in scale, many bugs fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23