/[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.39 - (hide annotations) (download)
Tue Nov 4 15:03:27 2014 UTC (10 years, 1 month ago) by mocchiut
Branch: MAIN
CVS Tags: v10REDr01, HEAD
Changes since 1.38: +2 -1 lines
PamLevel2 not initialized bug, fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23