/[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.1 - (hide annotations) (download)
Fri Jul 14 14:18:04 2006 UTC (18 years, 5 months ago) by mocchiut
Branch: MAIN
CVS Tags: v2r00beta
New _BETA_ and buggy version

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

  ViewVC Help
Powered by ViewVC 1.1.23