/[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.34 - (hide annotations) (download)
Tue Jan 3 20:53:29 2012 UTC (13 years ago) by mocchiut
Branch: MAIN
Changes since 1.33: +20 -8 lines
ToF visualization bug fixed - now showing all hit paddles

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

  ViewVC Help
Powered by ViewVC 1.1.23