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

  ViewVC Help
Powered by ViewVC 1.1.23