/[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.33 - (hide annotations) (download)
Tue May 11 09:13:47 2010 UTC (14 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.32: +2 -0 lines
New input option (still backward compatible) + noDB option

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

  ViewVC Help
Powered by ViewVC 1.1.23