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

  ViewVC Help
Powered by ViewVC 1.1.23