/[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.26 - (hide annotations) (download)
Fri May 23 15:54:28 2008 UTC (16 years, 7 months ago) by mocchiut
Branch: MAIN
CVS Tags: v4r00
Changes since 1.25: +17 -7 lines
Calorimeter saturated strips in black

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

  ViewVC Help
Powered by ViewVC 1.1.23