Changeset 87 in Idarraga
- Timestamp:
- Mar 11, 2011, 6:42:24 PM (13 years ago)
- Location:
- allpix
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
allpix/newdigitizer.sh
r85 r87 45 45 sed "s|__|${nameFragment}|g" < include/${digiHeader} > include/${digiHeader}_new 46 46 sed "s|AAAuthor|${authorS}|g" < include/${digiHeader}_new > include/${digiHeader}_new2 47 rm -f include/${digiHeader}_new 47 48 mv include/${digiHeader}_new2 include/${digiHeader} 48 49 … … 50 51 sed "s|__|${nameFragment}|g" < src/${digiImp} > src/${digiImp}_new 51 52 sed "s|AAAuthor|${authorS}|g" < src/${digiImp}_new > src/${digiImp}_new2 53 rm -f src/${digiImp}_new 52 54 mv src/${digiImp}_new2 src/${digiImp} 53 55 … … 55 57 sed "s|__|${nameFragment}|g" < include/${digitizerHeader} > include/${digitizerHeader}_new 56 58 sed "s|AAAuthor|${authorS}|g" < include/${digitizerHeader}_new > include/${digitizerHeader}_new2 59 rm -f include/${digitizerHeader}_new 57 60 mv include/${digitizerHeader}_new2 include/${digitizerHeader} 58 61 … … 60 63 sed "s|__|${nameFragment}|g" < src/${digitizerImp} > src/${digitizerImp}_new 61 64 sed "s|AAAuthor|${authorS}|g" < src/${digitizerImp}_new > src/${digitizerImp}_new2 65 rm -f src/${digitizerImp}_new 62 66 mv src/${digitizerImp}_new2 src/${digitizerImp} 63 67 68 ### Proceed with activation of new digitizer at AllPixEventAction::SetupDigitizers() 69 echo "[INFO] including new digitizer in the setup" 70 # save old src/AllPixSetupDigitizers.cc file 71 mv src/AllPixSetupDigitizers.cc src/AllPixSetupDigitizers.cc_save 72 # copy headers and include the new one 73 cp src/digitizers_base/AllPixSetupDigitizers.cc_headers src/AllPixSetupDigitizers.cc 74 cat <<EOF>>src/AllPixSetupDigitizers.cc 75 // Included by newdigitizer.sh script --> ${digiName} 76 #include "${nameFragment}Digitizer.hh" 77 EOF 78 # copy the main code 79 cat src/digitizers_base/AllPixSetupDigitizers.cc_head >> src/AllPixSetupDigitizers.cc 80 # include new digi code 81 cat <<EOF>>src/AllPixSetupDigitizers.cc 82 // Included by newdigitizer.sh script --> ${digiName} 83 else 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 } 88 EOF 89 # include the tail 90 cat src/digitizers_base/AllPixSetupDigitizers.cc_tail >> src/AllPixSetupDigitizers.cc 91 92 echo "*************************************************************************************" 93 echo "README !!!" 94 echo "1) please recompile allpix: gmake" 95 echo "2) If you want to use this digitizer you need to call it in the detector description." 96 echo " The name of your new digitizer is: ${digiName}" 97 echo " I can be used in the corresponding tag, i.e: <digitizer>${digiName}</digitizer>" 98 echo " inside the file models/pixeldetector.xml which you should modify by hand." 99 echo "*************************************************************************************" 100 101 echo "[DONE]" -
allpix/src/AllPixDetectorConstructionAppliances.cc
r84 r87 45 45 // fit in. 46 46 47 48 47 // Example 49 48 G4cout << "Build Appliance " << G4endl; … … 51 50 G4NistManager * nistman = G4NistManager::Instance(); 52 51 //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; 54 62 55 63 G4Box * appliance_box = new G4Box("Appliance_box", … … 69 77 G4String appPhysS = "Appliance_"; 70 78 char temp[128]; 79 80 // SD manager 81 G4SDManager * SDman = G4SDManager::GetSDMpointer(); 71 82 72 83 for( ; aplItr != m_posVectorAppliances.end() ; aplItr++) { … … 97 108 0, 98 109 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 99 120 } 100 121 -
allpix/src/AllPixDetectorConstructionTestStructure.cc
r52 r87 1 /**1 /** 2 2 * Author: John Idarraga <idarraga@cern.ch> , 2010 3 3 * -
allpix/src/AllPixEventAction.cc
r57 r87 28 28 } 29 29 30 void AllPixEventAction::SetupDigitizers(){31 30 32 // Digit manager33 G4DigiManager * fDM = G4DigiManager::GetDMpointer();34 35 // geo description36 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 hitCollections41 // There is one hit collection by detector42 // but not all of them are pixel detectors43 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 db56 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 digitized78 G4String searchS = "BoxSD";79 80 if(!digitizerModName.contains("Box")){81 G4cout << "SD [" << hcName82 << "] --> 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 there88 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 \"" << digitizerModName98 << "\" was already created ... skipping." << G4endl;99 continue;100 }101 102 digitizerModulesNames.push_back(digitizerModName);103 104 // Now build the digit Collection name105 G4String digitColectionName = GetNewName(hcName,"HitsCollection","_DigitCollection");106 107 // Creating an instance of the actual digitizer, and keep pointer through the interface108 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 interface124 // pass here the AllPixGeoDsc ptr125 dmPtr->SetDetectorGeoDscPtr((*geoMap)[detectorId]);126 127 // push back the digitizer128 m_digiPtrs.push_back( dmPtr );129 fDM->AddNewModule(m_digiPtrs[itr]);130 m_nDigitizers++;131 132 }133 134 }135 31 136 32 G4String AllPixEventAction::GetNewName(G4String oldName, G4String toErase, G4String toAppend){ -
allpix/src/AllPixTrackerSD.cc
r64 r87 71 71 m_rotationOfWrapper = rot; 72 72 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 */ 80 AllPixTrackerSD::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; 73 95 } 74 96 … … 96 118 } 97 119 120 98 121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 99 122 … … 110 133 const G4TouchableHandle touchablepost = postStepPoint->GetTouchableHandle(); 111 134 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; 145 137 G4int copyIDy_post = -1; 146 138 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 } 148 176 // Look at the touchablepost only if in the same volume, i.e. in the sensitive Si Box 149 177 // If the hit is in a different pixel, it is still the same phys volume 150 178 // The problem is that if I the postStep is in a different volume, GetCopyNumber(1) 151 179 // doesn't make sense anymore. 180 G4ThreeVector postPos(0,0,0); 152 181 if(preStepPoint->GetPhysicalVolume() == postStepPoint->GetPhysicalVolume()){ 153 182 postPos = postStepPoint->GetPosition(); … … 222 251 G4cout << "previous correctedPos : " << correctedPos.x()/um << " " << correctedPos.y()/um 223 252 << " " << correctedPos.z()/um << " [um]" << G4endl << G4endl; 224 */225 253 */ 254
Note: See TracChangeset
for help on using the changeset viewer.