/[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.19 - (hide annotations) (download)
Tue Apr 17 16:05:21 2007 UTC (17 years, 7 months ago) by mocchiut
Branch: MAIN
CVS Tags: v2r01
Changes since 1.18: +12 -6 lines
Strange bug (lead to crash) which appears using ROOT >= 5.14 fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23