/[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.30 - (hide annotations) (download)
Fri Oct 2 11:12:41 2009 UTC (15 years, 3 months ago) by mocchiut
Branch: MAIN
Changes since 1.29: +9 -8 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.15 Int_t numtr = 1;
2779 mocchiut 1.30 //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.30 if ( numtr >= (repuntiltr+1-1) ) repeat = false;
2814 mocchiut 1.1 //
2815 mocchiut 1.16 // 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     L2->GetToFLevel2()->GetMatrix(myseq,adc,tdc);
2834     //
2835     // printf(" qua \n");
2836 mocchiut 1.1 //
2837     for ( Int_t i = 0; i<8; i++ ) {
2838     if ( adc[ch11a[i]][hb11a[i]] < 1000. ){
2839     ms11a[i] = adc[ch11a[i]][hb11a[i]];
2840     };
2841     if ( adc[ch11b[i]][hb11b[i]] < 1000. ){
2842     ms11b[i] = adc[ch11b[i]][hb11b[i]];
2843     };
2844 mocchiut 1.2 // xp11[i] = 0.;
2845 mocchiut 1.1 };
2846    
2847     Int_t nmtof = 0;
2848     Float_t mtof = 0.;
2849     var.beta[4] = 0.;
2850     if ( ptt->beta[12] != 0. && ptt->beta[12] != 100. ){
2851     var.beta[4] = ptt->beta[12];
2852     } else {
2853     for (Int_t tf = 0; tf<12 ;tf++){
2854     if ( ptt->beta[tf] != 0. && ptt->beta[tf] != 100.){
2855     mtof += ptt->beta[tf];
2856     nmtof++;
2857     };
2858     };
2859     if ( nmtof ){
2860     var.beta[4] = mtof/nmtof;
2861     } else {
2862     var.beta[4] = 0.;
2863     };
2864     };
2865     ii = 2;
2866     //
2867     for ( Int_t i = 0; i<8; i++ ) {
2868     if ( adc[ch11a[i]][hb11a[i]] < 1000. ){
2869     ms11a[i] = adc[ch11a[i]][hb11a[i]];
2870     };
2871     if ( adc[ch11b[i]][hb11b[i]] < 1000. ){
2872     ms11b[i] = adc[ch11b[i]][hb11b[i]];
2873     };
2874     xp11[i] = 0.;
2875     };
2876     //
2877     xp11[0] = ptt->ytofpos[0];
2878     //
2879     for ( Int_t i = 0; i<6; i++ ) {
2880     if ( adc[ch12a[i]][hb12a[i]] < 1000. ) ms12a[i] = adc[ch12a[i]][hb12a[i]];
2881     if ( adc[ch12b[i]][hb12b[i]] < 1000. ) ms12b[i] = adc[ch12b[i]][hb12b[i]];
2882     xp12[i] = 0.;
2883     };
2884 mocchiut 1.2 //
2885 mocchiut 1.1 xp12[0] = ptt->xtofpos[0];
2886     //
2887     ii = 2;
2888     for ( Int_t i = 0; i<2; i++ ) {
2889     ii--;
2890     if ( adc[ch21a[i]][hb21a[i]] < 1000. ) ms21a[ii] = adc[ch21a[i]][hb21a[i]];
2891     if ( adc[ch21b[i]][hb21b[i]] < 1000. ) ms21b[ii] = adc[ch21b[i]][hb21b[i]];
2892 mocchiut 1.2 xp21[i] = 0.;
2893 mocchiut 1.1 };
2894     xp21[0] = ptt->xtofpos[1];
2895     //
2896     for ( Int_t i = 0; i<2; i++ ) {
2897     if ( adc[ch22a[i]][hb22a[i]] < 1000. ) ms22a[i] = adc[ch22a[i]][hb22a[i]];
2898     if ( adc[ch22b[i]][hb22b[i]] < 1000. ) ms22b[i] = adc[ch22b[i]][hb22b[i]];
2899     xp22[i] = 0.;
2900     };
2901     xp22[0] = ptt->ytofpos[1];
2902     //
2903     for ( Int_t i = 0; i<3; i++ ) {
2904     if ( adc[ch31a[i]][hb31a[i]] < 1000. ) ms31a[i] = adc[ch31a[i]][hb31a[i]];
2905     if ( adc[ch31b[i]][hb31b[i]] < 1000. ) ms31b[i] = adc[ch31b[i]][hb31b[i]];
2906     xp31[i] = 0.;
2907     };
2908     xp31[0] = ptt->ytofpos[2];
2909     //
2910     for ( Int_t i = 0; i<3; i++ ) {
2911     if ( adc[ch32a[i]][hb32a[i]] < 1000. ) ms32a[i] = adc[ch32a[i]][hb32a[i]];
2912     if ( adc[ch32b[i]][hb32b[i]] < 1000. ) ms32b[i] = adc[ch32b[i]][hb32b[i]];
2913     xp32[i] = 0.;
2914     };
2915     xp32[0] = ptt->xtofpos[2];
2916     //
2917     numtr++;
2918     //numtr = repuntil+10;
2919     // repeat = false;
2920     // printf("pre drawingdrawing... %i %i\n",numtr,ptt->trkseqno);
2921     //
2922     }; // end if level2
2923     //
2924     //
2925     // drawtof:
2926     //
2927     // printf("drawingdrawing... %i \n",repuntil);
2928     //
2929     Int_t colo = 0;
2930     Int_t ocolo = 0;
2931     Float_t xs2x = var.xxvc;
2932     Float_t ys2x = var.yxvc + 0.36*var.sfy;
2933     Float_t xs2y = var.xyvc;
2934     Float_t ys2y = var.yyvc + 0.36*var.sfy;
2935     Float_t ws2 = 0.005;
2936     Float_t ws13 = 0.007;
2937     //
2938     // S11 X-view
2939     //
2940     Float_t s11p = 0.051;
2941     ocolo = 10;
2942     TPolyLine *ftof11x[8];
2943     for ( Int_t j=0; j<8; j++){
2944     Float_t nxc1[5]={ (s11p*j), (s11p*j), s11p*(j+1), s11p*(j+1), (s11p*j)};
2945     Float_t nyc1[5]={ 0., ws13, ws13, 0., 0.};
2946     Float_t nxc[5];
2947     Float_t nyc[5];
2948     for (Int_t i = 0; i<5 ; i++) {
2949     nxc[i]= xs2x + (-0.204+nxc1[i])*var.sfx;
2950     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
2951     };
2952     ftof11x[j] = new TPolyLine(5,nxc,nyc);
2953     ftof11x[j]->SetLineColor(1);
2954     if ( var.bw ){
2955     colo = -1;
2956     } else {
2957     colo = 1;
2958     };
2959     if ( level.file == -1 ){
2960     ColorMIP(ms11a[j]+ms11b[j],colo);
2961     } else {
2962     ColorTOFMIP(ms11a[j]+ms11b[j],colo);
2963     };
2964     //
2965     if ( colo != 10 ) ocolo = colo;
2966     //
2967     ftof11x[j]->SetFillColor(colo);
2968     ftof11x[j]->SetLineWidth(1);
2969     ftof11x[j]->Draw("f");
2970     ftof11x[j]->Draw();
2971     };
2972     //
2973     // S11 Y-view
2974     //
2975     Float_t nxc1[5]={ -0.165, 0.165, 0.165, -0.165, -0.165};
2976     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
2977     Float_t nxc[5];
2978     Float_t nyc[5];
2979     for (Int_t i = 0; i<5 ; i++) {
2980     nxc[i]= xs2y + nxc1[i]*var.sfx;
2981     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
2982     };
2983     TPolyLine *ftof11y = new TPolyLine(5,nxc,nyc);
2984     ftof11y->SetFillStyle(4000);
2985     ftof11y->SetFillColor(0);
2986     ftof11y->SetLineColor(1);
2987     ftof11y->SetLineWidth(1);
2988     ftof11y->Draw("f");
2989     ftof11y->Draw();
2990     TPolyLine *sftof11[8];
2991     tt = 1;
2992 mocchiut 1.25 rj=1;
2993     if ( level.file == -1 ){
2994     tt = 8;
2995     rj = 8;
2996     };
2997 mocchiut 1.1 for ( Int_t j=0; j<tt; j++){
2998 mocchiut 1.25 rj--;
2999     if ( (mt11[0][rj]<4095. || mt11[1][rj]<4095.)){
3000 mocchiut 1.1 if ( ocolo == 10 ) ocolo = noadc;
3001 mocchiut 1.25 Float_t lowp = -(xp11[rj]+E11[rj])/100.;
3002     Float_t higp = -(xp11[rj]-E11[rj])/100.;
3003 mocchiut 1.1 if ( lowp < -0.164 ) lowp = -0.164;
3004     if ( higp > 0.164 ) higp = 0.164;
3005 mocchiut 1.25 if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp11[rj] != 0.))){
3006 mocchiut 1.1 Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3007     Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015};
3008     Float_t nxc[5];
3009     Float_t nyc[5];
3010     for (Int_t i = 0; i<5 ; i++) {
3011     nxc[i]= xs2y + nxc1[i]*var.sfx;
3012     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
3013     };
3014     sftof11[j] = new TPolyLine(5,nxc,nyc);
3015     sftof11[j]->SetLineColor(ocolo);
3016     sftof11[j]->SetFillColor(ocolo);
3017     sftof11[j]->SetLineWidth(1);
3018     sftof11[j]->Draw("f");
3019     sftof11[j]->Draw();
3020     };
3021     };
3022     };
3023    
3024     //
3025     // S12 Y-view
3026     //
3027     Float_t s12p = 0.055;
3028     ocolo = 10;
3029     TPolyLine *ftof12y[6];
3030 mocchiut 1.25 rj = 6;
3031 mocchiut 1.1 for ( Int_t j=0; j<6; j++){
3032 mocchiut 1.25 rj--;
3033 mocchiut 1.1 Float_t nxc1[5]={ (s12p*j), (s12p*j), s12p*(j+1), s12p*(j+1), (s12p*j)};
3034     Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13};
3035     Float_t nxc[5];
3036     Float_t nyc[5];
3037     for (Int_t i = 0; i<5 ; i++) {
3038     nxc[i]= xs2y + (-0.165+nxc1[i])*var.sfx;
3039     nyc[i] = ys2y + (0.295+nyc1[i])*var.sfy;
3040     };
3041     ftof12y[j] = new TPolyLine(5,nxc,nyc);
3042     ftof12y[j]->SetLineColor(1);
3043     if ( var.bw ){
3044     colo = -1;
3045     } else {
3046     colo = 1;
3047     };
3048     if ( level.file == -1 ){
3049 mocchiut 1.25 ColorMIP(ms12a[rj]+ms12b[rj],colo);
3050 mocchiut 1.1 } else {
3051 mocchiut 1.25 ColorTOFMIP(ms12a[rj]+ms12b[rj],colo);
3052 mocchiut 1.1 };
3053     //
3054     if ( colo != 10 ) ocolo = colo;
3055     //
3056     ftof12y[j]->SetFillColor(colo);
3057     ftof12y[j]->SetLineWidth(1);
3058     ftof12y[j]->Draw("f");
3059     ftof12y[j]->Draw();
3060     };
3061     //
3062     // S12 X-view
3063     //
3064     if ( true ){
3065     Float_t nxc1[5]={ -0.204, 0.204, 0.204, -0.204, -0.204};
3066     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
3067     Float_t nxc[5];
3068     Float_t nyc[5];
3069     for (Int_t i = 0; i<5 ; i++) {
3070     nxc[i]= xs2x + nxc1[i]*var.sfx;
3071     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
3072     };
3073     TPolyLine *ftof12x = new TPolyLine(5,nxc,nyc);
3074     ftof12x->SetLineColor(1);
3075     ftof12x->SetFillStyle(4000);
3076     ftof12x->SetFillColor(0);
3077     ftof12x->SetLineWidth(1);
3078     ftof12x->Draw("f");
3079     ftof12x->Draw();
3080     TPolyLine *sftof12[6];
3081     tt = 1;
3082     if ( level.file == -1 ) tt = 6;
3083     for (Int_t j=0; j<tt; j++){
3084     // for ( Int_t j=0; j<6; j++){
3085     if ( (mt12[0][j]<4095. || mt12[1][j]<4095.) ){
3086     if ( ocolo == 10 ) ocolo = noadc;
3087     Float_t lowp = (xp12[j]-E12[j])/100.;
3088     Float_t higp = (xp12[j]+E12[j])/100.;
3089     if ( lowp < -0.203 ) lowp = -0.203;
3090     if ( higp > 0.203 ) higp = 0.203;
3091     if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp12[j] != 0.))){
3092     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3093     Float_t nyc1[5]={ -0.0015, -0.0015, -ws13+0.0015, -ws13+0.0015, -0.0015};
3094     Float_t nxc[5];
3095     Float_t nyc[5];
3096     for (Int_t i = 0; i<5 ; i++) {
3097     nxc[i]= xs2x + nxc1[i]*var.sfx;
3098     nyc[i] = ys2x + (0.295+nyc1[i])*var.sfy;
3099     };
3100     sftof12[j] = new TPolyLine(5,nxc,nyc);
3101     sftof12[j]->SetLineColor(ocolo);
3102     sftof12[j]->SetFillColor(ocolo);
3103     sftof12[j]->SetLineWidth(1);
3104     sftof12[j]->Draw("f");
3105     sftof12[j]->Draw();
3106     };
3107     };
3108     };
3109     };
3110     //
3111    
3112     //
3113     // S21 Y-view
3114     //
3115     Float_t s21p = 0.075;
3116     ocolo = 10;
3117     TPolyLine *ftof21y[2];
3118 mocchiut 1.25 rj=2;
3119 mocchiut 1.1 for ( Int_t j=0; j<2; j++){
3120 mocchiut 1.25 rj--;
3121 mocchiut 1.1 Float_t nxc1[5]={ s21p*(j-1), s21p*(j-1), s21p*j,s21p*j, s21p*(j-1)};
3122     Float_t nyc1[5]={ 0., ws2, ws2, 0., 0.};
3123     Float_t nxc[5];
3124     Float_t nyc[5];
3125     for (Int_t i = 0; i<5 ; i++) {
3126     nxc[i]= xs2y + nxc1[i]*var.sfx;
3127     nyc[i] = ys2y + nyc1[i]*var.sfy;
3128     };
3129     ftof21y[j] = new TPolyLine(5,nxc,nyc);
3130     ftof21y[j]->SetLineColor(1);
3131     if ( var.bw ){
3132     colo = -1;
3133     } else {
3134     colo = 1;
3135     };
3136     if ( level.file == -1 ){
3137 mocchiut 1.25 ColorMIP(ms21a[rj]+ms21b[rj],colo);
3138 mocchiut 1.1 } else {
3139 mocchiut 1.25 ColorTOFMIP(ms21a[rj]+ms21b[rj],colo);
3140 mocchiut 1.1 };
3141     //
3142     if ( colo != 10 ) ocolo = colo;
3143     //
3144     ftof21y[j]->SetFillColor(colo);
3145     ftof21y[j]->SetLineWidth(1);
3146     ftof21y[j]->Draw("f");
3147     ftof21y[j]->Draw();
3148     };
3149     //
3150     // S21 X-view
3151     //
3152     if ( true ){
3153     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
3154     Float_t nyc1[5]={ 0., 0., ws2, ws2, 0.};
3155     Float_t nxc[5];
3156     Float_t nyc[5];
3157     for (Int_t i = 0; i<5 ; i++) {
3158     nxc[i]= xs2x + nxc1[i]*var.sfx;
3159     nyc[i] = ys2x + nyc1[i]*var.sfy;
3160     };
3161     TPolyLine *ftof21x = new TPolyLine(5,nxc,nyc);
3162     ftof21x->SetLineColor(1);
3163     ftof21x->SetFillStyle(4000);
3164     ftof21x->SetFillColor(0);
3165     ftof21x->SetLineWidth(1);
3166     ftof21x->Draw("f");
3167     ftof21x->Draw();
3168     TPolyLine *sftof21[2];
3169     tt = 1;
3170     if ( level.file == -1 ) tt = 2;
3171     for ( Int_t j=0; j<tt; j++){
3172     // for ( Int_t j=0; j<2; j++){
3173     if ( (mt21[0][j]<4095. || mt21[1][j]<4095.) ){
3174     if ( ocolo == 10 ) ocolo = noadc;
3175     Float_t lowp = (xp21[j]-E21[j])/100.;
3176     Float_t higp = (xp21[j]+E21[j])/100.;
3177     if ( lowp < -0.089 ) lowp = -0.089;
3178     if ( higp > 0.089 ) higp = 0.089;
3179     if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp21[j] != 0.))){
3180     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3181     Float_t nyc1[5]={ 0.0015, 0.0015, ws2-0.0015, ws2-0.0015, 0.};
3182     Float_t nxc[5];
3183     Float_t nyc[5];
3184     for (Int_t i = 0; i<5 ; i++) {
3185     nxc[i]= xs2x + nxc1[i]*var.sfx;
3186     nyc[i] = ys2x + nyc1[i]*var.sfy;
3187     };
3188     sftof21[j] = new TPolyLine(5,nxc,nyc);
3189     sftof21[j]->SetLineColor(ocolo);
3190     sftof21[j]->SetFillColor(ocolo);
3191     sftof21[j]->SetLineWidth(1);
3192     sftof21[j]->Draw("f");
3193     sftof21[j]->Draw();
3194     };
3195     };
3196     };
3197     };
3198     //
3199    
3200     //
3201     // S22 X-view
3202     //
3203     Float_t s22p = 0.090;
3204     ocolo = 10;
3205     TPolyLine *ftof22x[2];
3206     for ( Int_t j=0; j<2; j++){
3207     Float_t nxc1[5]={ s22p*(j-1), s22p*(j-1), s22p*j, s22p*j, s22p*(j-1)};
3208     Float_t nyc1[5]={ -ws2, 0., 0., -ws2, -ws2};
3209     Float_t nxc[5];
3210     Float_t nyc[5];
3211     for (Int_t i = 0; i<5 ; i++) {
3212     nxc[i]= xs2x + nxc1[i]*var.sfx;
3213     nyc[i] = ys2x + nyc1[i]*var.sfy;
3214     };
3215     ftof22x[j] = new TPolyLine(5,nxc,nyc);
3216     ftof22x[j]->SetLineColor(1);
3217     if ( var.bw ){
3218     colo = -1;
3219     } else {
3220     colo = 1;
3221     };
3222     if ( level.file == -1 ){
3223     ColorMIP(ms22a[j]+ms22b[j],colo);
3224     } else {
3225     ColorTOFMIP(ms22a[j]+ms22b[j],colo);
3226     };
3227     //
3228     if ( colo != 10 ) ocolo = colo;
3229     //
3230     ftof22x[j]->SetFillColor(colo);
3231     ftof22x[j]->SetLineWidth(1);
3232     ftof22x[j]->Draw("f");
3233     ftof22x[j]->Draw();
3234     };
3235     //
3236     // S22 Y-view
3237     //
3238     if ( true ){
3239     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
3240     Float_t nyc1[5]={ 0., 0., -ws2, -ws2, 0.};
3241     Float_t nxc[5];
3242     Float_t nyc[5];
3243     for (Int_t i = 0; i<5 ; i++) {
3244     nxc[i]= xs2y + nxc1[i]*var.sfx;
3245     nyc[i] = ys2y + nyc1[i]*var.sfy;
3246     };
3247     TPolyLine *ftof22y = new TPolyLine(5,nxc,nyc);
3248     ftof22y->SetLineColor(1);
3249     ftof22y->SetFillStyle(4000);
3250     ftof22y->SetFillColor(0);
3251     ftof22y->SetLineWidth(1);
3252     ftof22y->Draw("f");
3253     ftof22y->Draw();
3254     TPolyLine *sftof22[2];
3255     tt = 1;
3256 mocchiut 1.25 rj = 1;
3257     if ( level.file == -1 ){
3258     tt = 2;
3259     rj = 2;
3260     };
3261 mocchiut 1.1 for (Int_t j=0; j<tt; j++){
3262 mocchiut 1.25 rj--;
3263 mocchiut 1.1 // for ( Int_t j=0; j<2; j++){
3264 mocchiut 1.25 if ( (mt22[0][rj]<4095. || mt22[1][rj]<4095.) ){
3265 mocchiut 1.1 if ( ocolo == 10 ) ocolo = noadc;
3266 mocchiut 1.25 Float_t lowp = -(xp22[rj]+E22[rj])/100.;
3267     Float_t higp = -(xp22[rj]-E22[rj])/100.;
3268 mocchiut 1.1 if ( lowp < -0.074 ) lowp = -0.074;
3269     if ( higp > 0.074 ) higp = 0.074;
3270 mocchiut 1.25 if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp22[rj] != 0.))){
3271 mocchiut 1.1 Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3272     Float_t nyc1[5]={ -0.0015, -0.0015, -ws2+0.0015, -ws2+0.0015, -0.0015};
3273     Float_t nxc[5];
3274     Float_t nyc[5];
3275     for (Int_t i = 0; i<5 ; i++) {
3276     nxc[i]= xs2y + nxc1[i]*var.sfx;
3277     nyc[i] = ys2y + nyc1[i]*var.sfy;
3278     };
3279     sftof22[j] = new TPolyLine(5,nxc,nyc);
3280     sftof22[j]->SetLineColor(ocolo);
3281     sftof22[j]->SetFillColor(ocolo);
3282     sftof22[j]->SetLineWidth(1);
3283     sftof22[j]->Draw("f");
3284     sftof22[j]->Draw();
3285     };
3286     };
3287     };
3288     };
3289     //
3290 mocchiut 1.25 //daquiinbasso
3291 mocchiut 1.1 //
3292     // S31 X-view
3293     //
3294     Float_t s31p = 0.060;
3295     ocolo = 10;
3296     TPolyLine *ftof31x[3];
3297     for ( Int_t j=0; j<3; j++){
3298     Float_t nxc1[5]={ (s31p*j), (s31p*j), s31p*(j+1), s31p*(j+1), (s31p*j)};
3299     Float_t nyc1[5]={ 0., ws13, ws13, 0., 0.};
3300     Float_t nxc[5];
3301     Float_t nyc[5];
3302     for (Int_t i = 0; i<5 ; i++) {
3303     nxc[i]= xs2x + (-0.090+nxc1[i])*var.sfx;
3304     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
3305     };
3306     ftof31x[j] = new TPolyLine(5,nxc,nyc);
3307     ftof31x[j]->SetLineColor(1);
3308     if ( var.bw ){
3309     colo = -1;
3310     } else {
3311     colo = 1;
3312     };
3313     if ( level.file == -1 ){
3314     ColorMIP(ms31a[j]+ms31b[j],colo);
3315     } else {
3316     ColorTOFMIP(ms31a[j]+ms31b[j],colo);
3317     };
3318     //
3319     if ( colo != 10 ) ocolo = colo;
3320     //
3321     ftof31x[j]->SetFillColor(colo);
3322     ftof31x[j]->SetLineWidth(1);
3323     ftof31x[j]->Draw("f");
3324     ftof31x[j]->Draw();
3325     };
3326     //
3327     // S31 Y-view
3328     //
3329     if ( true ){
3330     Float_t nxc1[5]={ -0.075, 0.075, 0.075, -0.075, -0.075};
3331     Float_t nyc1[5]={ 0., 0., ws13, ws13, 0.};
3332     Float_t nxc[5];
3333     Float_t nyc[5];
3334     for (Int_t i = 0; i<5 ; i++) {
3335     nxc[i]= xs2y + nxc1[i]*var.sfx;
3336     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
3337     };
3338     TPolyLine *ftof31y = new TPolyLine(5,nxc,nyc);
3339     ftof31y->SetLineColor(1);
3340     ftof31y->SetFillStyle(4000);
3341     ftof31y->SetFillColor(0);
3342     ftof31y->SetLineWidth(1);
3343     ftof31y->Draw("f");
3344     ftof31y->Draw();
3345     TPolyLine *sftof31[3];
3346     tt = 1;
3347 mocchiut 1.25 rj = 1;
3348     if ( level.file == -1 ){
3349     tt = 3;
3350     rj = 3;
3351     };
3352 mocchiut 1.1 for (Int_t j=0; j<tt; j++){
3353 mocchiut 1.25 rj--;
3354 mocchiut 1.1 // for ( Int_t j=0; j<3; j++){
3355 mocchiut 1.25 if ( (mt31[0][rj]<4095. || mt31[1][rj]<4095.)){
3356 mocchiut 1.1 if ( ocolo == 10 ) ocolo = noadc;
3357 mocchiut 1.25 Float_t lowp = -(xp31[rj]+E31[rj])/100.;
3358     Float_t higp = -(xp31[rj]-E31[rj])/100.;
3359 mocchiut 1.1 if ( lowp < -0.074 ) lowp = -0.074;
3360     if ( higp > 0.074 ) higp = 0.074;
3361 mocchiut 1.25 if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp31[rj] != 0.))){
3362 mocchiut 1.1 Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3363     Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015};
3364     Float_t nxc[5];
3365     Float_t nyc[5];
3366     for (Int_t i = 0; i<5 ; i++) {
3367     nxc[i]= xs2y + nxc1[i]*var.sfx;
3368     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
3369     };
3370     sftof31[j] = new TPolyLine(5,nxc,nyc);
3371     sftof31[j]->SetLineColor(ocolo);
3372     sftof31[j]->SetFillColor(ocolo);
3373     sftof31[j]->SetLineWidth(1);
3374     sftof31[j]->Draw("f");
3375     sftof31[j]->Draw();
3376     };
3377     };
3378     };
3379     };
3380     //
3381    
3382     //
3383     // S32 Y-view
3384     //
3385     Float_t s32p = 0.050;
3386     ocolo = 10;
3387     TPolyLine *ftof32y[3];
3388 mocchiut 1.25 rj = 3;
3389 mocchiut 1.1 for ( Int_t j=0; j<3; j++){
3390 mocchiut 1.25 rj--;
3391 mocchiut 1.1 Float_t nxc1[5]={ (s32p*j), (s32p*j), s32p*(j+1),s32p*(j+1), (s32p*j)};
3392     Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13};
3393     Float_t nxc[5];
3394     Float_t nyc[5];
3395     for (Int_t i = 0; i<5 ; i++) {
3396     nxc[i]= xs2y + (-0.075+nxc1[i])*var.sfx;
3397     nyc[i] = ys2y + (-0.488+nyc1[i])*var.sfy;
3398     };
3399     ftof32y[j] = new TPolyLine(5,nxc,nyc);
3400     ftof32y[j]->SetLineColor(1);
3401     if ( var.bw ){
3402     colo = -1;
3403     } else {
3404     colo = 1;
3405     };
3406     if ( level.file == -1 ){
3407 mocchiut 1.25 ColorMIP(ms32a[rj]+ms32b[rj],colo);
3408 mocchiut 1.1 } else {
3409 mocchiut 1.25 ColorTOFMIP(ms32a[rj]+ms32b[rj],colo);
3410 mocchiut 1.1 };
3411     //
3412     if ( colo != 10 ) ocolo = colo;
3413     //
3414     ftof32y[j]->SetFillColor(colo);
3415     ftof32y[j]->SetLineWidth(1);
3416     ftof32y[j]->Draw("f");
3417     ftof32y[j]->Draw();
3418     };
3419     //
3420     // S32 X-view
3421     //
3422     if ( true ){
3423     Float_t nxc1[5]={ -0.09, 0.09, 0.09, -0.09, -0.09};
3424     Float_t nyc1[5]={ 0., 0., -ws13, -ws13, 0.};
3425     Float_t nxc[5];
3426     Float_t nyc[5];
3427     for (Int_t i = 0; i<5 ; i++) {
3428     nxc[i]= xs2x + nxc1[i]*var.sfx;
3429     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
3430     };
3431     TPolyLine *ftof32x = new TPolyLine(5,nxc,nyc);
3432     ftof32x->SetLineColor(1);
3433     ftof32x->SetLineWidth(1);
3434     ftof32x->SetFillStyle(4000);
3435     ftof32x->SetFillColor(0);
3436     ftof32x->Draw("f");
3437     ftof32x->Draw();
3438     TPolyLine *sftof32[3];
3439     tt = 1;
3440     if ( level.file == -1 ) tt = 3;
3441     for (Int_t j=0; j<tt; j++){
3442     // for ( Int_t j=0; j<3; j++){
3443     if ( (mt32[0][j]<4095. || mt32[1][j]<4095.) ){
3444     if ( ocolo == 10 ) ocolo = noadc;
3445     Float_t lowp = (xp32[j]-E32[j])/100.;
3446     Float_t higp = (xp32[j]+E32[j])/100.;
3447     if ( lowp < -0.089 ) lowp = -0.089;
3448     if ( higp > 0.089 ) higp = 0.089;
3449     if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp32[j] != 0.))){
3450     Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp};
3451     Float_t nyc1[5]={ -0.0015, -0.0015, -ws13+0.0015, -ws13+0.0015, -0.0015};
3452     Float_t nxc[5];
3453     Float_t nyc[5];
3454     for (Int_t i = 0; i<5 ; i++) {
3455     nxc[i]= xs2x + nxc1[i]*var.sfx;
3456     nyc[i] = ys2x + (-0.488+nyc1[i])*var.sfy;
3457     };
3458     sftof32[j] = new TPolyLine(5,nxc,nyc);
3459     sftof32[j]->SetLineColor(ocolo);
3460     sftof32[j]->SetFillColor(ocolo);
3461     sftof32[j]->SetLineWidth(1);
3462     sftof32[j]->Draw("f");
3463     sftof32[j]->Draw();
3464     };
3465     };
3466     };
3467     };
3468     //
3469     if ( level.file == -1 || numtr >= repuntil ) repeat = false;
3470     //
3471     };
3472     //
3473     }
3474    
3475    
3476     void FEVdetector::ShowAC(){
3477     //
3478     //
3479     //
3480     if ( !var.AC ) return;
3481     //
3482     Int_t hitmapA = 0;
3483     Int_t hitmapB = 0;
3484     Int_t hitstatusA = 0;
3485     Int_t hitstatusB = 0;
3486     //
3487     // level0 and level-1 do not give infos about out of trigger events
3488     //
3489     if ( level.file == 0 || level.file == -1 ){
3490     hitmapA = ace->hitmap[0];
3491     hitmapB = ace->hitmap[1];
3492     hitstatusA = 65535;
3493     hitstatusB = 65535;
3494     };
3495     //
3496     // full infos from ac
3497     //
3498     if ( level.file == 2 ){
3499 mocchiut 1.6 hitmapA = L2->GetAcLevel2()->hitmap[0];
3500     hitmapB = L2->GetAcLevel2()->hitmap[1];
3501     hitstatusA = L2->GetAcLevel2()->hitstatus[0];
3502     hitstatusB = L2->GetAcLevel2()->hitstatus[1];
3503 mocchiut 1.1 };
3504     //
3505     //
3506     //
3507     Float_t cas1 = 0.;
3508     Float_t cas2 = 0.;
3509     Float_t cas3 = 0.;
3510     Float_t cas4 = 0.;
3511     Float_t cas1b = 0.;
3512     Float_t cas2b = 0.;
3513     Float_t cas3b = 0.;
3514     Float_t cas4b = 0.;
3515     //
3516     Float_t cat1 = 0.;
3517     Float_t cat2 = 0.;
3518     Float_t cat3 = 0.;
3519     Float_t cat4 = 0.;
3520     Float_t cat1b = 0.;
3521     Float_t cat2b = 0.;
3522     Float_t cat3b = 0.;
3523     Float_t cat4b = 0.;
3524     //
3525     Float_t card1 = 0.;
3526     Float_t card2 = 0.;
3527     Float_t card3 = 0.;
3528     Float_t card4 = 0.;
3529     Float_t card1b = 0.;
3530     Float_t card2b = 0.;
3531     Float_t card3b = 0.;
3532     Float_t card4b = 0.;
3533     //
3534     Float_t intime = -0.25;
3535     Float_t outtime = -0.375;
3536     if ( var.bw ){
3537     intime = -0.25;
3538     outtime = -0.375;
3539     } else {
3540     intime = 1.;
3541     outtime = -4.;
3542     };
3543     //
3544     // main board
3545     //
3546     if ( hitmapA & (1<<0) ) {
3547     card4 = intime;
3548     if ( !(hitstatusA & (1<<0)) ) card4 = outtime ;
3549     var.hcard++;
3550     }
3551     if ( hitmapA & (1<<1) ) {
3552     cat2 = intime;
3553     if ( !(hitstatusA & (1<<1)) ) cat2 = outtime ;
3554     var.hcat++;
3555     }
3556     if ( hitmapA & (1<<2) ) {
3557     cas1 = intime;
3558     if ( !(hitstatusA & (1<<2)) ) cas1 = outtime ;
3559     var.hcas++;
3560     }
3561     //
3562     if ( hitmapA & (1<<4) ) {
3563     card2 = intime;
3564     if ( !(hitstatusA & (1<<4)) ) card2 = outtime ;
3565     var.hcard++;
3566     }
3567     if ( hitmapA & (1<<5) ) {
3568     cat4 = intime;
3569     if ( !(hitstatusA & (1<<5)) ) cat4 = outtime ;
3570     var.hcat++;
3571     }
3572     if ( hitmapA & (1<<6) ) {
3573     cas4 = intime;
3574     if ( !(hitstatusA & (1<<6)) ) cas4 = outtime ;
3575     var.hcas++;
3576     }
3577     //
3578     if ( hitmapA & (1<<8) ) {
3579     card3 = intime;
3580     if ( !(hitstatusA & (1<<8)) ) card3 = outtime ;
3581     var.hcard++;
3582     }
3583     if ( hitmapA & (1<<9) ) {
3584     cat3 = intime;
3585     if ( !(hitstatusA & (1<<9)) ) cat3 = outtime ;
3586     var.hcat++;
3587     }
3588     if ( hitmapA & (1<<10) ) {
3589     cas3 = intime;
3590     if ( !(hitstatusA & (1<<10)) ) cas3 = outtime ;
3591     var.hcas++;
3592     }
3593     //
3594     if ( hitmapA & (1<<12) ) {
3595     card1 = intime;
3596     if ( !(hitstatusA & (1<<12)) ) card1 = outtime ;
3597     var.hcard++;
3598     }
3599     if ( hitmapA & (1<<13) ) {
3600     cat1 = intime;
3601     if ( !(hitstatusA & (1<<13)) ) cat1 = outtime ;
3602     var.hcat++;
3603     }
3604     if ( hitmapA & (1<<14) ) {
3605     cas2 = intime;
3606     if ( !(hitstatusA & (1<<14)) ) cas2 = outtime ;
3607     var.hcas++;
3608     }
3609     //
3610     // extra board
3611     //
3612     if ( hitmapB & (1<<0) ) {
3613     card4b = intime;
3614     if ( !(hitstatusB & (1<<0)) ) card4b = outtime ;
3615     var.hcard++;
3616     }
3617     if ( hitmapB & (1<<1) ) {
3618     cat2b = intime;
3619     if ( !(hitstatusB & (1<<1)) ) cat2b = outtime ;
3620     var.hcat++;
3621     }
3622     if ( hitmapB & (1<<2) ) {
3623     cas1b = intime;
3624     if ( !(hitstatusB & (1<<2)) ) cas1b = outtime;
3625     var.hcas++;
3626     }
3627     //
3628     if ( hitmapB & (1<<4) ) {
3629     card2b = intime;
3630     if ( !(hitstatusB & (1<<4)) ) card2b = outtime ;
3631     var.hcard++;
3632     }
3633     if ( hitmapB & (1<<5) ) {
3634     cat4b = intime;
3635     if ( !(hitstatusB & (1<<5)) ) cat4b = outtime ;
3636     var.hcat++;
3637     }
3638     if ( hitmapB & (1<<6) ) {
3639     cas4b = intime;
3640     if ( !(hitstatusB & (1<<6)) ) cas4b = outtime ;
3641     var.hcas++;
3642     }
3643     //
3644     if ( hitmapB & (1<<8) ) {
3645     card3b = intime;
3646     if ( !(hitstatusB & (1<<8)) ) card3b = outtime ;
3647     var.hcard++;
3648     }
3649     if ( hitmapB & (1<<9) ) {
3650     cat3b = intime;
3651     if ( !(hitstatusB & (1<<9)) ) cat3b = outtime ;
3652     var.hcat++;
3653     }
3654     if ( hitmapB & (1<<10) ) {
3655     cas3b = intime;
3656     if ( !(hitstatusB & (1<<10)) ) cas3b = outtime ;
3657     var.hcas++;
3658     }
3659     //
3660     if ( hitmapB & (1<<12) ) {
3661     card1b = intime;
3662     if ( !(hitstatusB & (1<<12)) ) card1b = outtime ;
3663     var.hcard++;
3664     }
3665     if ( hitmapB & (1<<13) ) {
3666     cat1b = intime;
3667     if ( !(hitstatusB & (1<<13)) ) cat1b = outtime ;
3668     var.hcat++;
3669     }
3670     if ( hitmapB & (1<<14) ) {
3671     cas2b = intime;
3672     if ( !(hitstatusB & (1<<14)) ) cas2b = outtime ;
3673     var.hcas++;
3674     };
3675     Int_t colo = 0;
3676     //
3677     // CAS height and width
3678     //
3679     Float_t csh = 0.194*var.sfy;
3680     Float_t csw = 0.008*var.sfx;
3681     Float_t ctw = 0.008;
3682    
3683     //
3684     // CAS2 -0.039-0.081 |TRX TRY
3685     //
3686     if ( true ){
3687     Float_t xofs = var.xxvc -(0.039+0.081+0.0273)*var.sfx;
3688     Float_t yofs = var.yxvc + 0.09*var.sfy ;
3689     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
3690     Double_t y[4] = {yofs-csh,yofs-csh,yofs+csh,yofs-csh};
3691     TPolyLine *fcas2 = new TPolyLine(4,x,y);
3692     fcas2->SetLineColor(1);
3693     colo = (int)(10. - cas2 * 8.);
3694     fcas2->SetFillColor(colo);
3695     fcas2->SetLineWidth(1);
3696     fcas2->Draw("f");
3697     fcas2->Draw();
3698     };
3699     if ( true ){
3700     Float_t xofs = var.xxvc -(0.039 +0.081 +0.0273)*var.sfx;
3701     Float_t yofs = var.yxvc + 0.09*var.sfy ;
3702     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
3703     Double_t y[4] = {yofs+csh,yofs-csh,yofs+csh,yofs+csh};
3704     TPolyLine *fcas2b = new TPolyLine(4,x,y);
3705     fcas2b->SetLineColor(1);
3706     colo = (int)(10. - cas2b * 8.);
3707     fcas2b->SetFillColor(colo);
3708     fcas2b->SetLineWidth(1);
3709     fcas2b->Draw("f");
3710     fcas2b->Draw();
3711     };
3712     //
3713     // CAS1 -0.039+0.081 TRX| TRY
3714     //
3715     if ( true ){
3716     Float_t xofs = var.xxvc + (0.039 +0.081+0.0273)*var.sfx +csw;
3717     Float_t yofs = var.yxvc + 0.09*var.sfy ;
3718     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
3719     Double_t y[4] = {yofs-csh,yofs+csh,yofs-csh,yofs-csh};
3720     TPolyLine *fcas1 = new TPolyLine(4,x,y);
3721     fcas1->SetLineColor(1);
3722     colo = (int)(10. - cas1 * 8.);
3723     fcas1->SetFillColor(colo);
3724     fcas1->SetLineWidth(1);
3725     fcas1->Draw("f");
3726     fcas1->Draw();
3727     };
3728     if ( true ){
3729     Float_t xofs = var.xxvc + (0.039 +0.081+0.0273)*var.sfx +csw;
3730     Float_t yofs = var.yxvc + 0.09*var.sfy ;
3731     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
3732     Double_t y[4] = {yofs+csh,yofs+csh,yofs-csh,yofs+csh};
3733     TPolyLine *fcas1b = new TPolyLine(4,x,y);
3734     fcas1b->SetLineColor(1);
3735     colo = (int)(10. - cas1b * 8.);
3736     fcas1b->SetFillColor(colo);
3737     fcas1b->SetLineWidth(1);
3738     fcas1b->Draw("f");
3739     fcas1b->Draw();
3740     };
3741     //
3742     // CAS4 -0.039-0.081 TRX |TRY
3743     //
3744     if ( true ){
3745     Float_t xofs = var.xyvc - (0.048 +0.066 +0.0273)*var.sfx;
3746     Float_t yofs = var.yyvc + 0.09*var.sfy ;
3747     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
3748     Double_t y[4] = {yofs-csh,yofs-csh,yofs+csh,yofs-csh};
3749     TPolyLine *fcas4 = new TPolyLine(4,x,y);
3750     fcas4->SetLineColor(1);
3751     colo = (int)(10. - cas4 * 8.);
3752     fcas4->SetFillColor(colo);
3753     fcas4->SetLineWidth(1);
3754     fcas4->Draw("f");
3755     fcas4->Draw();
3756     };
3757     if ( true ){
3758     Float_t xofs = var.xyvc - (0.048 +0.066 +0.0273)*var.sfx;
3759     Float_t yofs = var.yyvc + 0.09*var.sfy ;
3760     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
3761     Double_t y[4] = {yofs+csh,yofs-csh,yofs+csh,yofs+csh};
3762     TPolyLine *fcas4b = new TPolyLine(4,x,y);
3763     fcas4b->SetLineColor(1);
3764     colo = (int)(10. - cas4b * 8.);
3765     fcas4b->SetFillColor(colo);
3766     fcas4b->SetLineWidth(1);
3767     fcas4b->Draw("f");
3768     fcas4b->Draw();
3769     };
3770    
3771     //
3772     // CAS3 -0.039+0.081 TRX TRY|
3773     //
3774     if ( true ){
3775     Float_t xofs = var.xyvc + (0.048 +0.066+0.0273)*var.sfx +csw;
3776     Float_t yofs = var.yyvc + 0.09*var.sfy ;
3777     Double_t x[4] = {xofs-csw,xofs-csw,xofs,xofs-csw};
3778     Double_t y[4] = {yofs-csh,yofs+csh,yofs-csh,yofs-csh};
3779     TPolyLine *fcas3 = new TPolyLine(4,x,y);
3780     fcas3->SetLineColor(1);
3781     colo = (int)(10. - cas3 * 8.);
3782     fcas3->SetFillColor(colo);
3783     fcas3->SetLineWidth(1);
3784     fcas3->Draw("f");
3785     fcas3->Draw();
3786     };
3787     if ( true ){
3788     Float_t xofs = var.xyvc + (0.048 +0.066+0.0273)*var.sfx +csw;
3789     Float_t yofs = var.yyvc + 0.09*var.sfy ;
3790     Double_t x[4] = {xofs-csw,xofs,xofs,xofs-csw};
3791     Double_t y[4] = {yofs+csh,yofs+csh,yofs-csh,yofs+csh};
3792     TPolyLine *fcas3b = new TPolyLine(4,x,y);
3793     fcas3b->SetLineColor(1);
3794     colo = (int)(10. - cas3b * 8.);
3795     fcas3b->SetFillColor(colo);
3796     fcas3b->SetLineWidth(1);
3797     fcas3b->Draw("f");
3798     fcas3b->Draw();
3799     };
3800    
3801     //
3802     // CAT coordinate system
3803     //
3804     Float_t xcat = var.xcat;
3805     Float_t ycat = var.ycat;
3806     Float_t pmt1 = 0.0356;
3807     Float_t pmt2 = 0.038;
3808     Float_t xpmt1 = -0.149*var.sfx;
3809     Float_t ypmt1 = 0.251*var.sfy;
3810     Float_t apmt1 = atan((11.*var.sfy)/(14.*var.sfx));
3811     Float_t xpmt2 = -0.257*var.sfx;
3812     Float_t ypmt2 = 0.158*var.sfy;
3813     Float_t apmt2 = atan((11.*var.sfx)/(15.*var.sfy));
3814     //
3815     Int_t cattime = 13;
3816     Int_t catnoti = 12;
3817     if ( var.bw ){
3818     cattime = 13;
3819     catnoti = 12;
3820     } else {
3821     cattime = 2;
3822     catnoti = 42;
3823     };
3824     //
3825     if ( true ){
3826     // PMTs
3827     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.};
3828     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.};
3829     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.};
3830     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.};
3831     // SCINTs
3832     Float_t xcc1[10]={-0.149, -0.090165, -0.090165, -0.149, -0.242, -0.257, -0.212, -0.257, -0.242, -0.149};
3833     Float_t ycc1[10]={ 0.169, 0.108165, -0.108165, -0.169, -0.169, -0.158, 0., 0.158, 0.169, 0.169};
3834     Float_t xcc2[10]={-0.149, -0.149, -0.138, 0., 0.138, 0.149, 0.149, 0.090165, -0.090165, -0.149};
3835     Float_t ycc2[10]={ 0.169, 0.251, 0.265, 0.220, 0.265, 0.251, 0.169, 0.108165, 0.108165, 0.169};
3836     //
3837     // CAT sections
3838     //
3839     if ( true ){
3840     Float_t xofs = var.xxvc -0.108165*var.sfx;
3841     Float_t yofs = var.yxvc + 0.3725*var.sfy ;
3842     Double_t xx[5] = {xofs,xofs-0.112*var.sfx,xofs-0.112*var.sfx,xofs,xofs};
3843     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
3844     TPolyLine *fcat3 = new TPolyLine(5,xx,yy);
3845     fcat3->SetLineColor(1);
3846     if ( cat3 != 0. || cat3b != 0. ){
3847     if ( cat3 > 0 || cat3b > 0 || cat3 == -0.25 || cat3b == -0.25 ){
3848     colo = cattime;
3849     } else {
3850     colo = catnoti;
3851     };
3852     } else {
3853     colo = 10;
3854     };
3855     fcat3->SetFillColor(colo);
3856     fcat3->SetLineWidth(1);
3857     fcat3->Draw("f");
3858     fcat3->Draw();
3859     };
3860     if ( true ){
3861     Float_t xofs = var.xxvc +0.108165*var.sfx;
3862     Float_t yofs = var.yxvc + 0.3725 *var.sfy;
3863     Double_t xx[5] = {xofs,xofs+0.112*var.sfx,xofs+0.112*var.sfx,xofs,xofs};
3864     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
3865     TPolyLine *fcat4 = new TPolyLine(5,xx,yy);
3866     fcat4->SetLineColor(1);
3867     if ( cat4 != 0. || cat4b != 0. ){
3868     if ( cat4 > 0 || cat4b > 0 || cat4 == -.25 || cat4b == -.25 ){
3869     colo = cattime;
3870     } else {
3871     colo = catnoti;
3872     };
3873     } else {
3874     colo = 10;
3875     };
3876     fcat4->SetFillColor(colo);
3877     fcat4->SetLineWidth(1);
3878     fcat4->Draw("f");
3879     fcat4->Draw();
3880     };
3881     if ( true ){
3882     Float_t xofs = var.xyvc + 0.090165*var.sfx;
3883     Float_t yofs = var.yyvc + 0.3725*var.sfy ;
3884     Double_t xx[5] = {xofs,xofs+0.122*var.sfx,xofs+0.122*var.sfx,xofs,xofs};
3885     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
3886     TPolyLine *fcat1 = new TPolyLine(5,xx,yy);
3887     fcat1->SetLineColor(1);
3888     if ( cat1 != 0. || cat1b != 0. ){
3889     if ( cat1 > 0 || cat1b > 0 || cat1 ==-.25 || cat1b ==-.25 ){
3890     colo = cattime;
3891     } else {
3892     colo = catnoti;
3893     };
3894     } else {
3895     colo = 10;
3896     };
3897     fcat1->SetFillColor(colo);
3898     fcat1->SetLineWidth(1);
3899     fcat1->Draw("f");
3900     fcat1->Draw();
3901     };
3902     if ( true ){
3903     Float_t xofs = var.xyvc - 0.090165*var.sfx;
3904     Float_t yofs = var.yyvc + 0.3725*var.sfy ;
3905     Double_t xx[5] = {xofs,xofs-0.122*var.sfx,xofs-0.122*var.sfx,xofs,xofs};
3906     Double_t yy[5] = {yofs,yofs,yofs+ctw,yofs+ctw,yofs};
3907     TPolyLine *fcat2 = new TPolyLine(5,xx,yy);
3908     fcat2->SetLineColor(1);
3909     if ( cat2 != 0. || cat2b != 0. ){
3910     if ( cat2 > 0 || cat2b > 0 || cat2 ==-.25 || cat2b ==-.25 ){
3911     colo = cattime;
3912     } else {
3913     colo = catnoti;
3914     };
3915     } else {
3916     colo = 10;
3917     };
3918     fcat2->SetFillColor(colo);
3919     fcat2->SetLineWidth(1);
3920     fcat2->Draw("f");
3921     fcat2->Draw();
3922     };
3923     //
3924     // CAT1
3925     //
3926     Float_t xcc[10];
3927     Float_t ycc[10];
3928     if ( true ){
3929     for (Int_t i = 0; i<10 ; i++) {
3930     xcc[i]= xcat - xcc1[i]*var.sfx;
3931     ycc[i] = ycat + ycc1[i]*var.sfy;
3932     };
3933     TPolyLine *fcat1 = new TPolyLine(10,xcc,ycc);
3934     fcat1->SetLineColor(1);
3935     colo = 10;
3936     if ( cat1 != 0. || cat1b != 0. ) {
3937     if ( cat1 > 0 || cat1b > 0 || cat1 ==-.25 || cat1b ==-.25 ){
3938     colo = cattime;
3939     } else {
3940     colo = catnoti;
3941     };
3942     };
3943     fcat1->SetFillColor(colo);
3944     fcat1->SetLineWidth(1);
3945     fcat1->Draw("f");
3946     fcat1->Draw();
3947     };
3948     //
3949     // CAT2
3950     //
3951     if ( true ){
3952     for (Int_t i = 0; i<10 ; i++) {
3953     xcc[i]= xcat + xcc1[i]*var.sfx;
3954     ycc[i] = ycat + ycc1[i]*var.sfy;
3955     };
3956     TPolyLine *fcat2 = new TPolyLine(10,xcc,ycc);
3957     fcat2->SetLineColor(1);
3958     colo = 10;
3959     if ( cat2 != 0. || cat2b != 0. ) {
3960     if ( cat2 > 0 || cat2b > 0 || cat2 ==-.25 || cat2b ==-.25 ){
3961     colo = cattime;
3962     } else {
3963     colo = catnoti;
3964     };
3965     };
3966     fcat2->SetFillColor(colo);
3967     fcat2->SetLineWidth(1);
3968     fcat2->Draw("f");
3969     fcat2->Draw();
3970     };
3971     //
3972     // CAT3
3973     //
3974     if ( true ){
3975     for (Int_t i = 0; i<10 ; i++) {
3976     xcc[i]= xcat + xcc2[i]*var.sfx;
3977     ycc[i] = ycat - ycc2[i]*var.sfy;
3978     };
3979     TPolyLine *fcat3 = new TPolyLine(10,xcc,ycc);
3980     fcat3->SetLineColor(1);
3981     colo = 10;
3982     if ( cat3 != 0. || cat3b != 0. ) {
3983     if ( cat3 > 0 || cat3b > 0 || cat3 == -.25 || cat3b ==-.25 ){
3984     colo = cattime;
3985     } else {
3986     colo = catnoti;
3987     };
3988     };
3989     fcat3->SetFillColor(colo);
3990     fcat3->SetLineWidth(1);
3991     fcat3->Draw("f");
3992     fcat3->Draw();
3993     };
3994     //
3995     // CAT4
3996     //
3997     if ( true ){
3998     for (Int_t i = 0; i<10 ; i++) {
3999     xcc[i]= xcat + xcc2[i]*var.sfx;
4000     ycc[i] = ycat + ycc2[i]*var.sfy;
4001     };
4002     TPolyLine *fcat4 = new TPolyLine(10,xcc,ycc);
4003     fcat4->SetLineColor(1);
4004     colo = 10;
4005     if ( cat4 != 0. || cat4b != 0. ) {
4006     if ( cat4 > 0 || cat4b > 0 || cat4 == -.25 || cat4b ==-.25 ){
4007     colo = cattime;
4008     } else {
4009     colo = catnoti;
4010     };
4011     };
4012     fcat4->SetFillColor(colo);
4013     fcat4->SetLineWidth(1);
4014     fcat4->Draw("f");
4015     fcat4->Draw();
4016     };
4017     //
4018     // CAT1 PMTs
4019     //
4020     Float_t xc[5];
4021     Float_t yc[5];
4022     if ( true ){
4023     for (Int_t i = 0; i<5 ; i++) {
4024     xc[i]= xcat - xpmt2 - xc1[i];
4025     yc[i] = ycat + ypmt2 + yc1[i];
4026     };
4027     TPolyLine *fcat1 = new TPolyLine(5,xc,yc);
4028     fcat1->SetLineColor(1);
4029     colo = (int)(10. - cat1 * 8.);
4030     fcat1->SetFillColor(colo);
4031     fcat1->SetLineWidth(1);
4032     fcat1->Draw("f");
4033     fcat1->Draw();
4034     };
4035     if ( true ){
4036     for (Int_t i = 0; i<5 ; i++) {
4037     xc[i]= xcat - xpmt2 - xc1[i];
4038     yc[i] = ycat - ypmt2 - yc1[i];
4039     };
4040     TPolyLine *fcat1b = new TPolyLine(5,xc,yc);
4041     fcat1b->SetLineColor(1);
4042     colo = (int)(10. - cat1b * 8.);
4043     fcat1b->SetFillColor(colo);
4044     fcat1b->SetLineWidth(1);
4045     fcat1b->Draw("f");
4046     fcat1b->Draw();
4047     };
4048     //
4049     // CAT2 PMTs
4050     //
4051     if ( true ){
4052     for (Int_t i = 0; i<5 ; i++) {
4053     xc[i]= xcat + xpmt2 + xc1[i];
4054     yc[i] = ycat + ypmt2 + yc1[i];
4055     };
4056     TPolyLine *fcat2 = new TPolyLine(5,xc,yc);
4057     fcat2->SetLineColor(1);
4058     colo = (int)(10. - cat2 * 8.);
4059     fcat2->SetFillColor(colo);
4060     fcat2->SetLineWidth(1);
4061     fcat2->Draw("f");
4062     fcat2->Draw();
4063     };
4064     if ( true ){
4065     for (Int_t i = 0; i<5 ; i++) {
4066     xc[i]= xcat + xpmt2 + xc1[i];
4067     yc[i] = ycat - ypmt2 - yc1[i];
4068     };
4069     TPolyLine *fcat2b = new TPolyLine(5,xc,yc);
4070     fcat2b->SetLineColor(1);
4071     colo = (int)(10. - cat2b * 8.);
4072     fcat2b->SetFillColor(colo);
4073     fcat2b->SetLineWidth(1);
4074     fcat2b->Draw("f");
4075     fcat2b->Draw();
4076     };
4077     //
4078     // CAT3 PMTs
4079     //
4080     if ( true ){
4081     for (Int_t i = 0; i<5 ; i++) {
4082     xc[i]= xcat + xpmt1 + xc2[i];
4083     yc[i] = ycat - ypmt1 - yc2[i];
4084     };
4085     TPolyLine *fcat3b = new TPolyLine(5,xc,yc);
4086     fcat3b->SetLineColor(1);
4087     colo = (int)(10. - cat3b * 8.);
4088     fcat3b->SetFillColor(colo);
4089     fcat3b->SetLineWidth(1);
4090     fcat3b->Draw("f");
4091     fcat3b->Draw();
4092     };
4093     if ( true ){
4094     for (Int_t i = 0; i<5 ; i++) {
4095     xc[i]= xcat - xpmt1 - xc2[i];
4096     yc[i] = ycat - ypmt1 - yc2[i];
4097     };
4098     TPolyLine *fcat3 = new TPolyLine(5,xc,yc);
4099     fcat3->SetLineColor(1);
4100     colo = (int)(10. - cat3 * 8.);
4101     fcat3->SetFillColor(colo);
4102     fcat3->SetLineWidth(1);
4103     fcat3->Draw("f");
4104     fcat3->Draw();
4105     };
4106     //
4107     // CAT4 PMTs
4108     //
4109     if ( true ){
4110     for (Int_t i = 0; i<5 ; i++) {
4111     xc[i]= xcat + xpmt1 + xc2[i];
4112     yc[i] = ycat + ypmt1 + yc2[i];
4113     };
4114     TPolyLine *fcat4b = new TPolyLine(5,xc,yc);
4115     fcat4b->SetLineColor(1);
4116     colo = (int)(10. - cat4b * 8.);
4117     fcat4b->SetFillColor(colo);
4118     fcat4b->SetLineWidth(1);
4119     fcat4b->Draw("f");
4120     fcat4b->Draw();
4121     };
4122     if ( true ){
4123     for (Int_t i = 0; i<5 ; i++) {
4124     xc[i]= xcat - xpmt1 - xc2[i];
4125     yc[i] = ycat + ypmt1 + yc2[i];
4126     };
4127     TPolyLine *fcat4 = new TPolyLine(5,xc,yc);
4128     fcat4->SetLineColor(1);
4129     colo = (int)(10. - cat4 * 8.);
4130     fcat4->SetFillColor(colo);
4131     fcat4->SetLineWidth(1);
4132     fcat4->Draw("f");
4133     fcat4->Draw();
4134     };
4135     };
4136     if ( true ){
4137     //
4138     // CAS plane view:
4139     //
4140     Float_t xofs = -0.025;
4141     Float_t yofs = 0.039 +0.081+0.0273;
4142     Float_t csy = 0.33/2.;
4143     Float_t pmofs = 0.004;
4144     Float_t csw2 = 0.008;
4145     Float_t xc1[5] = { xofs-csy, xofs-csy, xofs+csy, xofs+csy, xofs-csy};
4146     Float_t yc1[5] = { yofs, yofs+csw2, yofs+csw2, yofs, yofs};
4147    
4148     Float_t xc2[5] = { xofs-csy-csw2, xofs-csy-csw2, xofs-csy, xofs-csy, xofs-csy-csw2};
4149     Float_t yc2[5] = { yofs+pmofs, yofs+pmofs+csw2, yofs+pmofs+csw2, yofs+pmofs, yofs+pmofs};
4150     Float_t xc3[5] = { xofs-csy-csw2, xofs-csy-csw2, xofs-csy, xofs-csy, xofs-csy-csw2};
4151     Float_t yc3[5] = { yofs+pmofs, yofs+pmofs-csw2, yofs+pmofs-csw2, yofs+pmofs, yofs+pmofs};
4152    
4153     //
4154     // CAS1
4155     //
4156     Float_t xc[5];
4157     Float_t yc[5];
4158     for (Int_t i = 0; i<5 ; i++) {
4159     xc[i]= xcat + xc1[i]*var.sfx;
4160     yc[i] = ycat + yc1[i]*var.sfy;
4161     };
4162     TPolyLine *pcass1 = new TPolyLine(5,xc,yc);
4163     pcass1->SetLineColor(1);
4164     colo = 10;
4165     if ( cas1 != 0. || cas1b != 0. ) {
4166     if ( cas1 > 0 || cas1b > 0 || cas1 ==-.25 || cas1b ==-.25){
4167     colo = cattime;
4168     } else {
4169     colo = catnoti;
4170     };
4171     };
4172     if ( colo != 10 ) pcass1->SetFillStyle(3001);
4173     pcass1->SetFillColor(colo);
4174     pcass1->SetLineWidth(1);
4175     pcass1->SetLineStyle(2);
4176     pcass1->Draw("f");
4177     pcass1->Draw();
4178     //
4179     for (Int_t i = 0; i<5 ; i++) {
4180     xc[i]= xcat + xc2[i]*var.sfx;
4181     yc[i] = ycat + yc2[i]*var.sfy;
4182     };
4183     TPolyLine *pcasp1b = new TPolyLine(5,xc,yc);
4184     pcasp1b->SetLineColor(1);
4185     colo = (int)(10. - cas1b * 8.);
4186     if ( colo != 10 ) pcasp1b->SetFillStyle(3001);
4187     pcasp1b->SetFillColor(colo);
4188     pcasp1b->SetLineWidth(1);
4189     pcasp1b->SetLineStyle(2);
4190     pcasp1b->Draw("f");
4191     pcasp1b->Draw();
4192     //
4193     for (Int_t i = 0; i<5 ; i++) {
4194     xc[i]= xcat + xc3[i]*var.sfx;
4195     yc[i] = ycat + yc3[i]*var.sfy;
4196     };
4197     TPolyLine *pcasp1 = new TPolyLine(5,xc,yc);
4198     pcasp1->SetLineColor(1);
4199     colo = (int)(10. - cas1 * 8.);
4200     if ( colo != 10 ) pcasp1->SetFillStyle(3001);
4201     pcasp1->SetFillColor(colo);
4202     pcasp1->SetLineWidth(1);
4203     pcasp1->SetLineStyle(2);
4204     pcasp1->Draw("f");
4205     pcasp1->Draw();
4206     //
4207     // CAS2
4208     //
4209     for (Int_t i = 0; i<5 ; i++) {
4210     xc[i]= xcat - xc1[i]*var.sfx;
4211     yc[i] = ycat - yc1[i]*var.sfy;
4212     };
4213     TPolyLine *pcass2 = new TPolyLine(5,xc,yc);
4214     pcass2->SetLineColor(1);
4215     colo = 10;
4216     if ( cas2 != 0. || cas2b != 0. ) {
4217     if ( cas2 > 0 || cas2b > 0 || cas2 ==-.25 || cas2b ==-.25 ){
4218     colo = cattime;
4219     } else {
4220     colo = catnoti;
4221     };
4222     };
4223     if ( colo != 10 ) pcass2->SetFillStyle(3001);
4224     pcass2->SetFillColor(colo);
4225     pcass2->SetLineWidth(1);
4226     pcass2->SetLineStyle(2);
4227     pcass2->Draw("f");
4228     pcass2->Draw();
4229     //
4230     for (Int_t i = 0; i<5 ; i++) {
4231     xc[i]= xcat - xc2[i]*var.sfx;
4232     yc[i] = ycat - yc2[i]*var.sfy;
4233     };
4234     TPolyLine *pcasp2b = new TPolyLine(5,xc,yc);
4235     pcasp2b->SetLineColor(1);
4236     colo = (int)(10. - cas2b * 8.);
4237     if ( colo != 10 ) pcasp2b->SetFillStyle(3001);
4238     pcasp2b->SetFillColor(colo);
4239     pcasp2b->SetLineWidth(1);
4240     pcasp2b->SetLineStyle(2);
4241     pcasp2b->Draw("f");
4242     pcasp2b->Draw();
4243     //
4244     for (Int_t i = 0; i<5 ; i++) {
4245     xc[i]= xcat - xc3[i]*var.sfx;
4246     yc[i] = ycat - yc3[i]*var.sfy;
4247     };
4248     TPolyLine *pcasp2 = new TPolyLine(5,xc,yc);
4249     pcasp2->SetLineColor(1);
4250     colo = (int)(10. - cas2 * 8.);
4251     pcasp2->SetFillColor(colo);
4252     if ( colo != 10 ) pcasp2->SetFillStyle(3001);
4253     pcasp2->SetLineWidth(1);
4254     pcasp2->SetLineStyle(2);
4255     pcasp2->Draw("f");
4256     pcasp2->Draw();
4257    
4258     };
4259     if ( true ){
4260     Float_t xofs = 0.048 +0.066+0.0273;
4261     Float_t yofs = 0.02;
4262     Float_t csy = 0.33/2.;
4263     Float_t pmofs = 0.004;
4264     Float_t csw2 = 0.008;
4265     Float_t xc1[5] = { xofs, xofs+csw2, xofs+csw2, xofs, xofs};
4266     Float_t yc1[5] = { yofs-csy, yofs-csy, yofs+csy, yofs+csy, yofs-csy};
4267     Float_t xc2[5] = { xofs+pmofs, xofs+pmofs+csw2, xofs+pmofs+csw2, xofs+pmofs, xofs+pmofs};
4268     Float_t yc2[5] = { yofs+csy+csw2, yofs+csy+csw2, yofs+csy, yofs+csy, yofs+csy+csw2};
4269     Float_t xc3[5] = { xofs+pmofs, xofs+pmofs-csw2, xofs+pmofs-csw2, xofs+pmofs, xofs+pmofs};
4270     Float_t yc3[5] = { yofs+csy+csw2, yofs+csy+csw2, yofs+csy, yofs+csy, yofs+csy+csw2};
4271     //
4272     // CAS3
4273     //
4274     Float_t xc[5];
4275     Float_t yc[5];
4276     for (Int_t i = 0; i<5 ; i++) {
4277     xc[i]= xcat + xc1[i]*var.sfx;
4278     yc[i] = ycat + yc1[i]*var.sfy;
4279     };
4280     TPolyLine *pcass3 = new TPolyLine(5,xc,yc);
4281     pcass3->SetLineColor(1);
4282     colo = 10;
4283     if ( cas3 != 0. || cas3b != 0. ) {
4284     if ( cas3 > 0 || cas3b > 0 || cas3 ==-.25 || cas3b ==-.25){
4285     colo = cattime;
4286     } else {
4287     colo = catnoti;
4288     };
4289     };
4290     if ( colo != 10 ) pcass3->SetFillStyle(3001);
4291     pcass3->SetFillColor(colo);
4292     pcass3->SetLineWidth(1);
4293     pcass3->SetLineStyle(2);
4294     pcass3->Draw("f");
4295     pcass3->Draw();
4296     //
4297     for (Int_t i = 0; i<5 ; i++) {
4298     xc[i]= xcat + xc2[i]*var.sfx;
4299     yc[i] = ycat + yc2[i]*var.sfy;
4300     };
4301     TPolyLine *pcasp3b = new TPolyLine(5,xc,yc);
4302     pcasp3b->SetLineColor(1);
4303     colo = (int)(10. - cas3b * 8.);
4304     if ( colo != 10 ) pcasp3b->SetFillStyle(3001);
4305     pcasp3b->SetFillColor(colo);
4306     pcasp3b->SetLineWidth(1);
4307     pcasp3b->SetLineStyle(2);
4308     pcasp3b->Draw("f");
4309     pcasp3b->Draw();
4310     //
4311     for (Int_t i = 0; i<5 ; i++) {
4312     xc[i]= xcat + xc3[i]*var.sfx;
4313     yc[i] = ycat + yc3[i]*var.sfy;
4314     };
4315     TPolyLine *pcasp3 = new TPolyLine(5,xc,yc);
4316     pcasp3->SetLineColor(1);
4317     colo = (int)(10. - cas3 * 8.);
4318     pcasp3->SetFillColor(colo);
4319     if ( colo != 10 ) pcasp3->SetFillStyle(3001);
4320     pcasp3->SetLineWidth(1);
4321     pcasp3->SetLineStyle(2);
4322     pcasp3->Draw("f");
4323     pcasp3->Draw();
4324     //
4325     // CAS4
4326     //
4327     for (Int_t i = 0; i<5 ; i++) {
4328     xc[i]= xcat - xc1[i]*var.sfx;
4329     yc[i] = ycat - yc1[i]*var.sfy;
4330     };
4331     TPolyLine *pcass4 = new TPolyLine(5,xc,yc);
4332     pcass4->SetLineColor(1);
4333     colo = 10;
4334     if ( cas4 != 0. || cas4b != 0. ) {
4335     if ( cas4 > 0 || cas4b > 0 || cas4 ==-.25 || cas4b ==-.25 ){
4336     colo = cattime;
4337     } else {
4338     colo = catnoti;
4339     };
4340     };
4341     pcass4->SetFillColor(colo);
4342     if ( colo != 10 ) pcass4->SetFillStyle(3001);
4343     pcass4->SetLineWidth(1);
4344     pcass4->SetLineStyle(2);
4345     pcass4->Draw("f");
4346     pcass4->Draw();
4347     //
4348     for (Int_t i = 0; i<5 ; i++) {
4349     xc[i]= xcat - xc2[i]*var.sfx;
4350     yc[i] = ycat - yc2[i]*var.sfy;
4351     };
4352     TPolyLine *pcasp4 = new TPolyLine(5,xc,yc);
4353     pcasp4->SetLineColor(1);
4354     colo = (int)(10. - cas4 * 8.);
4355     pcasp4->SetFillColor(colo);
4356     if ( colo != 10 ) pcasp4->SetFillStyle(3001);
4357     pcasp4->SetLineWidth(1);
4358     pcasp4->SetLineStyle(2);
4359     pcasp4->Draw("f");
4360     pcasp4->Draw();
4361     //
4362     for (Int_t i = 0; i<5 ; i++) {
4363     xc[i]= xcat - xc3[i]*var.sfx;
4364     yc[i] = ycat - yc3[i]*var.sfy;
4365     };
4366     TPolyLine *pcasp4b = new TPolyLine(5,xc,yc);
4367     pcasp4b->SetLineColor(1);
4368     colo = (int)(10. - cas4b * 8.);
4369     pcasp4b->SetFillColor(colo);
4370     if ( colo != 10 ) pcasp4b->SetFillStyle(3001);
4371     pcasp4b->SetLineWidth(1);
4372     pcasp4b->SetLineStyle(2);
4373     pcasp4b->Draw("f");
4374     pcasp4b->Draw();
4375     };
4376 mocchiut 1.11 // Float_t alfax = 1.2020334;
4377     Float_t alfax = 1.22157778;
4378     Float_t alfay = 1.27393111;
4379 mocchiut 1.1 Float_t lcrd = 0.1815/2.;
4380     Float_t wcrd = 0.008;
4381     if ( true ){
4382     //
4383     // CARD plane view:
4384     //
4385     Float_t xc1[5] = { -0.090165, -0.090165, -0.082165, -0.082165, -0.090165};
4386     Float_t yc1[5] = { -0.100, 0.092, 0.092, -0.100, -0.100};
4387     Float_t xc2[5] = { -0.094165, -0.094165, -0.086165, -0.086165, -0.094165};
4388     Float_t yc2[5] = { 0.092, 0.100, 0.100, 0.092, 0.092};
4389     Float_t xc3[5] = { -0.086165, -0.086165, -0.078165, -0.078165, -0.086165};
4390     Float_t yc3[5] = { 0.092, 0.100, 0.100, 0.092, 0.092};
4391     //
4392     // CARD1
4393     //
4394     Float_t xc[5];
4395     Float_t yc[5];
4396     for (Int_t i = 0; i<5 ; i++) {
4397     xc[i]= xcat + xc1[i]*var.sfx;
4398     yc[i] = ycat + yc1[i]*var.sfy;
4399     };
4400     TPolyLine *pcars1 = new TPolyLine(5,xc,yc);
4401     pcars1->SetLineColor(1);
4402     colo = 10;
4403     if ( card1 != 0. || card1b != 0. ) {
4404     if ( card1 > 0 || card1b > 0 || card1 ==-.25 || card1b ==-.25 ){
4405     colo = cattime;
4406     } else {
4407     colo = catnoti;
4408     };
4409     };
4410     pcars1->SetFillColor(colo);
4411     pcars1->SetLineWidth(1);
4412     pcars1->Draw("f");
4413     pcars1->Draw();
4414     //
4415     for (Int_t i = 0; i<5 ; i++) {
4416     xc[i]= xcat + xc2[i]*var.sfx;
4417     yc[i] = ycat + yc2[i]*var.sfy;
4418     };
4419     TPolyLine *pcarp1b = new TPolyLine(5,xc,yc);
4420     pcarp1b->SetLineColor(1);
4421     colo = (int)(10. - card1b * 8.);
4422     pcarp1b->SetFillColor(colo);
4423     pcarp1b->SetLineWidth(1);
4424     pcarp1b->Draw("f");
4425     pcarp1b->Draw();
4426     //
4427     for (Int_t i = 0; i<5 ; i++) {
4428     xc[i] = xcat + xc3[i]*var.sfx;
4429     yc[i] = ycat + yc3[i]*var.sfy;
4430     };
4431     TPolyLine *pcarp1 = new TPolyLine(5,xc,yc);
4432     pcarp1->SetLineColor(1);
4433     colo = (int)(10. - card1 * 8.);
4434     pcarp1->SetFillColor(colo);
4435     pcarp1->SetLineWidth(1);
4436     pcarp1->Draw("f");
4437     pcarp1->Draw();
4438     //
4439     // CARD4
4440     //
4441     for (Int_t i = 0; i<5 ; i++) {
4442     xc[i]= xcat - xc1[i]*var.sfx;
4443     yc[i] = ycat - yc1[i]*var.sfy;
4444     };
4445     TPolyLine *pcars4 = new TPolyLine(5,xc,yc);
4446     pcars4->SetLineColor(1);
4447     colo = 10;
4448     if ( card4 != 0. || card4b != 0. ) {
4449     if ( card4 > 0 || card4b > 0 || card4 ==-.25 || card4b ==-.25){
4450     colo = cattime;
4451     } else {
4452     colo = catnoti;
4453     };
4454     };
4455     pcars4->SetFillColor(colo);
4456     pcars4->SetLineWidth(1);
4457     pcars4->Draw("f");
4458     pcars4->Draw();
4459     //
4460     for (Int_t i = 0; i<5 ; i++) {
4461     xc[i]= xcat - xc2[i]*var.sfx;
4462     yc[i] = ycat - yc2[i]*var.sfy;
4463     };
4464     TPolyLine *pcarp4b = new TPolyLine(5,xc,yc);
4465     pcarp4b->SetLineColor(1);
4466     colo = (int)(10. - card4b * 8.);
4467     pcarp4b->SetFillColor(colo);
4468     pcarp4b->SetLineWidth(1);
4469     pcarp4b->Draw("f");
4470     pcarp4b->Draw();
4471     //
4472     for (Int_t i = 0; i<5 ; i++) {
4473     xc[i]= xcat - xc3[i]*var.sfx;
4474     yc[i] = ycat - yc3[i]*var.sfy;
4475     };
4476     TPolyLine *pcarp4 = new TPolyLine(5,xc,yc);
4477     pcarp4->SetLineColor(1);
4478     colo = (int)(10. - card4 * 8.);
4479     pcarp4->SetFillColor(colo);
4480     pcarp4->SetLineWidth(1);
4481     pcarp4->Draw("f");
4482     pcarp4->Draw();
4483     };
4484     if ( true ){
4485     Float_t xc1[5] = { -0.074, 0.074, 0.074, -0.074, -0.074};
4486     Float_t yc1[5] = { 0.108165, 0.108165, 0.100165, 0.100165, 0.108165};
4487     Float_t xc2[5] = { 0.074, 0.082, 0.082, 0.074, 0.074};
4488     Float_t yc2[5] = { 0.112165, 0.112165, 0.104165, 0.104165, 0.112165};
4489     Float_t xc3[5] = { 0.074, 0.082, 0.082, 0.074, 0.074};
4490     Float_t yc3[5] = { 0.104165, 0.104165, 0.096165, 0.096165, 0.104165};
4491     //
4492     // CARD2
4493     //
4494     Float_t xc[5];
4495     Float_t yc[5];
4496     for (Int_t i = 0; i<5 ; i++) {
4497     xc[i]= xcat - (xc1[i]-0.0025)*var.sfx;
4498     yc[i] = ycat - yc1[i]*var.sfy;
4499     };
4500     TPolyLine *pcars2 = new TPolyLine(5,xc,yc);
4501     pcars2->SetLineColor(1);
4502     colo = 10;
4503     if ( card2 != 0. || card2b != 0.) {
4504     if ( card2 > 0 || card2b > 0 || card2 ==-.25 || card2b ==-.25 ){
4505     colo = cattime;
4506     } else {
4507     colo = catnoti;
4508     };
4509     };
4510     pcars2->SetFillColor(colo);
4511     pcars2->SetLineWidth(1);
4512     pcars2->Draw("f");
4513     pcars2->Draw();
4514     //
4515     for (Int_t i = 0; i<5 ; i++) {
4516     xc[i]= xcat - (xc2[i]-0.0025)*var.sfx;
4517     yc[i] = ycat - yc2[i]*var.sfy;
4518     };
4519     TPolyLine *pcarp2 = new TPolyLine(5,xc,yc);
4520     pcarp2->SetLineColor(1);
4521     colo = (int)(10. - card2 * 8.);
4522     pcarp2->SetFillColor(colo);
4523     pcarp2->SetLineWidth(1);
4524     pcarp2->Draw("f");
4525     pcarp2->Draw();
4526     //
4527     for (Int_t i = 0; i<5 ; i++) {
4528     xc[i]= xcat - (xc3[i]-0.0025)*var.sfx;
4529     yc[i] = ycat - yc3[i]*var.sfy;
4530     };
4531     TPolyLine *pcarp2b = new TPolyLine(5,xc,yc);
4532     pcarp2b->SetLineColor(1);
4533     colo = (int)(10. - card2b * 8.);
4534     pcarp2b->SetFillColor(colo);
4535     pcarp2b->SetLineWidth(1);
4536     pcarp2b->Draw("f");
4537     pcarp2b->Draw();
4538     //
4539     // CARD3
4540     //
4541     for (Int_t i = 0; i<5 ; i++) {
4542     xc[i]= xcat + (xc1[i]-0.0025)*var.sfx;
4543     yc[i] = ycat + yc1[i]*var.sfy;
4544     };
4545     TPolyLine *pcars3 = new TPolyLine(5,xc,yc);
4546     pcars3->SetLineColor(1);
4547     colo = 10;
4548     if ( card3 != 0. || card3b != 0. ) {
4549     if ( card3 > 0 || card3b > 0 || card3==-.25 || card3b ==-.25){
4550     colo = cattime;
4551     } else {
4552     colo = catnoti;
4553     };
4554     };
4555     pcars3->SetFillColor(colo);
4556     pcars3->SetLineWidth(1);
4557     pcars3->Draw("f");
4558     pcars3->Draw();
4559     //
4560     for (Int_t i = 0; i<5 ; i++) {
4561     xc[i]= xcat + (xc2[i]-0.0025)*var.sfx;
4562     yc[i] = ycat + yc2[i]*var.sfy;
4563     };
4564     TPolyLine *pcarp3 = new TPolyLine(5,xc,yc);
4565     pcarp3->SetLineColor(1);
4566     colo = (int)(10. - card3 * 8.);
4567     pcarp3->SetFillColor(colo);
4568     pcarp3->SetLineWidth(1);
4569     pcarp3->Draw("f");
4570     pcarp3->Draw();
4571     //
4572     for (Int_t i = 0; i<5 ; i++) {
4573     xc[i]= xcat + (xc3[i]-0.0025)*var.sfx;
4574     yc[i] = ycat + yc3[i]*var.sfy;
4575     };
4576     TPolyLine *pcarp3b = new TPolyLine(5,xc,yc);
4577     pcarp3b->SetLineColor(1);
4578     colo = (int)(10. - card3b * 8.);
4579     pcarp3b->SetFillColor(colo);
4580     pcarp3b->SetLineWidth(1);
4581     pcarp3b->Draw("f");
4582     pcarp3b->Draw();
4583    
4584     //
4585     // CARD - X-view
4586     //
4587     // Float_t cardcx = 0.143168*var.sfx;
4588     //Float_t cardcy = 0.1475*var.sfy;
4589 mocchiut 1.11 //
4590     // Float_t cardcx = 0.153168*var.sfx;
4591     //
4592     Float_t cardcx = (0.19123*(1.-lcrd*cos(alfax)))*var.sfx;
4593     // Float_t cardcy = 0.1575*var.sfy;
4594     Float_t cardcy = (0.179212*(1.-lcrd*sin(alfax)))*var.sfy;
4595     Float_t acrdx[4] = {-lcrd*cos(alfax), lcrd*cos(alfax), -lcrd*cos(alfax)+wcrd*sin(alfax), -lcrd*cos(alfax)};
4596     Float_t acrdy[4] = {-lcrd*sin(alfax), lcrd*sin(alfax), -lcrd*sin(alfax)-wcrd*cos(alfax), -lcrd*sin(alfax)};
4597     Float_t bcrdx[4] = { lcrd*cos(alfax), lcrd*cos(alfax)+wcrd*sin(alfax), -lcrd*cos(alfax)+wcrd*sin(alfax), lcrd*cos(alfax)};
4598     Float_t bcrdy[4] = { lcrd*sin(alfax), lcrd*sin(alfax)-wcrd*cos(alfax), -lcrd*sin(alfax)-wcrd*cos(alfax), lcrd*sin(alfax)};
4599 mocchiut 1.1
4600     //
4601     // CARD3 X/ Y
4602     //
4603     Float_t xcc[4];
4604     Float_t ycc[4];
4605     for (Int_t i = 0; i<4 ; i++) {
4606     xcc[i] = cardcx + var.xxvc + acrdx[i]*var.sfx;
4607     ycc[i] = cardcy + var.yxvc + (0.36 + acrdy[i])*var.sfy;
4608     };
4609     TPolyLine *fcard3 = new TPolyLine(4,xcc,ycc);
4610     fcard3->SetLineColor(1);
4611     colo = (int)(10. - card3 * 8.);
4612     fcard3->SetFillColor(colo);
4613     fcard3->SetLineWidth(1);
4614     fcard3->Draw("f");
4615     fcard3->Draw();
4616     //
4617     for (Int_t i = 0; i<4 ; i++) {
4618     xcc[i] = cardcx + var.xxvc + bcrdx[i]*var.sfx;
4619     ycc[i] = cardcy + var.yxvc + (0.36 + bcrdy[i])*var.sfy;
4620     };
4621     TPolyLine *fcard3b = new TPolyLine(4,xcc,ycc);
4622     fcard3b->SetLineColor(1);
4623     colo = (int)(10. - card3b * 8.);
4624     fcard3b->SetFillColor(colo);
4625     fcard3b->SetLineWidth(1);
4626     fcard3b->Draw("f");
4627     fcard3b->Draw();
4628    
4629     //
4630     // CARD2 \X Y
4631     //
4632     for (Int_t i = 0; i<4 ; i++) {
4633     xcc[i] = -cardcx + var.xxvc - acrdx[i]*var.sfx;
4634     ycc[i] = cardcy + var.yxvc + (0.36 + acrdy[i])*var.sfy;
4635     };
4636     TPolyLine *fcard2 = new TPolyLine(4,xcc,ycc);
4637     fcard2->SetLineColor(1);
4638     colo = (int)(10. - card2 * 8.);
4639     fcard2->SetFillColor(colo);
4640     fcard2->SetLineWidth(1);
4641     fcard2->Draw("f");
4642     fcard2->Draw();
4643     //
4644     for (Int_t i = 0; i<4 ; i++) {
4645     xcc[i] = -cardcx + var.xxvc - bcrdx[i]*var.sfx;
4646     ycc[i] = cardcy + var.yxvc + (0.36 + bcrdy[i])*var.sfy;
4647     };
4648     TPolyLine *fcard2b = new TPolyLine(4,xcc,ycc);
4649     fcard2b->SetLineColor(1);
4650     colo = (int)(10. - card2b * 8.);
4651     fcard2b->SetFillColor(colo);
4652     fcard2b->SetLineWidth(1);
4653     fcard2b->Draw("f");
4654     fcard2b->Draw();
4655     };
4656    
4657     if ( true ){
4658 mocchiut 1.11 Float_t acrdx[4] = {-lcrd*cos(alfay), lcrd*cos(alfay), -lcrd*cos(alfay)+wcrd*sin(alfay), -lcrd*cos(alfay)};
4659     Float_t acrdy[4] = {-lcrd*sin(alfay), lcrd*sin(alfay), -lcrd*sin(alfay)-wcrd*cos(alfay), -lcrd*sin(alfay)};
4660     Float_t bcrdx[4] = { lcrd*cos(alfay), lcrd*cos(alfay)+wcrd*sin(alfay), -lcrd*cos(alfay)+wcrd*sin(alfay), lcrd*cos(alfay)};
4661     Float_t bcrdy[4] = { lcrd*sin(alfay), lcrd*sin(alfay)-wcrd*cos(alfay), -lcrd*sin(alfay)-wcrd*cos(alfay), lcrd*sin(alfay)};
4662 mocchiut 1.1 //
4663     // CARD - Y-view
4664     //
4665 mocchiut 1.11 // Float_t cardcx = 0.12*var.sfx;
4666     Float_t cardcx = (0.16014*(1.-lcrd*cos(alfay)))*var.sfx;
4667     // Float_t cardcy = 0.178818*var.sfy;
4668     Float_t cardcy = (0.178818*(1.-lcrd*sin(alfay)))*var.sfy;
4669     // Float_t cardcy = 0.1475*var.sfy;
4670 mocchiut 1.1 //
4671     // CARD4 X Y/
4672     //
4673     Float_t xcc[4];
4674     Float_t ycc[4];
4675     for (Int_t i = 0; i<4 ; i++) {
4676     xcc[i] = cardcx + var.xyvc + acrdx[i]*var.sfx;
4677     ycc[i] = cardcy + var.yyvc + (0.36 + acrdy[i])*var.sfy;
4678     };
4679     TPolyLine *fcard4 = new TPolyLine(4,xcc,ycc);
4680     fcard4->SetLineColor(1);
4681     colo = (int)(10. - card4 * 8.);
4682     fcard4->SetFillColor(colo);
4683     fcard4->SetLineWidth(1);
4684     fcard4->Draw("f");
4685     fcard4->Draw();
4686     //
4687     for (Int_t i = 0; i<4 ; i++) {
4688     xcc[i] = cardcx + var.xyvc + bcrdx[i]*var.sfx;
4689     ycc[i] = cardcy + var.yyvc + (0.36 + bcrdy[i])*var.sfy;
4690     };
4691     TPolyLine *fcard4b = new TPolyLine(4,xcc,ycc);
4692     fcard4b->SetLineColor(1);
4693     colo = (int)(10. - card4b * 8.);
4694     fcard4b->SetFillColor(colo);
4695     fcard4b->SetLineWidth(1);
4696     fcard4b->Draw("f");
4697     fcard4b->Draw();
4698    
4699     //
4700     // CARD1 X \Y
4701     //
4702     for (Int_t i = 0; i<4 ; i++) {
4703     xcc[i] = -cardcx + var.xyvc - acrdx[i]*var.sfx;
4704     ycc[i] = cardcy + var.yyvc + (0.36 + acrdy[i])*var.sfy;
4705     };
4706     TPolyLine *fcard1 = new TPolyLine(4,xcc,ycc);
4707     fcard1->SetLineColor(1);
4708     colo = (int)(10. - card1 * 8.);
4709     fcard1->SetFillColor(colo);
4710     fcard1->SetLineWidth(1);
4711     fcard1->Draw("f");
4712     fcard1->Draw();
4713     //
4714     for (Int_t i = 0; i<4 ; i++) {
4715     xcc[i] = -cardcx + var.xyvc - bcrdx[i]*var.sfx;
4716     ycc[i] = cardcy + var.yyvc + (0.36 + bcrdy[i])*var.sfy;
4717     };
4718     TPolyLine *fcard1b = new TPolyLine(4,xcc,ycc);
4719     fcard1b->SetLineColor(1);
4720     colo = (int)(10. - card1b * 8.);
4721     fcard1b->SetFillColor(colo);
4722     fcard1b->SetLineWidth(1);
4723     fcard1b->Draw("f");
4724     fcard1b->Draw();
4725     };
4726     }
4727    
4728     void FEVdetector::ShowS4(Bool_t upd){
4729     //
4730     //
4731     //
4732     if ( !var.S4 ) return;
4733     //
4734     Float_t calibdata;
4735     Int_t data = 0;
4736     Float_t ms4[3] = {0.,0.,0.};
4737     Int_t S4 = 0;
4738     //
4739     // Level0 data
4740     //
4741     if ( level.file == 0 ){
4742     S4 = trigger->patterntrig[1];
4743     //
4744     for ( Int_t i = 0; i<3; i++ ) {
4745     if ( S4 & (1<<0) ) ms4[i] = 1.;
4746     };
4747     };
4748     //
4749     // Rough calibration of data
4750     //
4751     if ( level.file == -1 ){
4752     if ( !s4->unpackError && data > 31 ){
4753     data = s4->S4_DATA;
4754     calibdata = ((Float_t)data - 32.) * 0.5;
4755     } else {
4756     calibdata = 0.;
4757     };
4758     //
4759     for ( Int_t j = 0; j<3; j++ ) {
4760     ms4[j] = calibdata;
4761     };
4762     };
4763     //
4764     // Level2 data
4765     //
4766     if ( level.file == 2 ){
4767     for ( Int_t j = 0; j<3; j++ ) {
4768 mocchiut 1.6 if ( L2->GetS4Level2()->S4adc != 32. ) ms4[j] = L2->GetS4Level2()->S4calibrated;
4769 mocchiut 1.1 };
4770     };
4771     //
4772     var.s4sig = ms4[0];
4773     //
4774     if ( !upd ) return;
4775     //
4776     Int_t colo;
4777     Float_t xs4x = var.xxvc;
4778     Float_t ys4x = var.yxvc - 0.3250*var.sfy;
4779     Float_t xs4y = var.xyvc;
4780     Float_t ys4y = var.yyvc - 0.3250*var.sfy;
4781     Float_t ws4 = 0.010;
4782     //
4783     // Y-view
4784     //
4785     Float_t s4p = 0.1606667;
4786     Int_t ocolo = 0;
4787     TPolyLine *fs4y[3];
4788     for ( Int_t j=0; j<3; j++){
4789     Float_t xc1[5]={ (s4p*j), s4p*(j+1), s4p*(j+1), (s4p*j), (s4p*j)};
4790     Float_t yc1[5]={ 0., 0., ws4, ws4, 0.};
4791     Float_t xc[5];
4792     Float_t yc[5];
4793     for (Int_t i = 0; i<5 ; i++) {
4794     xc[i]= xs4y + (-0.241+xc1[i])*var.nds4;
4795     yc[i] = ys4y + (yc1[i]-0.03)*var.sfy;
4796     };
4797     fs4y[j] = new TPolyLine(5,xc,yc);
4798     fs4y[j]->SetLineColor(1);
4799     if ( var.bw ){
4800     colo = -1;
4801     } else {
4802     colo = 1;
4803     };
4804     ColorMIP(ms4[j],colo);
4805     //
4806     if ( colo != 10 ) ocolo = colo;
4807     //
4808     fs4y[j]->SetFillColor(colo);
4809     fs4y[j]->SetLineWidth(1);
4810     fs4y[j]->Draw("f");
4811     fs4y[j]->Draw();
4812     };
4813     //
4814     // X-view
4815     //
4816     Float_t xc1[5]={ -0.241, 0.241, 0.241, -0.241, -0.241};
4817     Float_t yc1[5]={ 0., 0., ws4, ws4, 0.};
4818     Float_t xc[5];
4819     Float_t yc[5];
4820     for (Int_t i = 0; i<5 ; i++) {
4821     xc[i]= xs4x + xc1[i]*var.nds4;
4822     yc[i] = ys4x + (yc1[i]-0.03)*var.sfy;
4823     };
4824     TPolyLine *fs4x = new TPolyLine(5,xc,yc);
4825     fs4x->SetLineColor(1);
4826     fs4x->SetFillColor(ocolo);
4827     fs4x->SetLineWidth(1);
4828     fs4x->Draw("f");
4829     fs4x->Draw();
4830     }
4831    
4832     void FEVdetector::ShowND(){
4833     //
4834     //
4835     //
4836     if ( !var.ND ) return;
4837     //
4838     Int_t tmpSize;
4839     Int_t yUpperTrig = 0;
4840     Int_t yUpperBk = 0;
4841     Int_t yBottomBk = 0;
4842     if ( level.file == 0 || level.file == -1 ){
4843     //
4844     tmpSize = ne->Records->GetEntries();
4845     for (Int_t j = 0; j < tmpSize; j++){
4846     nr = (pamela::neutron::NeutronRecord*)ne->Records->At(j);
4847     yUpperTrig += (int)nr->trigPhysics;
4848     yUpperBk += (int)nr->upperBack;
4849     yBottomBk += (int)nr->bottomBack;
4850     };
4851     };
4852     if ( level.file == 2 ){
4853 mocchiut 1.6 yUpperTrig = (Int_t)L2->GetNDLevel2()->trigPhysics;
4854     yUpperBk = (Int_t)L2->GetNDLevel2()->upperBack;
4855     yBottomBk = (Int_t)L2->GetNDLevel2()->bottomBack;
4856 mocchiut 1.1 };
4857     //
4858     var.trup = yUpperTrig;
4859     var.bkup = yUpperBk;
4860     var.bkbo = yBottomBk;
4861     //
4862     Int_t ucolo = 10;
4863     if ( var.bw ){
4864     if ( yUpperTrig == 1 ){
4865     ucolo = 17;
4866     }
4867     if ( yUpperTrig == 2 ){
4868     ucolo = 15;
4869     }
4870     if ( yUpperTrig > 2 && yUpperTrig < 7 ){
4871     ucolo = 14;
4872     }
4873     if ( yUpperTrig > 6 && yUpperTrig < 15 ){
4874     ucolo = 13;
4875     }
4876     if ( yUpperTrig >= 14 ){
4877     ucolo = 12;
4878     };
4879     } else {
4880     if ( yUpperTrig == 1 ){
4881     ucolo = 38;
4882     }
4883     if ( yUpperTrig == 2 ){
4884     ucolo = 4;
4885     }
4886     if ( yUpperTrig > 2 && yUpperTrig < 7 ){
4887     ucolo = 3;
4888     }
4889     if ( yUpperTrig > 6 && yUpperTrig < 15 ){
4890     ucolo = 2;
4891     }
4892     if ( yUpperTrig >= 14 ){
4893     ucolo = 6;
4894     };
4895     };
4896     //
4897     // figures:
4898     //
4899     if ( true ){
4900     Float_t xc1[5]={ -0.300, 0.300, 0.300, -0.300, -0.300 };
4901     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};
4902     //
4903     // Upper X-view
4904     //
4905     Float_t xc[5];
4906     Float_t yc[5];
4907     for (Int_t i = 0; i<5 ; i++) {
4908     xc[i]= var.xxvc + xc1[i]*var.nds4;
4909     yc[i] = var.yxvc + yc1[i]*var.sfy;
4910     };
4911     TPolyLine *fnd2x = new TPolyLine(5,xc,yc);
4912     fnd2x->SetLineColor(1);
4913     fnd2x->SetFillColor(ucolo);
4914     fnd2x->SetLineWidth(1);
4915     fnd2x->Draw("f");
4916     fnd2x->Draw();
4917     };
4918     if ( true ){
4919     Float_t xc1[5]={ -0.275, 0.275, 0.275, -0.275, -0.275 };
4920     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};
4921     //
4922     // Upper Y-view
4923     //
4924     Float_t xc[5];
4925     Float_t yc[5];
4926     for (Int_t i = 0; i<5 ; i++) {
4927     xc[i]= var.xyvc + xc1[i]*var.nds4;
4928     yc[i] = var.yyvc + (yc1[i]+0.075)*var.sfy;
4929     };
4930     TPolyLine *fnd2y = new TPolyLine(5,xc,yc);
4931     fnd2y->SetLineColor(1);
4932     fnd2y->SetFillColor(ucolo);
4933     fnd2y->SetLineWidth(1);
4934     fnd2y->Draw("f");
4935     fnd2y->Draw();
4936     };
4937     }
4938    
4939    
4940     void FEVdetector::ShowTRK(Bool_t upd){
4941     //
4942     //
4943     //
4944     if ( !var.TRK ) return;
4945     //
4946     // a matrix of pads for each view x and y
4947     //
4948     var.rig = 0.;
4949     var.chi2 = 0.;
4950     TPad *trkpad[12];
4951     for (Int_t n = 0; n<12; n++){
4952     stringstream spd;
4953     spd.str("");
4954     spd << "pd1" << n;
4955     gDirectory->Delete(spd.str().c_str());
4956     spd.str("");
4957     spd << "pd2" << n;
4958     gDirectory->Delete(spd.str().c_str());
4959     spd.str("");
4960     spd << "pd3" << n;
4961     gDirectory->Delete(spd.str().c_str());
4962     spd.str("");
4963     spd << "pd4" << n;
4964     gDirectory->Delete(spd.str().c_str());
4965     spd.str("");
4966     spd << "pd5" << n;
4967     gDirectory->Delete(spd.str().c_str());
4968     spd.str("");
4969     spd << "pd6" << n;
4970     gDirectory->Delete(spd.str().c_str());
4971     spd.str("");
4972     stringstream sbd;
4973     sbd.str("");
4974     Int_t magcol = 0;
4975     TPad *mag1 = 0;
4976     TPad *mag2 = 0;
4977     if ( n%2 ) {
4978     Float_t posx = var.xxvc;
4979     Float_t posy = var.yxvc + (0.29 - 0.089*((n/2.)-1.))*var.sfy;
4980     spd.str("");
4981     sbd.str("");
4982     spd << "pd1" << n;
4983     sbd << "bd1" << n;
4984     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);
4985     trkpad[n]->SetFillStyle(4000);
4986     trkpad[n]->SetFillColor(0);
4987     trkpad[n]->SetFrameFillStyle(4000);
4988     if ( upd ) trkpad[n]->Draw();
4989     if ( n != 1 ) {
4990     if ( var.bw ) {
4991     magcol = 1;
4992     } else {
4993     magcol = 45;
4994     };
4995     spd.str("");
4996     sbd.str("");
4997     spd << "pd2" << n;
4998     sbd << "bd2" << n;
4999     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);
5000     if ( var.bw ) mag1->SetFillStyle(3001);
5001     if ( upd ) mag1->Draw();
5002     spd.str("");
5003     sbd.str("");
5004     spd << "pd3" << n;
5005     sbd << "bd3" << n;
5006     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);
5007     if ( var.bw ) mag2->SetFillStyle(3001);
5008     if ( upd ) mag2->Draw();
5009     };
5010     } else {
5011     Float_t posx = var.xyvc;
5012     Float_t posy = var.yyvc + (0.29 - 0.089 * (((n+1.)/2.)-1.))*var.sfy;
5013     spd.str("");
5014     sbd.str("");
5015     spd << "pd4" << n;
5016     sbd << "bd4" << n;
5017     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);
5018     trkpad[n]->SetFillStyle(4000);
5019     trkpad[n]->SetFillColor(0);
5020     trkpad[n]->SetFrameFillStyle(4000);
5021     if ( upd ) trkpad[n]->Draw();
5022     if ( n != 0 ) {
5023     if ( var.bw ) {
5024     magcol = 1;
5025     } else {
5026     magcol = 45;
5027     };
5028     spd.str("");
5029     sbd.str("");
5030     spd << "pd5" << n;
5031     sbd << "bd5" << n;
5032     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);
5033     if ( var.bw ) mag1->SetFillStyle(3001);
5034     if ( upd ) mag1->Draw();
5035     spd.str("");
5036     sbd.str("");
5037     spd << "pd6" << n;
5038     sbd << "bd6" << n;
5039     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);
5040     if ( var.bw ) mag2->SetFillStyle(3001);
5041     if ( upd ) mag2->Draw();
5042     };
5043     };
5044     };
5045     TPad *trplv;
5046     gDirectory->Delete("trkplv");
5047     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);
5048     trplv->SetFillStyle(4000);
5049     trplv->SetFillColor(0);
5050     trplv->SetFrameFillStyle(4000);
5051     if ( upd ) trplv->Draw();
5052     //
5053     Int_t sigcol1 = 17;
5054     Int_t sigcol2 = 15;
5055     Int_t linecol = 13;
5056     if ( var.bw ) {
5057     sigcol1 = 17;
5058     sigcol2 = 15;
5059     linecol = 13;
5060     } else {
5061     sigcol1 = 32;
5062     sigcol2 = 38;
5063     linecol = 42;
5064     };
5065     TLine *linea = 0;
5066     TLine *linea1x = 0;
5067     TLine *linea2x = 0;
5068     TLine *linea1y = 0;
5069     Float_t x = 0.;
5070     for (Int_t l = 0; l<12; l++){
5071     trkpad[l]->cd();
5072     if ( l%2 ) {
5073     if ( level.file == 2 ){
5074     trkpad[l]->Range(-8.1,0.,8.1,8.);
5075     linea = new TLine(-8.1,0.01,8.1,0.01);
5076     linea1x = new TLine(-2.7,0.01,-2.7,0.030);
5077     linea2x = new TLine(2.7,0.01,2.7,0.030);
5078     } else {
5079     trkpad[l]->Range(0.,0.,3100.,1.);
5080     linea = new TLine(0.,0.01,3100.,0.01);
5081     linea1x = new TLine(1033.,0.01,1033,0.030);
5082     linea2x = new TLine(2066.,0.01,2066,0.030);
5083     };
5084     } else {
5085     if ( level.file == 2 ){
5086     trkpad[l]->Range(-7.05,0.,7.05,8.);
5087     linea = new TLine(-7.05,0.01,7.05,0.01);
5088     linea1y = new TLine(0.,0.01,0.,0.030);
5089     } else {
5090     trkpad[l]->Range(0.,0.,2076.,1.);
5091     linea = new TLine(0.,0.01,2076.,0.01);
5092     linea1y = new TLine(1038.,0.01,1038,0.030);
5093     };
5094     };
5095     linea->SetLineWidth(2);
5096     linea->SetLineColor(linecol);
5097     if ( upd ) linea->Draw();
5098     if ( l%2 ) {
5099     linea1x->SetLineWidth(1);
5100     linea1x->SetLineColor(1);
5101     if ( upd ) linea1x->Draw();
5102     linea2x->SetLineWidth(1);
5103     linea2x->SetLineColor(1);
5104     if ( upd ) linea2x->Draw();
5105     } else {
5106     linea1y->SetLineWidth(1);
5107     linea1y->SetLineColor(1);
5108     if ( upd ) linea1y->Draw();
5109     };
5110     //
5111     // LEVEL0 or LEVEL-1
5112     //
5113     if ( level.file == 0 || level.file == -1 ){
5114     Int_t planeno = trk->DSPnumber[l]-1;
5115     if ( planeno < 0 || planeno > 11 ) planeno = 0;
5116     if ( planeno >= 0 && !var.nosig ) {
5117     if ( (planeno+1)%2 ){
5118     trkpad[planeno]->cd();
5119     trkpad[planeno]->Range(0.,0.,2076.,1.);
5120     for (Int_t m = 0; m<3; m++){
5121     if ( trk->signcluster[l][m] != 0. ){
5122     if ( planeno == 10 ) {
5123 mocchiut 1.25 x = trk->addrcluster[l][m];
5124     } else {
5125 mocchiut 1.1 x = 1024 - trk->addrcluster[l][m];
5126     };
5127     linea = new TLine(14.+x,0.01,14.+x,0.3);
5128     linea->SetLineWidth(2);
5129     linea->SetLineColor(sigcol1);
5130     if ( upd ) linea->Draw();
5131     x += 1024.;
5132     linea = new TLine(14.+x,0.01,14.+x,0.3);
5133     linea->SetLineWidth(2);
5134     linea->SetLineColor(sigcol2);
5135     if ( upd ) linea->Draw();
5136     var.ncly++;
5137     };
5138     };
5139     } else {
5140     trkpad[planeno]->cd();
5141     trkpad[planeno]->Range(0.,0.,3100.,1.);
5142     for (Int_t m = 0; m<3; m++){
5143     if ( trk->signcluster[l][m] != 0. ){
5144     x = trk->addrcluster[l][m] + 1024. * m;
5145     linea = new TLine(14.+x,0.01,14.+x,0.3);
5146     linea->SetLineWidth(2);
5147     linea->SetLineColor(sigcol2);
5148     if ( upd ) linea->Draw();
5149     var.nclx++;
5150     };
5151     };
5152     };
5153     };
5154     };
5155     //
5156     if ( !upd ) return;
5157     //
5158     if ( level.file == 2 ){
5159     //
5160     // singlets X
5161     //
5162 mocchiut 1.6 for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsx(); sing++){
5163     TClonesArray &t = *(L2->GetTrkLevel2()->SingletX);
5164 mocchiut 1.1 TrkSinglet *singlet = (TrkSinglet*)t[sing];
5165     x = (singlet->coord[0]+singlet->coord[1])/2.;
5166     //
5167     Float_t xsig = singlet->sgnl;
5168     if ( xsig > 8. ) xsig = 8.;
5169     //
5170     Int_t planepad = (singlet->plane * 2) - 1;
5171     trkpad[planepad]->cd();
5172     trkpad[planepad]->Range(-8.1,0.,8.1,8.);
5173     if ( var.bw ){
5174     sigcol2 = -1;
5175     } else {
5176     sigcol2 = 1;
5177     };
5178     ColorTRKMIP(singlet->sgnl,sigcol2,0);
5179     linea = new TLine(x,0.01,x,xsig);
5180     linea->SetLineWidth(2);
5181     linea->SetLineColor(sigcol2);
5182     linea->Draw();
5183     };
5184     //
5185     // singlets Y
5186     //
5187 mocchiut 1.6 for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsy(); sing++){
5188     TClonesArray &t = *(L2->GetTrkLevel2()->SingletY);
5189 mocchiut 1.1 TrkSinglet *singlet = (TrkSinglet*)t[sing];
5190     //
5191     Int_t planepad = (singlet->plane - 1)* 2;
5192     trkpad[planepad]->cd();
5193     trkpad[planepad]->Range(-7.05,0.,7.05,8.);
5194     for (Int_t img=0; img<2; img++){
5195 mocchiut 1.25 x = -singlet->coord[img];
5196 mocchiut 1.1 Float_t xsig = singlet->sgnl;
5197     if ( xsig > 8. ) xsig = 8.;
5198     //
5199     if ( var.bw ){
5200     sigcol2 = -1;
5201     } else {
5202     sigcol2 = 1;
5203     };
5204     Int_t coloimg = img;
5205     //
5206     // last Y plane is reversed!
5207     //
5208     if ( planepad == 10 ){
5209     if ( img ){
5210     coloimg = 0;
5211     } else {
5212     coloimg = 1;
5213     };
5214     };
5215     ColorTRKMIP(singlet->sgnl,sigcol2,coloimg);
5216     linea = new TLine(x,0.01,x,xsig);
5217     linea->SetLineWidth(2);
5218     linea->SetLineColor(sigcol2);
5219     linea->Draw();
5220     };
5221     };
5222     //
5223     // Measured point relative to tracks and tracks
5224     // + dots on measured points
5225     //
5226     Int_t dcol;
5227     if ( var.bw ){
5228     dcol = 12;
5229     } else {
5230     dcol = 2;
5231     };
5232     //
5233 mocchiut 1.6 if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){
5234     for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){
5235 mocchiut 1.10 PamTrack *ptrack= L2->GetTrack(nt);
5236     TrkTrack *track = ptrack->GetTrkTrack();
5237 mocchiut 1.1 if ( nt == 0 ){
5238     var.rig = 0.;
5239     if ( track->al[4] != 0. ) var.rig = 1./track->al[4];
5240     var.chi2 = track->chi2;
5241     };
5242     for (Int_t plane = 0; plane<6; plane++){
5243     //
5244     // X view
5245     //
5246     Int_t planepad = (plane * 2) + 1;
5247     trkpad[planepad]->cd();
5248     trkpad[planepad]->Range(-8.1,0.,8.1,8.);
5249     //
5250     x = track->xm[plane];
5251 mocchiut 1.28 Float_t xsig = fabs(track->dedx_x[plane]);
5252 mocchiut 1.24 if ( track->XGood(plane) ){
5253 mocchiut 1.1 //if ( x > -100 ){
5254     if ( xsig > 8. ) xsig = 8.;
5255     if ( var.bw ){
5256     sigcol2 = -1;
5257     } else {
5258     sigcol2 = 1;
5259     };
5260 mocchiut 1.28 ColorTRKMIP(fabs(track->dedx_x[plane]),sigcol2,0);
5261 mocchiut 1.1 linea = new TLine(x,0.01,x,xsig);
5262     linea->SetLineWidth(2);
5263     linea->SetLineColor(sigcol2);
5264     linea->Draw();
5265     Float_t tx[5] = {x-0.3, x+0.3, x+0.3, x-0.3, x-0.3};
5266     Float_t tz[5] = {0., 0., 0.5, 0.5, 0.};
5267     TPolyLine *tlinea = new TPolyLine(5,tx,tz);
5268     tlinea->SetLineWidth(1);
5269     tlinea->SetLineColor(dcol);
5270     tlinea->SetFillColor(dcol);
5271     tlinea->Draw("f");
5272     tlinea->Draw();
5273     };
5274     //
5275     // Y view
5276     //
5277     planepad = plane * 2;
5278     trkpad[planepad]->cd();
5279     trkpad[planepad]->Range(-7.05,0.,7.05,8.);
5280 mocchiut 1.25 x = -track->ym[plane];
5281 mocchiut 1.28 xsig = fabs(track->dedx_y[plane]);
5282 mocchiut 1.24 if ( track->YGood(plane) ){
5283 mocchiut 1.1 // if ( x > -100 ){
5284     if ( xsig > 8. ) xsig = 8.;
5285     if ( var.bw ){
5286     sigcol2 = -1;
5287     } else {
5288     sigcol2 = 1;
5289     };
5290 mocchiut 1.28 ColorTRKMIP(fabs(track->dedx_y[plane]),sigcol2,0);
5291 mocchiut 1.1 linea = new TLine(x,0.01,x,xsig);
5292     linea->SetLineWidth(2);
5293     linea->SetLineColor(sigcol2);
5294     linea->Draw();
5295     Float_t tx[5] = {x-0.3, x+0.3, x+0.3, x-0.3, x-0.3};
5296     Float_t tz[5] = {0., 0., 0.5, 0.5, 0.};
5297     TPolyLine *tlinea = new TPolyLine(5,tx,tz);
5298     tlinea->SetLineColor(dcol);
5299     tlinea->SetFillColor(dcol);
5300     tlinea->SetLineWidth(1);
5301     tlinea->Draw("f");
5302     tlinea->Draw();
5303     };
5304     };
5305     };// loop on tracks
5306     };
5307     };
5308     //
5309     };
5310     //
5311     // Show track in the plane view!
5312     //
5313     if ( var.AC ){
5314     Float_t xh[6];
5315     Float_t yh1[6];
5316     Float_t yh2[6];
5317     Float_t mag[6];
5318     for (Int_t l = 0; l<6; l++ ){
5319     xh[l] = 0.;
5320     yh1[l] = 0.;
5321     yh2[l] = 0.;
5322     mag[l] = 0.;
5323     };
5324     Int_t ncro = 0;
5325     //
5326     // LEVEL2
5327     //
5328     if ( level.file == 2 ){
5329     //
5330     // first of all plot crosses relatives to tracks
5331     //
5332 mocchiut 1.6 if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){
5333 mocchiut 1.14 // for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){
5334     // TrkTrack *track = L2->GetTrkLevel2()->GetTrack(nt);
5335 mocchiut 1.6 for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){
5336 mocchiut 1.14 PamTrack *ptrack= L2->GetTrack(nt);
5337     TrkTrack *track = ptrack->GetTrkTrack();
5338     //
5339 mocchiut 1.1 for (Int_t plane = 0; plane<6; plane++){
5340     //
5341     x = track->xm[plane];
5342 mocchiut 1.25 Float_t y = -track->ym[plane];
5343 mocchiut 1.28 Float_t xsig = fabs(track->dedx_x[plane]);
5344     Float_t ysig = fabs(track->dedx_y[plane]);
5345 mocchiut 1.1 // if ( x > -100 && y > -100. ){
5346 mocchiut 1.24 if ( track->XGood(plane) && track->YGood(plane) ){
5347 mocchiut 1.1 if ( var.bw ){
5348     sigcol1 = -1;
5349     sigcol2 = -1;
5350     } else {
5351     sigcol1 = 1;
5352     sigcol2 = 1;
5353     };
5354     ColorTRKMIP(xsig,sigcol1,0);
5355     ColorTRKMIP(ysig,sigcol2,0);
5356     //
5357     // Draw crosses
5358     //
5359     trplv->cd();
5360     trplv->Range(-7.05,-8.1,7.05,8.1);
5361     //
5362     Float_t mg = ((float)plane+1.)/5.;
5363     Float_t cdx = (0.55/mg)*var.sfx;
5364     Float_t cdy = (0.55/mg)*var.sfy;
5365     Float_t lwx = (0.019)*var.sfy;
5366     Float_t lwy = (0.019)*var.sfx;
5367     //
5368     linea = new TLine(y-lwx/2.,x-cdy,y-lwx/2.,x+cdy);
5369     linea->SetLineWidth(1);
5370     linea->SetLineColor(sigcol1);
5371     linea->Draw();
5372     linea = new TLine(y-cdx,x-lwy/2.,y+cdx,x-lwy/2.);
5373     linea->SetLineWidth(1);
5374     linea->SetLineColor(sigcol2);
5375     linea->Draw();
5376     //
5377     };
5378     };
5379     };
5380     };
5381     //
5382     // try to plot crosses relative to singlets
5383     //
5384 mocchiut 1.6 if ( L2->GetTrkLevel2()->nclsx() > 0 && L2->GetTrkLevel2()->nclsy() > 0 ){
5385 mocchiut 1.1 for (Int_t plane = 1; plane<7; plane++){
5386     //
5387     // count how many singlet in the x and y view for this plane:
5388     //
5389     Int_t totsx = 0;
5390     Int_t totsy = 0;
5391     TArrayI *orderx = new TArrayI(5000);
5392     TArrayI *ordery = new TArrayI(5000);
5393     TArrayF *arrax = new TArrayF(5000);
5394     TArrayF *array1 = new TArrayF(5000);
5395     TArrayF *array2 = new TArrayF(5000);
5396     TArrayF *sigarrax = new TArrayF(5000);
5397     TArrayF *sigarray = new TArrayF(5000);
5398 mocchiut 1.6 for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsx(); sing++){
5399     TClonesArray &t = *(L2->GetTrkLevel2()->SingletX);
5400 mocchiut 1.1 TrkSinglet *singlet = (TrkSinglet*)t[sing];
5401     if ( singlet->plane == plane ){
5402     arrax->AddAt(((singlet->coord[0]+singlet->coord[1])/2.),totsx);
5403     sigarrax->AddAt(singlet->sgnl,totsx);
5404     if ( totsx == 0 || ( totsx > 0 && singlet->sgnl < sigarrax->At(orderx->At(totsx-1))) ){
5405     orderx->AddAt(totsx,totsx);
5406     } else {
5407     for (Int_t ord = totsx-1; ord >= 0; ord--){
5408     if ( singlet->sgnl < sigarrax->At(orderx->At(ord)) || ord == 0){
5409     if ( singlet->sgnl < sigarrax->At(orderx->At(ord)) ){
5410     for (Int_t reord = totsx; reord>(ord+1); reord--){
5411     orderx->AddAt(orderx->At(reord-1),reord);
5412     };
5413     orderx->AddAt(totsx,ord+1);
5414     break;
5415     } else {
5416     for (Int_t reord = totsx; reord>0; reord--){
5417     orderx->AddAt(orderx->At(reord-1),reord);
5418     };
5419     orderx->AddAt(totsx,0);
5420     break;
5421     };
5422     };
5423     };
5424     };
5425     totsx++;
5426     };
5427     };
5428 mocchiut 1.6 for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsy(); sing++){
5429     TClonesArray &t = *(L2->GetTrkLevel2()->SingletY);
5430 mocchiut 1.1 TrkSinglet *singlet = (TrkSinglet*)t[sing];
5431     if ( singlet->plane == plane ){
5432     array1->AddAt(singlet->coord[0],totsy);
5433     array2->AddAt(singlet->coord[1],totsy);
5434     sigarray->AddAt(singlet->sgnl,totsy);
5435     if ( totsy == 0 || ( totsy > 0 && singlet->sgnl < sigarray->At(ordery->At(totsy-1))) ){
5436     ordery->AddAt(totsy,totsy);
5437     } else {
5438     for (Int_t ord = totsy-1; ord >= 0; ord--){
5439     if ( singlet->sgnl < sigarray->At(ordery->At(ord)) || ord == 0){
5440     if ( singlet->sgnl < sigarray->At(ordery->At(ord)) ){
5441     for (Int_t reord = totsy; reord>(ord+1); reord--){
5442     ordery->AddAt(ordery->At(reord-1),reord);
5443     };
5444     ordery->AddAt(totsy,ord+1);
5445     break;
5446     } else {
5447     for (Int_t reord = totsy; reord>0; reord--){
5448     ordery->AddAt(ordery->At(reord-1),reord);
5449     };
5450     ordery->AddAt(totsy,0);
5451     break;
5452     };
5453     };
5454     };
5455     };
5456     totsy++;
5457     };
5458     };
5459     //
5460     if ( totsx && totsy ){
5461     for (Int_t sing = 0; sing < min(totsx,totsy); sing++){
5462     //
5463     x = arrax->At(orderx->At(sing));
5464 mocchiut 1.25 Float_t y1 = -array1->At(ordery->At(sing));
5465     Float_t y2 = -array2->At(ordery->At(sing));
5466 mocchiut 1.1 Float_t xsig = sigarrax->At(orderx->At(sing));
5467     Float_t ysig = sigarray->At(ordery->At(sing));
5468     if ( x > -100 && y1 > -100. ){
5469     if ( var.bw ){
5470     sigcol1 = -1;
5471     sigcol2 = -1;
5472     } else {
5473     sigcol1 = 1;
5474     sigcol2 = 1;
5475     };
5476     Int_t img = 0;
5477     if ( plane == 6 ) img = 1;
5478     ColorTRKMIP(xsig,sigcol1,img);
5479     ColorTRKMIP(ysig,sigcol2,img);
5480     //
5481     // Draw crosses
5482     //
5483     trplv->cd();
5484     trplv->Range(-7.05,-8.1,7.05,8.1);
5485     //
5486     Float_t mg = ((float)plane)/5.;
5487     Float_t cdx = (0.55/mg)*var.sfx;
5488     Float_t cdy = (0.55/mg)*var.sfy;
5489     Float_t lwx = (0.019)*var.sfy;
5490     Float_t lwy = (0.019)*var.sfx;
5491     //
5492     linea = new TLine(y1-lwx/2.,x-cdy,y1-lwx/2.,x+cdy);
5493     linea->SetLineWidth(1);
5494     linea->SetLineColor(sigcol1);
5495     linea->Draw();
5496     linea = new TLine(y1-cdx,x-lwy/2.,y1+cdx,x-lwy/2.);
5497     linea->SetLineWidth(1);
5498     linea->SetLineColor(sigcol2);
5499     linea->Draw();
5500     //
5501     };
5502     if ( x > -100 && y2 > -100. ){
5503     if ( var.bw ){
5504     sigcol1 = -1;
5505     sigcol2 = -1;
5506     } else {
5507     sigcol1 = 1;
5508     sigcol2 = 1;
5509     };
5510     Int_t img = 1;
5511     if ( plane == 6 ) img = 0;
5512     ColorTRKMIP(xsig,sigcol1,img);
5513     ColorTRKMIP(ysig,sigcol2,img);
5514     //
5515     // Draw crosses
5516     //
5517     trplv->cd();
5518     trplv->Range(-7.05,-8.1,7.05,8.1);
5519     //
5520     Float_t mg = ((float)plane)/5.;
5521     Float_t cdx = (0.55/mg)*var.sfx;
5522     Float_t cdy = (0.55/mg)*var.sfy;
5523     Float_t lwx = (0.019)*var.sfy;
5524     Float_t lwy = (0.019)*var.sfx;
5525     //
5526     linea = new TLine(y2-lwx/2.,x-cdy,y2-lwx/2.,x+cdy);
5527     linea->SetLineWidth(1);
5528     linea->SetLineColor(sigcol1);
5529     linea->Draw();
5530     linea = new TLine(y2-cdx,x-lwy/2.,y2+cdx,x-lwy/2.);
5531     linea->SetLineWidth(1);
5532     linea->SetLineColor(sigcol2);
5533     linea->Draw();
5534     };
5535     };
5536     };
5537     };
5538     };
5539     };
5540     //
5541     // LEVEL0 or LEVEL-1
5542     //
5543     if ( level.file == 0 || level.file == -1 ){
5544     for (Int_t l = 0; l<12; l++ ){
5545     Float_t xsig = 0.;
5546     Float_t ysig = 0.;
5547     Int_t planeno = trk->DSPnumber[l]-1;
5548     for (Int_t e = 0; e<12;e++){
5549     Int_t planeno2 = trk->DSPnumber[e]-1;
5550     if ( planeno == planeno2-1 ){
5551     if ( planeno < 0 || planeno > 11 ) planeno = 0;
5552     if ( planeno >= 0 && !var.nosig ) {
5553     mag[ncro] = ((float)planeno+1.)/5.;
5554     if ( (planeno+1)%2 ){
5555     for (Int_t m = 0; m<3; m++){
5556     if ( trk->signcluster[l][m] != 0. ){
5557     if ( planeno == 10 ) {
5558 mocchiut 1.25 x = trk->addrcluster[l][m];
5559     } else {
5560 mocchiut 1.1 x = 1024 - trk->addrcluster[l][m];
5561     };
5562     x += 1024.;
5563     if ( trk->signcluster[l][m]> ysig ){
5564     ysig = trk->signcluster[l][m];
5565 mocchiut 1.25 yh1[ncro] = x - 1024.;
5566 mocchiut 1.1 yh2[ncro] = x;
5567     };
5568     };
5569     };
5570     for (Int_t m = 0; m<3; m++){
5571     if ( trk->signcluster[e][m] != 0. ){
5572     x = trk->addrcluster[e][m] + 1024. * m;
5573     if ( trk->signcluster[e][m]> xsig ){
5574     xsig = trk->signcluster[e][m];
5575     xh[ncro] = x;
5576     };
5577     };
5578     };
5579     } else {
5580     for (Int_t m = 0; m<3; m++){
5581     if ( trk->signcluster[l][m] != 0. ){
5582     x = trk->addrcluster[l][m] + 1024. * m;
5583     if ( trk->signcluster[l][m]> xsig ){
5584     xsig = trk->signcluster[l][m];
5585     xh[ncro] = x;
5586     };
5587     };
5588     };
5589     if ( (planeno+1)%2 ){
5590     for (Int_t m = 0; m<3; m++){
5591     if ( trk->signcluster[e][m] != 0. ){
5592     if ( planeno == 10 ) {
5593 mocchiut 1.25 x = trk->addrcluster[e][m];
5594     } else {
5595 mocchiut 1.1 x = 1024 - trk->addrcluster[e][m];
5596     };
5597     x += 1024.;
5598     if ( trk->signcluster[e][m]> ysig ){
5599     ysig = trk->signcluster[e][m];
5600 mocchiut 1.25 yh1[ncro] = x - 1024.;
5601 mocchiut 1.1 yh2[ncro] = x;
5602     };
5603     };
5604     };
5605     };
5606     };
5607     if ( ysig > 0. && xsig > 0. ) {
5608     ncro++;
5609     };
5610     };
5611     };
5612     };
5613     };
5614     //
5615     // Draw crosses
5616     //
5617     if ( ncro && var.AC ) {
5618     trplv->cd();
5619     trplv->Range(0.,0.,2076.,3100.);
5620     for ( Int_t i = 0; i<ncro; i++){
5621     //
5622     Float_t cdx = (55./mag[i])*var.sfx;
5623     Float_t cdy = (55./mag[i])*var.sfy;
5624     Float_t lwx = (1.9)*var.sfy;
5625     Float_t lwy = (1.9)*var.sfx;
5626     //
5627     linea = new TLine(yh1[i]-lwx/2.,xh[i]-cdy,yh1[i]-lwx/2.,xh[i]+cdy);
5628     linea->SetLineWidth((int)lwx);
5629     linea->SetLineColor(sigcol1);
5630     linea->Draw();
5631     linea = new TLine(yh1[i]-cdx,xh[i]-lwy/2.,yh1[i]+cdx,xh[i]-lwy/2.);
5632     linea->SetLineWidth((int)lwy);
5633     linea->SetLineColor(sigcol1);
5634     linea->Draw();
5635     //
5636     linea = new TLine(yh2[i]-lwx/2.,xh[i]-cdy,yh2[i]-lwx/2.,xh[i]+cdy);
5637     linea->SetLineWidth((int)lwx);
5638     linea->SetLineColor(sigcol2);
5639     linea->Draw();
5640     linea = new TLine(yh2[i]-cdy,xh[i]-lwy/2.,yh2[i]+cdx,xh[i]-lwy/2.);
5641     linea->SetLineWidth((int)lwy);
5642     linea->SetLineColor(sigcol2);
5643     linea->Draw();
5644     };
5645     };
5646     };
5647     };
5648     }
5649    
5650     void FEVdetector::ShowTrack(){
5651     //
5652 mocchiut 1.18 if ( level.file != 2 ) return;
5653     //
5654 mocchiut 1.1 //
5655     //
5656 mocchiut 1.16 if ( var.CALO && var.CALOT ){
5657 mocchiut 1.7 if ( L2->GetCaloLevel2()->npcfit[0] > 0 && L2->GetCaloLevel2()->npcfit[1] > 0 ){
5658     Float_t calx[22];
5659     Float_t caly[22];
5660     Float_t calzx[22];
5661     Float_t calzy[22];
5662     Float_t zpiano[22];
5663     zpiano[0] = (CTZ+118.)*var.sfy/1000.;
5664     for (Int_t plane = 1; plane < 22; plane++){
5665     if ( !(plane%2) ){
5666     zpiano[plane] = zpiano[plane-1] - 8.09*var.sfy/1000.;
5667     }else {
5668     zpiano[plane] = zpiano[plane-1] - 10.09*var.sfy/1000.;
5669     };
5670     };
5671     for (Int_t plane = 0; plane < 22; plane++){
5672     calx[plane] = (L2->GetCaloLevel2()->cbar[plane][0]/100.)*var.sfx + var.xxvc;;
5673 mocchiut 1.25 caly[plane] = (-L2->GetCaloLevel2()->cbar[plane][1]/100.)*var.sfx + var.xyvc;
5674 mocchiut 1.7 // calzx[plane] = zpiano[plane] -5.81*var.sfy/1000. + var.yxvc;
5675     calzx[plane] = zpiano[plane] + var.yxvc;
5676     calzy[plane] = zpiano[plane] + var.yyvc;
5677     // printf(" calx %f caly %f calzx %f calzy %f \n",calx[plane],caly[plane],calzx[plane],calzy[plane]);
5678     };
5679     //
5680     // Calorimeter track
5681     //
5682     Int_t trcol = 30;
5683     if ( var.bw ){
5684     trcol = 14;
5685     } else {
5686     trcol = 44;
5687     };
5688     thefigure->cd();
5689     TPolyLine *trakx = new TPolyLine(22,calx,calzx);
5690     trakx->SetLineColor(trcol);
5691     if ( L2->GetCaloLevel2()->fitmode[0] == 1 ) trakx->SetLineStyle(3);
5692     if ( L2->GetCaloLevel2()->fitmode[0] == 2 ) trakx->SetLineStyle(4);
5693     trakx->SetLineWidth(2);
5694     trakx->Draw();
5695     TPolyLine *traky = new TPolyLine(22,caly,calzy);
5696     traky->SetLineColor(trcol);
5697     if ( L2->GetCaloLevel2()->fitmode[1] == 1 ) traky->SetLineStyle(3);
5698     if ( L2->GetCaloLevel2()->fitmode[1] == 2 ) traky->SetLineStyle(4);
5699     traky->SetLineWidth(2);
5700     traky->Draw();
5701     };
5702     if ( L2->GetCaloLevel2()->npcfit[2] > 0 ){
5703     Float_t calx[22];
5704     Float_t caly[22];
5705     Float_t calzx[22];
5706     Float_t calzy[22];
5707     Float_t zpiano[22];
5708     zpiano[0] = (CTZ+118.)*var.sfy/1000.;
5709     for (Int_t plane = 1; plane < 22; plane++){
5710     if ( !(plane%2) ){
5711     zpiano[plane] = zpiano[plane-1] - 8.09*var.sfy/1000.;
5712     }else {
5713     zpiano[plane] = zpiano[plane-1] - 10.09*var.sfy/1000.;
5714     };
5715     };
5716     //
5717     //
5718     CaloTrkVar *ctra = L2->GetCaloStoredTrack(-1);
5719     //
5720     for (Int_t plane = 0; plane < 22; plane++){
5721     calx[plane] = (ctra->tbar[plane][0]/100.)*var.sfx + var.xxvc;;
5722 mocchiut 1.25 caly[plane] = (-ctra->tbar[plane][1]/100.)*var.sfx + var.xyvc;
5723 mocchiut 1.7 // calzx[plane] = zpiano[plane] -5.81*var.sfy/1000. + var.yxvc;
5724     calzx[plane] = zpiano[plane] + var.yxvc;
5725     calzy[plane] = zpiano[plane] + var.yyvc;
5726     // printf(" calx %f caly %f calzx %f calzy %f \n",calx[plane],caly[plane],calzx[plane],calzy[plane]);
5727     };
5728     //
5729     // Calorimeter track
5730     //
5731     Int_t trcol = 30;
5732     if ( var.bw ){
5733     trcol = 16;
5734     } else {
5735     trcol = 46;
5736     };
5737     thefigure->cd();
5738     TPolyLine *trakx = new TPolyLine(22,calx,calzx);
5739     trakx->SetLineColor(trcol);
5740     trakx->SetLineStyle(3);
5741     trakx->SetLineWidth(2);
5742     trakx->Draw();
5743     TPolyLine *traky = new TPolyLine(22,caly,calzy);
5744     traky->SetLineColor(trcol);
5745     traky->SetLineStyle(3);
5746     traky->SetLineWidth(2);
5747     traky->Draw();
5748     };
5749     };
5750     //
5751 mocchiut 1.18 if ( !var.TRK ) return;
5752 mocchiut 1.1 //
5753 mocchiut 1.6 if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){
5754     for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){
5755 mocchiut 1.10
5756     // TrkTrack *track = L2->GetTrkLevel2()->GetTrack(nt);
5757 mocchiut 1.18 // printf("qui \n");
5758 mocchiut 1.10 PamTrack *ptrack = L2->GetTrack(nt);
5759     TrkTrack *track = ptrack->GetTrkTrack();
5760 mocchiut 1.18 // printf("qua \n");
5761 mocchiut 1.1 Int_t npoint = 100;
5762     Float_t zin[100];
5763     Double_t xout[100];
5764     Double_t yout[100];
5765     Int_t ifail = 0;
5766     Int_t trcol = 10;
5767     //
5768     Float_t tx[100];
5769     Float_t ty[100];
5770     Float_t ptx1[50];
5771     Float_t pty1[50];
5772     Float_t ptx2[50];
5773     Float_t pty2[50];
5774     Float_t tx1[15];
5775     Float_t ty1[15];
5776     Float_t tzx[100];
5777     Float_t tzy[100];
5778     Float_t tzx1[15];
5779     Float_t tzy1[15];
5780     //
5781     for ( Int_t e = 0; e < 100 ; e++) {
5782     xout[e] = 0.;
5783     yout[e] = 0.;
5784     //
5785     tx[e] = 0.;
5786     ty[e] = 0.;
5787     tzx[e] = 0.;
5788     tzy[e] = 0.;
5789     if ( e < 50 ){
5790     ptx1[e] = 0.;
5791     pty1[e] = 0.;
5792     ptx2[e] = 0.;
5793     pty2[e] = 0.;
5794     if ( e < 15 ){
5795     tx1[e] = 0.;
5796     ty1[e] = 0.;
5797     tzx1[e] = 0.;
5798     tzy1[e] = 0.;
5799     };
5800     };
5801     //
5802     zin[e] = 60. - (124./99.)*(float)e;
5803     };
5804     //
5805     zin[85] = -45.5;
5806     //
5807     Trajectory *tr = new Trajectory(npoint,zin);
5808     //
5809 mocchiut 1.27 // ifail = track->DoTrack2(tr);
5810     ifail = track->DoTrack(tr);
5811 mocchiut 1.1 //
5812     if ( !ifail ){
5813     for ( Int_t e = 0; e < npoint ; e++) {
5814     tx[e] = ((float)tr->x[e]/100.)*var.sfx + var.xxvc;
5815 mocchiut 1.25 ty[e] = (-(float)tr->y[e]/100.)*var.sfx + var.xyvc;
5816 mocchiut 1.1 if ( e < 50 ) {
5817 mocchiut 1.25 ptx1[e] = (-(float)tr->y[e]/100.)*var.sfx + var.xcat;
5818 mocchiut 1.1 pty1[e] = ((float)tr->x[e]/100.)*var.sfy + var.ycat;
5819     } else {
5820 mocchiut 1.25 ptx2[e-50] = (-(float)tr->y[e]/100.)*var.sfx + var.xcat;
5821 mocchiut 1.1 pty2[e-50] = ((float)tr->x[e]/100.)*var.sfy + var.ycat;
5822     };
5823     if ( e > 84 ) {
5824     tx1[e-85] = ((float)tr->x[e]/100.)*var.nds4 + var.xxvc;
5825 mocchiut 1.25 ty1[e-85] = (-(float)tr->y[e]/100.)*var.nds4 + var.xyvc;
5826 mocchiut 1.1 tzx1[e-85] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yxvc;
5827     tzy1[e-85] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yyvc;
5828     };
5829     tzx[e] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yxvc;
5830     tzy[e] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yyvc;
5831 mocchiut 1.7 // printf("tx[e] %f ty [e] %f tzx %f tzy %f \n",tx[e],ty[e],tzx[e],tzy[e]);
5832 mocchiut 1.1 };
5833     //
5834     // From S1 to CALO
5835     //
5836     if ( var.bw ){
5837     trcol = 17-nt;
5838     } else {
5839     trcol = 50-nt;
5840     };
5841     thefigure->cd();
5842     TPolyLine *trackx = new TPolyLine(86,tx,tzx);
5843     trackx->SetLineColor(trcol);
5844     trackx->SetLineWidth(1);
5845     trackx->Draw();
5846     TPolyLine *tracky = new TPolyLine(86,ty,tzy);
5847     tracky->SetLineColor(trcol);
5848     tracky->SetLineWidth(1);
5849     tracky->Draw();
5850     //
5851     // ND and S4
5852     //
5853     if ( var.tracknds4 ){
5854     TPolyLine *trackx1 = new TPolyLine(15,tx1,tzx1);
5855     trackx1->SetLineColor(trcol);
5856     trackx1->SetLineWidth(1);
5857     trackx1->Draw();
5858     TPolyLine *tracky1 = new TPolyLine(15,ty1,tzy1);
5859     tracky1->SetLineColor(trcol);
5860     tracky1->SetLineWidth(1);
5861     tracky1->Draw();
5862     };
5863     //
5864     // Plane View
5865     //
5866     if ( var.AC ){
5867     TPolyLine *trackp1 = new TPolyLine(50,ptx1,pty1);
5868     trackp1->SetLineColor(trcol);
5869     trackp1->SetLineWidth(1);
5870     trackp1->Draw();
5871     TPolyLine *trackp2 = new TPolyLine(50,ptx2,pty2);
5872     trackp2->SetLineColor(trcol);
5873     trackp2->SetLineWidth(1);
5874     trackp2->SetLineStyle(3);
5875     trackp2->Draw();
5876     };
5877    
5878     } else {
5879     pamgui->DIALOG(1," Failed in determining the track! ");
5880     printf(" WARNING: failed in determining the track! \n");
5881     };
5882     };
5883     };
5884     }
5885    
5886     void FEVdetector::ShowCalo(Bool_t upd){
5887     //
5888     //
5889     //
5890     if ( !var.CALO ) return;
5891     //
5892     var.qtot = 0;
5893     var.nstrip = 0;
5894     //
5895     if ( level.file == 0 ){
5896     //
5897     // Book the histograms:
5898     //
5899     //
5900     stringstream delex;
5901     delex.str("");
5902     delex << "x-view event " << (thisentry+1);
5903     stringstream deley;
5904     deley.str("");
5905     deley << "y-view event " << (thisentry+1);
5906     gDirectory->Delete(delex.str().c_str());
5907     gDirectory->Delete(deley.str().c_str());
5908     TH2F *Xview = new TH2F(delex.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
5909     TH2F *Yview = new TH2F(deley.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
5910     Xview->GetYaxis()->SetLabelColor(10);
5911     Yview->GetYaxis()->SetLabelColor(10);
5912     //
5913     // figures:
5914     //
5915     Int_t bgcolor = 10;
5916     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);
5917     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);
5918    
5919     pd1->SetFillStyle(4000);
5920     pd1->SetFillColor(0);
5921     pd1->SetFrameFillStyle(4000);
5922     pd2->SetFillStyle(4000);
5923     pd2->SetFillColor(0);
5924     pd2->SetFrameFillStyle(4000);
5925    
5926     TLatex *t=new TLatex();
5927     t->SetTextFont(32);
5928     t->SetTextColor(1);
5929     t->SetTextSize(0.03);
5930     t->SetTextAlign(12);
5931     pd1->Range(0.,0.,1.,1.);
5932     pd2->Range(0.,0.,1.,1.);
5933     pd1->SetTicks();
5934     pd2->SetTicks();
5935     pd1->Draw();
5936     pd2->Draw();
5937    
5938     pd1->cd();
5939     gStyle->SetOptStat(0);
5940     Xview->GetYaxis()->SetTitleOffset(0.5);
5941     Xview->SetFillColor(bgcolor);
5942     Xview->Fill(1.,1.,1.);
5943     Xview->Draw("box");
5944     pd1->Update();
5945     pd2->cd();
5946     gStyle->SetOptStat(0);
5947     Yview->GetYaxis()->SetTitleOffset(0.5);
5948     Yview->SetFillColor(bgcolor);
5949     Yview->Fill(1.,1.,1.);
5950     Yview->Draw("box");
5951     pd2->Update();
5952    
5953     //
5954     // run over views and planes
5955     //
5956     stringstream xevent;
5957     stringstream yevent;
5958     Float_t sdexy[2][22][96];
5959     Float_t sdexyc[2][22][96];
5960     //
5961     for (Int_t m = 0; m < 22; m++){
5962     for (Int_t l = 0; l < 2; l++){
5963     //
5964     // determine the section number
5965     //
5966     Int_t se = 5;
5967     if ( !l && m%2 == 0 ) se = 3;
5968     if ( !l && m%2 != 0 ) se = 2;
5969 mocchiut 1.18 if ( l && m%2 != 0 ) se = 1;
5970     if ( l && m%2 == 0 ) se = 0;
5971 mocchiut 1.1 //
5972     // determine what kind of event we are going to analyze
5973     //
5974     bool isCOMP = 0;
5975     bool isFULL = 0;
5976     bool isRAW = 0;
5977     if ( de->stwerr[se] & (1 << 16) ) isCOMP = 1;
5978     if ( de->stwerr[se] & (1 << 17) ) isFULL = 1;
5979     if ( de->stwerr[se] & (1 << 3) ) isRAW = 1;
5980     //
5981     // save the prevoius energy deposit and calibration in sbase, sdexy, sdexyc
5982     //
5983     Int_t pre = -1;
5984     if ( isRAW ){
5985     for (Int_t nn = 0; nn < 96; nn++){
5986     if ( nn%16 == 0 ) pre++;
5987     evento.base[l][m][pre] = calib.calbase[l][m][pre];
5988     sdexy[l][m][nn] = evento.dexy[l][m][nn];
5989     evento.dexy[l][m][nn] = de->dexy[l][m][nn] ;
5990     sdexyc[l][m][nn] = evento.dexy[l][m][nn];
5991     evento.dexyc[l][m][nn] = de->dexy[l][m][nn] ;
5992     };
5993     };
5994     //
5995     // run over strips
5996     //
5997     Int_t done = 0;
5998     Int_t rdone = 0;
5999     Int_t fdone = 0;
6000     pre = -1;
6001     for (Int_t n =0 ; n < 96; n++){
6002     if ( n%16 == 0 ) {
6003     pre++;
6004     done = 0;
6005     rdone = 0;
6006     fdone = 0;
6007     };
6008     //
6009     // baseline check and calculation
6010     //
6011     if ( isRAW ) {
6012     //
6013     // if it is a raw event and we haven't checked yet, calculate the baseline. Then check that the baseline is fine,
6014     // if not calculate it with relaxed algorithm.
6015     //
6016     if ( !rdone ){
6017     CaloFindBaseRaw(l,m,pre);
6018     rdone = 1;
6019     };
6020     //
6021     // no suitable new baseline, use old ones
6022     //
6023     if ( !done && (evento.base[l][m][pre] == 31000. || evento.base[l][m][pre] == 0.) ){
6024     evento.base[l][m][pre] = calib.sbase[l][m][pre];
6025     Int_t upnn = n+16;
6026     if ( upnn > 96 ) upnn = 96;
6027     for ( Int_t nn = n; nn<upnn; nn++ ){
6028     evento.dexyc[l][m][nn] = de->dexy[l][m][nn] ;
6029     };
6030     done = 1;
6031     };
6032     if ( !fdone ){
6033     CaloCompressData(l,m,pre);
6034     fdone = 1;
6035     };
6036     };
6037     //
6038     if ( de->dexyc[l][m][n] > 0. || ( isRAW && evento.dexyc[l][m][n] > 0. )){
6039     xevent.str("");
6040     yevent.str("");
6041     xevent << "x-view event " << n;
6042     xevent << " " << m;
6043     xevent << " " << l;
6044     yevent << "y-view event " << n;
6045     yevent << " " << m;
6046     yevent << " " << l;
6047     gDirectory->Delete(xevent.str().c_str());
6048     gDirectory->Delete(yevent.str().c_str());
6049     TH2F *Xview = new TH2F(xevent.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6050     TH2F *Yview = new TH2F(yevent.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6051     Int_t colo;
6052     if ( var.bw ){
6053     colo = 17;
6054     } else {
6055     colo = 38;
6056     };
6057     Xview->SetFillColor(colo);
6058     Yview->SetFillColor(colo);
6059     if ( l == 0 ) {
6060     Xview->Fill(n,21-m,1.);
6061     pd1->cd();
6062     Xview->Draw("box same");
6063     };
6064     if ( l == 1 ) {
6065 mocchiut 1.25 Yview->Fill(95-n,21-m,1.);
6066 mocchiut 1.1 pd2->cd();
6067     Yview->Draw("box same");
6068     };
6069     };
6070     };
6071     };
6072     };
6073     pd1->Update();
6074     pd2->Update();
6075     var.qtot=0;
6076     var.nstrip=0;
6077     };
6078     //
6079     if ( level.file == -1 ){
6080     Float_t qtot;
6081     Int_t nstrip;
6082     //
6083     // Define variables
6084     //
6085 mocchiut 1.15 UInt_t etime = var.etime;
6086 mocchiut 1.1 Float_t estrip[2][22][96], ener, basel,sdexy[2][22][96],sdexyc[2][22][96];
6087     Int_t badstrip = 0;
6088     qtot = 0.;
6089     nstrip = 0;
6090     //
6091     // Book the histograms:
6092     //
6093     //
6094     stringstream xvev;
6095     stringstream yvev;
6096     xvev.str("");
6097     yvev.str("");
6098     xvev << "x-view event " << (thisentry+1);
6099     yvev << "y-view event " << (thisentry+1);
6100     gDirectory->Delete(xvev.str().c_str());
6101     gDirectory->Delete(yvev.str().c_str());
6102     TH2F *Xview = new TH2F(xvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6103     TH2F *Yview = new TH2F(yvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6104     Xview->GetYaxis()->SetLabelColor(10);
6105     Yview->GetYaxis()->SetLabelColor(10);
6106     //
6107     // figures:
6108     //
6109     Int_t bgcolor = 10;
6110     gDirectory->Delete("caloy");
6111     gDirectory->Delete("calox");
6112     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);
6113     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);
6114     if ( upd ){
6115    
6116     pd1->SetFillStyle(4000);
6117     pd1->SetFillColor(0);
6118     pd1->SetFrameFillStyle(4000);
6119     pd2->SetFillStyle(4000);
6120     pd2->SetFillColor(0);
6121     pd2->SetFrameFillStyle(4000);
6122    
6123     TLatex *t=new TLatex();
6124     t->SetTextFont(32);
6125     t->SetTextColor(1);
6126     t->SetTextSize(0.03);
6127     t->SetTextAlign(12);
6128     pd1->Range(0.,0.,1.,1.);
6129     pd2->Range(0.,0.,1.,1.);
6130     pd1->SetTicks();
6131     pd2->SetTicks();
6132     pd1->Draw();
6133     pd2->Draw();
6134    
6135     pd1->cd();
6136     gStyle->SetOptStat(0);
6137     Xview->GetYaxis()->SetTitleOffset(0.5);
6138     Xview->SetFillColor(bgcolor);
6139     Xview->Fill(1.,1.,1.);
6140     Xview->Draw("box");
6141     pd1->Update();
6142     pd2->cd();
6143     gStyle->SetOptStat(0);
6144     Yview->GetYaxis()->SetTitleOffset(0.5);
6145     Yview->SetFillColor(bgcolor);
6146     Yview->Fill(1.,1.,1.);
6147     Yview->Draw("box");
6148     pd2->Update();
6149     };
6150     //
6151     // for each event check that the calibration we are using are still within calibration limits, if not call the next calibration
6152     //
6153     for (Int_t s = 0; s < 4; s++){
6154     if ( calib.ttime[s][b[s]+1] && calib.time[s][b[s]] ){
6155     while ( etime > calib.time[s][b[s]] && calib.time[s][b[s]] != 0 ){
6156     printf(" CALORIMETER: \n" );
6157 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]);
6158 mocchiut 1.1 printf(" END CALORIMETER. \n\n" );
6159     b[s]++;
6160     CaloPede(s);
6161     };
6162     };
6163     };
6164     //
6165     // run over views and planes
6166     //
6167     stringstream xve;
6168     stringstream yve;
6169     for (Int_t l = 0; l < 2; l++){
6170     for (Int_t m = 0; m < 22; m++){
6171     //
6172     // determine the section number
6173     //
6174     Int_t se = 5;
6175     if (l == 0 && m%2 == 0) se = 3;
6176     if (l == 0 && m%2 != 0) se = 2;
6177 mocchiut 1.18 if (l == 1 && m%2 != 0) se = 1;
6178     if (l == 1 && m%2 == 0) se = 0;
6179 mocchiut 1.1 //
6180     // determine what kind of event we are going to analyze
6181     //
6182     bool isCOMP = 0;
6183     bool isFULL = 0;
6184     bool isRAW = 0;
6185     if ( de->stwerr[se] & (1 << 16) ) isCOMP = 1;
6186     if ( de->stwerr[se] & (1 << 17) ) isFULL = 1;
6187     if ( de->stwerr[se] & (1 << 3) ) isRAW = 1;
6188     //
6189     // save the prevoius energy deposit and calibration in sbase, sdexy, sdexyc
6190     //
6191     Int_t pre = -1;
6192     if ( isRAW ){
6193     for (Int_t nn = 0; nn < 96; nn++){
6194     if ( nn%16 == 0 ) pre++;
6195     evento.base[l][m][pre] = calib.calbase[l][m][pre];
6196     sdexy[l][m][nn] = evento.dexy[l][m][nn];
6197     evento.dexy[l][m][nn] = de->dexy[l][m][nn] ;
6198     sdexyc[l][m][nn] = evento.dexy[l][m][nn];
6199     evento.dexyc[l][m][nn] = de->dexy[l][m][nn] ;
6200     };
6201     };
6202     //
6203     // run over strips
6204     //
6205     Int_t done = 0;
6206     Int_t rdone = 0;
6207     Int_t fdone = 0;
6208     pre = -1;
6209     for (Int_t n =0 ; n < 96; n++){
6210     if ( n%16 == 0 ) {
6211     pre++;
6212     done = 0;
6213     rdone = 0;
6214     fdone = 0;
6215     };
6216     //
6217     // baseline check and calculation
6218     //
6219     if ( !isRAW ) {
6220     //
6221     // 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.
6222     //
6223     if ( !done ){
6224     evento.base[l][m][pre] = de->base[l][m][pre] ;
6225     evento.dexyc[l][m][n] = de->dexyc[l][m][n] ;
6226     };
6227     } else {
6228     //
6229     // if it is a raw event and we haven't checked yet, calculate the baseline. Then check that the baseline is fine,
6230     // if not calculate it with relaxed algorithm.
6231     //
6232     if ( !rdone ){
6233     CaloFindBaseRaw(l,m,pre);
6234     rdone = 1;
6235     };
6236     };
6237     //
6238     // no suitable new baseline, use old ones
6239     //
6240     if ( !done && (evento.base[l][m][pre] == 31000. || evento.base[l][m][pre] == 0.) ){
6241     evento.base[l][m][pre] = calib.sbase[l][m][pre];
6242     Int_t upnn = n+16;
6243     if ( upnn > 96 ) upnn = 96;
6244     for ( Int_t nn = n; nn<upnn; nn++ ){
6245     if ( !isRAW ){
6246     evento.dexyc[l][m][nn] = de->dexyc[l][m][nn] ;
6247     } else {
6248     evento.dexyc[l][m][nn] = de->dexy[l][m][nn] ;
6249     };
6250     };
6251     CaloCompressData(l,m,pre);
6252     done = 1;
6253     };
6254     //
6255     // CALIBRATION ALGORITHM
6256     //
6257     basel = evento.base[l][m][pre];
6258     ener = evento.dexyc[l][m][n];
6259     estrip[l][m][n] = 0.;
6260     if ( basel>0 && basel < 30000. && ener > 0. ){
6261     estrip[l][m][n] = (ener - calib.calped[l][m][n] - basel)/mip[l][m][n] ;
6262     //
6263     // 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)
6264     //
6265     if ( upd ){
6266     xve.str("");
6267     yve.str("");
6268     xve << "x-view event " << n;
6269     xve << " " << m;
6270     xve << " " << l;
6271     yve << "y-view event " << n;
6272     yve << " " << m;
6273     yve << " " << l;
6274     gDirectory->Delete(xve.str().c_str());
6275     gDirectory->Delete(yve.str().c_str());
6276     TH2F *Xview = new TH2F(xve.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6277     TH2F *Yview = new TH2F(yve.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6278     if ( estrip[l][m][n] > 0.7 && !var.nosig ){
6279     Int_t colo;
6280     if ( var.bw ){
6281     colo = -1;
6282     } else {
6283     colo = 1;
6284     };
6285     ColorMIP(estrip[l][m][n],colo);
6286     Xview->SetFillColor(colo);
6287     Yview->SetFillColor(colo);
6288     if ( l == 0 ) {
6289     Xview->Fill(n,21-m,1.);
6290     pd1->cd();
6291     Xview->Draw("box same");
6292     };
6293     if ( l == 1 ) {
6294 mocchiut 1.25 Yview->Fill(96-n,21-m,1.);
6295 mocchiut 1.1 pd2->cd();
6296     Yview->Draw("box same");
6297     };
6298     };
6299     };
6300     if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] != 0 ) badstrip++;
6301     if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] == 0 ) {
6302     qtot += estrip[l][m][n];
6303     nstrip++;
6304     };
6305     };
6306     calib.sbase[l][m][pre] = evento.base[l][m][pre];
6307     };
6308     };
6309     };
6310     if ( upd ){
6311     pd1->Update();
6312     pd2->Update();
6313     };
6314     var.qtot=(int)qtot;
6315     var.nstrip=nstrip;
6316     };
6317     //
6318     if ( level.file == 2 ){
6319     //
6320     // Book the histograms:
6321     //
6322     //
6323     stringstream xview;
6324     stringstream yview;
6325     xview.str("");
6326     yview.str("");
6327     xview << "x-view event " << (thisentry+1);
6328     yview << "y-view event " << (thisentry+1);
6329     gDirectory->Delete(xview.str().c_str());
6330     gDirectory->Delete(yview.str().c_str());
6331     TH2F *Xview = new TH2F(xview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6332     TH2F *Yview = new TH2F(yview.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6333     Xview->GetYaxis()->SetLabelColor(10);
6334     Yview->GetYaxis()->SetLabelColor(10);
6335     //
6336     // figures:
6337     //
6338     Int_t bgcolor = 10;
6339     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);
6340     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);
6341    
6342     pd1->SetFillStyle(4000);
6343     pd1->SetFillColor(0);
6344     pd1->SetFrameFillStyle(4000);
6345     pd2->SetFillStyle(4000);
6346     pd2->SetFillColor(0);
6347     pd2->SetFrameFillStyle(4000);
6348    
6349     TLatex *t=new TLatex();
6350     t->SetTextFont(32);
6351     t->SetTextColor(1);
6352     t->SetTextSize(0.03);
6353     t->SetTextAlign(12);
6354     pd1->Range(0.,0.,1.,1.);
6355     pd2->Range(0.,0.,1.,1.);
6356     pd1->SetTicks();
6357     pd2->SetTicks();
6358     pd1->Draw();
6359     pd2->Draw();
6360    
6361     pd1->cd();
6362     gStyle->SetOptStat(0);
6363     Xview->GetYaxis()->SetTitleOffset(0.5);
6364     Xview->SetFillColor(bgcolor);
6365     Xview->Fill(1.,1.,1.);
6366     Xview->Draw("box");
6367     pd1->Update();
6368     pd2->cd();
6369     gStyle->SetOptStat(0);
6370     Yview->GetYaxis()->SetTitleOffset(0.5);
6371     Yview->SetFillColor(bgcolor);
6372     Yview->Fill(1.,1.,1.);
6373     Yview->Draw("box");
6374     pd2->Update();
6375    
6376     //
6377     // run over views and planes
6378     //
6379     stringstream xvev;
6380     stringstream yvev;
6381 mocchiut 1.6 for (Int_t ii = 0; ii < L2->GetCaloLevel2()->nstrip; ii++){
6382 mocchiut 1.1 Int_t colo;
6383     Int_t l;
6384     Int_t m;
6385     Int_t n;
6386 mocchiut 1.26 Bool_t satura = false;
6387     Float_t mip = L2->GetCaloLevel1()->DecodeEstrip(ii,l,m,n,satura);
6388 mocchiut 1.1 if ( var.bw ){
6389     colo = -1;
6390     } else {
6391     colo = 1;
6392 mocchiut 1.26 };
6393 mocchiut 1.1 ColorMIP(mip,colo);
6394     if ( l == 0 ) {
6395     xvev.str("");
6396     xvev << "x-view event " << n;
6397     xvev << " " << m;
6398     xvev << " " << l;
6399     gDirectory->Delete(xvev.str().c_str());
6400     TH2F *Xview = new TH2F(xvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6401 mocchiut 1.26 if ( satura ){
6402     Xview->SetFillColor(kBlack);
6403     } else {
6404     Xview->SetFillColor(colo);
6405     };
6406 mocchiut 1.1 Xview->Fill(n,21-m,1.);
6407     pd1->cd();
6408     Xview->Draw("box same");
6409     };
6410     if ( l == 1 ) {
6411     yvev.str("");
6412     yvev << "y-view event " << n;
6413     yvev << " " << m;
6414     yvev << " " << l;
6415     gDirectory->Delete(yvev.str().c_str());
6416     TH2F *Yview = new TH2F(yvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5);
6417 mocchiut 1.26 if ( satura ){
6418     Yview->SetFillColor(kBlack);
6419     } else {
6420     Yview->SetFillColor(colo);
6421     };
6422 mocchiut 1.25 Yview->Fill(96-n,21-m,1.);
6423 mocchiut 1.1 pd2->cd();
6424     Yview->Draw("box same");
6425     };
6426     };
6427     pd1->Update();
6428     pd2->Update();
6429 mocchiut 1.6 var.qtot=(int)L2->GetCaloLevel2()->qtot;
6430     var.nstrip=(int)L2->GetCaloLevel2()->nstrip;
6431 mocchiut 1.1 };
6432     }
6433    
6434     void FEVdetector::Calo1stcalib(){
6435     Float_t estrip[2][22][96];
6436     //
6437     // this is the value of the mip for each strip. To be changed when we will have the real values
6438     //
6439     for (Int_t s=0; s<4;s++){
6440     for (Int_t d = 0; d<50; d++){
6441     calib.ttime[s][d] = 0 ;
6442     if ( d < 49 ) calib.time[s][d] = 0 ;
6443     };
6444     };
6445     defcalib = false;
6446     //
6447     retry:
6448     //
6449     for (Int_t m = 0; m < 2 ; m++ ){
6450     for (Int_t k = 0; k < 22; k++ ){
6451     for (Int_t l = 0; l < 96; l++ ){
6452     calib.calped[m][k][l] = 0. ;
6453     estrip[m][k][l] = 0.;
6454     };
6455     };
6456     }
6457     //
6458     // first of all find the calibrations in the file
6459     //
6460     OLDCaloFindCalibs();
6461     //
6462     // print on the screen the results:
6463     //
6464     printf(" ---------------------------------------------------------- \n \n");
6465     Int_t calibex = 0;
6466     for (Int_t s=0; s<4;s++){
6467     Int_t stop = 0;
6468     for (Int_t d = 0; d<48; d++){
6469     if ( calib.ttime[s][d] != 0 ) calibex++;
6470     if ( calib.time[s][0] != 0 ){
6471 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]);
6472 mocchiut 1.1 if ( calib.time[s][d+1] != 0 ) {
6473 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]);
6474 mocchiut 1.1 } else {
6475     if ( !stop ){
6476 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]);
6477 mocchiut 1.1 stop = 1;
6478     };
6479     };
6480     } else {
6481 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]);
6482 mocchiut 1.1 };
6483     };
6484     printf("\n");
6485     };
6486     printf(" ---------------------------------------------------------- \n");
6487     if ( calibex < 1 ) {
6488     printf("No full calibration data in this file\n");
6489     printf(" Using default calibration \n");
6490     defcalib = true;
6491     goto retry;
6492     };
6493     //
6494     // calibrate before starting
6495     //
6496     for (Int_t s = 0; s < 4; s++){
6497     b[s]=0;
6498     CaloPede(s);
6499     };
6500     }
6501    
6502     int FEVdetector::OLDCaloFindCalibs(){
6503     for (Int_t s = 0; s < 4; s++){
6504     for (Int_t d = 1; d<50; d++){
6505     calib.ttime[s][d] = 0;
6506     if ( d < 49 ) calib.time[s][d] = 0;
6507     };
6508     };
6509     TString calibfile;
6510     if ( defcalib ){
6511     const char *pam_calib = pathtocalibration();
6512     stringstream calfile;
6513     calfile.str("");
6514     calfile << pam_calib << "/cal-param/FCaloDefaultCalib.root";
6515     calibfile = calfile.str().c_str();
6516     } else {
6517     calibfile = var.thefilename;
6518     };
6519     if ( !existfile(calibfile) ) return(1);
6520     //
6521     printf(" Using for calibrations file %s \n",calibfile.Data());
6522     //
6523     TFile *File = new TFile(calibfile.Data());
6524     TTree *tr = (TTree*)File->Get("CalibCalPed");
6525     pamela::CalibCalPedEvent *ce = 0;
6526     pamela::PscuHeader *cph = 0;
6527     pamela::EventHeader *ceh = 0;
6528     tr->SetBranchAddress("Header", &ceh);
6529     tr->SetBranchAddress("CalibCalPed", &ce);
6530     Long64_t ncalibs = tr->GetEntries();
6531     Int_t inter;
6532     for (Int_t s = 0; s < 4; s++){
6533     for (Int_t d = 1; d<50; d++){
6534     calib.ttime[s][d] = 0;
6535     if ( d < 49 ) calib.time[s][d] = 0;
6536     };
6537     };
6538     for (Int_t s = 0; s < 4; s++){
6539     inter = 0;
6540     for (Int_t c = 0; c < ncalibs; c++){
6541     tr->GetEntry(c);
6542     cph = ceh->GetPscuHeader();
6543     calib.ttime[s][inter] = 0;
6544     if ( ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) {
6545     //calib.ttime[s][inter] = cph->GetOrbitalTime();
6546 mocchiut 1.15 calib.ttime[s][inter] = (UInt_t)cph->OrbitalTime;
6547 mocchiut 1.1 inter++;
6548     } else {
6549     if ( ce->cstwerr[s] != 0 && ce->cperror[s] != 0 ) {
6550     printf(" ERROR: entry %i stwerr %X perror %f \n",c,ce->cstwerr[s],ce->cperror[s]);
6551     };
6552     };
6553     };
6554     if ( inter == 0 ){
6555     printf(" ERROR: no suitable calibration for section %i in this file!\n",s);
6556     };
6557     for (Int_t d = 1; d<50; d++){
6558     if ( calib.ttime[s][d] != 0 ) {
6559     calib.time[s][d-1] = calib.ttime[s][d-1] + (int)((calib.ttime[s][d] - calib.ttime[s][d-1])/2.);
6560     } else {
6561     if ( d == 1 ) {
6562     calib.time[s][d-1] = 0;
6563     };
6564     };
6565     };
6566     };
6567     File->Close();
6568     return(0);
6569     }
6570    
6571     int FEVdetector::CaloPede(Int_t s){
6572     //
6573     UInt_t atime = calib.ttime[s][b[s]];
6574     TString calibfile;
6575     if ( defcalib ){
6576     const char *pam_calib = pathtocalibration();
6577     stringstream calfile;
6578     calfile.str("");
6579     calfile << pam_calib << "/cal-param/FCaloDefaultCalib.root";
6580     calibfile = calfile.str().c_str();
6581     } else {
6582     calibfile = var.thefilename;
6583     };
6584     if ( !existfile(calibfile) ) return(3);
6585     //
6586     TFile *File = new TFile(calibfile.Data());
6587     TTree *tr = (TTree*)File->Get("CalibCalPed");
6588     //
6589     pamela::CalibCalPedEvent *ce = 0;
6590     pamela::PscuHeader *cph = 0;
6591     pamela::EventHeader *ceh = 0;
6592     tr->SetBranchAddress("Header", &ceh);
6593     tr->SetBranchAddress("CalibCalPed", &ce);
6594     //
6595     Long64_t ncalibs = tr->GetEntries();
6596     for (Int_t ci = 0; ci < ncalibs ; ci++){
6597     tr->GetEntry(ci);
6598     cph = ceh->GetPscuHeader();
6599     //if ( atime == cph->GetOrbitalTime()){
6600 mocchiut 1.15 if ( atime == (UInt_t)cph->OrbitalTime){
6601 mocchiut 1.1 // calib.iev = ce->iev;
6602     if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) {
6603     for ( Int_t d=0 ; d<11 ;d++ ){
6604     Int_t pre = -1;
6605     for ( Int_t j=0; j<96 ;j++){
6606     if ( j%16 == 0 ) pre++;
6607     if ( s == 2 ){
6608     calib.calped[0][2*d+1][j] = ce->calped[3][d][j];
6609     calib.cstwerr[3] = ce->cstwerr[3];
6610     calib.cperror[3] = ce->cperror[3];
6611     calib.calgood[0][2*d+1][j] = ce->calgood[3][d][j];
6612     calib.calthr[0][2*d+1][pre] = ce->calthr[3][d][pre];
6613     calib.calrms[0][2*d+1][j] = ce->calrms[3][d][j];
6614     calib.calbase[0][2*d+1][pre] = ce->calbase[3][d][pre];
6615     calib.calvar[0][2*d+1][pre] = ce->calvar[3][d][pre];
6616     };
6617     if ( s == 3 ){
6618     calib.calped[0][2*d][j] = ce->calped[1][d][j];
6619     calib.cstwerr[1] = ce->cstwerr[1];
6620     calib.cperror[1] = ce->cperror[1];
6621     calib.calgood[0][2*d][j] = ce->calgood[1][d][j];
6622     calib.calthr[0][2*d][pre] = ce->calthr[1][d][pre];
6623     calib.calrms[0][2*d][j] = ce->calrms[1][d][j];
6624     calib.calbase[0][2*d][pre] = ce->calbase[1][d][pre];
6625     calib.calvar[0][2*d][pre] = ce->calvar[1][d][pre];
6626     };
6627     if ( s == 0 ){
6628     calib.calped[1][2*d][j] = ce->calped[0][d][j];
6629     calib.cstwerr[0] = ce->cstwerr[0];
6630     calib.cperror[0] = ce->cperror[0];
6631     calib.calgood[1][2*d][j] = ce->calgood[0][d][j];
6632     calib.calthr[1][2*d][pre] = ce->calthr[0][d][pre];
6633     calib.calrms[1][2*d][j] = ce->calrms[0][d][j];
6634     calib.calbase[1][2*d][pre] = ce->calbase[0][d][pre];
6635     calib.calvar[1][2*d][pre] = ce->calvar[0][d][pre];
6636     };
6637     if ( s == 1 ){
6638     calib.calped[1][2*d+1][j] = ce->calped[2][d][j];
6639     calib.cstwerr[2] = ce->cstwerr[2];
6640     calib.cperror[2] = ce->cperror[2];
6641     calib.calgood[1][2*d+1][j] = ce->calgood[2][d][j];
6642     calib.calthr[1][2*d+1][pre] = ce->calthr[2][d][pre];
6643     calib.calrms[1][2*d+1][j] = ce->calrms[2][d][j];
6644     calib.calbase[1][2*d+1][pre] = ce->calbase[2][d][pre];
6645     calib.calvar[1][2*d+1][pre] = ce->calvar[2][d][pre];
6646     };
6647     };
6648     };
6649     };
6650     };
6651     };
6652     File->Close();
6653     return(0);
6654     }
6655    
6656     void FEVdetector::CaloFindBaseRaw(Int_t l, Int_t m, Int_t pre){
6657     Float_t minstrip = 100000.;
6658     Float_t rms = 0.;
6659     evento.base[l][m][pre] = 0.;
6660     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
6661     if ( calib.calgood[l][m][e] == 0. && evento.dexy[l][m][e]-calib.calped[l][m][e] < minstrip && evento.dexy[l][m][e] > 0.) {
6662     minstrip = evento.dexy[l][m][e]-calib.calped[l][m][e];
6663     rms = calib.calthr[l][m][pre];
6664     };
6665     };
6666     if ( minstrip != 100000. ) {
6667     Float_t strip6s = 0.;
6668     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
6669     if ( (evento.dexy[l][m][e]-calib.calped[l][m][e]) >= minstrip && (evento.dexy[l][m][e]-calib.calped[l][m][e]) <= (minstrip+rms) ) {
6670     strip6s += 1.;
6671     evento.base[l][m][pre] += (evento.dexy[l][m][e] - calib.calped[l][m][e]);
6672     };
6673     //
6674     // compression
6675     //
6676     if ( abs((int)(evento.dexy[l][m][e]-calib.calped[l][m][e])) <= (minstrip+rms) ) {
6677     evento.dexyc[l][m][e] = 0.;
6678     } else {
6679     evento.dexyc[l][m][e] = evento.dexy[l][m][e];
6680     };
6681     };
6682     if ( strip6s >= 9. ){
6683     Double_t arro = evento.base[l][m][pre]/strip6s;
6684     Float_t deci = 1000.*((float)arro - float(int(arro)));
6685     if ( deci < 500. ) {
6686     arro = double(int(arro));
6687     } else {
6688     arro = 1. + double(int(arro));
6689     };
6690     evento.base[l][m][pre] = arro;
6691     } else {
6692     evento.base[l][m][pre] = 31000.;
6693     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
6694     evento.dexyc[l][m][e] = evento.dexy[l][m][e];
6695     };
6696     };
6697     } else {
6698     evento.base[l][m][pre] = 31000.;
6699     };
6700     }
6701    
6702     void FEVdetector::CaloCompressData(Int_t l, Int_t m, Int_t pre){
6703     Float_t minstrip = 100000.;
6704     Float_t rms = 0.;
6705     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
6706     if ( calib.calgood[l][m][e] == 0. && evento.dexyc[l][m][e]-calib.calped[l][m][e] < minstrip && evento.dexyc[l][m][e] > 0.) {
6707     minstrip = evento.dexyc[l][m][e]-calib.calped[l][m][e];
6708     rms = calib.calthr[l][m][pre];
6709     };
6710     };
6711     //
6712     // compression
6713     //
6714     if ( minstrip < evento.base[l][m][pre] && minstrip != 100000.){
6715     for (Int_t e = pre*16; e < (pre+1)*16 ; e++){
6716     if ( evento.dexyc[l][m][e]-calib.calped[l][m][e] <= (minstrip+rms) ) evento.dexyc[l][m][e] = 0.;
6717     };
6718     };
6719     }

  ViewVC Help
Powered by ViewVC 1.1.23