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10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/exp_microdosimetry/ProcessMicro.C (Version 11.3.0) and /examples/advanced/exp_microdosimetry/ProcessMicro.C (Version 8.1.p2)


  1 {                                                   1 
  2 ////////////////////////////////////////////      
  3   gROOT->Reset();                                 
  4                                                   
  5   bool saveImage = true;                          
  6   string imageFileName = "microdosimetricSpect    
  7                                                   
  8   bool saveLinearEdep = true;                     
  9   bool saveLogEdep = true;                        
 10   bool saveydySpec = true;                        
 11                                                   
 12 ////////////////////////////////////////////      
 13 //Open File where data has been stored            
 14 ////////////////////////////////////////////      
 15   TFile* f = new TFile("radioprotection_t0.roo    
 16                                                   
 17   TDirectory* dir = (TDirectory*)f->Get("radio    
 18   TTree * nEdep = (TTree*)dir->Get("102");        
 19   Double_t edep;                                  
 20   nEdep->SetBranchAddress("edep", &edep);         
 21                                                   
 22   double meanChordLength = 1; //change based o    
 23 ////////////////////////////////////////////      
 24 //Put hits in microdosimeter into linear binne    
 25 ////////////////////////////////////////////      
 26   int numberLinearBins = 4096;                    
 27   double minLinealEnergy = 0;                     
 28   double maxLinealEnergy = 1000;                  
 29   TH1D*  histoLin = new TH1D("h1", "f(y)", num    
 30                                                   
 31   TH1D*  histoYFY = new TH1D("h2", "yf(y)", nu    
 32   TH1D*  histoDY = new TH1D("h3", "d(y)", numb    
 33                                                   
 34 ////////////////////////////////////////////      
 35 //Create log bin for microdosimetric plotting     
 36 ////////////////////////////////////////////      
 37   //Log bin stuff                                 
 38   int B = 20; //the number of increments in ea    
 39   //eg if B = 10: 1 2 3 ... 9 10 20 30 ... 90     
 40   double yMin = 0.01; // y = lineal energy        
 41   double yMax = 1000;                             
 42                                                   
 43   double range = yMax / yMin;                     
 44   double fooRange = range;                        
 45   double fooMag = 10; //any old silly no > 1      
 46   int order = 0;                                  
 47   while (fooMag > 1)                              
 48   {                                               
 49     fooMag = fooRange / 10 ;                      
 50     fooRange = fooRange / 10 ;                    
 51     order = order + 1 ;                           
 52   }                                               
 53                                                   
 54   int binsPerDecade = B;                          
 55   const int numberOfLogBins = binsPerDecade *     
 56                                                   
 57   vector<double> xbins;                           
 58   for (int b = 0; b < numberOfLogBins; b++)       
 59   {                                               
 60     xbins.push_back((yMin)*pow(10, ((b) / doub    
 61     //  cout << b << " " << xbins[b] << endl;     
 62   }                                               
 63                                                   
 64   TH1D*  histoLog = new TH1D("l1", "edepLin",     
 65                                                   
 66                                                   
 67 ////////////////////////////////////////////      
 68 //loop through the hits in the detector stored    
 69 ////////////////////////////////////////////      
 70   int numberHits = nEdep->GetEntries();           
 71   cout << "Number of hits in detector = " << n    
 72                                                   
 73   for (int i = 0; i < numberHits; i++)            
 74   {                                               
 75     nEdep->GetEntry(i);                           
 76     if (edep <= 0)                                
 77     {                                             
 78       cout << "Edep = 0" << endl;                 
 79     }                                             
 80                                                   
 81     histoLin->Fill(edep/meanChordLength);         
 82     histoLog->Fill(edep/meanChordLength);         
 83   }                                               
 84                                                   
 85 ////////////////////////////////////////////      
 86 //Normalise the log histogram based on the bin    
 87 ////////////////////////////////////////////      
 88   for (int bb = 1; bb <= numberOfLogBins-1; bb    
 89   {                                               
 90     histoLog->SetBinContent(bb, (histoLog->Get    
 91   }                                               
 92                                                   
 93                                                   
 94 ////////////////////////////////////////////      
 95 //---------Save values to file--------------      
 96 ////////////////////////////////////////////      
 97   ofstream outFile;                               
 98   if (saveLinearEdep)                             
 99   {                                               
100     outFile.open("linEdepSpec.txt");              
101     for (int i = 1 ; i <= numberLinearBins; i+    
102     {                                             
103       outFile << histoLin->GetBinCenter(i) * m    
104     }                                             
105     outFile.close();                              
106   }                                               
107   if (saveLogEdep)                                
108   {                                               
109     outFile.open("logEdepSpec.txt");              
110     for (int bb = 1; bb <= numberOfLogBins-1;     
111     {                                             
112       outFile << histoLog->GetBinCenter(bb) *     
113     }                                             
114     outFile.close();                              
115   }                                               
116                                                   
117 ////////////////////////////////////////////      
118 //----------Normalise Histo to get f(y)----       
119 ////////////////////////////////////////////      
120   double intOfHist = histoLin->Integral("width    
121   histoLin->Scale(1./intOfHist);                  
122   //histoLin->Sumw2();                            
123                                                   
124   double intOfLogHist = histoLog->Integral("wi    
125   histoLog->Scale(1./intOfLogHist);               
126   //histoLog->Sumw2();                            
127                                                   
128                                                   
129 //////////////////////////////////////////////    
130 //-------Calculate RBE using the modified MK m    
131 //////////////////////////////////////////////    
132 //Technically the use of the modified MKM is a    
133 //therapeutic ion beams and not used for radio    
134 //though it is included here for convience.       
135 //NOTE: the form used here is for "heavy ions"    
136 //to the more dose depedent protons               
137                                                   
138   //---------------------------------             
139   //Constants                                     
140   //---------------------------------             
141   const double satPar = 150.; //saturation par    
142   double satParSqr = satPar * satPar;             
143   const double pi = 3.14159265359;                
144   const double SiToMuscleCorrection = 0.57;       
145                                                   
146   //Cell reltated numbers                         
147   double alpha0 = 0.13;//0.164;//0.13; //Gy^-1    
148   double beta = 0.05; //Gy^-2                     
149   double rho = 1.; //g/cm^3                       
150   double rSV = 0.42; //um, the radius of the H    
151   //------------------------------------------    
152   //In order for consistent units, which in th    
153   //(1/(Gy^2))(keV/g)(cm^3/um^3)                  
154   // (1/Gy^2)(keV/um)(cm^3/g)(1/um^2)             
155   //------------------------------------------    
156   //So convert (keV/g) into Gy it is scaled by    
157   //And to get cm^3 into um^3 just scale by 10    
158   //------------------------------------------    
159   double scaleGray = 1.602E-16/0.001;             
160   double scaleLength = 1.E12;                     
161                                                   
162 //-------Calculate y*--------                     
163   double topIntegral = 0.;                        
164   double botIntegral = 0.;                        
165                                                   
166   //top integral                                  
167   for (Int_t i = 1; i <= numberLinearBins; i++    
168   {                                               
169     topIntegral += (1 - exp(-(histoLin->GetBin    
170     //        (1 - exp(-y^2/y_{0}^2)) * f(y) *    
171   }                                               
172   //bottom integral                               
173   for (Int_t i = 1; i <= numberLinearBins; i++    
174   {                                               
175     botIntegral += (histoLin->GetBinCenter(i)     
176     //        y (size of each being time bin n    
177   }                                               
178                                                   
179   //cout << "Top: " << topIntegral << endl;       
180   //cout << "Bot: " << botIntegral << endl;       
181                                                   
182   //saturation corrected dose averaged linel e    
183   double satCor = satParSqr * topIntegral / bo    
184   //(y_{0})^2*top/bottom                          
185   //cout << "--------------------------------"    
186   //cout << "y* = " << satCor << endl;            
187   //cout << "--------------------------------"    
188                                                   
189                                                   
190 //-----------alpha--------                        
191   double alpha = alpha0 + (beta / (rho*pi*rSV*    
192   //cout << "alpha = " << alpha << endl;          
193                                                   
194 //-----------finally RBE itself--------           
195   double ln01 = -2.302585093;                     
196   double RBE10;//= (2*beta*5.)((sqrt(alpha*alp    
197                                                   
198   double topRBE = (2 * beta*5.);                  
199   double botRBE = (sqrt(alpha*alpha - 4 * beta    
200   RBE10 = topRBE / botRBE;                        
201                                                   
202   //cout << "--------------------------------"    
203   cout << "RBE10 = " << RBE10 << endl;            
204   //cout << "--------------------------------"    
205                                                   
206 ////////////////////////////////////////////      
207 //-----------Calculate yF-------------------      
208 ////////////////////////////////////////////      
209 //yF = int(y * f(y) dy)                           
210   double linyF = 0.;                              
211   for (int i = 1 ; i <= numberLinearBins; i++)    
212   {                                               
213     linyF += histoLin->GetBinCenter(i) * histo    
214   }                                               
215                                                   
216   cout << "yF = " << linyF << endl;               
217                                                   
218   double logyF = 0;                               
219   for (int i = 1 ; i <= numberOfLogBins; i++)     
220   {                                               
221     logyF += histoLog->GetBinCenter(i) * histo    
222   }                                               
223   cout << "Log yF = " << logyF << endl;           
224                                                   
225                                                   
226 ////////////////////////////////////////////      
227 //--------------Calculate d(y)--------------      
228 ////////////////////////////////////////////      
229 //d(y) = y*f(y) / yF                              
230   for (int i = 1 ; i <= numberLinearBins; i++)    
231   {                                               
232     histoLin->SetBinContent(i, (histoLin->GetB    
233   }                                               
234                                                   
235   //check that it's normalised to 1               
236   double intOfHistDy = histoLin->Integral("wid    
237   cout << "Int of d(y) = " << intOfHistDy << e    
238                                                   
239   for (int bb = 1; bb <= numberOfLogBins-1; bb    
240   {                                               
241     histoLog->SetBinContent(bb, (histoLog->Get    
242   }                                               
243                                                   
244   double intOfHistLogDy = histoLog->Integral("    
245   cout << "Int of log d(y) = " << intOfHistLog    
246                                                   
247 ////////////////////////////////////////////      
248 //-------Calculate Average Q(y)-----------        
249 ////////////////////////////////////////////      
250 //Q(y) = (a1/y)[1-exp(-(a2)y*y - (a3)y*y*y)]      
251                                                   
252   //Quality factor values from ICRP 60 report     
253   double qualityCoeff1 = 5510.;                   
254   double qualityCoeff2 = 5.E-5;                   
255   double qualityCoeff3 = 2.E-7;                   
256                                                   
257   double aveQuality = 0.;                         
258   //AveQuality = int(Q(y)d(y)dy)                  
259                                                   
260   for (int i = 1 ; i <= numberLinearBins; i++)    
261   {                                               
262     aveQuality += (qualityCoeff1/histoLin->Get    
263   }                                               
264   cout << "<Q> = " << aveQuality << endl;         
265                                                   
266                                                   
267 ////////////////////////////////////////////      
268 //---------Calculate yD--------------------       
269 ////////////////////////////////////////////      
270 //yD = int (y * d(y) dy)                          
271   double linyD = 0.;                              
272                                                   
273   for (int i = 1 ; i <= numberLinearBins; i++)    
274   {                                               
275     linyD +=  histoLin->GetBinCenter(i) * hist    
276   }                                               
277                                                   
278   cout << "yD = " << linyD << endl;               
279                                                   
280   double logyD = 0.;                              
281                                                   
282   for (int bb = 1; bb <= numberOfLogBins-1; bb    
283   {                                               
284     logyD += histoLog->GetBinCenter(bb) * hist    
285   }                                               
286   cout << "log yD = " << logyD << endl;           
287                                                   
288 ////////////////////////////////////////////      
289 //---------Create yd(y)-------------------        
290 ////////////////////////////////////////////      
291   for (int bb = 1; bb <= numberOfLogBins-1; bb    
292   {                                               
293     histoLog->SetBinContent(bb, (histoLog->Get    
294   }                                               
295   //Scale bins by log(10)/B                       
296   //See Appendix B of the ICRU 36 report for m    
297   histoLog->Scale((log(10) / B));                 
298                                                   
299   if (saveydySpec)                                
300   {                                               
301     outFile.open("logYDYspec.txt");               
302     for (int bb = 1; bb <= numberOfLogBins-1;     
303     {                                             
304       outFile << histoLog->GetBinCenter(bb) <<    
305     }                                             
306     outFile.close();                              
307   }                                               
308                                                   
309   if (saveImage)                                  
310   {                                               
311                                                   
312     TCanvas *c1 = new TCanvas("c1", "", 1000,     
313     //gStyle->SetOptStat(0); //un-comment to r    
314                                                   
315     histoLog->SetTitle("");                       
316     histoLog->GetXaxis()->SetTitle("y (keV/#mu    
317     histoLog->GetYaxis()->SetTitle("yd(y)");      
318                                                   
319     histoLog->GetYaxis()->SetLabelFont(42);       
320     histoLog->GetXaxis()->SetLabelFont(42);       
321     histoLog->GetYaxis()->SetTitleFont(42);       
322     histoLog->GetXaxis()->SetTitleFont(42);       
323     histoLog->GetYaxis()->CenterTitle(1);         
324     histoLog->GetXaxis()->CenterTitle(1);         
325     histoLog->GetXaxis()->SetTitleSize(0.045);    
326     histoLog->GetYaxis()->SetTitleSize(0.045);    
327     //histoLog->GetYaxis()->SetRangeUser(0., 1    
328     //histoLog -> GetXaxis()->SetRangeUser(0.0    
329     histoLog->GetYaxis()->SetLabelSize(0.04);     
330     histoLog->GetXaxis()->SetLabelSize(0.04);     
331     histoLog->SetLineColor(1);                    
332     histoLog->SetLineWidth(4);                    
333     c1->SetLogx();                                
334     //c1->SetLogy();                              
335     //Plotting misbehaves in root6.XX             
336     histoLog->Draw("");                           
337                                                   
338     c1->SaveAs(imageFileName.c_str());            
339   }                                               
340 }                                                 
341