/[PAMELA software]/eventviewer/flight/src/FEVdetector.cpp
ViewVC logotype

Annotation of /eventviewer/flight/src/FEVdetector.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Tue Aug 1 08:39:40 2006 UTC (18 years, 4 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +4 -2 lines
Tofpos S12 not shown + palette bug fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23