Message: Error in Accumulating Square of Hits to a G4THitsMap for Precision Calculation Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Error in Accumulating Square of Hits to a G4THitsMap for Precision Calculation 

Forum: Biasing and Scoring
Date: 30 May, 2014
From: Matthew Lund <Matthew Lund>

  I've been using example RE02 as an example of recording hits using 16 different detectors with several primitive scorers. I accumulate hits fine in the hits map; however, I also want to create a G4THitsMap with all the detectors and scorers with the square of each hit so that I can calculate error. I have tried many different ways of recording the data, but I can't figure out how to correctly reference it. Below is the code and the error message, any ideas of how to correctly reference it?

Thanks!

void Run::RecordEvent(const G4Event* aEvent)
{
    numberOfEvent++; // This is an original line.
    
    //=============================
    // HitsCollection of This Event
    //============================
    G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
    if (!HCE) return;
       
    //=======================================================
    // Sum up HitsMap of this Event into HitsMap of this RUN
    //=======================================================

  G4int nCol = fCollID.size();
    for ( G4int i = 0; i < nCol ; i++ ){ // Loop over HitsCollection
        G4THitsMap<G4double>* evtMap=0;
        if ( fCollID[i] >= 0 ){ // Collection is attached to HCE
            evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fCollID[i]));
        }else{
            G4cout <<" Error evtMap Not Found "<< i << G4endl;
        }
        if ( evtMap ) {
            //=== Sum up HitsMap of this event to HitsMap of RUN.===
            *fRunMap[i] += *evtMap;

            //======================================================
            // Sum Up Hits Squared for error calculations
           //=======================================================

            std::map<G4int,G4double*>::iterator itr = evtMap->GetMap()->begin();
            for(; itr != evtMap->GetMap()->end(); itr++) {
                G4int key = (itr->first);
                fRunMap_Square[key]+=[key](*(itr->second))*(*(itr->second));
            }
}}

Compilation Error:
error: invalid operands to binary expression ('value_type' (aka 'G4THitsMap<double> *') and 'double')
                fRunMap_Square[key]+=(*(itr->second))*(*(itr->second));
                ~~~~~~~~~~~~~~~~~~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

1 None: Re: Error in Accumulating Square of Hits to a G4THitsMap for Precision Calculation   (Tsukasa Aso - 31 May, 2014)
 Add Message Add Message
to: "Error in Accumulating Square of Hits to a G4THitsMap for Precision Calculation"

 Subscribe Subscribe

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