/[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.17 - (hide annotations) (download)
Tue Mar 20 15:22:00 2007 UTC (17 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.16: +1 -47 lines
Small bug fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23