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

  ViewVC Help
Powered by ViewVC 1.1.23