// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * //olgusha.net// * 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. * // ******************************************************************** // //--------------------------------------------------------------------------- // // ClassName: Pixel - Charge transport and sharing // // Author: M. Esposito 20.03.13 // //---------------------------------------------------------------------------- // #include "Pixel.hh" #include "Transport.hh" ///#include "Histo.hh" #include "Randomize.hh" #include "Pixel.hh" #include "math.h" #include #include #include #include #include #include #include #include #include #include #include #include "G4PhysicalConstants.hh" #include "G4SystemOfUnits.hh" using namespace boost::numeric::ublas; Pixel::Pixel() { ///histo = new Histo(); histoManager = HistoManager::GetHistoManager(); pixelMessenger = new PixelMessenger(this); // default values length = 100*mm; pitch = 200*um; threshold=500; } Pixel::~Pixel(){ ///delete histo; if(histoManager){ delete histoManager; } } void Pixel::Sample(std::vector xHit,std::vector yHit, G4int motherCopyno, G4String RTtype,G4int number, G4int PDGid) { /// G4cout << "Pixel::Sample::Test" << G4endl; // ************************************************************************************************************* //********************* Detector parameters ******************************************************************** //************************************************************************************************************** if (RTtype=="CMOS"){ pitch=pitch;/// 0.05*mm; } else{ pitch= 0.100*mm; } ///G4cout << "length = " << length << ", pitch = " << pitch << ", threshold = " << threshold << G4endl; unsigned noPixel=length/pitch; // get the number of electrons as passed by transport G4double electrons=xHit.size(); //Parameters for DynAMITE: not currently used G4double gainM=59; //e/DN mean of the lognormal distribution G4double gainS=21; //e/DN std of the lognormal distribution //G4double noiseM=262; //e mean of the lognormal distribution G4double noiseM=698; //e mean of the lognormal distribution 8 LSB noise G4double noiseS=168; //e std of the lognormal distribution //************************************************************************************************************** //************************************************************************************************************** // ************************************************************************************************************* //********************* Matrices ******************************************************************************* //************************************************************************************************************** /* //Hit: Nx2 matrix with pixel coordinates matrix Hit(electrons,2); // Frame: 2Nx2N oversampled matrix counting hit per pixel matrix Frame(noPixel+1,noPixel+1); // SharedFrame: 2Nx2N oversampled matrix with charged shared in the neighbour pixels matrix SharedFrame(noPixel*2,noPixel*2); //ResFrame: NxN matrix resampled after charge sharing matrix ResFrame(noPixel,noPixel); //DNFrame: NxN matrix resampled after charge sharing and convert to DN matrix DNFrame(noPixel,noPixel); //************************************************************************************************************** //************************************************************************************************************** // ************************************************************************************************************* //********************* Random Engine ************************************************************************** //************************************************************************************************************** typedef boost::mt19937 ENG; // Mersenne Twister typedef boost::lognormal_distribution DISTg; // LogNormal Distribution Gain typedef boost::variate_generator GENg; // Variate generator Gain typedef boost::lognormal_distribution DISTn; // LogNormal Distribution Noise typedef boost::variate_generator GENn; // Variate generator Noise ENG eng; eng.seed(time(0)); DISTg distG(gainM,gainS); GENg genG(eng,distG); DISTn distN(noiseM,noiseS); GENn genN(eng,distN); //************************************************************************************************************** //************************************************************************************************************** G4int pixel=0; G4int x=0; G4int y=0; // set the pixel values all to zero for (unsigned i=0; i=0 && Hit(i,1)>=0 ){ //incriment the number of electrons in the location by 1 from the position of the hit Frame(Hit(i,0),Hit(i,1))=Frame(Hit(i,0),Hit(i,1))+1; } } //passing output to histo for write on file //loop through all of this pixels and see which ones contain enough electrons above threshold // i think this is bottle neck as looping 2000x2000 each time for sparse data for (unsigned i=0; ithreshold){ /// G4cout << Frame(i,j) << G4endl; // data.push_back(number); // data.push_back(PDGid); // data.push_back(motherCopyno); // data.push_back(i); // data.push_back(j); // data.push_back(Frame(i,j)); // G4cout << Frame(i,j) << G4endl; // /// histo->FillBuffer(data); // data.clear(); histoManager->AddRTEvent(number, PDGid, motherCopyno, i, j, Frame(i,j)); } } } } */ // // // // // // //This is to implement charge division between adjent pixel and conversion in DN // // // //Not recommended for Priapus yet as performance not known // // // // // // // //Filling SharedFrame // // // // for(unsigned i=1; i, unsigned> Frame; for(unsigned i=0; i hit(xpix,ypix); if(xpix=0 && ypix>=0) { //Frame(xpix,ypix)=Frame(xpix,ypix)+1; // eventually this will be changed to a map std::map, unsigned>::iterator it = Frame.find(hit); if(Frame.find(hit) != Frame.end()) // if already exists then add an electron to the frame(xpix,ypix) (*it).second++; else // if it does not exist add it to the map and set nelectrons = 1 Frame[hit] = 1; } } // now loop through the map and check if above threshold std::map, unsigned>::iterator it; for(it=Frame.begin(); it!=Frame.end(); it++) { if( (*it).second > threshold ) { if(histoManager){ histoManager->AddRTEvent(number, PDGid, motherCopyno, (*it).first.first, (*it).first.second, (*it).second); } else{ G4cout << number << " " << PDGid << " " << motherCopyno << " " << (*it).first.first << " " << (*it).first.second << " " << (*it).second << G4endl; } } } } }