B1EventAction.cc 18.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
//
// ********************************************************************
// * License and Disclaimer                                           *
// *                                                                  *
// * The  Geant4 software  is  copyright of the Copyright Holders  of *
// * the Geant4 Collaboration.  It is provided  under  the terms  and *
// * conditions of the Geant4 Software License,  included in the file *
// * LICENSE and available at  http://cern.ch/geant4/license .  These *
// * include a list of copyright holders.                             *
// *                                                                  *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work  make  any representation or  warranty, express or implied, *
// * regarding  this  software system or assume any liability for its *
// * use.  Please see the license in the file  LICENSE  and URL above *
// * for the full disclaimer and the limitation of liability.         *
// *                                                                  *
// * This  code  implementation is the result of  the  scientific and *
// * technical work of the GEANT4 collaboration.                      *
// * By using,  copying,  modifying or  distributing the software (or *
// * any work based  on the software)  you  agree  to acknowledge its *
// * use  in  resulting  scientific  publications,  and indicate your *
// * acceptance of all terms of the Geant4 Software license.          *
// ********************************************************************
//
//
/// \file B1EventAction.cc
/// \brief Implementation of the B1EventAction class

#include "B1EventAction.hh"
#include "B1RunAction.hh"
32
#include "B1Hits.hh"
33
#include "B1DetectorConstruction.hh"
34 35 36

#include "G4Event.hh"
#include "G4RunManager.hh"
37 38 39 40 41 42
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4VHitsCollection.hh"
#include "G4SDManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4ios.hh"
43
#include "B1Analysis.hh"
44

45 46
#include <iostream>
#include <fstream>
47 48 49

using namespace std;

50 51 52 53 54 55
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B1EventAction::B1EventAction(B1RunAction* runAction)
: G4UserEventAction(),
  fRunAction(runAction),
  fEdep(0.)
56
{}
57 58 59 60 61 62 63 64

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B1EventAction::~B1EventAction()
{}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

65 66
void B1EventAction::BeginOfEventAction(const G4Event* event)
{
67
  fEdep = 0.;
68

69 70


71 72 73 74
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

75 76
void B1EventAction::EndOfEventAction(const G4Event* event)
{
77 78
  // accumulate statistics in run action
  fRunAction->AddEdep(fEdep);
79

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  G4SDManager * SDman = G4SDManager::GetSDMpointer();
  G4String detName;

  auto Col1 = SDman->GetCollectionID("SD1");
  auto Col2 = SDman->GetCollectionID("SD2");
  auto Col3 = SDman->GetCollectionID("SD3");
  auto Col4 = SDman->GetCollectionID("SD4");
  auto Col5 = SDman->GetCollectionID("SD5");
  auto Col6 = SDman->GetCollectionID("SD6");
  auto Col7 = SDman->GetCollectionID("SD7");
  auto Col8 = SDman->GetCollectionID("SD8");
  auto Col9 = SDman->GetCollectionID("SD9");
  auto Col10 = SDman->GetCollectionID("SD10");
  auto Col11 = SDman->GetCollectionID("SD11");
  auto Col12 = SDman->GetCollectionID("SD12");
  auto Col13 = SDman->GetCollectionID("SD13");
  auto Col14 = SDman->GetCollectionID("SD14");
  auto Col15 = SDman->GetCollectionID("SD15");
  auto Col16 = SDman->GetCollectionID("SD16");
  auto Col17 = SDman->GetCollectionID("SD17");
  auto Col18 = SDman->GetCollectionID("SD18");
101
//  auto Col19 = SDman->GetCollectionID("SD19");
102 103


104 105

  G4HCofThisEvent* HCE = event->GetHCofThisEvent();
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
  B1HitsCollection* HitsCol1 = 0;
  B1HitsCollection* HitsCol2 = 0;
  B1HitsCollection* HitsCol3 = 0;
  B1HitsCollection* HitsCol4 = 0;
  B1HitsCollection* HitsCol5 = 0;
  B1HitsCollection* HitsCol6 = 0;
  B1HitsCollection* HitsCol7 = 0;
  B1HitsCollection* HitsCol8 = 0;
  B1HitsCollection* HitsCol9 = 0;
  B1HitsCollection* HitsCol10 = 0;
  B1HitsCollection* HitsCol11 = 0;
  B1HitsCollection* HitsCol12 = 0;
  B1HitsCollection* HitsCol13 = 0;
  B1HitsCollection* HitsCol14 = 0;
  B1HitsCollection* HitsCol15 = 0;
  B1HitsCollection* HitsCol16 = 0;
  B1HitsCollection* HitsCol17 = 0;
  B1HitsCollection* HitsCol18 = 0;
124
//  B1HitsCollection* HitsCol19 = 0;
125 126

  if(HCE) {
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
    HitsCol1 = (B1HitsCollection*)(HCE->GetHC(Col1));
    HitsCol2 = (B1HitsCollection*)(HCE->GetHC(Col2));
    HitsCol3 = (B1HitsCollection*)(HCE->GetHC(Col3));
    HitsCol4 = (B1HitsCollection*)(HCE->GetHC(Col4));
    HitsCol5 = (B1HitsCollection*)(HCE->GetHC(Col5));
    HitsCol6 = (B1HitsCollection*)(HCE->GetHC(Col6));
    HitsCol7 = (B1HitsCollection*)(HCE->GetHC(Col7));
    HitsCol8 = (B1HitsCollection*)(HCE->GetHC(Col8));
    HitsCol9 = (B1HitsCollection*)(HCE->GetHC(Col9));
    HitsCol10 = (B1HitsCollection*)(HCE->GetHC(Col10));
    HitsCol11 = (B1HitsCollection*)(HCE->GetHC(Col11));
    HitsCol12 = (B1HitsCollection*)(HCE->GetHC(Col12));
    HitsCol13 = (B1HitsCollection*)(HCE->GetHC(Col13));
    HitsCol14 = (B1HitsCollection*)(HCE->GetHC(Col14));
    HitsCol15 = (B1HitsCollection*)(HCE->GetHC(Col15));
    HitsCol16 = (B1HitsCollection*)(HCE->GetHC(Col16));
    HitsCol17 = (B1HitsCollection*)(HCE->GetHC(Col17));
    HitsCol18 = (B1HitsCollection*)(HCE->GetHC(Col18));
145
//    HitsCol19 = (B1HitsCollection*)(HCE->GetHC(Col19));
146 147
  }

148 149 150 151 152 153
 //G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
  std::ofstream gammafile("gamma.txt");
  std::ofstream mu_plusfile("mu+.txt");
  std::ofstream mu_minusfile("mu-.txt");


154 155 156 157 158 159 160
  detectorConstruction = (B1DetectorConstruction*) G4RunManager::GetRunManager()->GetUserDetectorConstruction();
  G4cout << "tttttt" << G4endl;
  dec_pos = detectorConstruction->GetPositions();
  half_height = detectorConstruction->get_size();
  variation = detectorConstruction->get_delta();


161
  if(HitsCol1) {
162 163 164
    G4cout << "test" << G4endl;
    G4double pos_detec = SetPosition(1);
    G4cout << "RRRRRRR" << G4endl;
165 166
    int n_hit = HitsCol1->entries();
    G4cout << "My detector 1 has " << n_hit << "hits" << G4endl;
167 168
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
169 170 171 172 173 174 175 176 177 178
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol1)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 1);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
179

180
  if(HitsCol2) {
181
    G4double pos_detec = SetPosition(2);
182 183 184 185
    int n_hit = HitsCol2->entries();
    G4cout << "My detector 2 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
186
      for(int i1 = 0; i1 < n_hit; i1++) {
187
      B1Hits* hit = (*HitsCol2)[i1];
188 189 190
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
191
      WriteHistogram(name, 2);
192
    }
193 194
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
195 196
  }

197
  if(HitsCol3) {
198
    G4double pos_detec = SetPosition(3);
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
    int n_hit = HitsCol3->entries();
    G4cout << "My detector 3 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol3)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 3);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

  if(HitsCol4) {
215
    G4double pos_detec = SetPosition(4);
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
    int n_hit = HitsCol4->entries();
    G4cout << "My detector 4 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol4)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      //WriteHistogram(name, 4);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

  if(HitsCol5) {
232
    G4double pos_detec = SetPosition(5);
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
    int n_hit = HitsCol5->entries();
    G4cout << "My detector 5 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol5)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 5);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

  if(HitsCol6) {
249
    G4double pos_detec = SetPosition(6);
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
    int n_hit = HitsCol6->entries();
    G4cout << "My detector 6 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol6)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 6);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol7) {
265
    G4double pos_detec = SetPosition(7);
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
    int n_hit = HitsCol7->entries();
    G4cout << "My detector 7 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol7)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 7);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol8) {
281
    G4double pos_detec = SetPosition(8);
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
    int n_hit = HitsCol8->entries();
    G4cout << "My detector 8 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol8)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 8);
    }
   PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

  if(HitsCol9) {
298
    G4double pos_detec = SetPosition(9);
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
    int n_hit = HitsCol9->entries();
    G4cout << "My detector 9 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol9)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 9);
    }
   PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

  if(HitsCol10) {
315
    G4double pos_detec = SetPosition(10);
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
    int n_hit = HitsCol10->entries();
    G4cout << "My detector 10 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol10)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 10);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

  if(HitsCol11) {
332
    G4double pos_detec = SetPosition(11);
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
    int n_hit = HitsCol11->entries();
    G4cout << "My detector 11 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol11)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 11);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol12) {
348
    G4double pos_detec = SetPosition(12);
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
    int n_hit = HitsCol12->entries();
    G4cout << "My detector 12 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol12)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 12);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol13) {
364
    G4double pos_detec = SetPosition(13);
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
    int n_hit = HitsCol13->entries();
    G4cout << "My detector 13 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol13)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 13);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol14) {
380
    G4double pos_detec = SetPosition(14);
381
    int n_hit = HitsCol14->entries();
382
    G4cout << "My detector 14 has " << n_hit << "hits" << G4endl;
383 384 385 386 387 388 389 390 391 392 393 394 395 396
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol14)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 14);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

  if(HitsCol15) {
397
    G4double pos_detec = SetPosition(15);
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
    int n_hit = HitsCol15->entries();
    G4cout << "My detector 15 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol15)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
    //  WriteHistogram(name, 15);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol16) {
413
    G4double pos_detec = SetPosition(16);
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
    int n_hit = HitsCol16->entries();
    G4cout << "My detector 16 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol16)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 6);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol17) {
429
    G4double pos_detec = SetPosition(17);
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
    int n_hit = HitsCol17->entries();
    G4cout << "My detector 17 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol17)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 6);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
  if(HitsCol18) {
445
    G4double pos_detec = SetPosition(18);
446 447 448 449 450 451 452 453 454 455 456 457 458 459
    int n_hit = HitsCol18->entries();
    G4cout << "My detector 18 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol18)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 6);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }
460
  /*
461
  if(HitsCol19) {
462
    G4double pos_detec = SetPosition(19);
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
    int n_hit = HitsCol19->entries();
    G4cout << "My detector 19 has " << n_hit << "hits" << G4endl;
    B1Hits* hit = new B1Hits;
    std::map<const G4String, int> fparticles;
      for(int i1 = 0; i1 < n_hit; i1++) {
      B1Hits* hit = (*HitsCol19)[i1];
      const G4String name = hit->getParticleInTarget();
      //G4cout << name << G4endl;
      fparticles[name]++;
      WriteHistogram(name, 6);
    }
    PrintParticles(fparticles, gammafile, mu_plusfile, mu_minusfile, pos_detec);
    fparticles.clear();
  }

478
*/
479 480 481 482

gammafile.close();
mu_plusfile.close();
mu_minusfile.close();
483 484
}

485
void B1EventAction::PrintParticles(std::map<const G4String, int>& container, std::ofstream& gamma, std::ofstream& mu_minus, std::ofstream& mu_plus, G4double position) {
486
  std::map<const G4String, int>::iterator it;
487 488 489
//  G4cout << "Número de párticulas identificadas no detetor: " << G4endl;
   G4bool isGamma, ismu_minus, ismu_plus = false;

490 491 492
    for(it = container.begin() ;it != container.end(); it ++)
    {
      G4cout << "N " << it->first << " : " << it->second << G4endl;
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
      if(it->first == "gamma") {
        gamma << it->second << " " << position << "\n";
        isGamma = true;
      } else if (it->first == "mu+") {
        mu_plus << it->second << " " << position << "\n";
        ismu_plus= true;
      } else if (it->first == "mu-") {
        mu_minus << it->second << " " << position << "\n";
        ismu_minus = true;
      }
  }

  if (!isGamma) {
    gamma << "0 " << position << "\n";
  }
  if (!ismu_plus) {
    mu_plus << "0 " << position << "\n";
  }
  if (!ismu_minus) {
    mu_minus << "0 " << position << "\n";
  }

515 516
}

517 518 519 520 521 522 523 524 525 526 527 528 529
void B1EventAction::WriteHistogram(const G4String name, G4int Detec) {
  /*
   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
  if (name == "gamma") {
    analysisManager->FillNtupleDColumn(2, Detec);
  } else if (name == "mu+") {
    analysisManager->FillNtupleDColumn(1, Detec);
  } else if (name == "mu-") {
    analysisManager->FillNtupleDColumn(0, Detec);
  }
  analysisManager->AddNtupleRow();
*/
}
530

531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
G4double B1EventAction::SetPosition(G4int detec) {
  G4int detec_index = detec - 1;
  G4double first_value = dec_pos[0]/1000000;
  G4cout << first_value << G4endl;
  G4double value =  dec_pos[detec_index];
  G4double value_c = value/1000000;
  G4double half_height_real = half_height/1000000;
  G4double h_real = half_height_real*2;
  G4double real_delta = variation/1000000;
  G4double first_distance = half_height_real + first_value ;
  if (detec_index == 0) {
    return first_distance;
  }
  return (first_distance + detec_index*real_delta);
}


548
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......