Changeset 87 in Idarraga


Ignore:
Timestamp:
Mar 11, 2011, 6:42:24 PM (13 years ago)
Author:
idarraga
Message:
 
Location:
allpix
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • allpix/newdigitizer.sh

    r85 r87  
    4545sed "s|__|${nameFragment}|g" < include/${digiHeader} > include/${digiHeader}_new
    4646sed "s|AAAuthor|${authorS}|g" < include/${digiHeader}_new > include/${digiHeader}_new2
     47rm -f include/${digiHeader}_new
    4748mv include/${digiHeader}_new2 include/${digiHeader}
    4849
     
    5051sed "s|__|${nameFragment}|g" < src/${digiImp} > src/${digiImp}_new
    5152sed "s|AAAuthor|${authorS}|g" < src/${digiImp}_new > src/${digiImp}_new2
     53rm -f src/${digiImp}_new
    5254mv src/${digiImp}_new2 src/${digiImp}
    5355
     
    5557sed "s|__|${nameFragment}|g" < include/${digitizerHeader} > include/${digitizerHeader}_new
    5658sed "s|AAAuthor|${authorS}|g" < include/${digitizerHeader}_new > include/${digitizerHeader}_new2
     59rm -f include/${digitizerHeader}_new
    5760mv include/${digitizerHeader}_new2 include/${digitizerHeader}
    5861
     
    6063sed "s|__|${nameFragment}|g" < src/${digitizerImp} > src/${digitizerImp}_new
    6164sed "s|AAAuthor|${authorS}|g" < src/${digitizerImp}_new > src/${digitizerImp}_new2
     65rm -f src/${digitizerImp}_new
    6266mv src/${digitizerImp}_new2 src/${digitizerImp}
    6367
     68### Proceed with activation of new digitizer at AllPixEventAction::SetupDigitizers()
     69echo "[INFO] including new digitizer in the setup"
     70# save old src/AllPixSetupDigitizers.cc file
     71mv src/AllPixSetupDigitizers.cc src/AllPixSetupDigitizers.cc_save
     72# copy headers and include the new one
     73cp src/digitizers_base/AllPixSetupDigitizers.cc_headers src/AllPixSetupDigitizers.cc
     74cat <<EOF>>src/AllPixSetupDigitizers.cc
     75// Included by newdigitizer.sh script --> ${digiName}
     76#include "${nameFragment}Digitizer.hh"
     77EOF
     78# copy the main code
     79cat src/digitizers_base/AllPixSetupDigitizers.cc_head >> src/AllPixSetupDigitizers.cc
     80# include new digi code
     81cat <<EOF>>src/AllPixSetupDigitizers.cc
     82// Included by newdigitizer.sh script --> ${digiName}
     83else if (digitizerName == "${digiName}") {
     84                        ${nameFragment}Digitizer * dp = new ${nameFragment}Digitizer(digitizerModulesNames[itr] , hcName, digitColectionName);
     85                        dmPtr = static_cast<AllPixDigitizerInterface *> (dp);
     86                        cout << "    Setting up a " << digitizerName << " digitizer for det : " << detectorId << endl;
     87                }
     88EOF
     89# include the tail
     90cat src/digitizers_base/AllPixSetupDigitizers.cc_tail >> src/AllPixSetupDigitizers.cc
     91
     92echo "*************************************************************************************"
     93echo "README !!!"
     94echo "1) please recompile allpix: gmake"
     95echo "2) If you want to use this digitizer you need to call it in the detector description."
     96echo "   The name of your new digitizer is: ${digiName}"
     97echo "   I can be used in the corresponding tag, i.e: <digitizer>${digiName}</digitizer>"
     98echo "    inside the file models/pixeldetector.xml which you should modify by hand."
     99echo "*************************************************************************************"
     100
     101echo "[DONE]"
  • allpix/src/AllPixDetectorConstructionAppliances.cc

    r84 r87  
    4545        // fit in.
    4646
    47 
    4847        // Example
    4948        G4cout << "Build Appliance " << G4endl;
     
    5150        G4NistManager * nistman = G4NistManager::Instance();
    5251        //G4Material * mat = nistman->FindOrBuildMaterial("G4_C");
    53         G4Material * mat = nistman->FindOrBuildMaterial("G4_Al");
     52        G4Material * mat = nistman->FindOrBuildMaterial("G4_POLYETHYLENE");
     53
     54        //G4_C
     55        //G4_Al
     56        //G4_LITHIUM_FLUORIDE
     57        //G4_POLYETHYLENE
     58
     59        //std::vector<G4String> mats = nistman->GetNistMaterialNames();
     60        //std::vector<G4String>::iterator itr = mats.begin();
     61        //for( ; itr != mats.end() ; itr++) G4cout << *itr << G4endl;
    5462
    5563        G4Box * appliance_box = new G4Box("Appliance_box",
     
    6977        G4String appPhysS = "Appliance_";
    7078        char temp[128];
     79
     80        // SD manager
     81        G4SDManager * SDman = G4SDManager::GetSDMpointer();
    7182
    7283        for( ; aplItr != m_posVectorAppliances.end() ; aplItr++) {
     
    97108                                0,
    98109                                true);
     110
     111                // Make this volume a sensitive device
     112                // I get automatically a hits ROOT file for each device
     113                AllPixTrackerSD * aTrackerSD = new AllPixTrackerSD( "NeutronSD",
     114                                m_posVectorAppliances[detId],
     115                                0);
     116
     117                SDman->AddNewDetector( aTrackerSD );
     118                appliance_log->SetSensitiveDetector( aTrackerSD );
     119
    99120        }
    100121
  • allpix/src/AllPixDetectorConstructionTestStructure.cc

    r52 r87  
    1 /**
     1 /**
    22 * Author: John Idarraga <idarraga@cern.ch> , 2010
    33 *
  • allpix/src/AllPixEventAction.cc

    r57 r87  
    2828}
    2929
    30 void AllPixEventAction::SetupDigitizers(){
    3130
    32         // Digit manager
    33         G4DigiManager * fDM = G4DigiManager::GetDMpointer();
    34 
    35         // geo description
    36         extern ReadGeoDescription * g_GeoDsc; // already loaded ! :)
    37         map<int, AllPixGeoDsc *> * geoMap = g_GeoDsc->GetDetectorsMap();
    38 
    39         // I need as many digitizer as detectors.
    40         // I decide that through the hitCollections
    41         // There is one hit collection by detector
    42         //  but not all of them are pixel detectors
    43         G4SDManager * SDman = G4SDManager::GetSDMpointer();
    44         G4HCtable * HCTable = SDman->GetHCtable();
    45         m_nHC = HCTable->entries();
    46         map<int, AllPixGeoDsc *>::iterator geoItr;
    47         G4String digitizerName;
    48         G4int detectorId;
    49 
    50         for(G4int itr = 0 ; itr < m_nHC ; itr++)
    51         {
    52 
    53                 G4String hcName = HCTable->GetHCname(itr);
    54 
    55                 // find the detector id for this digitizer in the detector db
    56                 bool found = false;
    57                 for( geoItr = geoMap->begin() ; geoItr != geoMap->end() ; geoItr++ ){
    58                         if( hcName == (*geoItr).second->GetHitsCollectionName() ){
    59                                 digitizerName = (*geoItr).second->GetSensorDigitizer();
    60                                 detectorId = (*geoItr).first;
    61                                 found = true;
    62                                 break;
    63                         }
    64                 }
    65                 if(!found){
    66                         cout << "Couldn't find the detector in the list !!!??? "<< endl;
    67                         exit(1);
    68                 }
    69 
    70                 G4String digitSuffix = "_";
    71                 digitSuffix += digitizerName;
    72                 digitSuffix += "Digitizer";
    73                 G4String digitizerModName = GetNewName(hcName, "HitsCollection", digitSuffix);
    74 
    75                 (*geoMap)[detectorId]->SetDigitCollectionName(digitizerModName);
    76 
    77                 // Check if this is a Box.  If it is not a Si wafer it doesn't need to be digitized
    78                 G4String searchS = "BoxSD";
    79 
    80                 if(!digitizerModName.contains("Box")){
    81                         G4cout << "SD [" << hcName
    82                                         << "] --> This is not a sensitive detector needing a Digitizer ! ... skipping"
    83                                         << G4endl;
    84                         continue;
    85                 }
    86 
    87                 // first check if this digitizer module is already there
    88                 vector<G4String>::iterator it;
    89                 it = find (digitizerModulesNames.begin(), digitizerModulesNames.end(), digitizerModName);
    90 
    91                 // If the digitizer module is in the list,
    92                 //  it means the digitizer was already created for this detector, jump !
    93                 G4cout << "SD [" << hcName << "] Attemping to build digitizer \""
    94                                 << digitizerModName << "\"" << G4endl;
    95 
    96                 if(it != digitizerModulesNames.end()) {
    97                         G4cout << "WARNING : Digitizer module \"" << digitizerModName
    98                                         << "\" was already created ... skipping." << G4endl;
    99                         continue;
    100                 }
    101 
    102                 digitizerModulesNames.push_back(digitizerModName);
    103 
    104                 // Now build the digit Collection name
    105                 G4String digitColectionName = GetNewName(hcName,"HitsCollection","_DigitCollection");
    106 
    107                 // Creating an instance of the actual digitizer, and keep pointer through the interface
    108                 AllPixDigitizerInterface * dmPtr;
    109                 if (digitizerName == "FEI3Standard") {
    110                         AllPixFEI3StandardDigitizer * dp = new AllPixFEI3StandardDigitizer(digitizerModulesNames[itr] , hcName, digitColectionName);
    111                         dmPtr = static_cast<AllPixDigitizerInterface *> (dp);
    112                         cout << "    Setting up a " << digitizerName << " digitizer for det : " << detectorId << endl;
    113                 } else if (digitizerName == "Medipix2") {
    114                         AllPixMedipix2Digitizer * dp = new AllPixMedipix2Digitizer(digitizerModulesNames[itr] , hcName, digitColectionName);
    115                         dmPtr = static_cast<AllPixDigitizerInterface *> (dp);
    116                         cout << "    Setting up a " << digitizerName << " digitizer for det : " << detectorId << endl;
    117                 } else {
    118                         G4cout << "    can't find digitizer with name : " << digitizerName << G4endl;
    119                         exit(1);
    120                 }
    121 
    122                 ///////////////////////////////////////////////////////////
    123                 // Common task to all digitizers provided in the interface
    124                 // pass here the AllPixGeoDsc ptr
    125                 dmPtr->SetDetectorGeoDscPtr((*geoMap)[detectorId]);
    126 
    127                 // push back the digitizer
    128                 m_digiPtrs.push_back( dmPtr );
    129                 fDM->AddNewModule(m_digiPtrs[itr]);
    130                 m_nDigitizers++;
    131 
    132         }
    133 
    134 }
    13531
    13632G4String AllPixEventAction::GetNewName(G4String oldName, G4String toErase, G4String toAppend){
  • allpix/src/AllPixTrackerSD.cc

    r64 r87  
    7171        m_rotationOfWrapper = rot;
    7272        m_gD = gD; // Geo description
     73        m_thisIsAPixelDetector = true;
     74}
     75
     76/*
     77 * Second constructor for sensitive devices wich are
     78 * not actual pixel detectors
     79 */
     80AllPixTrackerSD::AllPixTrackerSD(G4String name,
     81                G4ThreeVector absPos,
     82                G4RotationMatrix * rot)
     83:G4VSensitiveDetector(name)
     84{
     85
     86        m_thisHitsCollectionName = name + "_HitsCollection";
     87        collectionName.insert( m_thisHitsCollectionName ); // only one hit collection per detector for now
     88
     89        // reduced set of parameters for a SD which is not a pixel detector
     90        m_absolutePosOfWrapper = absPos;
     91        m_relativePosOfSD = G4ThreeVector(0,0,0);
     92        m_rotationOfWrapper = rot;
     93        m_gD = 0x0; // Geo description
     94        m_thisIsAPixelDetector = false;
    7395}
    7496
     
    96118}
    97119
     120
    98121//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
    99122
     
    110133        const G4TouchableHandle touchablepost = postStepPoint->GetTouchableHandle();
    111134
    112         // This positions are global, I will bring them to pixel-centered frame
    113         // I can use the physical volumes for that
    114         G4ThreeVector prePos = preStepPoint->GetPosition();
    115         G4ThreeVector postPos;
    116 
    117         // Find the inverse rotation
    118         G4RotationMatrix invRot = CLHEP::inverseOf(*m_rotationOfWrapper);
    119 
    120         // Absolute center of Si wafer
    121         G4ThreeVector absCenterOfDetector = m_absolutePosOfWrapper + m_relativePosOfSD;
    122 
    123         // Bring the detector to the Origin
    124         G4ThreeVector correctedPos = prePos;
    125         correctedPos -= absCenterOfDetector;
    126         // apply rotation !
    127         correctedPos = invRot * correctedPos;
    128 
    129         // Now let's finally provide pixel-centered coordinates for each hit
    130         // Build the center of the Pixel
    131         G4ThreeVector centerOfPixel(
    132                         m_gD->GetPixelX()*TMath::FloorNint(correctedPos.x() / m_gD->GetPixelX()) + m_gD->GetHalfPixelX(),
    133                         m_gD->GetPixelY()*TMath::FloorNint(correctedPos.y() / m_gD->GetPixelY()) + m_gD->GetHalfPixelY(),
    134                         0.); // in the middle of the tower
    135 
    136         // The position within the pixel !!!
    137         correctedPos = correctedPos - centerOfPixel;
    138         //G4cout << "correctedPos : " << correctedPos.x()/um << " " << correctedPos.y()/um
    139         //         << " " << correctedPos.z()/um << " [um]" << G4endl;
    140 
    141         // depth 1 --> x
    142         // depth 0 --> y
    143         G4int copyIDy_pre  = touchablepre->GetCopyNumber();
    144         G4int copyIDx_pre  = touchablepre->GetCopyNumber(1);
     135        G4int copyIDy_pre  = -1;
     136        G4int copyIDx_pre  = -1;
    145137        G4int copyIDy_post = -1;
    146138        G4int copyIDx_post = -1;
    147 
     139        G4ThreeVector correctedPos(0,0,0);
     140
     141        if(m_thisIsAPixelDetector){
     142                // This positions are global, I will bring them to pixel-centered frame
     143                // I can use the physical volumes for that
     144                G4ThreeVector prePos = preStepPoint->GetPosition();
     145
     146
     147                // Find the inverse rotation
     148                G4RotationMatrix invRot = CLHEP::inverseOf(*m_rotationOfWrapper);
     149
     150                // Absolute center of Si wafer
     151                G4ThreeVector absCenterOfDetector = m_absolutePosOfWrapper + m_relativePosOfSD;
     152
     153                // Bring the detector to the Origin
     154                correctedPos = prePos;
     155                correctedPos -= absCenterOfDetector;
     156                // apply rotation !
     157                correctedPos = invRot * correctedPos;
     158
     159                // Now let's finally provide pixel-centered coordinates for each hit
     160                // Build the center of the Pixel
     161                G4ThreeVector centerOfPixel(
     162                                m_gD->GetPixelX()*TMath::FloorNint(correctedPos.x() / m_gD->GetPixelX()) + m_gD->GetHalfPixelX(),
     163                                m_gD->GetPixelY()*TMath::FloorNint(correctedPos.y() / m_gD->GetPixelY()) + m_gD->GetHalfPixelY(),
     164                                0.); // in the middle of the tower
     165
     166                // The position within the pixel !!!
     167                correctedPos = correctedPos - centerOfPixel;
     168                //G4cout << "correctedPos : " << correctedPos.x()/um << " " << correctedPos.y()/um
     169                //         << " " << correctedPos.z()/um << " [um]" << G4endl;
     170
     171                // depth 1 --> x
     172                // depth 0 --> y
     173                copyIDy_pre  = touchablepre->GetCopyNumber();
     174                copyIDx_pre  = touchablepre->GetCopyNumber(1);
     175        }
    148176        // Look at the touchablepost only if in the same volume, i.e. in the sensitive Si Box
    149177        // If the hit is in a different pixel, it is still the same phys volume
    150178        // The problem is that if I the postStep is in a different volume, GetCopyNumber(1)
    151179        //  doesn't make sense anymore.
     180        G4ThreeVector postPos(0,0,0);
    152181        if(preStepPoint->GetPhysicalVolume() == postStepPoint->GetPhysicalVolume()){
    153182                postPos = postStepPoint->GetPosition();
     
    222251G4cout << "previous correctedPos : " << correctedPos.x()/um << " " << correctedPos.y()/um
    223252                        << " " << correctedPos.z()/um << " [um]" << G4endl << G4endl;
    224 */
    225 
     253 */
     254
Note: See TracChangeset for help on using the changeset viewer.