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()
30 // Default constructor
33 TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what)
39 Int_t npar = (nopfl == 0)? 6 : 12;
40 for (Int_t i = 0; i < npar; i++) fWhat[i] = what[i];
43 TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what,
44 const char* det1, const char* det2, const char* det3)
50 Int_t npar = (nopfl == 0)? 6 : 12;
51 for (Int_t i = 0; i < npar; i++) fWhat[i] = what[i];
60 //______________________________________________
61 const char* TFlukaScoringOption::GetRegName(Int_t ndet)
63 // Return ndet'th region name
64 return fName[ndet - 1];
68 // Write Fluka Input Cards
70 void TFlukaScoringOption::WriteOpenFlukaFile()
73 // Write Fluka input card for output file opening
75 fprintf(fgFile, "OPEN %10.1f %s\n",
77 fprintf(fgFile, "%s\n", GetFileName());
81 void TFlukaScoringOption::WriteFlukaInputCards()
84 // Write the Fluka Input Cards for this scoring option
87 const char* cont_line = "&";
89 //***************************************************************************
90 //* Par()==0 only 6 parameter && regions by float *
91 //* Par()==1 only 6 parameter && regions by Name *
92 //* Par()==2 12 parameter && regions by float *
93 //* Par()==3 12 parameter && regions by Name *
94 //* Par()==4 12 parameter && regions by Name (for USRBIN only) *
95 //***************************************************************************
99 if(strncmp(GetName(), "USRBIN", 6) == 0){
101 fprintf(fgFile, "USRBIN %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
102 What(1), What(2), GetLun(), What(4), What(5), What(6));
103 } else if (Par() == 1) {
104 fprintf(fgFile, "USRBIN %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
105 What(1), What(2), GetLun(), What(4), What(5), What(6));
106 fprintf(fgFile, "USRBIN %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f %s\n",
107 What(7), What(8), What(9), What(10), What(11), What(12), cont_line);
108 } else if (Par() == 2) {
109 if(What(1) == 2.0 || What(1) == 12){
110 fprintf(fgFile, "USRBIN %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
111 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
112 Float_t(GetRegionByName(GetRegName(2))), Float_t(GetRegionByName(GetRegName(3))));
113 fprintf(fgFile, "USRBIN %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f %s\n",
114 Float_t(GetRegionByName(GetRegName(1))), Float_t(GetRegionByName(GetRegName(2))),
115 Float_t(GetRegionByName(GetRegName(3))), 1., 1., 1., cont_line);
117 printf("Check consistency of SetUserScoring values \n");
125 if(strncmp(GetName(), "USRBDX", 6) == 0){
127 fprintf(fgFile, "USRBDX %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
128 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
129 Float_t(GetRegionByName(GetRegName(2))), What(6));
130 } else if (Par() == 3) {
131 fprintf(fgFile, "USRBDX %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
132 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
133 Float_t(GetRegionByName(GetRegName(2))), What(6));
134 fprintf(fgFile, "USRBDX %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f %s\n",
135 What(7), What(8), What(9), What(10), What(11), What(12), cont_line);
142 if(strncmp(GetName(), "USRTRACK", 6) == 0){
143 fprintf(fgFile, "USRTRACK %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
144 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))), What(4), What(5));
145 fprintf(fgFile, "USRTRACK %10.1f%10.4g %s\n",
146 What(7), What(8), cont_line);
152 if(strncmp(GetName(), "USRCOLL", 6) == 0){
153 fprintf(fgFile, "USRCOLL %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, "USRCOLL %10.1f%10.4g %s\n",
156 What(7), What(8), cont_line);
161 Int_t TFlukaScoringOption::GetRegionByName(const char* detname)
163 // Get number of region for a given detector name
164 TGeoVolume* vol = dynamic_cast<TGeoVolume*>((gGeoManager->GetListOfVolumes())->FindObject(detname));
165 Int_t ireg = (vol)? vol->GetNumber() : -999;