/[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.11 - (hide annotations) (download)
Mon Feb 26 17:30:32 2007 UTC (17 years, 10 months ago) by mocchiut
Branch: MAIN
Changes since 1.10: +77 -42 lines
More bugs fixed + CARD position now is correct

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

  ViewVC Help
Powered by ViewVC 1.1.23