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

  ViewVC Help
Powered by ViewVC 1.1.23