1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "TFlukaScoringOption.h"
19 #include "TFlukaMCGeometry.h"
20 #include <TGeoManager.h>
21 #include <TGeoVolume.h>
23 ClassImp(TFlukaScoringOption)
25 FILE* TFlukaScoringOption::fgFile(0x0);
26 TFlukaMCGeometry* TFlukaScoringOption::fgGeom(0x0);
28 TFlukaScoringOption::TFlukaScoringOption()
34 // Default constructor
37 TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what)
46 Int_t npar = (nopfl == 0)? 6 : 12;
47 for (Int_t i = 0; i < npar; i++) fWhat[i] = what[i];
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)
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];
70 //______________________________________________
71 const char* TFlukaScoringOption::GetRegName(Int_t ndet)
73 // Return ndet'th region name
74 return fName[ndet - 1];
78 // Write Fluka Input Cards
80 void TFlukaScoringOption::WriteOpenFlukaFile()
83 // Write Fluka input card for output file opening
85 fprintf(fgFile, "OPEN %10.1f %s\n",
87 fprintf(fgFile, "%s\n", GetFileName());
91 void TFlukaScoringOption::WriteFlukaInputCards()
94 // Write the Fluka Input Cards for this scoring option
97 const char* cont_line = "&";
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 //***************************************************************************
109 if(strncmp(GetName(), "USRBIN", 6) == 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);
127 printf("Check consistency of SetUserScoring values \n");
135 if(strncmp(GetName(), "USRBDX", 6) == 0){
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);
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);
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);
171 Int_t TFlukaScoringOption::GetRegionByName(const char* detname)
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;