IAP GITLAB

Commit 33e67870 authored by Ralf Ulrich's avatar Ralf Ulrich

histogramms work now

parent 2a2a468b
......@@ -29,6 +29,10 @@ public:
virtual G4VPhysicalVolume* Construct();
static const int fgNumberLayers;
static const int fgNumberGrid;
private:
DetectorSD* fSciSD;
double fQe;
......
......@@ -42,12 +42,11 @@ using namespace std;
const double depth_tunnel = 80 * meter; // bei 2.2mm->1.2m, bei 6.5mm->3.5m
const double height_tunnel = 2.5 * meter;
const double angle = 43.1 * degree;
const double rockIP5 = 17 * meter;
const double distanceIP5 = 33 * meter;
const int nlay = 3;
const int nGrid = 20;
// DETECTOR DEFINITION
const int DetectorConstructionDet::fgNumberLayers = 3;
const int DetectorConstructionDet::fgNumberGrid = 20;
const double wCell = 5*centimeter;
const double crystalCase = 1*millimeter;
const double heightCrystal = 0.80*meter;
......@@ -56,6 +55,10 @@ const double distanceLayer = heightCrystal + 0.2*meter;
const double heightPMT = 130*millimeter;
const double radiusPMT = 2.4*centimeter;
const double angle = 43.1 * degree;
const double rockIP5 = 17 * meter;
const double distanceIP5 = 33 * meter;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstructionDet::DetectorConstructionDet(double qe)
......@@ -302,7 +305,7 @@ G4VPhysicalVolume* DetectorConstructionDet::Construct()
// --- one experiment
G4VSolid* calorimeterS
= new G4Box("Calorimeter", // its name
(wCell+2*crystalCase)*nGrid/2., (wCell+2*crystalCase)*nGrid/2., distanceLayer*nlay/2.); // its size
(wCell+2*crystalCase)*fgNumberGrid/2., (wCell+2*crystalCase)*fgNumberGrid/2., distanceLayer*fgNumberLayers/2.); // its size
G4LogicalVolume* calorLV
= new G4LogicalVolume(calorimeterS, // its solid
......@@ -327,7 +330,7 @@ G4VPhysicalVolume* DetectorConstructionDet::Construct()
//
G4VSolid* layerS
= new G4Box("Layer", // its name
(wCell+2*crystalCase)*nGrid/2., (wCell+2*crystalCase)*nGrid/2., distanceLayer/2.);
(wCell+2*crystalCase)*fgNumberGrid/2., (wCell+2*crystalCase)*fgNumberGrid/2., distanceLayer/2.);
G4LogicalVolume* layerLV
= new G4LogicalVolume(layerS, // its solid
......@@ -339,11 +342,11 @@ G4VPhysicalVolume* DetectorConstructionDet::Construct()
layerLV->SetVisAttributes(layer_logVisAtt);*/
layerLV->SetVisAttributes(G4VisAttributes::Invisible);
for (int ilay=0; ilay<nlay; ++ilay) {
for (int ilay=0; ilay<fgNumberLayers; ++ilay) {
ostringstream layname;
layname << "Layer_" << ilay;
new G4PVPlacement(0,
G4ThreeVector(0,0,distanceLayer*(ilay-double(nlay-1)/2)),
G4ThreeVector(0,0,distanceLayer*(ilay-double(fgNumberLayers-1)/2)),
layerLV,
layname.str().c_str(),
calorLV,
......@@ -356,17 +359,17 @@ G4VPhysicalVolume* DetectorConstructionDet::Construct()
// one sci-bar grid row
G4VSolid* rowS
= new G4Box("DetRow", // its name
(wCell+2*crystalCase)*nGrid/2., (wCell+2*crystalCase)/2., distanceLayer/2.);
(wCell+2*crystalCase)*fgNumberGrid/2., (wCell+2*crystalCase)/2., distanceLayer/2.);
G4LogicalVolume* rowLV
= new G4LogicalVolume(rowS, // its solid
air, // its material
"DetRow"); // its name
// new G4PVReplica("DetRow", rowLV, layerLV, kYAxis, nGrid, wCell+2*crystalCase);
for (int igrid=0; igrid<nGrid; ++igrid) {
// new G4PVReplica("DetRow", rowLV, layerLV, kYAxis, fgNumberGrid, wCell+2*crystalCase);
for (int igrid=0; igrid<fgNumberGrid; ++igrid) {
new G4PVPlacement(0,
G4ThreeVector(0, (wCell+2*crystalCase)*(igrid-double(nGrid-1)/2), 0),
G4ThreeVector(0, (wCell+2*crystalCase)*(igrid-double(fgNumberGrid-1)/2), 0),
rowLV,
"DetRow",
layerLV,
......@@ -387,10 +390,10 @@ G4VPhysicalVolume* DetectorConstructionDet::Construct()
air, // its material
"DetCol"); // its name
//new G4PVReplica("DetCol", colLV, rowLV, kXAxis, nGrid, (wCell+2*crystalCase));
for (int igrid=0; igrid<nGrid; ++igrid) {
//new G4PVReplica("DetCol", colLV, rowLV, kXAxis, fgNumberGrid, (wCell+2*crystalCase));
for (int igrid=0; igrid<fgNumberGrid; ++igrid) {
new G4PVPlacement(0,
G4ThreeVector((wCell+2*crystalCase)*(igrid-double(nGrid-1)/2), 0, 0),
G4ThreeVector((wCell+2*crystalCase)*(igrid-double(fgNumberGrid-1)/2), 0, 0),
colLV,
"DetCol",
rowLV,
......@@ -578,9 +581,7 @@ void DetectorConstructionDet::ConstructSDandField()
//
// Sensitive detectors
//
// int nofChannel = 3 * 20 * 20;
fSciSD = new DetectorSD("Scintillator", "ScintillatorHitsCollection", nlay, nGrid);
//SetSensitiveDetector("SciCol", sciSD);
fSciSD = new DetectorSD("Scintillator", "ScintillatorHitsCollection", fgNumberLayers, fgNumberGrid);
sdManager->AddNewDetector(fSciSD);
SetSensitiveDetector("SciBlock", fSciSD);
......
......@@ -11,7 +11,7 @@
#include "G4SDManager.hh"
#include "G4RunManager.hh"
// #include "Randomize.h"
#include "DetectorConstructionDet.hh"
#include "G4SystemOfUnits.hh"
......@@ -164,18 +164,19 @@ EventAction::EndOfEventAction(const G4Event* evt)
int count = 0;
for (int i=0; i<sciHC->entries()-1; ++i) {
const int nrow = 15;
const int nrow2 = nrow*nrow;
int idLay = i / nrow2;
int col = (i % nrow2) / nrow;
int row = (i % nrow2) % nrow;
const int nrow = DetectorConstructionDet::fgNumberGrid;
const int nrow2 = pow(nrow, 2);
const int idLay = i / nrow2;
const int col = (i % nrow2) / nrow;
const int row = (i % nrow2) % nrow;
DetectorHit* thesciHit = (*sciHC)[i];
double edep = thesciHit->GetEdep();
double length = thesciHit->GetTrackLength();
double nph = thesciHit->GetPh();
double nPE = (hitMap.count(i) ? hitMap[i] : 0);
const double edep = thesciHit->GetEdep();
const double length = thesciHit->GetTrackLength();
const double nph = thesciHit->GetPh();
const double nPE = (hitMap.count(i) ? hitMap[i] : 0);
thesciHit->SetNPE(int(nPE*0.2));
if (edep/keV>0 || nph>0 || nPE>0) {
analysisManager->FillH1(3, i);
count++;
......@@ -199,17 +200,14 @@ EventAction::EndOfEventAction(const G4Event* evt)
analysisManager->AddNtupleRow();
}
//int GetLayer(const int i) { return i % (fNGrid*fNGrid); }
//int GetColumn(const int i) { return (i / (fNGrid*fNGrid)) % fNGrid; }
//int GetRow(const int i) { return (i / (fNGrid*fNGrid)) / fNGrid; }
analysisManager->FillH2(1+idLay, col, row, edep/MeV);
}
} // loop sciHC hits
analysisManager->FillH1(4, count);
// check trigger
int nrow=15;
const int nrow = DetectorConstructionDet::fgNumberGrid;
for (int i=0; i<nrow; ++i) {
for (int j=0; j<nrow; ++j) {
......
......@@ -7,15 +7,19 @@
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "DetectorConstructionDet.hh"
#include "g4root.hh"
#include <iostream>
using namespace std;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction()
:G4UserRunAction()
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
// G4cout << "Using " << analysisManager->GetType() << G4endl;
G4cout << "Using " << analysisManager->GetType() << G4endl;
// Create directories
//analysisManager->SetHistoDirectoryName("histograms");
......@@ -31,12 +35,16 @@ RunAction::RunAction()
analysisManager->CreateH1("trackL","trackL in sci", 100, 0., 1*m);
analysisManager->CreateH1("channels","Channels", 1200, 0., 1200);
analysisManager->CreateH1("mult","Mult", 100, 0., 100);
int nGrid = 15;
analysisManager->CreateH2("layer1","layer1", nGrid, 0., nGrid, nGrid, 0, nGrid);
analysisManager->CreateH2("layer2","layer2", nGrid, 0., nGrid, nGrid, 0, nGrid);
analysisManager->CreateH2("layer3","layer3", nGrid, 0., nGrid, nGrid, 0, nGrid);
analysisManager->CreateH2("layer4","layer4", nGrid, 0., nGrid, nGrid, 0, nGrid);
const int nGrid = DetectorConstructionDet::fgNumberGrid;
const int nlay = DetectorConstructionDet::fgNumberLayers;
for (int i=0; i<nlay; ++i) {
ostringstream hname;
hname << "layer_" << i+1;
analysisManager->CreateH2(hname.str().c_str(), hname.str().c_str(), nGrid, 0., nGrid, nGrid, 0, nGrid);
}
// Create ntuple
analysisManager->CreateNtuple("MCPsim", "hits");
analysisManager->CreateNtupleDColumn("dEdX");
......@@ -68,7 +76,7 @@ void RunAction::BeginOfRunAction(const G4Run* aRun)
// Open an output file
//
G4String fileName = "B4";
G4String fileName = "output";
analysisManager->OpenFile(fileName);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment