]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/TFlukaScoringOption.cxx
Ignoring smell subdet
[u/mrichter/AliRoot.git] / TFluka / TFlukaScoringOption.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$*/
17
18 #include "TFlukaScoringOption.h"
19 #include "TFlukaMCGeometry.h"
20 #include <TGeoManager.h>
21 #include <TGeoVolume.h>
22
23 ClassImp(TFlukaScoringOption)
24
25 FILE*              TFlukaScoringOption::fgFile(0x0);
26 TFlukaMCGeometry*  TFlukaScoringOption::fgGeom(0x0);
27
28 TFlukaScoringOption::TFlukaScoringOption()
29    : fNopfl(0),
30      fOutFile(""),
31      fLun(0)
32 {
33
34     // Default constructor
35 }
36
37 TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what)
38     : TNamed(name, sdum),
39       fNopfl(nopfl),
40       fOutFile(outfile),
41       fLun(0)
42 {
43     // Constructor
44     fNopfl   = nopfl;
45     fOutFile = outfile;
46     Int_t npar = (nopfl == 0)? 6 : 12;
47     for (Int_t i = 0; i < npar; i++)  fWhat[i] = what[i];
48 }
49
50 TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what, 
51                                          const char* det1, const char* det2, const char* det3)
52     : TNamed(name, sdum),
53       fNopfl(nopfl + 2),
54       fOutFile(outfile),
55       fLun(0)
56 {
57     // Constructor
58 //    fNopfl   = nopfl + 2;
59 //    fOutFile = outfile;
60     Int_t npar = (nopfl == 0)? 6 : 12;
61     for (Int_t i = 0; i < npar; i++)  fWhat[i] = what[i];
62
63     fName[0] = det1;
64     fName[1] = det2;
65     fName[2] = det3;
66 }
67
68
69 //--- GET METHODS
70 //______________________________________________
71 const char* TFlukaScoringOption::GetRegName(Int_t ndet) 
72 {
73     // Return ndet'th region name
74     return fName[ndet - 1];
75 }
76
77 //
78 // Write Fluka Input Cards
79 //
80 void TFlukaScoringOption::WriteOpenFlukaFile()
81 {
82     //
83     // Write Fluka input card for output file opening
84     // 
85     fprintf(fgFile, "OPEN      %10.1f                                                    %s\n", 
86             GetLun(), "NEW");
87     fprintf(fgFile, "%s\n", GetFileName());
88 }
89
90
91 void TFlukaScoringOption::WriteFlukaInputCards()
92 {
93     //
94     // Write the Fluka Input Cards for this scoring option
95     //
96
97     const char* cont_line = "&";
98
99 //***************************************************************************
100 //*    Par()==0  only 6 parameter && regions by float                       *
101 //*    Par()==1  only 6 parameter && regions by Name                        *
102 //*    Par()==2      12 parameter && regions by float                       *
103 //*    Par()==3      12 parameter && regions by Name                        *
104 //*    Par()==4      12 parameter && regions by Name (for USRBIN only)      *
105 //***************************************************************************
106 //
107 // USRBIN
108 //
109     if(strncmp(GetName(), "USRBIN", 6) == 0){
110         if (Par() == 0) {
111             fprintf(fgFile, "USRBIN    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f%s\n",
112                     What(1), What(2), GetLun(), What(4), What(5), What(6), GetTitle());
113         } else if (Par() == 1) {
114             fprintf(fgFile, "USRBIN    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f%s\n",
115                     What(1), What(2), GetLun(), What(4), What(5),  What(6), GetTitle());
116             fprintf(fgFile, "USRBIN    %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f  %s\n",
117                     What(7), What(8), What(9), What(10), What(11), What(12), cont_line);
118         } else if (Par() == 2) {
119             if(What(1) == 2.0 || What(1) == 12){
120                 fprintf(fgFile, "USRBIN    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f%s\n",
121                         What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
122                         Float_t(GetRegionByName(GetRegName(2))), Float_t(GetRegionByName(GetRegName(3))), GetTitle());
123                 fprintf(fgFile, "USRBIN    %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f  %s\n",
124                         Float_t(GetRegionByName(GetRegName(1))), Float_t(GetRegionByName(GetRegName(2))),
125                         Float_t(GetRegionByName(GetRegName(3))), 1., 1., 1., cont_line);
126             } else {
127                 printf("Check consistency of SetUserScoring values \n");
128             }
129         }
130     }
131    
132 //
133 // USRBDX
134 //
135     if(strncmp(GetName(), "USRBDX", 6) == 0){
136         if (Par() == 2) {
137             fprintf(fgFile, "USRBDX    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
138                     What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
139                     Float_t(GetRegionByName(GetRegName(2))), What(6));
140         } else if (Par() == 3) {
141             fprintf(fgFile, "USRBDX    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
142                     What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
143                     Float_t(GetRegionByName(GetRegName(2))), What(6));
144             fprintf(fgFile, "USRBDX    %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f  %s\n",
145                     What(7), What(8), What(9), What(10), What(11), What(12), cont_line);
146         }
147     }
148     
149 //
150 // USTRACK
151 //
152     if(strncmp(GetName(), "USRTRACK", 6) == 0){
153         fprintf(fgFile, "USRTRACK  %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
154                 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))), What(4), What(5));
155         fprintf(fgFile, "USRTRACK  %10.1f%10.4g                                          %s\n",
156                 What(7), What(8), cont_line);
157     }
158     
159 //
160 // USRCOLL
161 // 
162     if(strncmp(GetName(), "USRCOLL", 6) == 0){
163         fprintf(fgFile, "USRCOLL   %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
164                 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))), What(4), What(5));
165         fprintf(fgFile, "USRCOLL   %10.1f%10.4g                                          %s\n",
166                 What(7), What(8), cont_line);
167     }
168 }
169
170
171 Int_t TFlukaScoringOption::GetRegionByName(const char* detname)
172 {
173 // Get number of region for a given detector name
174     TGeoVolume* vol = dynamic_cast<TGeoVolume*>((gGeoManager->GetListOfVolumes())->FindObject(detname));
175     Int_t ireg = (vol)? vol->GetNumber() : -999;
176     return ireg;
177 }