]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/TFlukaScoringOption.cxx
Protection against id = 308, 211 removed.
[u/mrichter/AliRoot.git] / TFluka / TFlukaScoringOption.cxx
CommitLineData
f0d336ab 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"
f450e9d0 19#include "TFlukaMCGeometry.h"
20#include <TGeoManager.h>
21#include <TGeoVolume.h>
22
8be76537 23ClassImp(TFlukaScoringOption)
f0d336ab 24
f450e9d0 25FILE* TFlukaScoringOption::fgFile(0x0);
26TFlukaMCGeometry* TFlukaScoringOption::fgGeom(0x0);
f0d336ab 27
28TFlukaScoringOption::TFlukaScoringOption()
4aba9d66 29 : fNopfl(0),
30 fOutFile(""),
31 fLun(0)
f0d336ab 32{
4aba9d66 33
f0d336ab 34 // Default constructor
35}
36
f450e9d0 37TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what)
4aba9d66 38 : TNamed(name, sdum),
39 fNopfl(nopfl),
40 fOutFile(outfile),
41 fLun(0)
f450e9d0 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}
f0d336ab 49
f450e9d0 50TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what,
4aba9d66 51 const char* det1, const char* det2, const char* det3)
52 : TNamed(name, sdum),
53 fNopfl(nopfl + 2),
54 fOutFile(outfile),
55 fLun(0)
f0d336ab 56{
57 // Constructor
4aba9d66 58// fNopfl = nopfl + 2;
59// fOutFile = outfile;
f450e9d0 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//______________________________________________
71const 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//
80void TFlukaScoringOption::WriteOpenFlukaFile()
81{
82 //
83 // Write Fluka input card for output file opening
84 //
85 fprintf(fgFile, "OPEN %10.1f %s\n",
4aba9d66 86 GetLun(), "NEW");
f450e9d0 87 fprintf(fgFile, "%s\n", GetFileName());
f0d336ab 88}
f450e9d0 89
90
91void 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){
4aba9d66 110 if (Par() == 0) {
6f1aaa8e 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());
4aba9d66 113 } else if (Par() == 1) {
6f1aaa8e 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());
4aba9d66 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){
6f1aaa8e 120 fprintf(fgFile, "USRBIN %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f%s\n",
4aba9d66 121 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
6f1aaa8e 122 Float_t(GetRegionByName(GetRegName(2))), Float_t(GetRegionByName(GetRegName(3))), GetTitle());
4aba9d66 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 }
f450e9d0 130 }
131
132//
133// USRBDX
134//
135 if(strncmp(GetName(), "USRBDX", 6) == 0){
4aba9d66 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 }
f450e9d0 147 }
148
149//
150// USTRACK
151//
152 if(strncmp(GetName(), "USRTRACK", 6) == 0){
4aba9d66 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);
f450e9d0 157 }
158
159//
160// USRCOLL
161//
162 if(strncmp(GetName(), "USRCOLL", 6) == 0){
4aba9d66 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);
f450e9d0 167 }
168}
169
170
171Int_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}