Message: No hits in SD Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None No hits in SD 

Keywords: hits, event, SD
Forum: Hits, Digitization and Pileup
Date: 11 Jan, 2008
From: Agnieszka Priebe <Agnieszka Priebe>

Hallo, I've been preaparing simulation of a quadrupol (MQ). Every files which I used, was taken from previous dipol (MD), which worked. I have a problem with Geant4. Compilation is OK (gmake), but after:

bin/Linux-g++/MQ /run/beamOn 10

I receive:
"
### Run 0 start.
 Generating event number 0
shooting from G4ThreeVector(0.4*mm,0.2*cm,200.*cm)
MQCoilSD::Initialize - initializing collection
 MQCoilSD::EndOfEvent action - adding a collection
 MQCoilSD::EndOfEvent - adding hits collection
 MQCoilSD::EndOfEvent - added hits collection
RootInterface::RootInterface() incarnation
>>> Event 0
    0 trajectories stored in this event.
 MQEventAction::EndOfEventAction: collection found  for collection ID = 0
 MQEventAction::EndOfEventAction:  entering collection
  No of hits:   0
EventOK - tree filled ... event Clearing ...
"
I have no idea why there are no events, because my MQCoilSD.cc is:
"

#include "MQCoilSD.hh"
#include "MQCoilHit.hh"
#include "G4HCofThisEvent.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
#include "MQbinParameters.hh"

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

MQCoilSD::MQCoilSD(G4String name)
:G4VSensitiveDetector(name),
 numberOfCellsInZ(segmentsinZ),numberOfCellsInPhi(segmentsinPhi),
 numberOfCellsInRho(segmentsinRho)
{
//  G4cout << " MQCoilSD::MQCoilSD  - inserting collection " << G4endl;
  G4String HCname;
  collectionName.insert(HCname="coilCollection");
}

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

MQCoilSD::~MQCoilSD(){ }

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

void MQCoilSD::Initialize(G4HCofThisEvent* )
{
 G4cout << "MQCoilSD::Initialize - initializing collection" << G4endl; 
 #include "MQParameters.icc"

   coilCollection = new MQCoilHitsCollection
                       (SensitiveDetectorName,collectionName[0]); 
   for(G4int j=0;j<numberOfCellsInPhi;j++)
   for(G4int k=0;k<numberOfCellsInZ;k++)
   for(G4int m=0;m<numberOfCellsInRho;m++) {
     CellID[j][k][m] = -1;
   }

// verboseLevel = 2;

/*
  coilCollection = new MQCoilHitsCollection
                          (SensitiveDetectorName,collectionName[0]); 
  static G4int HCID = -1;
  if(HCID<0)
  { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
  HCE->AddHitsCollection( HCID, coilCollection ); 
*/  
}

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

G4bool MQCoilSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
{
G4cout << " MQCoilSD::ProcessHits  entering" << G4endl;
#include "MQParameters.icc"
  if(!ROhist) return false;

  G4double edep = aStep->GetTotalEnergyDeposit();

  if(edep==0.) return false;

  G4VPhysicalVolume* physVol = ROhist->GetVolume();
  G4int copyNumberVolume = ROhist->GetCopyNumber();
  G4int copyIDinPhi = ROhist->GetReplicaNumber(2);
  G4int copyIDinZ = ROhist->GetReplicaNumber(1);
  G4int copyIDinRho = ROhist->GetReplicaNumber(0);

  if(CellID[copyIDinPhi][copyIDinZ][copyIDinRho]==-1)
  {
    MQCoilHit* newHit = new MQCoilHit(physVol->GetLogicalVolume(),copyIDinZ,copyIDinPhi,copyIDinRho);

//     WSD4CoilHit* calHit
//           = new WSD4CoilHit(physVol->GetLogicalVolume(),copyIDinZ,copyIDinPhi,copyIDinRho);
     G4RotationMatrix rotM;
     rotM = *(ROhist->GetRotation());
     newHit->SetTrackID  (aStep->GetTrack()->GetTrackID());     
     newHit->SetEdep( edep );
// original version:
     newHit->SetPos( ROhist->GetTranslation() ); // this gives only z-position... x&y=0
//     newHit->SetRot( rotM );
     newHit->SetCellID(copyIDinZ, copyIDinPhi, copyIDinRho);    
     G4int icell = coilCollection->insert( newHit );
//     newHit->SetPos      (aStep->GetPostStepPoint()->GetPosition());
     CellID[copyIDinPhi][copyIDinZ][copyIDinRho] = icell - 1;
  }  else {
    (*coilCollection)[CellID[copyIDinPhi][copyIDinZ][copyIDinRho]]->AddEdep(edep);  
  }

return true; }

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

void MQCoilSD::EndOfEvent(G4HCofThisEvent* HCE)
{
  if (verboseLevel>0) { 
     G4int NbHits = coilCollection->entries();
     G4cout << "\n-------->Hits Collection: in this event they are " << NbHits 
            << " hits in the Coil chambers: " << G4endl;
     for (G4int i=0;i<NbHits;i++) (*coilCollection)[i]->Print();
    } 

  G4cout << " MQCoilSD::EndOfEvent action - adding a collection" << G4endl; 
  static G4int HCID = -1;
  if(HCID<0)
  { 
   HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); 
   //HCID = GetCollectionID(0);

  }
  G4cout << " MQCoilSD::EndOfEvent - adding hits collection " << G4endl;
  HCE->AddHitsCollection( HCID, coilCollection );     
  G4cout << " MQCoilSD::EndOfEvent - added hits collection " << G4endl;

}

"
                          and MQEventAction.cc is
"
#include "MQEventAction.hh"
#include "MQCoilHit.hh"
#include "MQParameters.hh"
#include "MQRunAction.hh"
#include "RootInterface.hh"

#include "G4Run.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4SDManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4ios.hh"
#include "G4RunManager.hh"
#include "G4VHitsCollection.hh"
#include "G4HCofThisEvent.hh"
#include <string>
#include <iostream>
#include "G4DCofThisEvent.hh"

#include "MQDetectorConstruction.hh" //nowa linijka //#include "G4PSTrackCounter.hh" //

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

MQEventAction::MQEventAction() {

   G4cout << " MQEventAction ini " << G4endl;
   G4String colName;
   G4SDManager* SDman = G4SDManager::GetSDMpointer();
   G4cout << " collections: " << SDman->GetHCtable()->entries() << G4endl;
   coilCollectionID = SDman->GetCollectionID(colName="coilCollection");
   G4cout << " MQEventAction end " << G4endl;

   numberOfCoilHitStoredAlongRun= 0;

}

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

MQEventAction::~MQEventAction() {}

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

void MQEventAction::BeginOfEventAction(const G4Event*) {}

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

void MQEventAction::EndOfEventAction(const G4Event* evt) {

   RootInterface* rootinterface = RootInterface::getInstance();

   const G4Run* currentrun=G4RunManager::GetRunManager()->GetCurrentRun();
   int nbevent=currentrun->GetNumberOfEventToBeProcessed();

  G4int event_id = evt->GetEventID();

  // get number of stored trajectories
  //
  G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
  G4int n_trajectories = 0;
  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();

  // periodic printing
  //
  if (event_id < 100 || event_id%100 == 0) {
    G4cout << ">>> Event " << evt->GetEventID() << G4endl;
    G4cout << "    " << n_trajectories
           << " trajectories stored in this event." << G4endl;

    //char a=SDman->GetName(); //
    //int *a = G4PSTrackCounter::G4PSTrackCounter ("licznik", 230.,0.);

    //G4cout<<a<<G4endl;//

  }

   // -------> Extract the hits (access all hits in G4Event)
   G4HCofThisEvent * HCE = evt->GetHCofThisEvent(); 
   MQCoilHitsCollection* CHC = 0;
   if(HCE) {
//     CHC = (MQCoilHitsCollection*)(HCE->GetHC(0));  
     CHC = (MQCoilHitsCollection*)(HCE->GetHC(coilCollectionID));
     G4cout << " MQEventAction::EndOfEventAction: collection found  for collection ID = " << coilCollectionID << G4endl;
   } 

   // write hits collection into the file:
   if(CHC)
   {
     G4cout << " MQEventAction::EndOfEventAction:  entering collection " << G4endl;   
     // number of particules/hits in event:
     int n_hit = CHC->entries();
     G4cout << "  No of hits:   " << n_hit << G4endl;

     // loop over particles in the event:
     if(n_hit>0) {  
        numberOfCoilHitStoredAlongRun += n_hit; 
        for(int i=0;i<n_hit;i++) {
                double edep = (*CHC)[i]->GetEdep()/MeV;        
                int rID = (*CHC)[i]->GetRID(); 
                int phiID = (*CHC)[i]->GetPhiID();     
                int zID = (*CHC)[i]->GetZID();
                G4cout << " edep = " << edep << " MeV " << G4endl;
                G4cout << " rID = " << rID << "  phiID = " << phiID << " zID = " << zID << G4endl;             
                rootinterface->AddCCell(1,edep,zID,phiID,rID);         
        }
     }
    }
    rootinterface->EventOK();
 // auto-save tree
    rootinterface->tree->AutoSave("SaveSelf");      

    G4cout << ">>> -------------------END-------------------------- " << G4endl;  //nowa linijka

     // Reintialize the counter of hits
     G4cout << "MQEventAction::EndOfEventAction, numberOfCoilHitStoredAlongRun = " << numberOfCoilHitStoredAlongRun << G4endl;
     numberOfCoilHitStoredAlongRun= 0;

}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... "

Do you know what could be a reason and how to fix it up?

I am so surprised because in previous MD there were hits.

I would be grateful for help

Best regards

Agnieszka Priebe

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "No hits in SD"

 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 ]