Message: SensitiveDetector.cc Problem. Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question SensitiveDetector.cc Problem. 

Forum: Hits, Digitization and Pileup
Date: 25 Jul, 2018
From: Hyewon Moon <Hyewon Moon>

Hi

I made SensitiveDetector.cc in TestEm1

#include "SensitiveDetector.hh"
#include "G4SdManager.hh"

SensitiveDetector::SensitiveDetector(G4String name)
:G4VSensitiveDetector(name)
{
   KE_scatt.open("Kinetic_Energy.txt");   // std::ios::app
   KE_down.open("Decreasing_Kinetic Energy.txt");
   gnup.open("DE.out");
   stopping_power.open("Stopping power.txt", std::ios::app);
   for(G4int i=0; i<100; i++)
        {
	     for(G4int j=0; j<100; j++)
	             {
	    	   DEMaterix[i][j] = 0;
	             }
        }
   for(G4int i=0; i<100; i++)
        {
	     KE[i]=0;
	     stepL[i]=0;
        }
   NumofRep = 0;

   for(G4int i=0; i<MAX_INDEX; i++)
       {
	    _dE[i]=0.0; dz[i]=0.0; KE[i]=0.0; stepL[i]=0.0;
       }
}

SensitiveDetector::~SensitiveDetector()
{
	//G4int nPrimaries = G4RunManager::GetRunManager()->GetNumberOfEventsToBeProcessed();
	NumofRep /= 100;
	G4double layer_width=0.0;
	for(G4int i=0; i<100; i++)
	{
		kE_scatt << layer_width << "\t" << KE[i]/NumofRep/MeV << G4end;
		layer_width += 0.1;
	}

	G4int nPrimaries = G4RunManager::GetRunManager()->GetNumberOfEventsToBeProcessed
();
	G4double z=0.0;
	for(G4int i=0; i<100; i++)
	{
		  for(G4int j=0; j<100; j++)
		     {
			   gnup<< z << "\t" << y << "\t" << DEMatrix[i][j]/nPrimaries/MeV << G4end;
			   y+=0.1;
		     }
		  z+=0.015;
		  y=0.0;
		  gnup << G4endl;

		  }
  	kE_scatt.close();
  	kE_down.close();
  	gnup.close();
  	stopping_power.close();
}

void SensitiveDetector::Initialize(G4HCofThisEvent*) {

}

G4bool SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
	 G4double kE = aStep->GetPreStepPoint()->GetKineticEnergy();
	 //G4double kE_end = aStep->GetPostStepPoint()->GetKineticEnergy
	 //G4double kE = aStep->GetPreStepPoint()->GetTotalEnergy();

	 G4int RepZNo = aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(0);
	 G4ThreeVector pos = aStep->GetTrack()->GetPosition();
	 kE_scatt << pos.x()<< "\t" << pos.y() << "\t" << pos.z() << "\t" << kE/MeV <<G4endl;

	 KE[RepZNo] += kE;
	 /*if(RepZNo ==99)
	  {
	    KE[10] += kE_end;
	   } */
	 NumofRep++;

	 //G4int RepZNo = aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(0);
	 G4int RepYNo = aStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(1);
	 G4double dE = aStep->GetTotalEnergyDeposit();
	 G4double stepL = aStep->GetStepLength();
	 G4double trackL = astep->GetTrack()->GetTrackLength();

	 DEMatrix[RepZNo][RepYNo] += dE;

	 stepL[RepZNo] = aStep->GetSteplength();
	 trackL[RepZNo] = aStep->GetTrack()->GetTrackLength();
	 E[RepZNo] = aStep->GetTrack()->GetkineticEnergy();
	 _dE[RepZNo] = aStep->GetTotalEnergyDeposit();
	 dz[RepZNo] = aStep->GetDeltaPosition().getZ();

	 if(E[RepZNo] > 0 && ((dE[RepZNo]/MeV)/(dz[RepzNo]/cm)) > 0 && RepZNo < 5)
		  stopping_power << stepL[RepZNo]/cm << "\t" << trackL[RepZNo]/cm << "\t" << E[RepZNo]/MeV << "\t" << (_dE[RepZNo]/MeV)/(dz[RepZNo]/cm) << G4endl;

	  //G4cout << "Replica Num: " << RepZNo << "Step Length(cm): " << stepL/cm <<",Track length(cm):"<<trackL/cm << ",Total Energy(MeV): " << kE/MeV <<G4endl;

	   return true;
}

void SensitiveDetector::EndOfEvent(G4HCofThisEvent*) {

} }

Then, I tried to make -j 4, but errors occurred.

[  4%] Building CXX object CMakeFiles/TestEm1.dir/src/SensitiveDetector.cc.o
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc: In constructor ‘SensitiveDetector::SensitiveDetector(G4String)’:
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:33:4: error: ‘KE_scatt’ was not declared in this scope
    KE_scatt.open("Kinetic_Energy.txt");   // std::ios::app
    ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:34:4: error: ‘KE_down’ was not declared in this scope
    KE_down.open("Decreasing_Kinetic Energy.txt");
    ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:35:4: error: ‘gnup’ was not declared in this scope
    gnup.open("DE.out");
    ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:41:10: error: ‘DEMaterix’ was not declared in this scope
          DEMaterix[i][j] = 0;
          ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:47:7: error: ‘stepL’ was not declared in this scope
       stepL[i]=0;
       ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:49:4: error: ‘NumofRep’ was not declared in this scope
    NumofRep = 0;
    ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:53:40: error: ‘stepL’ was not declared in this scope
      _dE[i]=0.0; dz[i]=0.0; KE[i]=0.0; stepL[i]=0.0;
                                        ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc: In destructor ‘virtual SensitiveDetector::~SensitiveDetector()’:
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:60:2: error: ‘NumofRep’ was not declared in this scope
  NumofRep /= 100;
  ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:64:3: error: ‘kE_scatt’ was not declared in this scope
   kE_scatt << layer_width << "\t" << KE[i]/NumofRep/MeV << G4end;
   ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:64:60: error: ‘G4end’ was not declared in this scope
   kE_scatt << layer_width << "\t" << KE[i]/NumofRep/MeV << G4end;
                                                            ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:75:7: error: ‘gnup’ was not declared in this scope
       gnup<< z << "\t" << y << "\t" << DEMatrix[i][j]/nPrimaries/MeV << G4end;
       ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:75:27: error: ‘y’ was not declared in this scope
       gnup<< z << "\t" << y << "\t" << DEMatrix[i][j]/nPrimaries/MeV << G4end;
                           ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:75:40: error: ‘DEMatrix’ was not declared in this scope
       gnup<< z << "\t" << y << "\t" << DEMatrix[i][j]/nPrimaries/MeV << G4end;
                                        ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:75:73: error: ‘G4end’ was not declared in this scope
       gnup<< z << "\t" << y << "\t" << DEMatrix[i][j]/nPrimaries/MeV << G4end;
                                                                         ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:79:5: error: ‘y’ was not declared in this scope
     y=0.0;
     ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:80:5: error: ‘gnup’ was not declared in this scope
     gnup << G4endl;
     ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:83:4: error: ‘kE_scatt’ was not declared in this scope
    kE_scatt.close();
    ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:84:4: error: ‘kE_down’ was not declared in this scope
    kE_down.close();
    ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:85:4: error: ‘gnup’ was not declared in this scope
    gnup.close();
    ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc: In member function ‘virtual G4bool SensitiveDetector::ProcessHits(G4Step*, G4TouchableHistory*)’:
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:102:3: error: ‘kE_scatt’ was not declared in this scope
   kE_scatt << pos.x()<< "\t" << pos.y() << "\t" << pos.z() << "\t" << kE/MeV <<G4endl;
   ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:112:3: error: ‘NumofRep’ was not declared in this scope
   NumofRep++;
   ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:119:21: error: ‘astep’ was not declared in this scope
   G4double trackL = astep->GetTrack()->GetTrackLength();
                     ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:121:3: error: ‘DEMatrix’ was not declared in this scope
   DEMatrix[RepZNo][RepYNo] += dE;
   ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:125:15: error: invalid types ‘G4double {aka double}[G4int {aka int}]’ for array subscript
   stepL[RepZNo] = aStep->GetSteplength();
               ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:125:26: error: ‘class G4Step’ has no member named ‘GetSteplength’
   stepL[RepZNo] = aStep->GetSteplength();
                          ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:126:16: error: invalid types ‘G4double {aka double}[G4int {aka int}]’ for array subscript
   trackL[RepZNo] = aStep->GetTrack()->GetTrackLength();
                ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:127:3: error: ‘E’ was not declared in this scope
   E[RepZNo] = aStep->GetTrack()->GetkineticEnergy();
   ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:127:34: error: ‘class G4Track’ has no member named ‘GetkineticEnergy’
   E[RepZNo] = aStep->GetTrack()->GetkineticEnergy();
                                  ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:131:34: error: invalid types ‘G4double {aka double}[G4int {aka int}]’ for array subscript
   if(E[RepZNo] > 0 && ((dE[RepZNo]/MeV)/(dz[RepzNo]/cm)) > 0 && RepZNo < 5)
                                  ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:131:45: error: ‘RepzNo’ was not declared in this scope
   if(E[RepZNo] > 0 && ((dE[RepZNo]/MeV)/(dz[RepzNo]/cm)) > 0 && RepZNo < 5)
                                             ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:132:35: error: invalid types ‘G4double {aka double}[G4int {aka int}]’ for array subscript
     stopping_power << stepL[RepZNo]/cm << "\t" << trackL[RepZNo]/cm << "\t" << E[RepZNo]/MeV << "\t" << (_dE[RepZNo]/MeV)/(dz[RepZNo]/cm) << G4endl;
                                   ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:132:64: error: invalid types ‘G4double {aka double}[G4int {aka int}]’ for array subscript
     stopping_power << stepL[RepZNo]/cm << "\t" << trackL[RepZNo]/cm << "\t" << E[RepZNo]/MeV << "\t" << (_dE[RepZNo]/MeV)/(dz[RepZNo]/cm) << G4endl;
                                                                ^
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc: At global scope:
/home/won0625/examples/extended/electromagnetic/TestEm1/src/SensitiveDetector.cc:144:1: error: expected declaration before ‘}’ token
 }
 ^
make[2]: *** [CMakeFiles/TestEm1.dir/src/SensitiveDetector.cc.o] error 1
make[1]: *** [CMakeFiles/TestEm1.dir/all] error 2
make: *** [all] error 2

 Add Message Add Message
to: "SensitiveDetector.cc Problem."

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]