From 8479e8019ca7f52ce3f8582c217d596caa1947d1 Mon Sep 17 00:00:00 2001 From: Tony Price Date: Thu, 17 Nov 2016 23:45:40 +0100 Subject: [PATCH 01/28] toprice first commit of DECAL geometry --- Detector/DetCommon/compact/HcalBarrelAir.xml | 51 ++ .../DetCommon/compact/TrackerBarrelAir.xml | 37 ++ Detector/DetFCChhECalDigital/CMakeLists.txt | 27 + .../compact/FCChh_DECalBarrel_Mockup.xml | 45 ++ .../compact/FCChh_DECalDefinition.xml | 10 + .../src/ECalBarrel_geo.cpp | 150 +++++ .../DetSensitive/DigitalCalorimeterSD.h | 198 +++++++ .../DetSensitive/src/DigitalCalorimeterSD.cpp | 395 ++++++++++++++ analyseDataSet.py | 513 ++++++++++++++++++ analysePads.py | 27 + geant_batch_temp.py | 88 +++ geant_fullsim_ecal_SPG_new.py | 90 +++ makeMIPSPerPixelPlot.py | 42 ++ makeMultiplicityResolutionPlot.py | 86 +++ make_resolution_digital.py | 12 + submit_energy_res_to_lxbatch.py | 74 +++ 16 files changed, 1845 insertions(+) create mode 100644 Detector/DetCommon/compact/HcalBarrelAir.xml create mode 100644 Detector/DetCommon/compact/TrackerBarrelAir.xml create mode 100644 Detector/DetFCChhECalDigital/CMakeLists.txt create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml create mode 100644 Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp create mode 100644 Detector/DetSensitive/DetSensitive/DigitalCalorimeterSD.h create mode 100644 Detector/DetSensitive/src/DigitalCalorimeterSD.cpp create mode 100644 analyseDataSet.py create mode 100644 analysePads.py create mode 100644 geant_batch_temp.py create mode 100644 geant_fullsim_ecal_SPG_new.py create mode 100644 makeMIPSPerPixelPlot.py create mode 100644 makeMultiplicityResolutionPlot.py create mode 100644 make_resolution_digital.py create mode 100644 submit_energy_res_to_lxbatch.py diff --git a/Detector/DetCommon/compact/HcalBarrelAir.xml b/Detector/DetCommon/compact/HcalBarrelAir.xml new file mode 100644 index 000000000..6dc41bd68 --- /dev/null +++ b/Detector/DetCommon/compact/HcalBarrelAir.xml @@ -0,0 +1,51 @@ + + + + + HCal Place-Holder + + + + + + + + + + + + + Envelope for HCal barrel + + + + + + + + diff --git a/Detector/DetCommon/compact/TrackerBarrelAir.xml b/Detector/DetCommon/compact/TrackerBarrelAir.xml new file mode 100644 index 000000000..b0e8614f9 --- /dev/null +++ b/Detector/DetCommon/compact/TrackerBarrelAir.xml @@ -0,0 +1,37 @@ + + + + + Tracker Place-Holder + + + + + + + + + + Envelope for Tracker + + + + + + diff --git a/Detector/DetFCChhECalDigital/CMakeLists.txt b/Detector/DetFCChhECalDigital/CMakeLists.txt new file mode 100644 index 000000000..6404a80c8 --- /dev/null +++ b/Detector/DetFCChhECalDigital/CMakeLists.txt @@ -0,0 +1,27 @@ +################################################################################ +# Package: DetFCChhECalDigital +################################################################################ +gaudi_subdir(DetFCChhECalDigital v1r0) + +gaudi_depends_on_subdirs(GaudiKernel + Detector/DetExtensions) + + +find_package(DD4hep) +find_package(Geant4) +include(${Geant4_USE_FILE}) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_ROOT}/cmake ) +include( DD4hep ) + +find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED) + +gaudi_add_module(DetFCChhECalDigital + src/*.cpp + INCLUDE_DIRS DD4hep ROOT DetExtensions Geant4 + LINK_LIBRARIES GaudiKernel DD4hep ROOT Geant4) + +set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +message(STATUS "LIBRARY_OUTPUT_PATH -> ${LIBRARY_OUTPUT_PATH}") +dd4hep_generate_rootmap(DetFCChhECalDigital) + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml new file mode 100644 index 000000000..f2324055e --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml @@ -0,0 +1,45 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:11:-17,y:-17,z:-19 + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml new file mode 100644 index 000000000..f8b8c5d3d --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp new file mode 100644 index 000000000..2516f804f --- /dev/null +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -0,0 +1,150 @@ +// DD4hep includes +#include "DD4hep/DetFactoryHelper.h" + +// Gaudi +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/IMessageSvc.h" +#include "GaudiKernel/MsgStream.h" + +using DD4hep::Geometry::Volume; +using DD4hep::Geometry::DetElement; +using DD4hep::XML::Dimension; +using DD4hep::Geometry::PlacedVolume; + +namespace det { + +static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xmlElement, + DD4hep::Geometry::SensitiveDetector sensDet) +{ + + ServiceHandle msgSvc("MessageSvc", "DECalConstruction"); + MsgStream lLog(&(*msgSvc), "DECalConstruction"); + + lLog << MSG::DEBUG << "++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endmsg; + lLog << MSG::DEBUG << "\t\t\t Building DECAL " << endmsg; + lLog << MSG::DEBUG << " +++++++++++++++++++++++++++++++++++++++++++++++++++++" << endmsg; + + xml_det_t xmlDet = xmlElement; + std::string detName = xmlDet.nameStr(); + //Make DetElement + DetElement eCal(detName, xmlDet.id()); + + // Make volume that envelopes the whole barrel; set material to air + Dimension dimensions(xmlDet.dimensions()); + DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz()); + Volume envelopeVolume(detName, envelopeShape, lcdd.air()); + // Invisibility seems to be broken in visualisation tags, have to hardcode that + std::cout << "dimensions.visStr() = " << dimensions.visStr()<< std::endl; + envelopeVolume.setVisAttributes(lcdd, dimensions.visStr()); + + xml_comp_t calo = xmlElement.child("calorimeter"); + Dimension calo_dims(calo.dimensions()); + std::string calo_name=calo.nameStr(); + double calo_id=calo.id(); + + xml_comp_t active = calo.child("active_layers"); + std::string active_mat=active.materialStr(); + double active_tck=active.thickness(); + int active_samples=active.attr("nSamplings"); + + xml_comp_t substrate = calo.child("substrate_layers"); + std::string substrate_mat=substrate.materialStr(); + double substrate_tck=substrate.thickness(); + + xml_comp_t passive = calo.child("passive_layers"); + std::string passive_mat=passive.materialStr(); + double passive_tck=passive.thickness(); + + xml_comp_t padding = calo.child("between_layers"); + std::string padding_mat=padding.materialStr(); + double padding_tck=padding.thickness(); + + double module_tck = active_tck+substrate_tck+passive_tck+padding_tck; + double calo_tck=active_samples*module_tck; + + lLog << MSG::DEBUG << "ECAL Epitaxial Thickness = " << active_tck << endmsg; + lLog << MSG::DEBUG << "ECAL Substrate Thickness = " << substrate_tck << endmsg; + lLog << MSG::DEBUG << "ECAL Passive Thickness = " << passive_tck << endmsg; + lLog << MSG::DEBUG << "ECAL Between Layers Thickness = " << padding_tck << endmsg; + lLog << MSG::DEBUG << "ECAL Module Thickness = " << module_tck << endmsg; + + lLog << MSG::DEBUG << "nSamplings Layers = " << active_samples << endmsg; + lLog << MSG::DEBUG << "Total Calorimeter thickness = " << calo_tck << endmsg; + + // create a lump of air the entire size of the barrel ECAL + // place it within the ECAL envelope + DetElement caloDet(calo_name, calo_id); + DD4hep::Geometry::Tube caloShape(calo_dims.rmin() , calo_dims.rmin()+calo_tck, calo_dims.dz()); + lLog << MSG::DEBUG << "ECAL: Building the calorimeter from " << calo_dims.rmin() << " to " << calo_dims.rmin()+calo_tck << endmsg; + Volume caloVolume(padding_mat, caloShape, lcdd.material(padding_mat)); + lLog << MSG::DEBUG << "ECAL: Filling the calorimeter volume with " << padding_mat << endmsg; + PlacedVolume placedCalo = envelopeVolume.placeVolume(caloVolume); + placedCalo.addPhysVolID("EM_barrel", calo_id); + caloDet.setPlacement(placedCalo); + + // set the sensitive detector type to the DD4hep calorimeter + sensDet.setType("DigitalCalorimeterSD"); + + + // Calorimeter runs + // 1) epitaxial + // 2) substrate + // 3) passive material + // 4) air gap between layers (this is the caleVolume made of air + + // loop on the sensitive and substrate layers and place within the caloVolume + for (int i=0;i +#include + +#include "TFile.h" +#include "TH1F.h" + +/** DigitalCalorimeterSD DetectorDescription/DetSensitive/src/DigitalCalorimeterSD.h DigitalCalorimeterSD.h + * + * Simple sensitive detector for calorimeter. + * It is based on DD4hep::Simulation::Geant4GenericSD (but it is not identical). + * In particular, the position of the hit is set to G4Step::GetPreStepPoint() position. + * New hit is created for each energy deposit. + * No timing information is saved. + * + * @author Anna Zaborowska + */ + +struct Strixel +{ + int layer; + int x; + int y; + int z; + + bool operator<(const Strixel &other) const + { + if(layer + struct hash + { + std::size_t operator()(const Strixel& s) const + { + using std::size_t; + using std::hash; + using std::string; + + // Compute individual hash values for first, + // second and third and combine them using XOR + // and bit shifting: + + return hash()( + std::to_string(s.layer) +","+ + std::to_string(s.x) +","+ + std::to_string(s.y) +","+ + std::to_string(s.z) + ); + } + }; + +} + +struct Pad +{ + int layer; + int r; + int z; + + bool operator<(const Pad &other) const + { + if(layer + struct hash + { + std::size_t operator()(const Pad& p) const + { + using std::size_t; + using std::hash; + using std::string; + + // Compute individual hash values for first, + // second and third and combine them using XOR + // and bit shifting: + + return hash()( + std::to_string(p.layer) +","+ + std::to_string(p.r) +","+ + std::to_string(p.z) + ); + } + }; + +} + +namespace det { +class DigitalCalorimeterSD : public G4VSensitiveDetector +{ + public: + /** Constructor. + * @param aDetectorName Name of the detector + * @param aReadoutName Name of the readout (used to name the collection) + * @param aSeg Segmentation of the detector (used to retrieve the cell ID) + */ + DigitalCalorimeterSD(const std::string& aDetectorName, + const std::string& aReadoutName, + const DD4hep::Geometry::Segmentation& aSeg); + /// Destructor + virtual ~DigitalCalorimeterSD(); + /** Initialization. + * Creates the hit collection with the name passed in the constructor. + * The hit collection is registered in Geant. + * @param aHitsCollections Geant hits collection. + */ + virtual void Initialize(G4HCofThisEvent* aHitsCollections) final; + /** Process hit once the particle hit the sensitive volume. + * Checks if the energy deposit is larger than 0, calculates the position and cellID, + * saves that into the hit collection. + * New hit is created for each energy deposit. + * @param aStep Step in which particle deposited the energy. + */ + virtual bool ProcessHits(G4Step* aStep, G4TouchableHistory*) final; + + virtual void EndOfEvent(G4HCofThisEvent* aHitsCollections) final; + + virtual bool IsAllowedCellID(unsigned long cid) final; + virtual void AddCellIDMask(unsigned long cid) final; + virtual void UpdateCellIDMask() final; + +private: + /// Collection of calorimeter hits + G4THitsCollection* m_calorimeterCollection; + G4THitsCollection* m_tempCollection; + /// Segmentation of the detector used to retrieve the cell Ids + DD4hep::Geometry::Segmentation m_seg; + + std::string m_pixelsOverThresholdFileName; + std::ofstream m_pixelsOverThresholdFile; + + std::string m_pixelsOverThresholdPerLayerFileName; + std::ofstream m_pixelsOverThresholdPerLayerFile; + + std::string m_mipsPerPixelFileName; + std::ofstream m_mipsPerPixelFile; + + std::string m_padMultiplicityFileName; + std::ofstream m_padMultiplicityFile; + + bool m_headerPrinted; + int m_incidentParticles; + + std::map m_CellIDsMaskedFromPreviousEvent; + + //TFile* m_rootFile; + //TH1F* m_padMultiplicity; +}; +} + +#endif /* DETSENSITIVE_DIGITALCALORIMETERSD_H */ diff --git a/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp b/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp new file mode 100644 index 000000000..c6d38fac4 --- /dev/null +++ b/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp @@ -0,0 +1,395 @@ +#include "DetSensitive/DigitalCalorimeterSD.h" + +// FCCSW +#include "DetSensitive/SegmentationHelper.h" +#include "DDSegmentation/BitField64.h" + +// DD4hep +#include "DDG4/Geant4Mapping.h" +#include "DDG4/Geant4VolumeManager.h" + +// CLHEP +#include "CLHEP/Vector/ThreeVector.h" + +// Geant4 +#include "G4SDManager.hh" +#include "G4ThreeVector.hh" + +#include "iostream" +#include "map" +#include "unordered_map" + +namespace det { +DigitalCalorimeterSD::DigitalCalorimeterSD(const std::string& aDetectorName, + const std::string& aReadoutName, + const DD4hep::Geometry::Segmentation& aSeg) + : G4VSensitiveDetector(aDetectorName), m_seg(aSeg), m_calorimeterCollection(nullptr) { + // name of the collection of hits is determined byt the readout name (from XML) + collectionName.insert(aReadoutName); + + m_headerPrinted = false; + + m_pixelsOverThresholdFileName = aReadoutName+"_pixelsOverThreshold.txt"; + m_pixelsOverThresholdPerLayerFileName = aReadoutName+"_pixelsOverThresholdPerLayer.txt"; + m_mipsPerPixelFileName = aReadoutName+"_mipsPerPixel.txt"; + m_padMultiplicityFileName = aReadoutName+"_padMultiplicity.txt"; + + //m_rootFile = new TFile("test.root"); + //m_padMultiplicity = new TH1F("padMultiplicity", "Number of 5x5mm2 pads fired per event", 10000,0,10000); +} + +DigitalCalorimeterSD::~DigitalCalorimeterSD(){ + m_pixelsOverThresholdFile.close(); + m_padMultiplicityFile.close(); + //m_rootFile->Close(); + std::cout << std::endl; +} + +void DigitalCalorimeterSD::Initialize(G4HCofThisEvent* aHitsCollections) +{ + // create a collection of hits and add it to G4HCofThisEvent + // deleted in ~G4Event + m_calorimeterCollection = new G4THitsCollection + (SensitiveDetectorName,collectionName[0]); + aHitsCollections->AddHitsCollection(G4SDManager::GetSDMpointer()->GetCollectionID(m_calorimeterCollection), m_calorimeterCollection); + + //this collection is just a temp and not added to the HitsCollection just used to store raw hits before summing together + m_tempCollection = new G4THitsCollection + (SensitiveDetectorName,"temp"); + + // m_pixelsOverThresholdFile.open("pixelsOverThreshold.txt", std::ios_base::app);. + + if(!m_headerPrinted){ + std::cout << "incident particles\tunique cellIDs\tcells over thresh\tunique strixels\tstrixel pixels (3)\tstrixel pixels (7)\tstrixel pixels (15)\tstrixel pixels (31)" << std::endl; + m_headerPrinted=true; + } + m_incidentParticles = 0; + +} + +bool DigitalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // check if energy was deposited + G4double edep = aStep->GetTotalEnergyDeposit(); + if(edep==0.) + return false; + + if(aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary){ + m_incidentParticles++; + } + + // as in DD4hep::Simulation::Geant4GenericSD + CLHEP::Hep3Vector prePos = aStep->GetPreStepPoint()->GetPosition(); +/* CLHEP::Hep3Vector postPos = aStep->GetPostStepPoint()->GetPosition(); + double delta_r = sqrt(pow(postPos.x(),2) + pow(postPos.y(),2)) - sqrt(pow(prePos.x(),2) + pow(prePos.y(),2)); + if(delta_r<0) { + return false; + } +*/ + DD4hep::Simulation::Position pos(prePos.x(), prePos.y(), prePos.z()); + auto hit = new DD4hep::Simulation::Geant4CalorimeterHit(pos); + hit->cellID = segmentation::cellID(m_seg, *aStep); + hit->energyDeposit = edep; + m_tempCollection->insert(hit); + return true; +} + +bool DigitalCalorimeterSD::IsAllowedCellID(unsigned long cid) { + // check if the cellID occurred in the previous event + // if the counter is zero the cell is allowed and can remove cell from the mask + std::map::iterator valid_it = m_CellIDsMaskedFromPreviousEvent.find(cid); + if(m_CellIDsMaskedFromPreviousEvent.find(cid) != m_CellIDsMaskedFromPreviousEvent.end()) { + if((*valid_it).second > 0) { + //std::cout << "CellID " << cid << " is inactive for the next " << (*valid_it).second << " events" << std::endl; + return false; + } else { + m_CellIDsMaskedFromPreviousEvent.erase(valid_it); + return true; + } + } else { + return true; + } +} + +void DigitalCalorimeterSD::AddCellIDMask(unsigned long cid) { + // look for the cellID in the std::map. If it exists then reset the dead time + // if it does not exist then add it to the map + int nEventsMasked = 40; + std::map::iterator add_it = m_CellIDsMaskedFromPreviousEvent.find(cid); + if(m_CellIDsMaskedFromPreviousEvent.find(cid) != m_CellIDsMaskedFromPreviousEvent.end()) { + (*add_it).second = nEventsMasked; + } else { + m_CellIDsMaskedFromPreviousEvent[cid] = nEventsMasked; + } +} + +void DigitalCalorimeterSD::UpdateCellIDMask() { + // loop through the mask and remove one from each mask ID. + // if it reaches zero then remove from the list. + std::map::iterator update_it; + for (update_it = m_CellIDsMaskedFromPreviousEvent.begin(); update_it != m_CellIDsMaskedFromPreviousEvent.end(); update_it++){ + (*update_it).second -= 1; + } + for (update_it = m_CellIDsMaskedFromPreviousEvent.begin(); update_it != m_CellIDsMaskedFromPreviousEvent.end(); update_it++){ + if((*update_it).second == 0) m_CellIDsMaskedFromPreviousEvent.erase(update_it); + } + std::cout << "There are currently " << m_CellIDsMaskedFromPreviousEvent.size() << " pixels masked out" << std::endl; +} + +void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { + + int nHits = m_tempCollection->entries(); + + // std::cout << "Total Number of hits = " << nHits << std::endl; + + // the key here will be the cellID (unique to each layer and cell depending on segmentation) + // second is a pair of number particles and total energy + std::map > counter; + DD4hep::Simulation::Geant4CalorimeterHit* hit = nullptr; + + auto decoderBarrel = m_seg->decoder(); + //std::cout << "Barrel segmentation of type " << m_seg->type() << std::endl; + for(int i=0; i (m_tempCollection->GetHit(i)); + + uint64_t cellID = hit->cellID; + + if(IsAllowedCellID(cellID)){ + // this map stored the energy per cell + std::map >::iterator it = counter.find(cellID); + + if(counter.find(cellID) != counter.end()) { + (*it).second.first++; + (*it).second.second->energyDeposit += hit->energyDeposit; + } else { + std::pair info = std::make_pair(1, hit); + counter[cellID] = info; + } + } + } + + // now loop through all the hits and check the Mask. Cannot do it before as may cut out multiple hits to cells + for(int i=0; i (m_tempCollection->GetHit(i)); + uint64_t cellID = hit->cellID; + AddCellIDMask(cellID); + } + + double threshold = 480*0.0000036; // 350 electrons in MeV which should be default value + int pixelsOverThreshold = 0; + int pixelsOverThresholdPerLayer[50]; + std::vector mipsPerPixel[50]; + for(int n(0); n<50; ++n){ + pixelsOverThresholdPerLayer[n]=0; + mipsPerPixel[n].clear(); + } + + DD4hep::Simulation::Geant4CalorimeterHit* digi = nullptr; + std::map >::iterator it; + std::map StrixelHitCounter; + for(it=counter.begin(); it!=counter.end(); it++) + { + + + // if the energy deposited in the cellID is gtreather than threshold then do something + if((*it).second.second->energyDeposit>threshold) { + + pixelsOverThreshold++; + + // insert the collection to G4 so can be passed on later + digi = dynamic_cast ((*it).second.second); + digi->energyDeposit = (*it).second.second->energyDeposit; //(*it).second.first; // overwrite the energy deposit with the number of mips in the cell + m_calorimeterCollection->insert(digi); // this passes to ROOT the readout... interesting! + + uint64_t cellID = (*it).first; + + decoderBarrel->setValue(cellID); + int layer_id = (*decoderBarrel)["layer"]; + int px = (*decoderBarrel)["x"]; + int py = (*decoderBarrel)["y"]; + int pz = (*decoderBarrel)["z"]; + + // convert pixel to strixel + Strixel strixel; + strixel.layer = layer_id; + strixel.x = px; + strixel.y = py; + strixel.z = floor(pz/100); //group in z the pixels into a strixel + + std::map::iterator strixel_it = StrixelHitCounter.find(strixel); + if(StrixelHitCounter.find(strixel) != StrixelHitCounter.end()) { + (*strixel_it).second++; + } else { + StrixelHitCounter[strixel] = 1; + } + + +// std::cout << "layer=" << layer_id +// << "\npx=" << px << ", py=" << py << ", pz=" << pz +// << "\nsx=" << strixel.x << ", sy=" << strixel.y << ", sz=" << strixel.z +// << "\nc=" << pos_round_circ << ", pad.r=" << pad.r << ", pad.z=" << pad.z +// << std::endl << std::endl; + + pixelsOverThresholdPerLayer[layer_id-1]++; + mipsPerPixel[layer_id-1].push_back((*it).second.first); + + } + } + + UpdateCellIDMask(); + + int strixelHits = StrixelHitCounter.size(); + int strixelPixelHits_3 = 0; + int strixelPixelHits_7 = 0; + int strixelPixelHits_15 = 0; + int strixelPixelHits_31 = 0; + //int strixelMaxPixels = 3; + + std::map > PadHitCounter; + std::map::iterator it_strixel; + for(it_strixel=StrixelHitCounter.begin(); it_strixel!=StrixelHitCounter.end(); ++it_strixel) { + + // convert strixel to pad + double x1 = (*it_strixel).first.x; + double y1 = (*it_strixel).first.y; + double r1 = pow((x1*x1+y1*y1),0.5); + + double x0 = r1; + double y0 = 0.0; // set r0 to be at y=0 x=radius + double cord = pow(pow((x1-x0),2)+pow((y1-y0),2),0.5); + double theta = 2*asin(cord/(2*r1)); + double pos_round_circ = theta*r1; + + // for pad counting + std::vector counter; + counter.resize(6); + counter.at(0) = 1; + + int npixels = (*it_strixel).second; + + if(npixels<3) { + strixelPixelHits_3 += npixels; + counter.at(1) = npixels; + } + else { + strixelPixelHits_3 += 3; + counter.at(1) = 3; + } + + if(npixels<7) { + strixelPixelHits_7 += npixels; + counter.at(2) = npixels; + } + else { + strixelPixelHits_7 += 7; + counter.at(2) = 7; + } + if(npixels<15) { + strixelPixelHits_15 += npixels; + counter.at(3) = npixels; + } + else { + strixelPixelHits_15 += 15; + counter.at(3) = 15; + } + + if(npixels<31) { + strixelPixelHits_31 += npixels; + counter.at(4) = npixels; + } + else { + strixelPixelHits_31 += 31; + counter.at(4) = 31; + } + + counter.at(5) = npixels; + + //------------------------------------------------- + Pad pad; + pad.layer = (*it_strixel).first.layer; + pad.r = floor(pos_round_circ/5.0); + pad.z = (*it_strixel).first.z; + + std::map >::iterator it_pad = PadHitCounter.find(pad); + if( PadHitCounter.find(pad) != PadHitCounter.end() ) { + // add to the relevant int part + (*it_pad).second.at(0) += counter.at(0); // count hits in pad limited by 1 hit per column + (*it_pad).second.at(1) += counter.at(1); // count hits in pad limited by 3 hits per column + (*it_pad).second.at(2) += counter.at(2); // count hits in pad limited by 7 hits per column + (*it_pad).second.at(3) += counter.at(3); // count hits in pad limited by 15 hits per column + (*it_pad).second.at(4) += counter.at(4); // count hits in pad limited by 31 hits per column + (*it_pad).second.at(5) += counter.at(5); // count all hits in pad + } else { + PadHitCounter[pad] = counter; + } + + } + + // now we loop through the map of pads to get total hits + if(!m_padMultiplicityFile.is_open()) { + std::map >::iterator it_pad; + m_padMultiplicityFile.open(m_padMultiplicityFileName, std::ios_base::app); + for(it_pad=PadHitCounter.begin(); it_pad!=PadHitCounter.end(); ++it_pad) { + + //std::cout << (*it_pad).second.at(1) << " "; + m_padMultiplicityFile << (*it_pad).second.at(1) << " "; + + } + m_padMultiplicityFile << "\n"; + m_padMultiplicityFile.close(); + } + +/* std::cout << std::endl; + std::cout << nHits << " " << pixelsOverThreshold << std::endl; + std::cout << "Total number of unique cellIDs = " << pixelsOverThreshold << std::endl; + std::cout << "Total number of unique strixels = " << strixelHits << std::endl; + std::cout << "Total number of strixel pixels (3) = " << strixelPixelHits_3 << std::endl ; + std::cout << "Total number of strixel pixels (7) = " << strixelPixelHits_7 << std::endl; + std::cout << "Total number of strixel pixels (15) = " << strixelPixelHits_15 << std::endl; + std::cout << "Total number of strixel pixels (31) = " << strixelPixelHits_31 << std::endl; + std::cout << "Total number of unique pads = " << PadHitCounter.size() << std::endl << std::endl; +*/ + + std::cout << m_incidentParticles << "\t" << counter.size() << "\t" << pixelsOverThreshold << "\t" << strixelHits << "\t" << strixelPixelHits_3 << "\t" << strixelPixelHits_7 << "\t" << strixelPixelHits_15 << "\t" << strixelPixelHits_31 << "\t" << PadHitCounter.size() << std::endl; + + +/* + + if(!m_pixelsOverThresholdFile.is_open()){ + m_pixelsOverThresholdFile.open(m_pixelsOverThresholdFileName, std::ios_base::app); + m_pixelsOverThresholdFile << pixelsOverThreshold << " "; + m_pixelsOverThresholdFile.close(); + } + + if(!m_pixelsOverThresholdPerLayerFile.is_open()){ + m_pixelsOverThresholdPerLayerFile.open(m_pixelsOverThresholdPerLayerFileName, std::ios_base::app); + for(int l(0); l<50; l++){ + m_pixelsOverThresholdPerLayerFile << pixelsOverThresholdPerLayer[l] << " "; + } + m_pixelsOverThresholdPerLayerFile << "\n"; + m_pixelsOverThresholdPerLayerFile.close(); + } + + if(!m_mipsPerPixelFile.is_open()){ + m_mipsPerPixelFile.open(m_mipsPerPixelFileName, std::ios_base::app); + for(int l(0); l<50; l++){ + m_mipsPerPixelFile << "L" << l << " "; + for(unsigned p(0); p 1.0 and e<10000:# and e<900.0 and e != 70.0 and e !=200.0: + sqrte = 1/pow(e,0.5) + n = parseFile(fname, var) + mean = np.mean(n) + + energy.append(e) + count.append(mean) + + print energy, count + plot = ROOT.TGraph(len(energy), array("d",energy), array("d",count)) + plot.SetTitle(det+" BFIELD="+str(bfield)+" Mode:"+config) + plot.GetXaxis().SetTitle("Energy [GeV]") + plot.GetYaxis().SetTitle("#mu_{N}") + + return plot + + +def makeResolutionPlot(det='', bfield='',config=''): + + var = getVarFromConfig(config) + + energy = [] + resolution = [] + + paths = [p for p in os.listdir("./batch/"+det) if "BFIELD"+str(bfield) in p] + for p in paths: + fname = "./batch/"+det+"/"+p+"/logs" + if not os.path.isfile(fname): + continue + e = float(p[0:p.find("GeV")]) + if e > 1.0 and e<1001.0:# and e<900.0 and e != 70.0 and e !=200.0: + sqrte = 1/pow(e,0.5) + n = parseFile(fname, var) + print "N=",len(n) + mean = np.mean(n) + std = np.std(n) + res = std/mean + + energy.append(sqrte) + resolution.append(res) + + print energy, resolution + plot = ROOT.TGraph(len(energy), array("d",energy), array("d",resolution)) + plot.SetTitle(det+" BFIELD="+str(bfield)+" Mode:"+config) + plot.SetName(det+" BFIELD="+str(bfield)+" Mode:"+config) + plot.GetXaxis().SetTitle("1/#sqrt{E}") + plot.GetYaxis().SetTitle("#sigma_{N}/#mu_{N}") + + return plot + +def fitResolutionPlot(plot=None,fit="",min=0.07, max=0.35): + fit = ROOT.TF1("fit", fit,min,max) + plot.Fit(fit,"NR") + fit.SetRange(0.001, 0.35) + return fit + +def fitLinearityPlot(plot=None, fit="", min=0, max=100): + fit = ROOT.TF1("fit",fit, min, max) + fit.FixParameter(0,0) + plot.Fit(fit, "NR") + fit.SetRange(0, 1000) + return fit + +def plotSingleResolution(plot=None, fit=None): + canvas = ROOT.TCanvas(plot.GetTitle(),"single") + canvas.cd() + if plot is not None: + plot.SetMarkerStyle(21) + plot.SetMarkerSize(1) + plot.Draw("ap") + if fit is not None: + fit.SetLineColor(1) + fit.SetLineStyle(2) + print fit.GetNpar() + fit.DrawCopy("same") + + pt = ROOT.TPaveText(0.2,0.7,0.5,0.8,"NDC") + pt.SetFillColor(0) + pt.SetBorderSize(0) + if fit.GetNpar() == 2: + print "#frac{#sigma(E)}{E} = #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit.GetParameter(1)*100, fit.GetParameter(0)*100) + pt.AddText("#frac{#sigma(E)}{E} = #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit.GetParameter(1)*100, fit.GetParameter(0)*100)) + if fit.GetNpar() == 3: + print "#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit.GetParameter(2)*100, fit.GetParameter(1)*100, fit.GetParameter(0)*100) + pt.AddText("#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit.GetParameter(2)*100, fit.GetParameter(1)*100, fit.GetParameter(0)*100) ) + pt.Draw() + + canvas.Update() + return canvas + +def plotDoubleResolution(plot1=None, fit1=None, plot2=None, fit2=None): + canvas = ROOT.TCanvas("double","double") + canvas.cd() + if plot1 is not None: + plot1.SetMarkerStyle(21) + plot1.SetMarkerSize(1) + plot1.Draw("ap") + if fit1 is not None: + fit1.SetLineColor(1) + fit1.SetLineStyle(2) + fit1.DrawCopy("same") + + pt1 = ROOT.TPaveText(0.2,0.7,0.5,0.8,"NDC") + pt1.SetFillColor(0) + pt1.SetBorderSize(0) + if fit1.GetNpar() == 2: + print "#frac{#sigma(E)}{E} = #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit1.GetParameter(1)*100, fit1.GetParameter(0)*100) + pt1.AddText("#frac{#sigma(E)}{E} = #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit1.GetParameter(1)*100, fit1.GetParameter(0)*100)) + if fit1.GetNpar() == 3: + print "#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit1.GetParameter(2)*100, fit1.GetParameter(1)*100, fit1.GetParameter(0)*100) + pt1.AddText("#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit1.GetParameter(2)*100, fit1.GetParameter(1)*100, fit1.GetParameter(0)*100) ) + pt1.Draw() + + if plot2 is not None: + plot2.SetMarkerStyle(22) + plot2.SetMarkerSize(1) + plot2.Draw("p") + if fit2 is not None: + fit2.SetLineColor(1) + fit2.SetLineStyle(3) + fit2.DrawCopy("same") + + pt2 = ROOT.TPaveText(0.2,0.6,0.5,0.7,"NDC") + pt2.SetFillColor(0) + pt2.SetBorderSize(0) + if fit2.GetNpar() == 2: + print "#frac{#sigma(E)}{E} = #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit2.GetParameter(1)*100, fit2.GetParameter(0)*100) + pt2.AddText("#frac{#sigma(E)}{E} = #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit2.GetParameter(1)*100, fit2.GetParameter(0)*100)) + if fit2.GetNpar() == 3: + print "#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit2.GetParameter(2)*100, fit2.GetParameter(1)*100, fit2.GetParameter(0)*100) + pt2.AddText("#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit2.GetParameter(2)*100, fit2.GetParameter(1)*100, fit2.GetParameter(0)*100) ) + pt2.Draw() + + canvas.Update() + return canvas + +def plotResolution(plot=None, fit=None, cname=None): + + if plot is None: + print "Error: No plots were sent for plotting" + return + if len is None: + print "Warning: no fits were sent for plotting" + if plot is not None and fit is not None and len(plot) != len(fit) : + print "Error: length of plot and fit are not the same!!!" + return + + if cname is None: + cname = "rC_"+plot[0].GetTitle()+"_"+str(len(plot))+"plots" + rC = ROOT.TCanvas(cname,cname) + rC.cd() + +# if fit is not None: +# legend = ROOT.TLegend(0.6,(0.45-len(plot)*0.08), 0.85, 0.45) +# else: + # legend = ROOT.TLegend(0.6,(0.45-len(plot)*0.04), 0.85, 0.45) + + if fit is not None: + legend = ROOT.TLegend(0.125,(0.85-len(plot)*0.08), 0.525, 0.875) + else: + legend = ROOT.TLegend(0.125,(0.85-len(plot)*0.04), 0.525, 0.875) + + #legend.SetFillColor(0) + legend.SetFillStyle(0) + legend.SetBorderSize(0) + + maxy = 0 + miny = 1000 + + for i in np.arange(0,len(plot)): + print "\n",plot[i].GetTitle() + print "--------------------" + # first draw the plots + if plot[i] is not None: + plot[i].SetMarkerStyle(int(21+i)) + plot[i].SetMarkerSize(0.5) + #plot[i].SetMaximum(0.05) + + max = ROOT.TMath.MaxElement(plot[i].GetN(),plot[i].GetY()); + if max > maxy: + maxy = max + min = ROOT.TMath.MinElement(plot[i].GetN(),plot[i].GetY()); + if min < miny: + miny = min + + if i == 0: + plot[i].Draw("ap") + else: + plot[i].Draw("p") + legend.AddEntry(plot[i], plot[i].GetName(), "p") + # then draw the fit to the plot + if fit is not None and fit[i] is not None: + fit[i].SetLineStyle(int(2+i)) + fit[i].Draw("same") + fit_res = "" + if fit[i].GetNpar() == 2: + fit_res="#frac{#sigma(E)}{E} = #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit[i].GetParameter(1)*100, fit[i].GetParameter(0)*100) + elif fit[i].GetNpar() == 3: + fit_res="#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit[i].GetParameter(2)*100, fit[i].GetParameter(1)*100, fit[i].GetParameter(0)*100) + print fit_res + legend.AddEntry(fit[i], fit_res, "l") + + plot[0].SetMaximum(maxy*1.1) + plot[0].SetMinimum(miny*0.85) + legend.Draw() + rC.Update() + rC.Print(rC.GetTitle()+".png") + +def plotLinearity(plot=None, fit=None, cname=None): + + if plot is None: + print "Error: No plots were sent for plotting" + return + if len is None: + print "Warning: no fits were sent for plotting" + if plot is not None and fit is not None and len(plot) != len(fit) : + print "Error: length of plot and fit are not the same!!!" + return + + if cname is None: + cname = "lC_"+plot[0].GetTitle()+"_"+str(len(plot))+"plots" + lC = ROOT.TCanvas(cname,cname) + lC.cd() + + if fit is not None: + legend = ROOT.TLegend(0.125,(0.85-len(plot)*0.08), 0.525, 0.875) + else: + legend = ROOT.TLegend(0.125,(0.85-len(plot)*0.04), 0.525, 0.875) + + legend.SetFillStyle(0) + legend.SetBorderSize(0) + + miny = 1000 + maxy = 0 + + for i in np.arange(0,len(plot)): + print "\n",plot[i].GetTitle() + print "--------------------" + # first draw the plots + if plot[i] is not None: + plot[i].SetMarkerStyle(int(21+i)) + plot[i].SetMarkerSize(0.5) + #plot[i].GetXaxis().SetRangeUser(0,100) + + max = ROOT.TMath.MaxElement(plot[i].GetN(),plot[i].GetY()); + if max > maxy: + maxy = max + min = ROOT.TMath.MinElement(plot[i].GetN(),plot[i].GetY()); + if min < miny: + miny = min + + if i == 0: + plot[i].Draw("ap") + else: + plot[i].Draw("p") + legend.AddEntry(plot[i], plot[i].GetTitle(), "p") + # then draw the fit to the plot + if fit is not None and fit[i] is not None: + fit[i].SetLineStyle(int(2+i)) + if i==0: + fit[i].Draw("same") + fit_res = "" + if fit[i].GetNpar() == 2: + fit_res="N = %03.1fE + %03.1f" % (fit[i].GetParameter(1), fit[i].GetParameter(0)) + elif fit[i].GetNpar() == 3: + fit_res="#frac{#sigma(E)}{E} = %03.1f + #frac{%03.1f}{#sqrt{E}} + %03.1f" % (fit[i].GetParameter(2)*100, fit[i].GetParameter(1)*100, fit[i].GetParameter(0)*100) + print fit_res + #legend.AddEntry(fit[i], fit_res, "l") + + legend.Draw() + + plot[0].SetMinimum(miny*0.85) + plot[0].SetMaximum(maxy*1.15) + lC.Update() + lC.Print(lC.GetTitle()+".png") + +def analyseSingleDataSet(detector="", b=1, name=None): + + res_i = makeResolutionPlot(det=detector, bfield=b, config="Particle") + #res_i.SetNameTitle("Particle","Particle") + res_i.SetTitle(detector+" BField="+str(b)) + res_i.SetName("Particle") + res_p = makeResolutionPlot(det=detector, bfield=b, config="Pixel") + res_p.SetNameTitle("Pixel","Pixel") + res_s = makeResolutionPlot(det=detector, bfield=b, config="Strixel") + res_s.SetNameTitle("Strixel","Strixel") + res_s3 = makeResolutionPlot(det=detector, bfield=b, config="Strixel_3") + res_s3.SetNameTitle("Strixel_3","Strixel_3") + res_s7 = makeResolutionPlot(det=detector, bfield=b, config="Strixel_7") + res_s7.SetNameTitle("Strixel_7","Strixel_7") + res_s15 = makeResolutionPlot(det=detector, bfield=b, config="Strixel_15") + res_s15.SetNameTitle("Strixel_15","Strixel_15") + res_s31 = makeResolutionPlot(det=detector, bfield=b, config="Strixel_31") + res_s31.SetNameTitle("Strixel_31","Strixel_31") + res_canvas = plotResolution([res_i,res_p, res_s, res_s3, res_s7, res_s15, res_s31],cname="res_"+name) + + + lin_i = makeLinearityPlot(det=detector, bfield=b, config="Particle") + lin_p = makeLinearityPlot(det=detector, bfield=b, config="Pixel") + lin_s = makeLinearityPlot(det=detector, bfield=b, config="Strixel") + lin_s3 = makeLinearityPlot(det=detector, bfield=b, config="Strixel_3") + lin_s7 = makeLinearityPlot(det=detector, bfield=b, config="Strixel_7") + lin_s15 = makeLinearityPlot(det=detector, bfield=b, config="Strixel_15") + lin_s31 = makeLinearityPlot(det=detector, bfield=b, config="Strixel_31") + lin_canvas = plotLinearity([lin_i,lin_p, lin_s, lin_s3, lin_s7, lin_s15, lin_s31],cname="lin_"+name) + +detector="30Layers_3.5mmW_50umPixels" +bfield_on = 1 + +analyseSingleDataSet(detector, bfield_on, "test_plot") + +""" +# +# look at the particle configurations... should be the same +# +# + +res_25_p_b0 = makeResolutionPlot(det="50Layers_2.1mmW_25umPixels", bfield=0, config="Particle") +res_25_p_b1 = makeResolutionPlot(det="50Layers_2.1mmW_25umPixels", bfield=1, config="Particle") +res_50_p_b0 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=0, config="Particle") +res_50_p_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Particle") + +res_25_p_b0_fit = fitResolutionPlot(res_25_p_b0, "pol1",0.12,0.35) +res_25_p_b1_fit = fitResolutionPlot(res_25_p_b1, "pol1",0.12,0.35) +res_50_p_b0_fit = fitResolutionPlot(res_50_p_b0, "pol1",0.12,0.35) +res_50_p_b1_fit = fitResolutionPlot(res_50_p_b1, "pol1",0.12,0.35) +plotResolution([res_25_p_b1,res_50_p_b0, res_50_p_b1],[res_25_p_b1_fit,res_50_p_b0_fit,res_50_p_b1_fit]) + +lin_25_p_b0 = makeLinearityPlot(det="50Layers_2.1mmW_25umPixels", bfield=0, config="Particle") +lin_25_p_b1 = makeLinearityPlot(det="50Layers_2.1mmW_25umPixels", bfield=1, config="Particle") +lin_50_p_b0 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=0, config="Particle") +lin_50_p_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Particle") + +lin_25_p_b0_fit = fitLinearityPlot(lin_25_p_b0, "pol1", 0,100) +lin_25_p_b1_fit = fitLinearityPlot(lin_25_p_b1, "pol1", 0,100) +lin_50_p_b0_fit = fitLinearityPlot(lin_50_p_b0, "pol1", 0,100) +lin_50_p_b1_fit = fitLinearityPlot(lin_50_p_b1, "pol1", 0,100) + +plotLinearity([lin_25_p_b0, lin_25_p_b1, lin_50_p_b0, lin_50_p_b1], [lin_25_p_b0_fit,lin_25_p_b1_fit, lin_50_p_b0_fit, lin_50_p_b1_fit]) + +# +# compare bfield=1 for different pixel size +# + +res_25_p_b1 = makeResolutionPlot(det="50Layers_2.1mmW_25umPixels", bfield=1, config="Pixel") +res_50_p_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") + +res_25_p_b1_fit = fitResolutionPlot(res_25_p_b1, "pol1",0.12,0.35) +res_50_p_b1_fit = fitResolutionPlot(res_50_p_b1, "pol1",0.12,0.35) +plotResolution([res_25_p_b1, res_50_p_b1],[res_25_p_b1_fit,res_50_p_b1_fit]) + +lin_25_p_b0 = makeLinearityPlot(det="50Layers_2.1mmW_25umPixels", bfield=0, config="Pixel") +lin_25_p_b1 = makeLinearityPlot(det="50Layers_2.1mmW_25umPixels", bfield=1, config="Pixel") +lin_50_p_b0 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=0, config="Pixel") +lin_50_p_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") + +lin_25_p_b0_fit = fitLinearityPlot(lin_25_p_b0, "pol1", 0,100) +lin_25_p_b1_fit = fitLinearityPlot(lin_25_p_b1, "pol1", 0,100) +lin_50_p_b0_fit = fitLinearityPlot(lin_50_p_b0, "pol1", 0,100) +lin_50_p_b1_fit = fitLinearityPlot(lin_50_p_b1, "pol1", 0,100) + +plotLinearity([lin_25_p_b0, lin_25_p_b1, lin_50_p_b0, lin_50_p_b1], [lin_25_p_b0_fit,lin_25_p_b1_fit, lin_50_p_b0_fit, lin_50_p_b1_fit]) +""" + +""" +res_50_pa_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Particle") +res_50_p_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") +res_50_s3_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_3") +res_50_s7_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_7") +res_50_s15_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_15") +res_50_s31_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_31") + +res_50_pa_b1_fit = fitResolutionPlot(res_50_pa_b1, "pol1",0.12,0.35) +res_50_p_b1_fit = fitResolutionPlot(res_50_p_b1, "pol1",0.12,0.35) +res_50_s3_b1_fit = fitResolutionPlot(res_50_s3_b1, "pol1",0.17,0.35) +res_50_s7_b1_fit = fitResolutionPlot(res_50_s7_b1, "pol1",0.12,0.35) + +plotResolution([res_50_pa_b1,res_50_p_b1,res_50_s3_b1,res_50_s7_b1, res_50_s15_b1],cname="spec_meeting_resolution")#,[res_50_pa_b1_fit,res_50_p_b1_fit,res_50_s3_b1_fit,res_50_s7_b1_fit]) +plotResolution([res_50_pa_b1,res_50_s15_b1, res_50_s31_b1],cname="spec_meeting_resolution_highE") + +lin_50_pa_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Particle") +lin_50_p_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") +lin_50_s_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel") +lin_50_s3_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_3") +lin_50_s7_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_7") + +lin_50_pa_b1_fit = fitLinearityPlot(lin_50_pa_b1, "pol2",0,100) +lin_50_p_b1_fit = fitLinearityPlot(lin_50_p_b1, "pol2",0,100) +lin_50_s_b1_fit = fitLinearityPlot(lin_50_s_b1, "pol2",0,100) +lin_50_s3_b1_fit = fitLinearityPlot(lin_50_s3_b1, "pol2",0,100) +lin_50_s7_b1_fit = fitLinearityPlot(lin_50_s7_b1, "pol2",0,100) + +plotLinearity([lin_50_pa_b1,lin_50_p_b1,lin_50_s_b1, lin_50_s3_b1,lin_50_s7_b1] ,[lin_50_pa_b1_fit,lin_50_p_b1_fit,lin_50_s_b1_fit,lin_50_s3_b1_fit,lin_50_s7_b1_fit], cname="spec_meeting_linearity") +""" +""" +# +# compare the pixel size +# + +res_50_s7_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_7") +res_60_s7_b1 = makeResolutionPlot(det="50Layers_2.1mmW_60umPixels", bfield=1, config="Strixel_7") +res_50_p_b1 = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_15") +res_60_p_b1 = makeResolutionPlot(det="50Layers_2.1mmW_60umPixels", bfield=1, config="Strixel_15") +res_50_p_b1_fit = fitResolutionPlot(res_50_p_b1, "pol1",0.12,0.35) +res_60_p_b1_fit = fitResolutionPlot(res_60_p_b1, "pol1",0.12,0.35) +#plotResolution([res_50_pa_b1, res_50_s7_b1,res_60_s7_b1,res_50_p_b1,res_60_p_b1],cname="test")#,[res_50_p_b1_fit,res_60_p_b1_fit],cname="test") +plotResolution([res_60_p_b1,res_50_s7_b1],cname="test2") + +lin_50_s7_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_7") +lin_60_s7_b1 = makeLinearityPlot(det="50Layers_2.1mmW_60umPixels", bfield=1, config="Strixel_7") +lin_50_p_b1 = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Strixel_15") +lin_60_p_b1 = makeLinearityPlot(det="50Layers_2.1mmW_60umPixels", bfield=1, config="Strixel_15") +lin_50_p_b1_fit = fitLinearityPlot(res_50_p_b1, "pol1",0,100) +lin_60_p_b1_fit = fitLinearityPlot(res_60_p_b1, "pol1",0,100) +plotLinearity([lin_50_s7_b1,lin_60_s7_b1,lin_50_p_b1,lin_60_p_b1], cname="test_lin")#,[lin_50_p_b1_fit,lin_60_p_b1_fit],cname="test_lin") +""" + + + +res_50L = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") +res_50L_fit = fitResolutionPlot(res_50L, "pol1", 0.1, 0.35) + +lin_50L = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") +lin_50L_truth = makeLinearityPlot(det="50Layers_2.1mmW", bfield=1, config="Particle") +plotLinearity([lin_50L_truth, lin_50L]) +""" +res_35L = makeResolutionPlot(det="30Layers_3.5mmW_50umPixels", bfield=1, config="Pixel") +res_35L_fit = fitResolutionPlot(res_35L, "pol1", 0.1, 0.35) +plotResolution([res_50L,res_35L],[res_50L_fit,res_35L_fit], cname="CompareLayers") + +# +# compare the epi thickness +# +res_25um = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") +res_25um_fit = fitResolutionPlot(res_25um, "pol1", 0.1, 0.35) +res_15um = makeResolutionPlot(det="50Layers_2.1mmW_50umPixels_15umEpi", bfield=1, config="Pixel") +res_15um_fit = fitResolutionPlot(res_15um, "pol1", 0.1, 0.35) +plotResolution([res_25um,res_15um],[res_25um_fit,res_15um_fit], cname="CompareEpi") + +# +# compare the pizel size +# +res_25umPixels = makeResolutionPlot(det="50Layers_2.1mmW_25umPixels", bfield=1, config="Pixel") +res_25umPixels_fit = fitResolutionPlot(res_25umPixels, "pol1", 0.1,0.35) +res_50umPixels = makeResolutionPlot(det="50Layers_2.1mmW", bfield=1, config="Pixel") +res_50umPixels_fit = fitResolutionPlot(res_50umPixels, "pol1", 0.1,0.35) +res_60umPixels = makeResolutionPlot(det="50Layers_2.1mmW_60umPixels", bfield=1, config="Pixel") +res_60umPixels_fit = fitResolutionPlot(res_60umPixels, "pol1", 0.1,0.35) +res_100umPixels = makeResolutionPlot(det="50Layers_2.1mmW_100umPixels", bfield=1, config="Pixel") +res_100umPixels_fit = fitResolutionPlot(res_100umPixels, "pol1", 0.1,0.35) +plotResolution(cname="PixelPitch", plot=[res_25umPixels,res_50umPixels,res_60umPixels,res_100umPixels], fit=[res_25umPixels_fit,res_50umPixels_fit,res_60umPixels_fit,res_100umPixels_fit]) +# +# look at effect of mask +# + +res_mask = makeResolutionPlot(det="50Layers_2.1mmW_50umPixels_Mask", bfield=1, config="Pixel") +res_mask_fit = fitResolutionPlot(res_mask, "pol1", 0.1,0.35) +plotResolution([res_50L, res_mask],[res_50L_fit, res_mask_fit], cname="CompareMask") +""" +import time +time.sleep(200) diff --git a/analysePads.py b/analysePads.py new file mode 100644 index 000000000..bb9a103a9 --- /dev/null +++ b/analysePads.py @@ -0,0 +1,27 @@ +import ROOT +import os + +filename="./BarDECal_Readout_padMultiplicity_100GeV.txt"; + +ppe = ROOT.TH1F("PadsPerEvent","", 10000,0,10000); +hpp = ROOT.TH1F("HitsPerPad","", 100,0,100); + +lines = [line.rstrip('\n') for line in open(filename)] +for line in lines[506:]: + hitsPerPad = line.split(' ') + padsPerEvent = len(hitsPerPad) - 1 + print padsPerEvent, 'pads with hits in this event' + ppe.Fill(padsPerEvent) + [ hpp.Fill(float(n)) for n in hitsPerPad[:-1] ] + +import time + +canvas = ROOT.TCanvas("canvas") +canvas.Divide(2,1) +canvas.cd(1) +ppe.Draw() +canvas.cd(2) +hpp.Draw() +canvas.Update() + +time.sleep(30) diff --git a/geant_batch_temp.py b/geant_batch_temp.py new file mode 100644 index 000000000..7718ae0f1 --- /dev/null +++ b/geant_batch_temp.py @@ -0,0 +1,88 @@ +#JANA: variables ENE (energy in MeV!!!!), BFIELD (0,1), EVTMAX (number of events) to be defined before running +ENE = 000 +BFIELD = +EVTMAX = + +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +podioevent = FCCDataSvc("EventDataSvc") + +# DD4hep geometry service +# Parses the given xml file +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml' + ], + OutputLevel = INFO) + +# Geant4 service +# Configures the Geant simulation: geometry, physics list and user actions +from Configurables import SimG4Svc +# Configures the Geant simulation: geometry, physics list and user actions +geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", actions="SimG4FullSimActions") + + +# Magnetic field +from Configurables import SimG4ConstantMagneticFieldTool +if BFIELD==1: + field = SimG4ConstantMagneticFieldTool("SimG4ConstantMagneticFieldTool",FieldOn=True,IntegratorStepper="ClassicalRK4") +else: + field = SimG4ConstantMagneticFieldTool("SimG4ConstantMagneticFieldTool",FieldOn=False) + +#Setting random seeds for Geant4 simulations +#Two parameters required (don't know why), Anna suggested to fix the second one to 0 and change only the first one +import random +x=random.randrange(1, 384649202, 1) +print "random seed=",x +geantservice.G4commands += ["/random/setSeeds "+str(x)+" 0"] #where x is the number you want + +#range cut +geantservice.G4commands += ["/run/setCut 0.1 mm"] + +# Geant4 algorithm +# Translates EDM to G4Event, passes the event to G4, writes out outputs via tools +from Configurables import SimG4Alg, SimG4SaveCalHits +# and a tool that saves the calorimeter hits with a name "G4SaveCalHits/saveHCalHits" + +saveecaltool = SimG4SaveCalHits("saveECalHits",readoutNames = ["BarDECal_Readout"]) +saveecaltool.DataOutputs.caloClusters.Path = "ECalClusters" +saveecaltool.DataOutputs.caloHits.Path = "ECalHits" + +# next, create the G4 algorithm, giving the list of names of tools ("XX/YY") +from Configurables import SimG4SingleParticleGeneratorTool +pgun=SimG4SingleParticleGeneratorTool("SimG4SingleParticleGeneratorTool",saveEdm=True, + particleName="e-",energyMin=ENE,energyMax=ENE,etaMin=-0.01,etaMax=0.01, + OutputLevel =INFO) +#Following lines do not work, no idea why: +#pgun.DataOutputs.genParticles.Path = "genParticles" +#pgun.DataOutputs.genVertices.Path="genVertices" +geantsim = SimG4Alg("SimG4Alg", + outputs= ["SimG4SaveCalHits/saveECalHits"], + eventProvider=pgun) + +# PODIO algorithm +from Configurables import PodioOutput +out = PodioOutput("out", + OutputLevel=INFO) +out.outputCommands = ["keep *"] +out.filename = "output_GeV_BFIELD.root" + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +geantsim.AuditExecute = True + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [geantsim, out], + EvtSel = 'NONE', + EvtMax = EVTMAX, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podioevent, geoservice, geantservice, audsvc], + OutputLevel=INFO +) + diff --git a/geant_fullsim_ecal_SPG_new.py b/geant_fullsim_ecal_SPG_new.py new file mode 100644 index 000000000..2a51eb55a --- /dev/null +++ b/geant_fullsim_ecal_SPG_new.py @@ -0,0 +1,90 @@ +#JANA: variables ENE (energy in MeV!!!!), BFIELD (0,1), EVTMAX (number of events) to be defined before running +ENE = 100000 +BFIELD = 0 +EVTMAX = 100 + +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +podioevent = FCCDataSvc("EventDataSvc") + +# DD4hep geometry service +# Parses the given xml file +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml' + ], + OutputLevel = DEBUG) + +# Geant4 service +# Configures the Geant simulation: geometry, physics list and user actions +from Configurables import SimG4Svc +# Configures the Geant simulation: geometry, physics list and user actions +geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", actions="SimG4FullSimActions") + + +# Magnetic field +from Configurables import SimG4ConstantMagneticFieldTool +if BFIELD==1: + field = SimG4ConstantMagneticFieldTool("SimG4ConstantMagneticFieldTool",FieldOn=True,IntegratorStepper="ClassicalRK4") +else: + field = SimG4ConstantMagneticFieldTool("SimG4ConstantMagneticFieldTool",FieldOn=False) + +#Setting random seeds for Geant4 simulations +#Two parameters required (don't know why), Anna suggested to fix the second one to 0 and change only the first one +#x=12768674 +import random +x=random.randrange(1, 384649202, 1) + +print x +geantservice.G4commands += ["/random/setSeeds "+str(x)+" 0"] #where x is the number you want + +#range cut +geantservice.G4commands += ["/run/setCut 0.1 mm"] + +# Geant4 algorithm +# Translates EDM to G4Event, passes the event to G4, writes out outputs via tools +from Configurables import SimG4Alg, SimG4SaveCalHits +# and a tool that saves the calorimeter hits with a name "G4SaveCalHits/saveHCalHits" + +saveecaltool = SimG4SaveCalHits("saveECalHits",readoutNames = ["BarDECal_Readout"]) +saveecaltool.DataOutputs.caloClusters.Path = "ECalClusters" +saveecaltool.DataOutputs.caloHits.Path = "ECalHits" + +# next, create the G4 algorithm, giving the list of names of tools ("XX/YY") +from Configurables import SimG4SingleParticleGeneratorTool +pgun=SimG4SingleParticleGeneratorTool("SimG4SingleParticleGeneratorTool",saveEdm=True, + particleName="e-",energyMin=ENE,energyMax=ENE,etaMin=-0.01,etaMax=0.01, + OutputLevel =DEBUG) +#Following lines do not work, no idea why: +#pgun.DataOutputs.genParticles.Path = "genParticles" +#pgun.DataOutputs.genVertices.Path="genVertices" +geantsim = SimG4Alg("SimG4Alg", + outputs= ["SimG4SaveCalHits/saveECalHits"], + eventProvider=pgun) + +# PODIO algorithm +from Configurables import PodioOutput +out = PodioOutput("out", + OutputLevel=DEBUG) +out.outputCommands = ["keep *"] +out.filename = "output_50GeV.root" + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +geantsim.AuditExecute = True + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [geantsim, out], + EvtSel = 'NONE', + EvtMax = EVTMAX, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podioevent, geoservice, geantservice, audsvc], + OutputLevel=DEBUG +) + diff --git a/makeMIPSPerPixelPlot.py b/makeMIPSPerPixelPlot.py new file mode 100644 index 000000000..4e72c01bd --- /dev/null +++ b/makeMIPSPerPixelPlot.py @@ -0,0 +1,42 @@ +import ROOT +import os +import numpy as np +import time + +config="30Layers_3.5mmW" +dir="./batch/"+config+"/" +file="BarDECal_Readout_mipsPerPixel.txt" +energies = os.listdir(dir) + +energy = np.zeros(len(energies)) +mean = np.zeros(len(energies)) +single = np.zeros(len(energies)) + +for i in np.arange(len(energies)): + ene = energies[i] + + path=dir+"/"+ene+"/"+file + print path + + if not os.path.exists(path): + continue + + #h = ROOT.TH1F("counts", + N = [float(n) for n in open(path,'r').read().split(' ')[:-1] if "L" not in n] + print len(N) + + histo = ROOT.TH1F(ene+"GeV mipsPerPixel","mips per pixel", 20, -0.5, 19.5) + for n in N: + histo.Fill(n) + + if "100GeV" in ene: + histo.Draw() + time.sleep(10) + + e = float(path[len(dir)+1:path.find("GeV")]) + if histo.GetEntries() > 0: + m = histo.GetMean() + s = histo.GetBinContent(2) / histo.GetEntries() + print s + + diff --git a/makeMultiplicityResolutionPlot.py b/makeMultiplicityResolutionPlot.py new file mode 100644 index 000000000..cf7529dbd --- /dev/null +++ b/makeMultiplicityResolutionPlot.py @@ -0,0 +1,86 @@ +import ROOT +import os +import numpy as np + +config="30Layers_3.5mmW" +dir="./batch/"+config+"/" +file="BarDECal_Readout_pixelsOverThreshold.txt" +energies = os.listdir(dir) + +energy = np.zeros(len(energies)) +mean = np.zeros(len(energies)) +sigma = np.zeros(len(energies)) +resolution = np.zeros(len(energies)) + +for i in np.arange(len(energies)): + ene = energies[i] + + path=dir+"/"+ene+"/"+file + print path + + if not os.path.exists(path): + continue + + #h = ROOT.TH1F("counts", + N = [float(n) for n in open(path,'r').read().split(' ')[:-1]] + + print len(N) + + e = float(path[len(dir)+1:path.find("GeV")]) + m = np.mean(N) + s = np.std(N) + r = s/m + + energy[i] = e + mean[i] = m + sigma[i] = s + resolution[i] = r + print e, m, s, r + +linearity_canvas = ROOT.TCanvas("linearity_canvas") +linearity_canvas.cd() +linearity = ROOT.TGraph(len(energy),energy,mean) +linearity.SetTitle("nPixelsOver Threshold / Event as function of single e- energy") +linearity.GetXaxis().SetTitle("Energy [GeV]") +linearity.GetYaxis().SetTitle("nPixelsOverThreshold / Event") +linearity_fit = ROOT.TF1("linearity_fit", "pol1", 0,400) +linearity_fit.FixParameter(0,0) +linearity.Fit(linearity_fit, "NR") +linearity.Draw("A*") +linearity_fit.SetRange(0,1000) +linearity_fit.Draw("same") +label = ROOT.TPaveText(0.3,0.7,0.5,0.8, "NDC") +label.SetFillColor(0) +label.SetBorderSize(0) +label.AddText(config) +label.Draw() +linearity_canvas.Print(config+"_linearity.png") + +energy_resolution_canvas = ROOT.TCanvas("energy_resolution_canvas") +energy_resolution_canvas.cd() +indices = np.logical_and(energy>0, energy<501) +energy_resolution = ROOT.TGraph(len(energy[indices]), 1/np.sqrt(energy[indices]), resolution[indices]) +energy_resolution.SetTitle("Energy resolution") +energy_resolution.GetXaxis().SetTitle("1/#sqrt{Energy [GeV]}") +energy_resolution.GetYaxis().SetTitle("#sigma_{N}/N") +energy_resolution.Draw("A*") +energy_resolution_fit = ROOT.TF1("energy_resolution_fit", "pol1", 0.04,1.0) +energy_resolution.Fit(energy_resolution_fit, "NR") +energy_resolution_fit.Draw("same") +energy_resolution_info = ROOT.TPaveText(0.2,0.6,0.5,0.8,"NDC") +energy_resolution_info.SetBorderSize(0) +#energy_resolution_info.SetTextFont(energy_resolution.GetTitleFontSize()) +#energy_resolution_info.SetTextSize(energy_resolution.GetTextSize()) +energy_resolution_info.SetFillColor(0) +energy_resolution_info.AddText(config) +energy_resolution_info.AddText("25um epi") +energy_resolution_info.AddText("threshold = 350e-") +energy_resolution_info.AddText(str(round(energy_resolution_fit.GetParameter(1)*100,1))+"%/#sqrt{E}") +energy_resolution_info.Draw() +energy_resolution_canvas.Print(config+"_resolution.png") + + +import time +time.sleep(600) + + diff --git a/make_resolution_digital.py b/make_resolution_digital.py new file mode 100644 index 000000000..47af53d26 --- /dev/null +++ b/make_resolution_digital.py @@ -0,0 +1,12 @@ +from ROOT import gSystem +from ROOT import TCanvas, TFile, TGraph,TF1, gPad, CaloAnalysis_digital, TH3F +import os + +PARTICLE = "30Layers_3.5mmW_5mmAir_50umPixels" +ENERGY = [10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000] +RESOLUTION = {} +LINEARITY = {} + +fin = TFile(PARTICLE+".root") + + diff --git a/submit_energy_res_to_lxbatch.py b/submit_energy_res_to_lxbatch.py new file mode 100644 index 000000000..1345af9f8 --- /dev/null +++ b/submit_energy_res_to_lxbatch.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +import os, re +import commands +import math, time +import sys + +print +print 'START' +print +######## YOU ONLY NEED TO FILL THE AREA BELOW ######### +######## customization area ######### +#ENERGIES = ["1","10","20","30","40","50","60","70","80","90","100","200"]#,"300","400","500"]#,"600","700","800","900","1000" ] # number of jobs to be submitted +ENERGIES = ["300","400","500","600","700","800","900","1000" ] # number of jobs to be submitted +BFIELD = "1" +EVENTS = "100" +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +queue = "8nh" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw +######## customization end ######### + +path = os.getcwd() +print +#print 'do not worry about folder creation:' +#os.system("rm -r tmp") +os.system("mkdir batch") +#os.system("mkdir res") +print + +##### loop for creating and sending jobs ##### +for e in ENERGIES: + ##### creates directory and file list for job ####### + dir="batch/30Layers_5.6mmPb_50umPixels_18umThick/"+str(e)+"GeV_BFIELD"+str(BFIELD) + os.system("mkdir -p "+dir) + os.chdir(dir) + + ##### creates steering file ####### + #os.system("cp ../../geant_batch_temp.py run.py") + #os.system("sed -i 's//"+str(e)+"/' run.py") + #os.system("sed -i 's//"+str(BFIELD)+"/' run.py") + #os.system("sed -i 's//"+str(EVENTS)+"/' run.py") + + ##### creates jobs ####### + with open('job.sh', 'w') as fout: + fout.write("#!/bin/sh\n") + fout.write("echo\n") + fout.write("echo 'START---------------'\n") + fout.write("echo 'WORKDIR ' ${PWD}\n") + + fout.write("##### creates steering file #######\n") + fout.write("cp "+FCCSW_DIR+"/geant_batch_temp.py run.py\n") + fout.write("sed -i 's//"+str(e)+"/' run.py\n") + fout.write("sed -i 's//"+str(BFIELD)+"/' run.py\n") + fout.write("sed -i 's//"+str(EVENTS)+"/' run.py\n\n") + + fout.write("source "+FCCSW_DIR+"init.sh\n") + fout.write(FCCSW_DIR+"run gaudirun.py run.py\n") + fout.write("echo 'STOP---------------'\n") + fout.write("echo\n") + fout.write("cp *.txt "+path+"/"+dir+"\n") + fout.write("cp *.root "+path+"/"+dir+"\n") + fout.write("echo\n") + os.system("chmod 755 job.sh") + + ###### sends bjobs ###### + os.system("bsub -q "+queue+" -o logs job.sh") + print "job nr " + str(e) + " submitted" + + os.chdir(path) + +print +print "your jobs:" +os.system("bjobs") +print +print 'END' +print From 2fd40d7f1057d64376607ae0ee15b6ba7540a3cf Mon Sep 17 00:00:00 2001 From: Tony Price Date: Fri, 25 Nov 2016 01:10:29 +0100 Subject: [PATCH 02/28] first commit of the DECAL before updating master FCCSW --- .../compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml | 10 ++++++++++ .../compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml | 10 ++++++++++ .../compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml | 10 ++++++++++ .../FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml | 10 ++++++++++ .../FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml | 10 ++++++++++ .../FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml | 10 ++++++++++ 6 files changed, 60 insertions(+) create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml new file mode 100644 index 000000000..9da5b9c78 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml new file mode 100644 index 000000000..f8b8c5d3d --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml new file mode 100644 index 000000000..8fc43b910 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml new file mode 100644 index 000000000..4b279eeb5 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml new file mode 100644 index 000000000..a0737aa1a --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml new file mode 100644 index 000000000..b4d03d3e3 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml @@ -0,0 +1,10 @@ + + + + + + + + + + From ba49172182e9833bfe092ae14813ca49797a0d07 Mon Sep 17 00:00:00 2001 From: Tony Price Date: Wed, 5 Apr 2017 18:42:09 +0200 Subject: [PATCH 03/28] DECAL Geometry first commit --- .../compact/FCChh_DECalBarrel_Mockup.xml | 25 +++++++-- .../FCChh_DECalDefinition_50Layers_2.1mmW.xml | 1 + ...finition_50Layers_2.1mmW_1mmAir_SiAirW.xml | 10 ++++ .../src/ECalBarrel_geo.cpp | 52 +++++++++++++++++-- 4 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml index f2324055e..476d311ed 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml @@ -14,10 +14,11 @@ - + - + + @@ -31,15 +32,29 @@ - - system:3,active:1,EM_barrel:1,layer:6,x:11:-17,y:-17,z:-19 + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + - + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml index 8fc43b910..8f94d43b9 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml @@ -6,5 +6,6 @@ + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml new file mode 100644 index 000000000..a35162fb8 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp index 2516f804f..d08a6d81e 100644 --- a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -6,6 +6,8 @@ #include "GaudiKernel/IMessageSvc.h" #include "GaudiKernel/MsgStream.h" +#include "cmath" + using DD4hep::Geometry::Volume; using DD4hep::Geometry::DetElement; using DD4hep::XML::Dimension; @@ -42,6 +44,10 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm std::string calo_name=calo.nameStr(); double calo_id=calo.id(); + xml_comp_t trkr = calo.child("tracker"); + std::string trkr_mat = trkr.materialStr(); + double trkr_tck = trkr.thickness(); + xml_comp_t active = calo.child("active_layers"); std::string active_mat=active.materialStr(); double active_tck=active.thickness(); @@ -59,9 +65,12 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm std::string padding_mat=padding.materialStr(); double padding_tck=padding.thickness(); - double module_tck = active_tck+substrate_tck+passive_tck+padding_tck; + // here we take the fabs value of padding as if it is negative it goes before the W volume + double module_tck = active_tck+substrate_tck+passive_tck+std::fabs(padding_tck); double calo_tck=active_samples*module_tck; + lLog << MSG::DEBUG << "Tracker Material Thickness = " << trkr_tck << endmsg; + lLog << MSG::DEBUG << "ECAL Epitaxial Thickness = " << active_tck << endmsg; lLog << MSG::DEBUG << "ECAL Substrate Thickness = " << substrate_tck << endmsg; lLog << MSG::DEBUG << "ECAL Passive Thickness = " << passive_tck << endmsg; @@ -85,20 +94,45 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm // set the sensitive detector type to the DD4hep calorimeter sensDet.setType("DigitalCalorimeterSD"); - + // if we add material for the tracker then it needs to be placed first + if(trkr_tck > 0.0) { + DetElement trkrLayer(trkr_mat, 0); + DD4hep::Geometry::Tube trkrShape(calo_dims.rmin(), calo_dims.rmin()+trkr_tck, calo_dims.dz()); + lLog << MSG::DEBUG << "TRKR: Tracker from " << calo_dims.rmin() << " to " << calo_dims.rmin()+trkr_tck << endmsg; + Volume trkrVolume(trkr_mat, trkrShape, lcdd.material(trkr_mat)); + PlacedVolume placedTrkrLayer = caloVolume.placeVolume(trkrVolume); + placedTrkrLayer.addPhysVolID("trkrLayer", 0); + trkrLayer.setPlacement(placedTrkrLayer); + } // Calorimeter runs // 1) epitaxial // 2) substrate - // 3) passive material + // 3) passive material (absorber) // 4) air gap between layers (this is the caleVolume made of air + // STANDARD CONFIGURATION WITH PADDING (air) >= 0 mm + // | MODULE 1 | MODULE 2 | ... | MODULE N | + // | | | | | | | | | ... | | | | | + // | E | S | A | A | E | S | A | A | ... | E | S | A | A | + // | P | U | B | I | P | U | B | I | ... | P | U | B | I | + // | I | B | S | R | I | B | S | R | ... | I | B | S | R | + // | | | | | | | | | ... | | | | | + + // ALTERNATIVE CONFIGURATION WITH PADDING (air) < 0 mm + // | MODULE 1 | MODULE 2 | ... | MODULE N | + // | | | | | | | | | ... | | | | | + // | E | S | A | A | E | S | A | A | ... | E | S | A | A | + // | P | U | I | B | P | U | I | B | ... | P | U | I | B | + // | I | B | R | S | I | B | R | S | ... | I | B | R | S | + // | | | | | | | | | ... | | | | | + // loop on the sensitive and substrate layers and place within the caloVolume for (int i=0;i Date: Wed, 5 Apr 2017 18:45:23 +0200 Subject: [PATCH 04/28] SD classes for DECAL --- Detector/DetSensitive/CMakeLists_TP.txt | 55 +++++++++++ .../DetSensitive/DigitalCalorimeterSD.h | 1 + .../DetSensitive/src/DigitalCalorimeterSD.cpp | 92 +++++++++++++------ Detector/DetSensitive/src/SDWrapper.cpp | 11 +++ Detector/DetSensitive/src/SDWrapper_TP.cpp | 66 +++++++++++++ 5 files changed, 197 insertions(+), 28 deletions(-) create mode 100644 Detector/DetSensitive/CMakeLists_TP.txt create mode 100644 Detector/DetSensitive/src/SDWrapper_TP.cpp diff --git a/Detector/DetSensitive/CMakeLists_TP.txt b/Detector/DetSensitive/CMakeLists_TP.txt new file mode 100644 index 000000000..9762c59e7 --- /dev/null +++ b/Detector/DetSensitive/CMakeLists_TP.txt @@ -0,0 +1,55 @@ +################################################################################ +# Package: DetSensitive +################################################################################ +gaudi_subdir(DetSensitive v1r0) + +gaudi_depends_on_subdirs(GaudiKernel) + +find_package(DD4hep COMPONENTS DDG4 DDSegmentation REQUIRED) +find_package(Geant4) +include(${Geant4_USE_FILE}) +include(DD4hep) + +find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED) + +gaudi_install_headers(DetSensitive) + +gaudi_add_library(DetSensitive + src/*.cpp + INCLUDE_DIRS Geant4 DD4hep ROOT + LINK_LIBRARIES GaudiKernel Geant4 DD4hep ROOT ${DD4hep_COMPONENT_LIBRARIES} + PUBLIC_HEADERS DetSensitive) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_ROOT}/cmake ) + +set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +dd4hep_generate_rootmap(DetSensitive) + +include(CTest) +gaudi_add_test(InternalTrackerSD + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Detector/DetSensitive/tests/ + FRAMEWORK tests/options/testDd4hepTrackerSD.py) +gaudi_add_test(ExternalTrackerSD + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Detector/DetSensitive/tests/ + FRAMEWORK tests/options/testSimpleTrackerSD.py) +gaudi_add_test(CmpTrackerSDNoHits + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Detector/DetSensitive/tests/ + COMMAND python ./scripts/cmpTrackerSdNoHits.py + ENVIRONMENT PYTHONPATH+=$ENV{PODIO}/python + DEPENDS InternalTrackerSD ExternalTrackerSD) +gaudi_add_test(CmpTrackerSDDetailed + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Detector/DetSensitive/tests/ + COMMAND python ./scripts/cmpTrackerSdDetailed.py + ENVIRONMENT PYTHONPATH+=$ENV{PODIO}/python + DEPENDS InternalTrackerSD ExternalTrackerSD) +gaudi_add_test(CmpTrackerSDHitsAndClusters + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Detector/DetSensitive/tests/ + COMMAND python ./scripts/cmpTrackerSdHitsAndClusters.py + ENVIRONMENT PYTHONPATH+=$ENV{PODIO}/python + DEPENDS InternalTrackerSD ExternalTrackerSD) +gaudi_add_test(InternalCalorimeterSD + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Detector/DetSensitive/tests/ + FRAMEWORK tests/options/testDd4hepCaloSD.py) +gaudi_add_test(ExternalCalorimeterSD + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Detector/DetSensitive/tests/ + FRAMEWORK tests/options/testSimpleCaloSD.py) diff --git a/Detector/DetSensitive/DetSensitive/DigitalCalorimeterSD.h b/Detector/DetSensitive/DetSensitive/DigitalCalorimeterSD.h index 8edcefe98..b9760eda9 100644 --- a/Detector/DetSensitive/DetSensitive/DigitalCalorimeterSD.h +++ b/Detector/DetSensitive/DetSensitive/DigitalCalorimeterSD.h @@ -189,6 +189,7 @@ class DigitalCalorimeterSD : public G4VSensitiveDetector int m_incidentParticles; std::map m_CellIDsMaskedFromPreviousEvent; + std::map m_TrackIDsPerEvent; //TFile* m_rootFile; //TH1F* m_padMultiplicity; diff --git a/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp b/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp index c6d38fac4..93c6009c1 100644 --- a/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp +++ b/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp @@ -1,8 +1,9 @@ #include "DetSensitive/DigitalCalorimeterSD.h" // FCCSW -#include "DetSensitive/SegmentationHelper.h" +//#include "DetSensitive/SegmentationHelper.h" #include "DDSegmentation/BitField64.h" +#include "DetCommon/DetUtils.h" // DD4hep #include "DDG4/Geant4Mapping.h" @@ -14,6 +15,7 @@ // Geant4 #include "G4SDManager.hh" #include "G4ThreeVector.hh" +//#include "G4SystemOfUnits.hh" #include "iostream" #include "map" @@ -65,6 +67,8 @@ void DigitalCalorimeterSD::Initialize(G4HCofThisEvent* aHitsCollections) } m_incidentParticles = 0; + m_TrackIDsPerEvent.clear(); + } bool DigitalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) @@ -74,21 +78,34 @@ bool DigitalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) if(edep==0.) return false; + CLHEP::Hep3Vector prePos = aStep->GetPreStepPoint()->GetPosition(); + CLHEP::Hep3Vector postPos = aStep->GetPostStepPoint()->GetPosition(); + if(aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary){ m_incidentParticles++; - } - // as in DD4hep::Simulation::Geant4GenericSD - CLHEP::Hep3Vector prePos = aStep->GetPreStepPoint()->GetPosition(); -/* CLHEP::Hep3Vector postPos = aStep->GetPostStepPoint()->GetPosition(); - double delta_r = sqrt(pow(postPos.x(),2) + pow(postPos.y(),2)) - sqrt(pow(prePos.x(),2) + pow(prePos.y(),2)); - if(delta_r<0) { - return false; + G4int trackID = aStep->GetTrack()->GetTrackID(); + std::map::iterator trackID_it = m_TrackIDsPerEvent.find(trackID); + if(m_TrackIDsPerEvent.find(trackID) != m_TrackIDsPerEvent.end()) { + (*trackID_it).second++; + } else { + m_TrackIDsPerEvent[trackID] = 1; + } + + + // as in DD4hep::Simulation::Geant4GenericSD + double delta_r = sqrt(pow(postPos.x(),2) + pow(postPos.y(),2)) - sqrt(pow(prePos.x(),2) + pow(prePos.y(),2)); + if(delta_r<0) { + std::map::iterator trackID_it = m_TrackIDsPerEvent.find(trackID); + (*trackID_it).second = -1e6; + //std::cout << "BACKWARDS STEP" << std::endl; + } } -*/ + DD4hep::Simulation::Position pos(prePos.x(), prePos.y(), prePos.z()); auto hit = new DD4hep::Simulation::Geant4CalorimeterHit(pos); - hit->cellID = segmentation::cellID(m_seg, *aStep); + //hit->cellID = segmentation::cellID(m_seg, *aStep); + hit->cellID = utils::cellID(m_seg, *aStep); hit->energyDeposit = edep; m_tempCollection->insert(hit); return true; @@ -136,17 +153,29 @@ void DigitalCalorimeterSD::UpdateCellIDMask() { std::cout << "There are currently " << m_CellIDsMaskedFromPreviousEvent.size() << " pixels masked out" << std::endl; } + + void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { int nHits = m_tempCollection->entries(); // std::cout << "Total Number of hits = " << nHits << std::endl; + std::cout << "Total number of TrackIDs in SD = " << m_TrackIDsPerEvent.size() << std::endl; + std::map::iterator trackID_it; + int fwd_tracks = 0; + for(trackID_it=m_TrackIDsPerEvent.begin(); trackID_it!=m_TrackIDsPerEvent.end(); trackID_it++){ + if((*trackID_it).second>0) { + fwd_tracks++; + } + } + std::cout << "Total number of only forward track IDs in SD = " << fwd_tracks << std::endl; // the key here will be the cellID (unique to each layer and cell depending on segmentation) // second is a pair of number particles and total energy std::map > counter; DD4hep::Simulation::Geant4CalorimeterHit* hit = nullptr; + std::cout << "####" << m_seg->type() << std::endl; auto decoderBarrel = m_seg->decoder(); //std::cout << "Barrel segmentation of type " << m_seg->type() << std::endl; for(int i=0; icellID; - if(IsAllowedCellID(cellID)){ + //if(IsAllowedCellID(cellID)){ + if(cellID==cellID){ // this map stored the energy per cell std::map >::iterator it = counter.find(cellID); @@ -198,29 +228,34 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { // insert the collection to G4 so can be passed on later digi = dynamic_cast ((*it).second.second); - digi->energyDeposit = (*it).second.second->energyDeposit; //(*it).second.first; // overwrite the energy deposit with the number of mips in the cell + //digi->energyDeposit = (*it).second.second->energyDeposit; //(*it).second.first; // overwrite the energy deposit with the number of mips in the cell m_calorimeterCollection->insert(digi); // this passes to ROOT the readout... interesting! + uint64_t cellID = (*it).first; decoderBarrel->setValue(cellID); int layer_id = (*decoderBarrel)["layer"]; - int px = (*decoderBarrel)["x"]; - int py = (*decoderBarrel)["y"]; - int pz = (*decoderBarrel)["z"]; - - // convert pixel to strixel - Strixel strixel; - strixel.layer = layer_id; - strixel.x = px; - strixel.y = py; - strixel.z = floor(pz/100); //group in z the pixels into a strixel - - std::map::iterator strixel_it = StrixelHitCounter.find(strixel); - if(StrixelHitCounter.find(strixel) != StrixelHitCounter.end()) { - (*strixel_it).second++; - } else { - StrixelHitCounter[strixel] = 1; + + if(m_seg->type() == "CartesianGridXYZ") { + + int px = (*decoderBarrel)["x"]; + int py = (*decoderBarrel)["y"]; + int pz = (*decoderBarrel)["z"]; + + // convert pixel to strixel + Strixel strixel; + strixel.layer = layer_id; + strixel.x = px; + strixel.y = py; + strixel.z = floor(pz/100); //group in z the pixels into a strixel + + std::map::iterator strixel_it = StrixelHitCounter.find(strixel); + if(StrixelHitCounter.find(strixel) != StrixelHitCounter.end()) { + (*strixel_it).second++; + } else { + StrixelHitCounter[strixel] = 1; + } } @@ -391,5 +426,6 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { } + } diff --git a/Detector/DetSensitive/src/SDWrapper.cpp b/Detector/DetSensitive/src/SDWrapper.cpp index 1b2ca87cb..b324e5092 100644 --- a/Detector/DetSensitive/src/SDWrapper.cpp +++ b/Detector/DetSensitive/src/SDWrapper.cpp @@ -6,6 +6,7 @@ #include "DetSensitive/SimpleCalorimeterSD.h" #include "DetSensitive/AggregateCalorimeterSD.h" #include "DetSensitive/GflashCalorimeterSD.h" +#include "DetSensitive/DigitalCalorimeterSD.h" namespace DD4hep { namespace Simulation { @@ -47,6 +48,15 @@ static G4VSensitiveDetector* create_aggregate_calorimeter_sd( readoutName, aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); } +// Factory method to create an instance of DigitalCalorimeterSD +static G4VSensitiveDetector* create_digital_calorimeter_sd( + const std::string& aDetectorName, + DD4hep::Geometry::LCDD& aLcdd) { + std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); + return new det::DigitalCalorimeterSD(aDetectorName, + readoutName, + aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); +} // Factory method to create an instance of GflashCalorimeterSD static G4VSensitiveDetector* create_gflash_calorimeter_sd( const std::string& aDetectorName, @@ -63,3 +73,4 @@ DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(MiddleStepTrackerSD,DD4hep::Simulation: DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(SimpleCalorimeterSD,DD4hep::Simulation::create_simple_calorimeter_sd) DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(AggregateCalorimeterSD,DD4hep::Simulation::create_aggregate_calorimeter_sd) DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(GflashCalorimeterSD,DD4hep::Simulation::create_gflash_calorimeter_sd) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(DigitalCalorimeterSD,DD4hep::Simulation::create_digital_calorimeter_sd) diff --git a/Detector/DetSensitive/src/SDWrapper_TP.cpp b/Detector/DetSensitive/src/SDWrapper_TP.cpp new file mode 100644 index 000000000..925ee5460 --- /dev/null +++ b/Detector/DetSensitive/src/SDWrapper_TP.cpp @@ -0,0 +1,66 @@ +#include "DDG4/Factories.h" +#include "DD4hep/LCDD.h" + +#include "DetSensitive/SimpleTrackerSD.h" +#include "DetSensitive/MiddleStepTrackerSD.h" +#include "DetSensitive/SimpleCalorimeterSD.h" +#include "DetSensitive/AggregateCalorimeterSD.h" +#include "DetSensitive/DigitalCalorimeterSD.h" + +namespace DD4hep { +namespace Simulation { + +// All G4VSensitiveDetector are deleted by ~G4SDManager called by ~G4RunManagerKernel +// Factory method to create an instance of SimpleTrackerSD +static G4VSensitiveDetector* create_simple_tracker_sd( + const std::string& aDetectorName, + DD4hep::Geometry::LCDD& aLcdd) { + std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); + return new det::SimpleTrackerSD(aDetectorName, + readoutName, + aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); +} +// Factory method to create an instance of MiddleStepTrackerSD +static G4VSensitiveDetector* create_middle_step_tracker_sd( + const std::string& aDetectorName, + DD4hep::Geometry::LCDD& aLcdd) { + std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); + return new det::MiddleStepTrackerSD(aDetectorName, + readoutName, + aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); +} +// Factory method to create an instance of SimpleCalorimeterSD +static G4VSensitiveDetector* create_simple_calorimeter_sd( + const std::string& aDetectorName, + DD4hep::Geometry::LCDD& aLcdd) { + std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); + return new det::SimpleCalorimeterSD(aDetectorName, + readoutName, + aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); +} +// Factory method to create an instance of AggregateCalorimeterSD +static G4VSensitiveDetector* create_aggregate_calorimeter_sd( + const std::string& aDetectorName, + DD4hep::Geometry::LCDD& aLcdd) { + std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); + return new det::AggregateCalorimeterSD(aDetectorName, + readoutName, + aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); +} + +// Factory method to create an instance of DigitalCalorimeterSD +static G4VSensitiveDetector* create_digital_calorimeter_sd( + const std::string& aDetectorName, + DD4hep::Geometry::LCDD& aLcdd) { + std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); + return new det::DigitalCalorimeterSD(aDetectorName, + readoutName, + aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); +} +} +} +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(SimpleTrackerSD,DD4hep::Simulation::create_simple_tracker_sd) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(MiddleStepTrackerSD,DD4hep::Simulation::create_middle_step_tracker_sd) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(SimpleCalorimeterSD,DD4hep::Simulation::create_simple_calorimeter_sd) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(AggregateCalorimeterSD,DD4hep::Simulation::create_aggregate_calorimeter_sd) +DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(DigitalCalorimeterSD,DD4hep::Simulation::create_digital_calorimeter_sd) From acd1cadf8f083623bf075ace2bf15e5084b57cf4 Mon Sep 17 00:00:00 2001 From: tonypba Date: Wed, 5 Apr 2017 18:51:54 +0200 Subject: [PATCH 05/28] Redo Segmentation of DECAL pixel to Pad --- .../options/redoSegmentationXYZ_DEcal.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py diff --git a/Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py b/Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py new file mode 100644 index 000000000..cf8bfbf57 --- /dev/null +++ b/Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py @@ -0,0 +1,47 @@ +from Gaudi.Configuration import * +from Configurables import ApplicationMgr + +from Configurables import FCCDataSvc +inputfile = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/batch/50Layers_2.1mmW_1mmAir_50umPixels_18umThick_FCCSW0.8pre/1PILEUPEVENTS_BFIELD1/output.root" +podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) + +from Configurables import PodioInput +podioinput = PodioInput("PodioReader", collections=["positionedCaloHits"], OutputLevel=DEBUG) + +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml' + ], + OutputLevel = DEBUG) + +from Configurables import RedoSegmentation +resegment = RedoSegmentation("ReSegmentation", + # old bitfield (readout) + oldReadoutName = "BarDECal_Readout", + # specify which fields are going to be deleted + oldSegmentationIds = ["x","y","z"], + # new bitfield (readout), with new segmentation + newReadoutName="BarDECal_Pads", + OutputLevel = DEBUG) +# clusters are needed, with deposit position and cellID in bits +resegment.DataInputs.inhits.Path = "positionedCaloHits" +resegment.DataOutputs.outhits.Path = "newCaloHits" + +from Configurables import CreateCaloCells +createcells = CreateCaloCells("CreateCaloCells", + doCellCalibration = False, + addCellNoise = False, filterCellNoise = False, + OutputLevel = DEBUG) +createcells.DataInputs.hits.Path="newCaloHits" +createcells.DataOutputs.cells.Path="newCaloCells" + +from Configurables import FCCDataSvc, PodioOutput +#podiosvc = FCCDataSvc("EventDataSvc") +podioout = PodioOutput("out", filename="testResegmentationXYZ.root") +podioout.outputCommands = ["keep *"] + +ApplicationMgr(EvtSel='NONE', + EvtMax=5000, + TopAlg=[podioinput, resegment, createcells, podioout], + ExtSvc = [podiosvc, geoservice], + OutputLevel=DEBUG) From e5210b883cf69b73356ede78b5be8d1eb19ee027 Mon Sep 17 00:00:00 2001 From: tonypba Date: Fri, 7 Apr 2017 09:48:02 +0200 Subject: [PATCH 06/28] added back in geant_fullsim_ecal_SPG_new.py --- geant_fullsim_ecal_SPG_new.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geant_fullsim_ecal_SPG_new.py b/geant_fullsim_ecal_SPG_new.py index 2a51eb55a..6e360d136 100644 --- a/geant_fullsim_ecal_SPG_new.py +++ b/geant_fullsim_ecal_SPG_new.py @@ -49,8 +49,8 @@ # and a tool that saves the calorimeter hits with a name "G4SaveCalHits/saveHCalHits" saveecaltool = SimG4SaveCalHits("saveECalHits",readoutNames = ["BarDECal_Readout"]) -saveecaltool.DataOutputs.caloClusters.Path = "ECalClusters" -saveecaltool.DataOutputs.caloHits.Path = "ECalHits" +saveecaltool.positionedCaloHits.Path = "ECalClusters" +saveecaltool.caloHits.Path = "ECalHits" # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") from Configurables import SimG4SingleParticleGeneratorTool From 2e12c474e8e7fb168feb61715ae881eb5c89115c Mon Sep 17 00:00:00 2001 From: tonypba Date: Fri, 28 Apr 2017 16:04:31 +0200 Subject: [PATCH 07/28] Added basic plotting for the DECAL into Detector/DetectorStudies and added script to run a simulation then reconstruct --- .../src/components/DECalLongitudinalTest.cpp | 127 ++++++++++++++++++ .../src/components/DECalLongitudinalTest.h | 82 +++++++++++ .../tests/options/longitudinalTest_DEcal.py | 83 ++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 Detector/DetStudies/src/components/DECalLongitudinalTest.cpp create mode 100644 Detector/DetStudies/src/components/DECalLongitudinalTest.h create mode 100644 Detector/DetStudies/tests/options/longitudinalTest_DEcal.py diff --git a/Detector/DetStudies/src/components/DECalLongitudinalTest.cpp b/Detector/DetStudies/src/components/DECalLongitudinalTest.cpp new file mode 100644 index 000000000..aea1d11a0 --- /dev/null +++ b/Detector/DetStudies/src/components/DECalLongitudinalTest.cpp @@ -0,0 +1,127 @@ +#include "SamplingFractionInLayers.h" + +// FCCSW +#include "DetInterface/IGeoSvc.h" + +// datamodel +#include "datamodel/PositionedCaloHitCollection.h" + +#include "CLHEP/Vector/ThreeVector.h" +#include "GaudiKernel/ITHistSvc.h" +#include "TH1F.h" +#include "TVector2.h" + +// DD4hep +#include "DD4hep/LCDD.h" +#include "DD4hep/Readout.h" + +DECLARE_ALGORITHM_FACTORY(SamplingFractionInLayers) + +SamplingFractionInLayers::SamplingFractionInLayers(const std::string& aName, ISvcLocator* aSvcLoc) + : GaudiAlgorithm(aName, aSvcLoc), + m_histSvc("THistSvc", "SamplingFractionInLayers"), + m_geoSvc("GeoSvc", "SamplingFractionInLayers"), + m_totalEnergy(nullptr), + m_totalActiveEnergy(nullptr), + m_sf(nullptr) { + declareProperty("deposits", m_deposits, "Energy deposits in sampling calorimeter (input)"); +} +SamplingFractionInLayers::~SamplingFractionInLayers() {} + +StatusCode SamplingFractionInLayers::initialize() { + if (GaudiAlgorithm::initialize().isFailure()) { + return StatusCode::FAILURE; + } + // check if readouts exist + if (m_geoSvc->lcdd()->readouts().find(m_readoutName) == m_geoSvc->lcdd()->readouts().end()) { + error() << "Readout <<" << m_readoutName << ">> does not exist." << endmsg; + return StatusCode::FAILURE; + } + // create histograms + for (uint i = 0; i < m_numLayers; i++) { + m_totalEnLayers.push_back(new TH1F(("ecal_totalEnergy_layer" + std::to_string(i)).c_str(), + ("Total deposited energy in layer " + std::to_string(i)).c_str(), 1000, 0, + 1.2 * m_energy)); + if (m_histSvc->regHist("/rec/ecal_total_layer" + std::to_string(i), m_totalEnLayers.back()).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + m_activeEnLayers.push_back(new TH1F(("ecal_activeEnergy_layer" + std::to_string(i)).c_str(), + ("Deposited energy in active material, in layer " + std::to_string(i)).c_str(), + 1000, 0, 1.2 * m_energy)); + if (m_histSvc->regHist("/rec/ecal_active_layer" + std::to_string(i), m_activeEnLayers.back()).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + m_sfLayers.push_back(new TH1F(("ecal_sf_layer" + std::to_string(i)).c_str(), + ("SF for layer " + std::to_string(i)).c_str(), 1000, 0, 1)); + if (m_histSvc->regHist("/rec/ecal_sf_layer" + std::to_string(i), m_sfLayers.back()).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + } + m_totalEnergy = new TH1F("ecal_totalEnergy", "Total deposited energy", 1000, 0, 1.2 * m_energy); + if (m_histSvc->regHist("/rec/ecal_total", m_totalEnergy).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + m_totalActiveEnergy = new TH1F("ecal_active", "Deposited energy in active material", 1000, 0, 1.2 * m_energy); + if (m_histSvc->regHist("/rec/ecal_active", m_totalActiveEnergy).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + m_sf = new TH1F("ecal_sf", "Sampling fraction", 1000, 0, 1); + if (m_histSvc->regHist("/rec/ecal_sf", m_sf).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; +} + +StatusCode SamplingFractionInLayers::execute() { + auto decoder = m_geoSvc->lcdd()->readout(m_readoutName).idSpec().decoder(); + double sumE = 0.; + std::vector sumElayers; + double sumEactive = 0.; + std::vector sumEactiveLayers; + sumElayers.assign(m_numLayers, 0); + sumEactiveLayers.assign(m_numLayers, 0); + + const auto deposits = m_deposits.get(); + for (const auto& hit : *deposits) { + sumElayers[(*decoder)[m_layerFieldName]] += hit.core().energy; + // check if energy was deposited in the calorimeter (active/passive material) + // layers are numbered starting from 1, layer == 0 is cryostat/bath + if ((*decoder)[m_layerFieldName] > 0) { + sumE += hit.core().energy; + decoder->setValue(hit.core().cellId); + // active material of calorimeter + if ((*decoder)[m_activeFieldName] == m_activeFieldValue) { + sumEactive += hit.core().energy; + sumEactiveLayers[(*decoder)[m_layerFieldName]] += hit.core().energy; + } + } + } + // Fill histograms + m_totalEnergy->Fill(sumE); + m_totalActiveEnergy->Fill(sumEactive); + if (sumE > 0) { + m_sf->Fill(sumEactive / sumE); + } + for (uint i = 0; i < m_numLayers; i++) { + m_totalEnLayers[i]->Fill(sumElayers[i]); + m_activeEnLayers[i]->Fill(sumEactiveLayers[i]); + if (i == 0) { + debug() << "total energy deposited in cryostat and bath = " << sumElayers[i] << endmsg; + } else { + debug() << "total energy in layer " << i << " = " << sumElayers[i] << " active = " << sumEactiveLayers[i] + << endmsg; + } + if (sumElayers[i] > 0) { + m_sfLayers[i]->Fill(sumEactiveLayers[i] / sumElayers[i]); + } + } + return StatusCode::SUCCESS; +} + +StatusCode SamplingFractionInLayers::finalize() { return GaudiAlgorithm::finalize(); } diff --git a/Detector/DetStudies/src/components/DECalLongitudinalTest.h b/Detector/DetStudies/src/components/DECalLongitudinalTest.h new file mode 100644 index 000000000..bc43995ad --- /dev/null +++ b/Detector/DetStudies/src/components/DECalLongitudinalTest.h @@ -0,0 +1,82 @@ +#ifndef DETSTUDIES_SAMPLINGFRACTIONINLAYERS_H +#define DETSTUDIES_SAMPLINGFRACTIONINLAYERS_H + +// GAUDI +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ServiceHandle.h" + +// FCCSW +#include "FWCore/DataHandle.h" +class IGeoSvc; + +// datamodel +namespace fcc { +class PositionedCaloHitCollection; +} + +class TH1F; +class ITHistSvc; +/** @class SamplingFractionInLayers SamplingFractionInLayers.h + * + * Histograms of energy deposited in active material and total energy deposited in the calorimeter. + * Passive material needs to be marked as sensitive. It needs to be divided into layers (cells) as active material. + * Layers (cells) are numbered starting at 1 so that energy depoisted in cryostat and bath could be easily recognised. + * Sampling fraction is calculated for each layer as the ratio of energy deposited in active material to energy + * deposited in the layer (also in passive material). + * + * @author Anna Zaborowska + */ + +class SamplingFractionInLayers : public GaudiAlgorithm { +public: + explicit SamplingFractionInLayers(const std::string&, ISvcLocator*); + virtual ~SamplingFractionInLayers(); + /** Initialize. + * @return status code + */ + virtual StatusCode initialize() final; + /** Fills the histograms. + * @return status code + */ + virtual StatusCode execute() final; + /** Finalize. + * @return status code + */ + virtual StatusCode finalize() final; + +private: + /// Pointer to the interface of histogram service + ServiceHandle m_histSvc; + /// Pointer to the geometry service + ServiceHandle m_geoSvc; + /// Handle for the energy deposits + DataHandle m_deposits{"rec/caloHits", Gaudi::DataHandle::Reader, this}; + /// Name of the active field + Gaudi::Property m_activeFieldName{this, "activeFieldName", "", "Identifier of active material"}; + /// Value of the active material + Gaudi::Property m_activeFieldValue{this, "activeFieldValue", 0, "Value of identifier for active material"}; + /// Name of the layer/cell field + Gaudi::Property m_layerFieldName{this, "layerFieldName", "", "Identifier of layers"}; + /// Number of layers/cells + Gaudi::Property m_numLayers{this, "numLayers", 8, "Number of layers"}; + /// Name of the detector readout + Gaudi::Property m_readoutName{this, "readoutName", "", "Name of the detector readout"}; + // Maximum energy for the axis range + Gaudi::Property m_energy{this, "energyAxis", 500, "Maximum energy for axis range"}; + // Histograms of total deposited energy within layer + // Layers are numbered starting at 1. Layer 0 includes total energy deposited in cryostat and bath (in front and + // behind calo) + std::vector m_totalEnLayers; + // Histogram of total deposited energy in the calorimeter (in active and passive material, excluding cryostat and + // bath) + TH1F* m_totalEnergy; + // Histograms of energy deposited in the active material within layer + std::vector m_activeEnLayers; + // Histogram of energy deposited in the active material of the calorimeter + TH1F* m_totalActiveEnergy; + // Histograms of sampling fraction (active/total energy) calculated within layer + std::vector m_sfLayers; + // Histogram of sampling fraction (active/total energy) calculated for the calorimeter (excluding cryostat and bath) + TH1F* m_sf; +}; +#endif /* DETSTUDIES_SAMPLINGFRACTIONINLAYERS_H */ diff --git a/Detector/DetStudies/tests/options/longitudinalTest_DEcal.py b/Detector/DetStudies/tests/options/longitudinalTest_DEcal.py new file mode 100644 index 000000000..2f49726a0 --- /dev/null +++ b/Detector/DetStudies/tests/options/longitudinalTest_DEcal.py @@ -0,0 +1,83 @@ +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +podioevent = FCCDataSvc("EventDataSvc") + +# DD4hep geometry service +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml' +], + OutputLevel = INFO) + +# Geant4 service +# Configures the Geant simulation: geometry, physics list and user actions +from Configurables import SimG4Svc +geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", actions="SimG4FullSimActions") +geantservice.G4commands += ["/run/setCut 0.1 mm"] + +# Geant4 algorithm +# Translates EDM to G4Event, passes the event to G4, writes out outputs via tools +# and a tool that saves the calorimeter hits +from Configurables import SimG4Alg, SimG4SaveCalHits, SimG4SingleParticleGeneratorTool +saveecaltool = SimG4SaveCalHits("saveECalHits",readoutNames = ["BarDECal_Readout"]) +#saveecaltool.DataOutputs.caloClusters.Path = "ECalClusters" +saveecaltool.positionedCaloHits.Path = "positionedCaloHits" +saveecaltool.caloHits.Path = "ECalHits" + +from Configurables import SimG4SingleParticleGeneratorTool +pgun=SimG4SingleParticleGeneratorTool("SimG4SingleParticleGeneratorTool", + saveEdm=True, + particleName="e-", + energyMin=100000,energyMax=100000, + etaMin=0,etaMax=0, +# phiMin=0, phiMax=0.001, + vertexX=0,vertexY=0,vertexZ=0, + OutputLevel =DEBUG) + +# next, create the G4 algorithm, giving the list of names of tools ("XX/YY") +geantsim = SimG4Alg("SimG4Alg", + outputs= ["SimG4SaveCalHits/saveECalHits"], + eventProvider = pgun, + OutputLevel = DEBUG) + +from Configurables import DECalLongitudinalTest +hist = DECalLongitudinalTest("hists", + readoutName = "BarDECal_Readout", + layerFieldName = "layer", + numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + OutputLevel = DEBUG) +hist.deposits.Path="positionedCaloHits" + +THistSvc().Output = ["rec DATAFILE='hist_test.root' TYP='ROOT' OPT='RECREATE'"] +THistSvc().PrintAll=True +THistSvc().AutoSave=True +THistSvc().AutoFlush=False +THistSvc().OutputLevel=INFO + + +# PODIO algorithm +from Configurables import PodioOutput +out = PodioOutput("out", + OutputLevel=DEBUG) +out.outputCommands = ["keep *"] +out.filename = "output_10GeV_1mmAir_0T_SiAirW.root" + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +geantsim.AuditExecute = True +hist.AuditExecute = True + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [geantsim, out, hist], + EvtSel = 'NONE', + EvtMax = 10, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podioevent, geoservice, geantservice, audsvc], + OutputLevel = DEBUG +) From 77fcad13e19ee798e94c9ec522d09073f22cc126 Mon Sep 17 00:00:00 2001 From: tonypba Date: Mon, 11 Sep 2017 12:33:32 +0200 Subject: [PATCH 08/28] Added DEcal analysis to count pixels and analyse variables per layer. This generates the tree for statisics analysis. Also changed syntax for xml file naming to make easier to submit different geometry from single top level file. Setup file for SiW analogue readout with 300um of Silicon as sensitive layer, 50 layers of 2.1mm W --- ...l_30Layers_3.5mmW_50umPixels_18umThick.xml | 67 ++++ ..._30Layers_5.6mmPb_50umPixels_18umThick.xml | 67 ++++ ..._50Layers_2.1mmW_100umPixels_18umThick.xml | 67 ++++ ...ers_2.1mmW_1mmAir_50umPixels_18umThick.xml | 67 ++++ ..._1mmAir_50umPixels_18umThick_TRKR0.3X0.xml | 67 ++++ ...l_50Layers_2.1mmW_25umPixels_18umThick.xml | 67 ++++ ...hh_DECalBarrel_50Layers_2.1mmW_300umSi.xml | 61 +++ ..._3mmAir_50umPixels_18umThick_TRKR0.3X0.xml | 67 ++++ ...l_50Layers_2.1mmW_50umPixels_18umThick.xml | 67 ++++ ..._2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml | 67 ++++ ..._2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml | 67 ++++ ..._5mmAir_50umPixels_18umThick_TRKR0.3X0.xml | 67 ++++ ...rs_3.4mmPb_3mmAir_25umPixels_18umThick.xml | 61 +++ ...rs_3.4mmPb_3mmAir_50umPixels_18umThick.xml | 67 ++++ ..._50Layers_3.4mmPb_50umPixels_18umThick.xml | 67 ++++ .../compact/FCChh_DECalBarrel_Mockup.xml | 8 +- .../src/components/DECalAnalysis.cpp | 363 ++++++++++++++++++ .../DetStudies/src/components/DECalAnalysis.h | 128 ++++++ .../tests/options/decalAnalysis_DEcal.py | 85 ++++ .../options/decalAnalysis_DEcal_batch.py | 87 +++++ .../options/longitudinalAnalysis_DEcal.py | 50 +++ .../longitudinalAnalysis_DEcal_batch.py | 57 +++ submit_decalAnalysis.py | 93 +++++ submit_longitudinalAnalysis.py | 92 +++++ 24 files changed, 1952 insertions(+), 4 deletions(-) create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml create mode 100644 Detector/DetStudies/src/components/DECalAnalysis.cpp create mode 100644 Detector/DetStudies/src/components/DECalAnalysis.h create mode 100644 Detector/DetStudies/tests/options/decalAnalysis_DEcal.py create mode 100644 Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py create mode 100644 Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py create mode 100644 Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py create mode 100644 submit_decalAnalysis.py create mode 100644 submit_longitudinalAnalysis.py diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml new file mode 100644 index 000000000..77c6f8f2a --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml new file mode 100644 index 000000000..bf67614ca --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml new file mode 100644 index 000000000..3ce4a88fb --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml new file mode 100644 index 000000000..b133552d7 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml new file mode 100644 index 000000000..81371510b --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml new file mode 100644 index 000000000..ca0a8ffd6 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-18,y:-18,z:-17 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml new file mode 100644 index 000000000..6cd6d5048 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml @@ -0,0 +1,61 @@ + + + + + SiW first design + + + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-18,y:-18,z:-17 + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml new file mode 100644 index 000000000..8e4c8a381 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml new file mode 100644 index 000000000..f8dbfa021 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml new file mode 100644 index 000000000..a282eaad4 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml new file mode 100644 index 000000000..8c4d74cc3 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml new file mode 100644 index 000000000..a7d9cb449 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml new file mode 100644 index 000000000..912dc0dcf --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml @@ -0,0 +1,61 @@ + + + + + SiW first design + + + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-18,y:-18,z:-17 + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml new file mode 100644 index 000000000..cd040223c --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml new file mode 100644 index 000000000..b58476c2d --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml index 476d311ed..ca1cea574 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml @@ -17,8 +17,8 @@ - - + + @@ -34,8 +34,8 @@ - - + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 diff --git a/Detector/DetStudies/src/components/DECalAnalysis.cpp b/Detector/DetStudies/src/components/DECalAnalysis.cpp new file mode 100644 index 000000000..b7c368601 --- /dev/null +++ b/Detector/DetStudies/src/components/DECalAnalysis.cpp @@ -0,0 +1,363 @@ + +#include "DECalAnalysis.h" + +// FCCSW +#include "DetInterface/IGeoSvc.h" + +// datamodel +#include "datamodel/PositionedCaloHitCollection.h" +#include "datamodel/CaloHitCollection.h" +#include "datamodel/MCParticleCollection.h" + +#include "CLHEP/Vector/ThreeVector.h" +#include "GaudiKernel/ITHistSvc.h" +#include "TH1F.h" +#include "TVector2.h" +#include "TMath.h" +#include "TString.h" +#include "string" + +// DD4hep +#include "DD4hep/LCDD.h" +#include "DD4hep/Readout.h" + +DECLARE_ALGORITHM_FACTORY(DECalAnalysis) + +DECalAnalysis::DECalAnalysis(const std::string& aName, ISvcLocator* aSvcLoc) + : GaudiAlgorithm(aName, aSvcLoc), + m_histSvc("THistSvc", "DECalAnalysis"), + m_geoSvc("GeoSvc", "DECalAnalysis") +{ + declareProperty("pixels", m_deposits, "Energy deposits in sampling calorimeter (input)"); + declareProperty("pads", m_pads, "Energy deposits in Pad mode (input)"); + declareProperty("truth", m_truth, "Generated particle truth"); +} +DECalAnalysis::~DECalAnalysis() {} + +StatusCode DECalAnalysis::initialize() { + if (GaudiAlgorithm::initialize().isFailure()) { + return StatusCode::FAILURE; + } + // check if readouts exist + if (m_geoSvc->lcdd()->readouts().find(m_pixelReadoutName) == m_geoSvc->lcdd()->readouts().end()) { + error() << "Readout <<" << m_pixelReadoutName << ">> does not exist." << endmsg; + return StatusCode::FAILURE; + } + + m_sumPixelsLayers.assign(m_numLayers+1,0); + m_sumPadsLayers.assign(m_numLayers+1,0); + + m_treeInfo = new TTree("decal_info", "for Kostas"); + m_treeInfo->Branch("event_number", &m_treeEvtNumber); + m_treeInfo->Branch("truth_energy", &m_truthEnergy); + m_treeInfo->Branch("pixels_tot", &m_sumPixels); + for(uint l(0); lBranch(Form("pixels_l%i", l), &m_sumPixelsLayers[l]); + } + m_treeInfo->Branch("pads_tot", &m_sumPads); + for(uint l(0); lBranch(Form("pads_l%i", l), &m_sumPadsLayers[l]); + } + /* m_treeInfo->Branch("fit_E0", &m_fitE0); + m_treeInfo->Branch("fit_a", &m_fita); + m_treeInfo->Branch("fit_b", &m_fitb); + m_treeInfo->Branch("rising50", &m_rising50); + m_treeInfo->Branch("rising90", &m_rising90); + m_treeInfo->Branch("fwhm", &m_fwhm); + */ if(m_histSvc->regTree("/rec/decalInfo", m_treeInfo).isFailure()) { + error() << "Couldn't register tree" << endmsg; + return StatusCode::FAILURE; + } + // create histograms + m_totalHits = new TH1F("decal_totalHits", "Total hits in an event", 15000, 0, 150000); + if (m_histSvc->regHist("/rec/decal_hits", m_totalHits).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + m_totalHitsVsLayer = new TH1F("decal_totalHitsVsLayer", "Total hits per layer", m_numLayers+1, -0.5, m_numLayers+0.5); + m_totalHitsVsLayer->Sumw2(kFALSE); + if(m_histSvc->regHist("/rec/decal_hitsVsLayer", m_totalHitsVsLayer).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_totalPadsVsLayer = new TH1F("decal_totalPadsVsLayer", "Total pads per layer", m_numLayers+1, -0.5, m_numLayers+0.5); + m_totalPadsVsLayer->Sumw2(kFALSE); + if(m_histSvc->regHist("/rec/decal_padsVsLayer", m_totalPadsVsLayer).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + for(uint n(0); n<100; n++) { + m_hitsVsLayerEvent[n] = new TH1F(("decal_hitsVsLayerEvent"+std::to_string(n)).c_str(), "", m_numLayers+1, -0.5, m_numLayers+0.5); + m_hitsVsLayerEvent[n]->Sumw2(kFALSE); + if(m_histSvc->regHist("/rec/decal_hitsVsLayerEvent"+std::to_string(n), m_hitsVsLayerEvent[n]).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + } + + m_hitsInMaxLayer = new TH1F("decal_hitsInMaxLayer", "Total hits in max layer", 150, 0, 15000); + if (m_histSvc->regHist("/rec/decal_hitsInMaxLayer", m_hitsInMaxLayer).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_maxLayer = new TH1F("decal_maxLayer", "Layer with the maximum hits in an event",m_numLayers+1, -0.5, m_numLayers+0.5 ); + if (m_histSvc->regHist("/rec/decal_maxLayer", m_maxLayer).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_totalPadsAbovePixelThreshold = new TH1F("decal_totalPadsAbovePixelThreshold","", 1000,0,10000); + if (m_histSvc->regHist("/rec/decal_totalPadsAbovePixelThreshold", m_totalPadsAbovePixelThreshold).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_totalPads = new TH1F("decal_totalPads","", 1000,0,10000); + if (m_histSvc->regHist("/rec/decal_totalPads", m_totalPads).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + for (uint i = 0; i < m_numLayers+1; i++) { + m_totalHitsLayers.push_back(new TH1F(("decal_Hits_layer" + std::to_string(i)).c_str(), + ("Total pixel hits in layer " + std::to_string(i)).c_str(), 1000, 0, + 10000)); + if (m_histSvc->regHist("/rec/decal_total_hits_layer" + std::to_string(i), m_totalHitsLayers.back()).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_totalPadsLayers.push_back(new TH1F(("decal_Pads_layer" + std::to_string(i)).c_str(), + ("Total pads with hits in layer " + std::to_string(i)).c_str(), 100, 0, + 1000)); + if (m_histSvc->regHist("/rec/decal_total_pads_layer" + std::to_string(i), m_totalPadsLayers.back()).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + + m_totalPixelsPerPadLayers.push_back(new TH1F(("decal_Pixels_Per_Pad_layer" + std::to_string(i)).c_str(), + ("Total pixels per pad in layer " + std::to_string(i)).c_str(), 200, 0, + 200)); + if (m_histSvc->regHist("/rec/decal_Pixels_Per_Pad_layer" + std::to_string(i), m_totalPixelsPerPadLayers.back()).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + } + m_XYEvent0 = new TH2F("decal_XYEvent0", "XY Positions for Event 0", 5000, -2500, 2500, 5000, -2500, 2500); + if (m_histSvc->regHist("/rec/decal_XYEvent0", m_XYEvent0).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_EtaPhiEvent0 = new TH2F("decal_EtaPhiEvent0", "Eta Phi Positions for Event 0", 222, -0.004, 0.002, 222, -0.8305,-0.8245); + if (m_histSvc->regHist("/rec/decal_EtaPhiEvent0", m_EtaPhiEvent0).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_EtaPhiSeparation = new TH1F("decal_EtaSeparation", "Eta Phi Positions", 1200, 0, 1); + if (m_histSvc->regHist("/rec/decal_EtaPhiSeparation", m_EtaPhiSeparation).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_nEventsFilled = 0; + +/* m_fitLongProfile = new TF1("longEnergyDepFit",FitLongProfile , 0.5, 50.0, 3); + m_fitLongProfile->SetParameter(0, 3); + m_fitLongProfile->SetParName(0, "E_0"); + m_fitLongProfile->SetParameter(1, 3.7); + m_fitLongProfile->SetParName(1, "a"); + m_fitLongProfile->SetParameter(2, 0.5); + m_fitLongProfile->SetParName(2, "b"); + m_fitLongProfile->SetLineColor(1); + m_fitLongProfile->SetLineStyle(7); +*/ + // if it gets to here then it has registered all histograms + return StatusCode::SUCCESS; +} + +StatusCode DECalAnalysis::execute() { + // get the decoder for the readout + // this will allow to extract layers etc. + auto decoder = m_geoSvc->lcdd()->readout(m_pixelReadoutName).idSpec().decoder(); + + // calculate the MC truth energy of the incident particle + const auto truth = m_truth.get(); + for (const auto& t : *truth) { + double px = t.core().p4.px; + double py = t.core().p4.py; + double pz = t.core().p4.pz; + double m = t.core().p4.mass; + + m_truthEnergy = TMath::Sqrt(m*m + px*px + py*py + pz*pz); + } + + // added a little print out to ensure it is still working + if(m_treeEvtNumber < 10 or m_treeEvtNumber % 100 == 0) { + info() << "Event Number " << m_treeEvtNumber << endmsg; + info() << "Truth energy of single particle = " << m_truthEnergy << endmsg; + } + + + // set some variables to hold information for an event + m_sumPixels = 0.; + m_sumPixelsLayers.assign(m_numLayers+1, 0); + m_meanEta.assign(m_numLayers+1, 0); + m_meanPhi.assign(m_numLayers+1, 0); + + bool fillXY = true; + if (m_XYEvent0->GetEntries()>0) { + fillXY = false; + } + + const auto deposits = m_deposits.get(); + for (const auto& hit : *deposits) { + decoder->setValue(hit.core().cellId); + int layer = (*decoder)[m_layerFieldName]; + m_sumPixelsLayers[layer] += 1; + // check if energy was deposited in the calorimeter (active/passive material) + // layers are numbered starting from 1, layer == 0 is cryostat/bath + if (layer > 0) { + m_sumPixels++; + decoder->setValue(hit.core().cellId); + + // calculate eta and phi + double r = TMath::Sqrt(hit.position().x*hit.position().x + hit.position().y*hit.position().y + hit.position().z*hit.position().z); + double theta = TMath::ACos(hit.position().z/r); + double eta = -TMath::Log2(TMath::Tan(theta/2.0)); + double phi = TMath::ATan(hit.position().y / hit.position().x); + + m_meanEta[layer] += eta; + m_meanPhi[layer] += phi; + + } + } + + // loop through eta and phi and calculate the mean + for(uint l(1); l maxHits) { + maxHits = m_sumPixelsLayers[l]; + maxLayer = l; + } + } + + // loop through and fill the hitsVsLayer histogram for first N(=100) events + for(uint l=1; lSetBinContent(l+1, m_sumPixelsLayers[l]); + m_hitsVsLayerEvent[m_nEventsFilled+1]->SetBinError(l+1, TMath::Power(m_sumPixelsLayers[l],0.5)); + } + // the 0th element is changed each run to allow fitting in code of the profile + m_hitsVsLayerEvent[0]->SetBinContent(l+1, m_sumPixelsLayers[l]); + m_hitsVsLayerEvent[0]->SetBinError(l+1, TMath::Power(m_sumPixelsLayers[l],0.5)); + } + m_nEventsFilled++; + + // fit the m_hitsVsLayerEvent[0] histogram + /* if(m_hitsVsLayerEvent[0]->GetEntries()>0) { + m_hitsVsLayerEvent[0]->Fit(m_fitLongProfile, "NR"); + m_fitE0 = m_fitLongProfile->GetParameter("E_0"); + m_fita = m_fittLongProfile->GetParameter("a"); + m_fitb = m_fitLongProfile->GetParameter("b"); + + // calculate where function is half the value of max + double fitMax = m_fitLongProfile->GetMaximum(); + double half_lowx = m_fitLongProfile->GetX(fitMax/2, 0, m_fitLongProfile->GetX(fitMax)); + double half_highx = m_fitLongProfile->GetX(fitMax/2,m_fitLongProfile->GetX(fitMax)); + m_fwhm = half_highx-half_lowx; + m_rising50->Fill(half_lowx); + m_rising80->Fill(->GetX(fitMax*0.8, 0, m_fitLongProfile->GetX(fitMax))); + }*/ + + // Fill histograms + m_totalHits->Fill(m_sumPixels); + //debug() << "total hits in event = " << sumHits << endmsg; + for (uint i = 1; i < m_numLayers+1; i++) { + m_totalHitsLayers[i]->Fill(m_sumPixelsLayers[i]); + //debug() << "total hits in layer " << i << " = " << m_sumPixelsLayers[i] << endmsg; + } + + m_hitsInMaxLayer->Fill(maxHits); + m_maxLayer->Fill(maxLayer); + + + // Pads analysis + m_sumPads = 0; + int pixelsPerPadThreshold = 10; + m_sumPadsLayers.assign(m_numLayers+1, 0); + std::vector sumPadsAbovePixelThreshold; + sumPadsAbovePixelThreshold.assign(m_numLayers, 0); + + auto decoder_pad = m_geoSvc->lcdd()->readout(m_padReadoutName).idSpec().decoder(); + const auto pads = m_pads.get(); + for (const auto& hit : *pads) { + decoder_pad->setValue(hit.core().cellId); + uint layer = (*decoder_pad)[m_layerFieldName]; + m_sumPadsLayers[layer] ++; + if (layer > 0) { + m_sumPads++; + double pixelsPerPad = hit.core().energy; + m_totalPixelsPerPadLayers[layer]->Fill(pixelsPerPad); + if(pixelsPerPad > pixelsPerPadThreshold) { + sumPadsAbovePixelThreshold[layer]++; + } + } + } + + + uint totalPadsAbovePixelThreshold = 0; + for( uint i=1; iFill(m_sumPadsLayers[i]); + totalPadsAbovePixelThreshold += sumPadsAbovePixelThreshold[i]; + } + + m_totalPads->Fill(m_sumPads); + m_totalPadsAbovePixelThreshold->Fill(totalPadsAbovePixelThreshold); + + if(m_sumPixels>0 || m_sumPads>0) { + m_treeInfo->Fill(); + } + + m_treeEvtNumber++; + + return StatusCode::SUCCESS; +} + +StatusCode DECalAnalysis::finalize() { + debug() << "StatusCode DECalAnalysis::finalize()" << endmsg; + + // count from 1 to avoid the hits in the Trkr volume + for (uint i = 1; i < m_numLayers+1; i++) { + m_totalHitsVsLayer->SetBinContent(i+1,m_totalHitsLayers[i]->GetMean()); + m_totalPadsVsLayer->SetBinContent(i+1,m_totalPadsLayers[i]->GetMean());//sumPadslayers[i]); + //debug() << "total hits in layer " << i << " = " << m_sumPixelsLayers[i] << endmsg; + } + +return GaudiAlgorithm::finalize(); } + +Double_t DECalAnalysis::FitLongProfile( Double_t *x, Double_t *par) +{ + double E_0 = par[0]; + double a = par[1]; + double b = par[2]; + double led = E_0*b * (pow( (b*x[0]), a-1 )* exp(-(b*x[0])) ) / TMath::Gamma(a); + + return led; +} diff --git a/Detector/DetStudies/src/components/DECalAnalysis.h b/Detector/DetStudies/src/components/DECalAnalysis.h new file mode 100644 index 000000000..e97693b5f --- /dev/null +++ b/Detector/DetStudies/src/components/DECalAnalysis.h @@ -0,0 +1,128 @@ +#ifndef DETSTUDIES_DECalAnalysis_H +#define DETSTUDIES_DECalAnalysis_H + +// GAUDI +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ServiceHandle.h" + +// FCCSW +#include "FWCore/DataHandle.h" +#include "TH2F.h" +#include "TTree.h" +#include "TF1.h" + +class IGeoSvc; + +// datamodel +namespace fcc { +class PositionedCaloHitCollection; +class CaloHitCollection; +class MCParticleCollection; +} + +class TH1F; +class ITHistSvc; +/** @class DECalAnalysis DECalAnalysis.h + * + * Histograms of energy deposited in active material and total energy deposited in the calorimeter. + * Passive material needs to be marked as sensitive. It needs to be divided into layers (cells) as active material. + * Layers (cells) are numbered starting at 1 so that energy depoisted in cryostat and bath could be easily recognised. + * Sampling fraction is calculated for each layer as the ratio of energy deposited in active material to energy + * deposited in the layer (also in passive material). + * + * @author Anna Zaborowska + */ + +class DECalAnalysis : public GaudiAlgorithm { +public: + explicit DECalAnalysis(const std::string&, ISvcLocator*); + virtual ~DECalAnalysis(); + /** Initialize. + * @return status code + */ + virtual StatusCode initialize() final; + /** Fills the histograms. + * @return status code + */ + virtual StatusCode execute() final; + /** Finalize. + * @return status code + */ + virtual StatusCode finalize() final; + + Double_t FitLongProfile( Double_t *x, Double_t *par); + +private: + /// Pointer to the interface of histogram service + ServiceHandle m_histSvc; + /// Pointer to the geometry service + ServiceHandle m_geoSvc; + /// Number of layers/cells + Gaudi::Property m_numLayers{this, "numLayers", 50, "Number of layers"}; + /// Name of the layer/cell field + Gaudi::Property m_layerFieldName{this, "layerFieldName", "", "Identifier of layers"}; + + /// The Pixel analysis + /// Handle for the energy deposits + DataHandle m_deposits{"rec/pixels", Gaudi::DataHandle::Reader, this}; + /// Name of the detector readout + Gaudi::Property m_pixelReadoutName{this, "pixelReadoutName", "", "Name of the detector readout"}; + + /// The Pad analysis + /// Handle for the energy deposits + DataHandle m_pads{"rec/pads", Gaudi::DataHandle::Reader, this}; + /// Name of the detector readout + Gaudi::Property m_padReadoutName{this, "padReadoutName", "", "Name of the detector readout"}; + + DataHandle m_truth{"truth", Gaudi::DataHandle::Reader, this}; + + + // Histograms of total deposited energy within layer + // Histograms for the number of hits per layer + std::vector m_totalHitsLayers; + + // Histogram of total hits in the calorimeter + TH1F* m_totalHits; + // Histogram of number of hits per layer in single histogram + TH1F* m_totalHitsVsLayer; + TH1F* m_hitsVsLayerEvent[100]; + + TH1F* m_totalPadsVsLayer; + std::vector m_totalPadsLayers; + std::vector m_totalPixelsPerPadLayers; + TH1F* m_totalPixelsPerPad; + TH1F* m_totalPads; + TH1F* m_totalPadsAbovePixelThreshold; + + TH2F* m_XYEvent0; + TH2F* m_EtaPhiEvent0; + TH1F* m_EtaPhiSeparation; + + // Histogram of the number of hits in the layer with most hits + TH1F* m_hitsInMaxLayer; + // Histogram of the layer with maximum hits + TH1F* m_maxLayer; + + TTree* m_treeInfo; + int m_treeEvtNumber; + + int m_nEventsFilled; + int m_truthEnergy; + int m_sumPixels; + std::vector m_sumPixelsLayers; + int m_sumPads; + std::vector m_sumPadsLayers; + + std::vector m_meanEta; + std::vector m_meanPhi; + + double m_fitE0; + double m_fita; + double m_fitb; + double m_rising50; + double m_rising90; + double m_fwhm; + + TF1* m_fitLongProfile; +}; +#endif /* DETSTUDIES_DECalAnalysis_H */ diff --git a/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py b/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py new file mode 100644 index 000000000..581aee7ce --- /dev/null +++ b/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py @@ -0,0 +1,85 @@ +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +batch_dir = "/eos/user/t/toprice/private/FCC/FCCSW/v8.0/XYZ/" +fccsw_version = "FCCSW0.8" +det_config = "50Layers_2.1mmW_50umPixels_18umThick_FCCSW0.8" +run_config = "0GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001" +file = "0GeV_BFIELD4T_2.root" +#inputfile = batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/"+file +inputfile = batch_dir+"/"+det_config+"/"+run_config+"/output_"+file +podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) + + +from Configurables import PodioInput +podioinput = PodioInput("PodioReader", collections=["positionedCaloHits", "GenParticles"], OutputLevel=INFO) + +# DD4hep geometry service +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_'+det_config[:-9]+'.xml' +], + OutputLevel = INFO) + + +from Configurables import RedoSegmentation +resegment = RedoSegmentation("ReSegmentation", + # old bitfield (readout) + oldReadoutName = "BarDECal_Readout", + # specify which fields are going to be deleted + oldSegmentationIds = ["x","y","z"], + # new bitfield (readout), with new segmentation + newReadoutName="BarDECal_Pads", + OutputLevel = INFO) +# clusters are needed, with deposit position and cellID in bits +resegment.inhits.Path = "positionedCaloHits" +resegment.outhits.Path = "newCaloHits" + +from Configurables import CreateCaloCells +createcells = CreateCaloCells("CreateCaloCells", + doCellCalibration = False, + addCellNoise = False, filterCellNoise = False, + OutputLevel = INFO) +createcells.hits.Path="newCaloHits" +createcells.cells.Path="newCaloCells" + +from Configurables import DECalAnalysis +hist = DECalAnalysis("DECalAnalysis", + pixelReadoutName = "BarDECal_Readout", + padReadoutName = "BarDECal_Pads", + layerFieldName = "layer", + numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + OutputLevel = INFO) +hist.pixels.Path="positionedCaloHits" +hist.pads.Path="newCaloCells" +hist.truth.Path="GenParticles" + +#THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] +THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/analysis_"+file+"' TYP='ROOT' OPT='RECREATE'"] +THistSvc().PrintAll=False +THistSvc().AutoSave=True +THistSvc().AutoFlush=True +THistSvc().OutputLevel=INFO + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +hist.AuditExecute = True + +from Configurables import FCCDataSvc, PodioOutput +#podiosvc = FCCDataSvc("EventDataSvc") +podioout = PodioOutput("out", filename=batch_dir+"/"+det_config+"/"+run_config+"/redoSegmentation_"+file) +podioout.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [podioinput, resegment, createcells,hist, podioout], + EvtSel = 'NONE', + # EvtMax = 10, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podiosvc,geoservice, audsvc], + OutputLevel = INFO +) diff --git a/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py b/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py new file mode 100644 index 000000000..ddcbe6d4c --- /dev/null +++ b/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py @@ -0,0 +1,87 @@ +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +batch_dir = "/eos/user/t/toprice/private/FCC/FCCSW/v8.0/XYZ/" +fccsw_version = "FCCSW0.8" +det_config = "" +run_config = "" +file = "" +file = file[7:] +#inputfile = batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/"+file +inputfile = batch_dir+"/"+det_config+"/"+run_config+"/output_"+file +podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) + + +from Configurables import PodioInput +podioinput = PodioInput("PodioReader", collections=["positionedCaloHits", "GenParticles"], OutputLevel=DEBUG) + +# DD4hep geometry service +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_'+det_config[:-9]+'.xml' +], + OutputLevel = INFO) + +from Configurables import RedoSegmentation +resegment = RedoSegmentation("ReSegmentation", + # old bitfield (readout) + oldReadoutName = "BarDECal_Readout", + # specify which fields are going to be deleted + oldSegmentationIds = ["x","y","z"], + # new bitfield (readout), with new segmentation + newReadoutName="BarDECal_Pads", + OutputLevel = INFO) +# clusters are needed, with deposit position and cellID in bits +resegment.inhits.Path = "positionedCaloHits" +resegment.outhits.Path = "newCaloHits" + +from Configurables import CreateCaloCells +createcells = CreateCaloCells("CreateCaloCells", + doCellCalibration = False, + addCellNoise = False, filterCellNoise = False, + OutputLevel = INFO) +createcells.hits.Path="newCaloHits" +createcells.cells.Path="newCaloCells" + +from Configurables import DECalAnalysis +hist = DECalAnalysis("DECalAnalysis", + pixelReadoutName = "BarDECal_Readout", + padReadoutName = "BarDECal_Pads", + layerFieldName = "layer", + numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + OutputLevel = INFO) +hist.pixels.Path="positionedCaloHits" +hist.pads.Path="newCaloCells" +hist.truth.Path="GenParticles" + + +#THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] +THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/analysis_"+file+"' TYP='ROOT' OPT='RECREATE'"] +THistSvc().PrintAll=False +THistSvc().AutoSave=True +THistSvc().AutoFlush=True +THistSvc().OutputLevel=INFO + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +hist.AuditExecute = True + +from Configurables import FCCDataSvc, PodioOutput +#podiosvc = FCCDataSvc("EventDataSvc") +podioout = PodioOutput("out", filename=batch_dir+"/"+det_config+"/"+run_config+"/redoSegmentation_"+file) +podioout.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [podioinput, resegment, createcells,hist],# podioout], + EvtSel = 'NONE', + # EvtMax = 10, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podiosvc,geoservice, audsvc], + OutputLevel = INFO + +) diff --git a/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py b/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py new file mode 100644 index 000000000..74d77cf6e --- /dev/null +++ b/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py @@ -0,0 +1,50 @@ +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +inputfile = "/afs/cern.ch/work/t/toprice/private/FCC/FCCSW/batch/XYZ/50Layers_2.1mmW_1mmAir_50umPixels_18umThick_FCCSW0.8pre/500GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001/output_500GeV_BFIELD4T.root" +podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) + + +from Configurables import PodioInput +podioinput = PodioInput("PodioReader", collections=["positionedCaloHits"], OutputLevel=DEBUG) + +# DD4hep geometry service +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml' +], + OutputLevel = INFO) + + + +from Configurables import DECalLongitudinalTest +hist = DECalLongitudinalTest("hists", + readoutName = "BarDECal_Readout", + layerFieldName = "layer", + numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + OutputLevel = DEBUG) +hist.deposits.Path="positionedCaloHits" + +THistSvc().Output = ["rec DATAFILE='hist_test.root' TYP='ROOT' OPT='RECREATE'"] +THistSvc().PrintAll=True +THistSvc().AutoSave=True +THistSvc().AutoFlush=False +THistSvc().OutputLevel=INFO + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +hist.AuditExecute = True + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [podioinput, hist], + EvtSel = 'NONE', +# EvtMax = 10, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podiosvc,geoservice, audsvc], + OutputLevel = DEBUG +) diff --git a/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py b/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py new file mode 100644 index 000000000..318cf9021 --- /dev/null +++ b/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py @@ -0,0 +1,57 @@ +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +batch_dir = "/eos/user/t/toprice/private/FCC/FCCSW/v8.0/XYZ/" +fccsw_version = "FCCSW0.8" +det_config = "" +run_config = "" +file = "" +#inputfile = batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/"+file +inputfile = batch_dir+"/"+det_config+"/"+run_config+"/"+file +podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) + + +from Configurables import PodioInput +podioinput = PodioInput("PodioReader", collections=["positionedCaloHits"], OutputLevel=DEBUG) + +# DD4hep geometry service +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_'+det_config[:-9]+'.xml' +], + OutputLevel = INFO) + + + +from Configurables import DECalLongitudinalTest +hist = DECalLongitudinalTest("hists", + readoutName = "BarDECal_Readout", + layerFieldName = "layer", + numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + OutputLevel = DEBUG) +hist.deposits.Path="positionedCaloHits" + +#THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] +THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] +THistSvc().PrintAll=True +THistSvc().AutoSave=True +THistSvc().AutoFlush=False +THistSvc().OutputLevel=INFO + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +hist.AuditExecute = True + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [podioinput, hist], + EvtSel = 'NONE', +# EvtMax = 10, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podiosvc,geoservice, audsvc], + OutputLevel = DEBUG +) diff --git a/submit_decalAnalysis.py b/submit_decalAnalysis.py new file mode 100644 index 000000000..1605312e0 --- /dev/null +++ b/submit_decalAnalysis.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +import os, re +import commands +import math, time +import sys + +print +print 'START' +print +######## YOU ONLY NEED TO FILL THE AREA BELOW ######### +######## customization area ######### +CONFIG="50Layers_2.1mmW_50umPixels_18umThick" +FCCSW_VERSION="FCCSW0.8" +ENERGIES = ["0"]#"10","20","50","100","200","300","400","500","1000"] +#ENERGIES = ["200","300","400","500","1000" ] # number of jobs to be submitted +#ENERGIES = ["30","40","60","70","80","90"] # number of jobs to be submitted +#ENERGIES = ["1000" ] # number of jobs to be submitted +BFIELD = "4" +EVENTS = 10000 +ETAMIN = -0.001 +ETAMAX = 0.001 +NRUNS = 400 +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +queue = "8nh" +######## customization end ######### + +path = os.getcwd() + +##### loop for creating and sending jobs ##### +#e = 100 +CONFIGS = os.listdir(FCCSW_DIR+"/batch_eos/") +CONFIGS = [ c for c in CONFIGS if CONFIG in c ] +#for e in ENERGIES: +for CONFIG in CONFIGS: + print CONFIG + for e in ENERGIES: + ##### creates directory and file list for job ####### + RUNCONFIG=str(e)+"GeV_BFIELD"+str(BFIELD)+"T_ETAMIN"+str(ETAMIN)+"_ETAMAX"+str(ETAMAX) + # dir="batch_eos/"+CONFIG+"_"+FCCSW_VERSION+"/"+RUNCONFIG + dir="batch_eos/"+CONFIG+"/"+RUNCONFIG + print dir + + if os.path.isdir(dir): + + files = [ f for f in os.listdir(dir) if "output" in f and "500" in f] + print files + + os.chdir(dir) + + for f in files: + #print "hist_"+f[7:] + #os.chdir(dir) + #os.system('pwd') + #os.system('cp -v '+FCCSW_DIR+'/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py run.py') + #os.system("sed -i 's//"+str(CONFIG)+"/' run.py") + #os.system("sed -i 's//"+str(RUNCONFIG)+"/' run.py") + #os.system("sed -i 's//"+f+"/' run.py") + #os.system("sed -i 's//hist_"+f[7:]+"/' run.py") + #os.chdir(path) + #os.system("./run gaudirun.py "+dir+"/run.py") + N = f[f.find("4T")+3:f.find(".root")] + if len(N) == 0: + N = 0 + print f + + with open('analyse'+str(N)+'.sh', 'w') as fout: + fout.write("#!/bin/sh\n") + fout.write("echo\n") + fout.write("echo 'START---------------'\n") + fout.write("echo 'WORKDIR ' ${PWD}\n") + + fout.write('cp -v '+FCCSW_DIR+'/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py ana.py\n') + fout.write("sed -i 's//"+str(CONFIG)+"/' ana.py\n") + fout.write("sed -i 's//"+str(RUNCONFIG)+"/' ana.py\n") + fout.write("sed -i 's//"+f+"/' ana.py\n") + fout.write("sed -i 's//analysis_"+f[7:]+"/' ana.py\n") + fout.write("echo\n") + fout.write("cat ana.py\n") + fout.write("echo\n") + fout.write("source "+FCCSW_DIR+"init.sh\n") + fout.write(FCCSW_DIR+"run gaudirun.py ana.py\n") + fout.write("echo 'STOP---------------'\n") + fout.write("echo\n") + fout.write("cp -v *.root "+path+"/"+dir+"\n") + fout.write("echo\n") + + + os.system("chmod 755 analyse"+str(N)+".sh") + os.system("bsub -q "+queue+" analyse"+str(N)+".sh") + + os.chdir(path) + + diff --git a/submit_longitudinalAnalysis.py b/submit_longitudinalAnalysis.py new file mode 100644 index 000000000..491e60157 --- /dev/null +++ b/submit_longitudinalAnalysis.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +import os, re +import commands +import math, time +import sys + +print +print 'START' +print +######## YOU ONLY NEED TO FILL THE AREA BELOW ######### +######## customization area ######### +CONFIG="50Layers_2.1mmW_50umPixels_18umThick" +FCCSW_VERSION="FCCSW0.8" +ENERGIES = ["10","20","50","100","200","300","400","500","1000"] +#ENERGIES = ["200","300","400","500","1000" ] # number of jobs to be submitted +#ENERGIES = ["30","40","60","70","80","90"] # number of jobs to be submitted +#ENERGIES = ["1000" ] # number of jobs to be submitted +BFIELD = "4" +EVENTS = 2000 +ETAMIN = -0.001 +ETAMAX = 0.001 +NRUNS = 20 +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +queue = "1nh" +######## customization end ######### + +path = os.getcwd() + +##### loop for creating and sending jobs ##### +#e = 100 +CONFIGS = os.listdir(FCCSW_DIR+"/batch_eos/") +#CONFIGS = [ c for c in CONFIGS if "50Layers_2.1mmW" in c ] +#for e in ENERGIES: +for CONFIG in CONFIGS: + for e in ENERGIES: + ##### creates directory and file list for job ####### + RUNCONFIG=str(e)+"GeV_BFIELD"+str(BFIELD)+"T_ETAMIN"+str(ETAMIN)+"_ETAMAX"+str(ETAMAX) + # dir="batch_eos/"+CONFIG+"_"+FCCSW_VERSION+"/"+RUNCONFIG + dir="batch_eos/"+CONFIG+"/"+RUNCONFIG + print dir + + if os.path.isdir(dir): + + files = [ f for f in os.listdir(dir) if "output" in f] + print files + + os.chdir(dir) + + for f in files: + #print "hist_"+f[7:] + #os.chdir(dir) + #os.system('pwd') + #os.system('cp -v '+FCCSW_DIR+'/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py run.py') + #os.system("sed -i 's//"+str(CONFIG)+"/' run.py") + #os.system("sed -i 's//"+str(RUNCONFIG)+"/' run.py") + #os.system("sed -i 's//"+f+"/' run.py") + #os.system("sed -i 's//hist_"+f[7:]+"/' run.py") + #os.chdir(path) + #os.system("./run gaudirun.py "+dir+"/run.py") + N = f[f.find("4T")+3:f.find(".root")] + if len(N) == 0: + N = 0 + print N + + with open('analyse'+str(N)+'.sh', 'w') as fout: + fout.write("#!/bin/sh\n") + fout.write("echo\n") + fout.write("echo 'START---------------'\n") + fout.write("echo 'WORKDIR ' ${PWD}\n") + + fout.write('cp -v '+FCCSW_DIR+'/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py ana.py\n') + fout.write("sed -i 's//"+str(CONFIG)+"/' ana.py\n") + fout.write("sed -i 's//"+str(RUNCONFIG)+"/' ana.py\n") + fout.write("sed -i 's//"+f+"/' ana.py\n") + fout.write("sed -i 's//hist_"+f[7:]+"/' ana.py\n") + fout.write("echo\n") + fout.write("cat ana.py\n") + fout.write("echo\n") + fout.write("source "+FCCSW_DIR+"init.sh\n") + fout.write(FCCSW_DIR+"run gaudirun.py ana.py\n") + fout.write("echo 'STOP---------------'\n") + fout.write("echo\n") + fout.write("cp -v *.root "+path+"/"+dir+"\n") + fout.write("echo\n") + + + os.system("chmod 755 analyse"+str(N)+".sh") + os.system("bsub -q "+queue+" analyse"+str(N)+".sh") + + os.chdir(path) + + From ae034317ec858ed4b721a517d7be39d3539ac427 Mon Sep 17 00:00:00 2001 From: tonypba Date: Thu, 28 Sep 2017 14:59:09 +0200 Subject: [PATCH 09/28] file to calculate the non linearity factor from total counts in an event --- calculate_nonLinFactor.py | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 calculate_nonLinFactor.py diff --git a/calculate_nonLinFactor.py b/calculate_nonLinFactor.py new file mode 100644 index 000000000..95c24e9ff --- /dev/null +++ b/calculate_nonLinFactor.py @@ -0,0 +1,43 @@ +from ROOT import TH1F, TTree, TChain, TFile +import os + +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +ETAMIN = -0.001 +ETAMAX = 0.001 + +CONFIGS = [ c for c in os.listdir(FCCSW_DIR+"/batch_eos/") if "50Layers_2.1mmW_50umPixels_18umThick" in c] +print CONFIGS + +for CONFIG in CONFIGS: + print CONFIG + + RUNCONFIGS = [ e for e in os.listdir(FCCSW_DIR+"/batch_eos/"+CONFIG) ] + for RUNCONFIG in RUNCONFIGS[1:]: + #print "\t",RUNCONFIG + + dir="batch_eos/"+CONFIG+"/"+RUNCONFIG+"/" + print "\n",dir + + chain = TChain("decal_info") + + if os.path.isdir(dir): + + FILES = [f for f in os.listdir(dir) if "analysis" in f] + for f in FILES: + temp_file = TFile(dir+f) + if temp_file.IsZombie(): + continue + else: + chain.Add(dir+f) + + print chain.GetEntries() + + temp_hist = TH1F("temp_hist", "temp hist", 2000, 0, 100000)#20) + chain.Draw("pixels_tot>>temp_hist","", "GOFF" ) + + energy = float(RUNCONFIG[:RUNCONFIG.find("GeV")]) + mean = temp_hist.GetMean() + sigma = temp_hist.GetRMS() + if mean > 0: + print energy, mean, sigma, sigma/mean + From 77a19a679f373c03f80a5ea711cdc8be9a3f55ca Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 21 Nov 2017 10:37:46 +0100 Subject: [PATCH 10/28] New xml files to run epitaxial and subtrate (analogue) Silicon ECAL --- .../FCChh_DECalBarrel_50Layers_2.1mmW.xml | 70 +++++++++++++++++++ ...CChh_DECalBarrel_50Layers_2.1mmW_450um.xml | 70 +++++++++++++++++++ ...ayers_2.1mmW_50umPixels_18umThick_Edep.xml | 67 ++++++++++++++++++ ...Chh_DECalBarrel_50Layers_3.4mmPb_450um.xml | 70 +++++++++++++++++++ 4 files changed, 277 insertions(+) create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml new file mode 100644 index 000000000..b4f87d860 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml @@ -0,0 +1,70 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + + + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml new file mode 100644 index 000000000..5d5f5455d --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml @@ -0,0 +1,70 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + + + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml new file mode 100644 index 000000000..633dcb23b --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml @@ -0,0 +1,67 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,subtype:1,x:-17,y:-17,z:-8 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,subtype:1,x:-17,y:-17,z:-8 + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml new file mode 100644 index 000000000..ec67bb9c2 --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml @@ -0,0 +1,70 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + + + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 + + + + + + + + + + + + + + + + + + + + + From cc7e7a2f21cf3da22fc7bd9cc636a1620e320368 Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 21 Nov 2017 10:39:20 +0100 Subject: [PATCH 11/28] Analysis code to extract analogue component and analyse --- .../DetStudies/src/components/SiWAnalysis.cpp | 169 ++++++++++++++++++ .../DetStudies/src/components/SiWAnalysis.h | 98 ++++++++++ .../tests/options/SiWAnalysis_batch.py | 87 +++++++++ 3 files changed, 354 insertions(+) create mode 100644 Detector/DetStudies/src/components/SiWAnalysis.cpp create mode 100644 Detector/DetStudies/src/components/SiWAnalysis.h create mode 100644 Detector/DetStudies/tests/options/SiWAnalysis_batch.py diff --git a/Detector/DetStudies/src/components/SiWAnalysis.cpp b/Detector/DetStudies/src/components/SiWAnalysis.cpp new file mode 100644 index 000000000..6aefa3c2b --- /dev/null +++ b/Detector/DetStudies/src/components/SiWAnalysis.cpp @@ -0,0 +1,169 @@ + +#include "SiWAnalysis.h" + +// FCCSW +#include "DetInterface/IGeoSvc.h" + +// datamodel +#include "datamodel/PositionedCaloHitCollection.h" +#include "datamodel/CaloHitCollection.h" +#include "datamodel/MCParticleCollection.h" + +#include "CLHEP/Vector/ThreeVector.h" +#include "GaudiKernel/ITHistSvc.h" +#include "TH1F.h" +#include "TVector2.h" +#include "TMath.h" +#include "TString.h" +#include "string" + +// DD4hep +#include "DD4hep/LCDD.h" +#include "DD4hep/Readout.h" + +DECLARE_ALGORITHM_FACTORY(SiWAnalysis) + +SiWAnalysis::SiWAnalysis(const std::string& aName, ISvcLocator* aSvcLoc) + : GaudiAlgorithm(aName, aSvcLoc), + m_histSvc("THistSvc", "SiWAnalysis"), + m_geoSvc("GeoSvc", "SiWAnalysis") +{ + declareProperty("deposits", m_deposits, "Energy deposits in sampling calorimeter (input)"); + declareProperty("truth", m_truth, "Generated particle truth"); + + m_calP0 = 239.74; + m_calP1 = 99.1602; + m_calP2 = -0.0143; + +} +SiWAnalysis::~SiWAnalysis() {} + +StatusCode SiWAnalysis::initialize() { + if (GaudiAlgorithm::initialize().isFailure()) { + return StatusCode::FAILURE; + } + // check if readouts exist + if (m_geoSvc->lcdd()->readouts().find(m_padReadoutName) == m_geoSvc->lcdd()->readouts().end()) { + error() << "Readout <<" << m_padReadoutName << ">> does not exist." << endmsg; + return StatusCode::FAILURE; + } + + + m_treeInfo = new TTree("info", "Analysis Tree"); + m_treeInfo->Branch("event_number", &m_treeEvtNumber); + m_treeInfo->Branch("truth_energy", &m_truthEnergy); + m_treeInfo->Branch("edep_tot", &m_sumEnergyDep); + + + if(m_histSvc->regTree("/rec/Info", m_treeInfo).isFailure()) { + error() << "Couldn't register tree" << endmsg; + return StatusCode::FAILURE; + } + + // create histograms + + m_totalEdep = new TH1F("SiW_totalEdep", "Total edep in an event", 15000, 0, 15); + if (m_histSvc->regHist("/rec/SiW_Edep", m_totalEdep).isFailure()) { + error() << "Couldn't register histogram" << endmsg; + return StatusCode::FAILURE; + } + + m_calFit = new TF1("calFit", "pol2", 0,3000); + m_calFit->SetParameter("p0", m_calP0); + m_calFit->SetParameter("p1", m_calP1); + m_calFit->SetParameter("p2", m_calP2); + + // if it gets to here then it has registered all histograms + return StatusCode::SUCCESS; +} + +StatusCode SiWAnalysis::execute() { + // get the decoder for the readout + // this will allow to extract layers etc. + auto decoder = m_geoSvc->lcdd()->readout(m_padReadoutName).idSpec().decoder(); + + // calculate the MC truth energy of the incident particle + const auto truth = m_truth.get(); + for (const auto& t : *truth) { + double px = t.core().p4.px; + double py = t.core().p4.py; + double pz = t.core().p4.pz; + double m = t.core().p4.mass; + + m_truthEnergy = TMath::Sqrt(m*m + px*px + py*py + pz*pz); + } + + // added a little print out to ensure it is still working + if(m_treeEvtNumber < 10 or m_treeEvtNumber % 100 == 0) { + info() << "Event Number " << m_treeEvtNumber << endmsg; + info() << "Truth energy of single particle = " << m_truthEnergy << endmsg; + } + + + // set some variables to hold information for an event + m_sumEdepLayers.assign(m_numLayers+1, 0); + m_sumEnergyDep = 0; + + int isdigital = 0, notdigital = 0; + + const auto deposits = m_deposits.get(); + for (const auto& hit : *deposits) { + decoder->setValue(hit.core().cellId); + int digital = (*decoder)["digital"]; + if(digital==0) { + notdigital++; + + } + if(digital==1) { + isdigital++; + continue; + } + + int layer = (*decoder)[m_layerFieldName]; + + // check if energy was deposited in the calorimeter (active/passive material) + // layers are numbered starting from 1, layer == 0 is cryostat/bath + if (layer > 0) { + decoder->setValue(hit.core().cellId); + int layer = (*decoder)[m_layerFieldName]; + // get the energy deposited in the active area + double edep = hit.core().energy; + m_sumEnergyDep += edep; + + } + } + + std::cout << "isdigital = " << isdigital << std::endl; + std::cout << "notdigital = " << notdigital << std::endl; +/* + m_calPixels = m_calFit->GetX(m_sumPixels); + //std::cout << "#### " << m_sumPixels << " " << m_calPixels << std::endl; +*/ + +// Fill histograms + m_totalEdep->Fill(m_sumEnergyDep); + + if(m_sumEnergyDep>0) { + m_treeInfo->Fill(); + } + + m_treeEvtNumber++; + + return StatusCode::SUCCESS; +} + +StatusCode SiWAnalysis::finalize() { + debug() << "StatusCode SiWAnalysis::finalize()" << endmsg; + + +return GaudiAlgorithm::finalize(); } + +Double_t SiWAnalysis::FitLongProfile( Double_t *x, Double_t *par) +{ + double E_0 = par[0]; + double a = par[1]; + double b = par[2]; + double led = E_0*b * (pow( (b*x[0]), a-1 )* exp(-(b*x[0])) ) / TMath::Gamma(a); + + return led; +} diff --git a/Detector/DetStudies/src/components/SiWAnalysis.h b/Detector/DetStudies/src/components/SiWAnalysis.h new file mode 100644 index 000000000..6ee703ef4 --- /dev/null +++ b/Detector/DetStudies/src/components/SiWAnalysis.h @@ -0,0 +1,98 @@ +#ifndef DETSTUDIES_SiWAnalysis_H +#define DETSTUDIES_SiWAnalysis_H + +// GAUDI +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ServiceHandle.h" + +// FCCSW +#include "FWCore/DataHandle.h" +#include "TH2F.h" +#include "TTree.h" +#include "TF1.h" +#include "TProfile.h" + +class IGeoSvc; + +// datamodel +namespace fcc { +class PositionedCaloHitCollection; +class CaloHitCollection; +class MCParticleCollection; +} + +class TH1F; +class ITHistSvc; +/** @class DECalAnalysis DECalAnalysis.h + * + * Histograms of energy deposited in active material and total energy deposited in the calorimeter. + * Passive material needs to be marked as sensitive. It needs to be divided into layers (cells) as active material. + * Layers (cells) are numbered starting at 1 so that energy depoisted in cryostat and bath could be easily recognised. + * Sampling fraction is calculated for each layer as the ratio of energy deposited in active material to energy + * deposited in the layer (also in passive material). + * + * @author Anna Zaborowska + */ + +class SiWAnalysis : public GaudiAlgorithm { +public: + explicit SiWAnalysis(const std::string&, ISvcLocator*); + virtual ~SiWAnalysis(); + /** Initialize. + * @return status code + */ + virtual StatusCode initialize() final; + /** Fills the histograms. + * @return status code + */ + virtual StatusCode execute() final; + /** Finalize. + * @return status code + */ + virtual StatusCode finalize() final; + + Double_t FitLongProfile( Double_t *x, Double_t *par); + +private: + /// Pointer to the interface of histogram service + ServiceHandle m_histSvc; + /// Pointer to the geometry service + ServiceHandle m_geoSvc; + /// Number of layers/cells + Gaudi::Property m_numLayers{this, "numLayers", 50, "Number of layers"}; + /// Name of the layer/cell field + Gaudi::Property m_layerFieldName{this, "layerFieldName", "", "Identifier of layers"}; + + /// The Pixel analysis + /// Handle for the energy deposits + DataHandle m_deposits{"rec/deposits", Gaudi::DataHandle::Reader, this}; + /// Name of the detector readout + Gaudi::Property m_padReadoutName{this, "padReadoutName", "", "Name of the detector readout"}; + + + DataHandle m_truth{"truth", Gaudi::DataHandle::Reader, this}; + + + + // calibration factors to compensate non linearity + float m_calP0, m_calP1, m_calP2; + TF1* m_calFit; + + TTree* m_treeInfo; + int m_treeEvtNumber; + + int m_truthEnergy; + float m_sumEnergyDep; + std::vector m_sumEdepLayers; + + double m_fitE0; + double m_fita; + double m_fitb; + double m_rising50; + double m_rising90; + double m_fwhm; + + TF1* m_fitLongProfile; + TH1F* m_totalEdep; +}; +#endif /* DETSTUDIES_SiWAnalysis_H */ diff --git a/Detector/DetStudies/tests/options/SiWAnalysis_batch.py b/Detector/DetStudies/tests/options/SiWAnalysis_batch.py new file mode 100644 index 000000000..188df42dc --- /dev/null +++ b/Detector/DetStudies/tests/options/SiWAnalysis_batch.py @@ -0,0 +1,87 @@ +from Gaudi.Configuration import * + +# Data service +from Configurables import FCCDataSvc +batch_dir = "/eos/user/t/toprice/private/FCC/FCCSW/v8.0/XYZ/" +fccsw_version = "FCCSW0.8" +det_config = "" +run_config = "" +file = "" +file = file[7:] +#inputfile = batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/"+file +inputfile = batch_dir+"/"+det_config+"/"+run_config+"/output_"+file +podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) + + +from Configurables import PodioInput +podioinput = PodioInput("PodioReader", collections=["positionedCaloHits", "GenParticles"], OutputLevel=DEBUG) + +# DD4hep geometry service +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_'+det_config[:-9]+'.xml' +], + OutputLevel = INFO) + +from Configurables import RedoSegmentation +resegment = RedoSegmentation("ReSegmentation", + # old bitfield (readout) + oldReadoutName = "BarDECal_Readout", + # specify which fields are going to be deleted + oldSegmentationIds = ["x","y","z"], + # new bitfield (readout), with new segmentation + newReadoutName="BarDECal_Pads", + OutputLevel = INFO) +# clusters are needed, with deposit position and cellID in bits +resegment.inhits.Path = "positionedCaloHits" +resegment.outhits.Path = "newCaloHits" + +from Configurables import CreateCaloCells +createcells = CreateCaloCells("CreateCaloCells", + doCellCalibration = False, + addCellNoise = False, filterCellNoise = False, + OutputLevel = INFO) +createcells.hits.Path="newCaloHits" +createcells.cells.Path="newCaloCells" + +from Configurables import SiWAnalysis +hist = SiWAnalysis("SiWAnalysis", + padReadoutName = "BarDECal_Pads", + layerFieldName = "layer", + numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + OutputLevel = INFO) + +hist.deposits.Path="newCaloCells" +hist.truth.Path="GenParticles" + + + +#THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] +THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/analogue_"+file+"' TYP='ROOT' OPT='RECREATE'"] +THistSvc().PrintAll=False +THistSvc().AutoSave=True +THistSvc().AutoFlush=True +THistSvc().OutputLevel=INFO + +#CPU information +from Configurables import AuditorSvc, ChronoAuditor +chra = ChronoAuditor() +audsvc = AuditorSvc() +audsvc.Auditors = [chra] +hist.AuditExecute = True + +from Configurables import FCCDataSvc, PodioOutput +#podiosvc = FCCDataSvc("EventDataSvc") +podioout = PodioOutput("out", filename=batch_dir+"/"+det_config+"/"+run_config+"/redoSegmentation_"+file) +podioout.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [podioinput, resegment, createcells, hist],#, podioout], + EvtSel = 'NONE', + # EvtMax = 10, + # order is important, as GeoSvc is needed by G4SimSvc + ExtSvc = [podiosvc,geoservice, audsvc], + OutputLevel = INFO + +) From e627926338a2a208e8299abfaa88a96965f866e0 Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 21 Nov 2017 10:40:05 +0100 Subject: [PATCH 12/28] code which creates resolution plot from SiWAnalysis --- analyse_SiW.py | 132 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 analyse_SiW.py diff --git a/analyse_SiW.py b/analyse_SiW.py new file mode 100644 index 000000000..4f5f24316 --- /dev/null +++ b/analyse_SiW.py @@ -0,0 +1,132 @@ +from ROOT import TH1F, TTree, TChain, TFile, TF1, TCanvas, TGraphErrors, TPaveText +from array import array +import os +import numpy as np + +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +ETAMIN = -0.001 +ETAMAX = 0.001 + +RESOLUTION= {} +RESOLUTION_SIGMA = {} +LINEARITY = {} +LINEARITY_SIGMA = {} + +CONFIGS = [ c for c in os.listdir(FCCSW_DIR+"/batch_eos/") if "50Layers_3.4mmPb" in c and "Pixels" not in c] +print CONFIGS + +for CONFIG in CONFIGS: + print CONFIG + + RUNCONFIGS = [ e for e in os.listdir(FCCSW_DIR+"/batch_eos/"+CONFIG)] + for RUNCONFIG in RUNCONFIGS: + #print "\t",RUNCONFIG + + dir="batch_eos/"+CONFIG+"/"+RUNCONFIG+"/" + print "\n",dir + + chain = TChain("info") + + if os.path.isdir(dir): + + FILES = [f for f in os.listdir(dir) if "analogue" in f and "root.root" not in f] + for f in FILES: + temp_file = TFile(dir+f) + if temp_file.IsZombie(): + continue + else: + chain.Add(dir+f) + #print f + + print chain.GetEntries() + + if chain.GetEntries() > 0: + + #schain.Print() + + chain.SetBranchStatus("*",0) + chain.SetBranchStatus("edep_tot",1) # this is the number of particles per pixel summed in an event + + + truth_energy = float(RUNCONFIG[:RUNCONFIG.find("GeV")]) + temp_edep = TH1F("edep_"+str(truth_energy)+"GeV", "Energy deposited per event; Energy Deposited [keV]; Count", 2000, 0, 500000) + + for i in np.arange(0,chain.GetEntries()): + + chain.GetEntry(i) + temp_edep.Fill(chain.edep_tot); + + gaus = TF1("gaus","gaus",0,500000) + temp_edep.Fit("gaus", "NQR") + mean = gaus.GetParameter(1) + sigma = gaus.GetParameter(2) + + if mean > 0: + + RESOLUTION[str(truth_energy)] = sigma/ mean + RESOLUTION_SIGMA[str(truth_energy)] = pow(pow(gaus.GetParError(1)/gaus.GetParameter(1),2) + pow(gaus.GetParError(2)/gaus.GetParameter(2),2),0.5) * RESOLUTION[str(truth_energy)] + LINEARITY[str(truth_energy)] = mean + LINEARITY_SIGMA[str(truth_energy)] = gaus.GetParError(1) + + + print RESOLUTION + + res_plot = TGraphErrors(len(RESOLUTION), array("d",[float(x) for x in RESOLUTION.keys()]), + array("d",[float(y) for y in RESOLUTION.values()]), + array("d",[float(0.1) for xe in RESOLUTION.keys()]), + array("d",[float(ye) for ye in RESOLUTION_SIGMA.values()])) + + + lin_plot = TGraphErrors(len(LINEARITY), array("d",[float(x) for x in LINEARITY.keys()]), + array("d",[float(y) for y in LINEARITY.values()]), + array("d",[float(0.1) for xe in LINEARITY.keys()]), + array("d",[float(ye) for ye in LINEARITY_SIGMA.values()])) + + c_res = TCanvas("Resolution") + + fit_min = 0 + fit_max = 1000 + fit = TF1("fit", "[0]/sqrt(x)+[1]", fit_min, fit_max) + + res_plot.SetMarkerStyle(22); + res_plot.SetMaximum(0.08); + res_plot.SetMinimum(0.0); + res_plot.SetTitle("Resolution: 5x5mm Pads") + res_plot.GetXaxis().SetTitle("Energy [GeV]") + res_plot.GetYaxis().SetTitle("sigma_E / mu_E") + res_plot.Fit(fit, "NR") + fit.SetRange(0,1000); + + res_plot.Draw("ap") + fit.Draw("same") + + pt = TPaveText(0.55,0.55,0.8,0.85, "NDC") + pt.SetBorderSize(0) + pt.SetFillColor(0) + pt.AddText('Fit Range: {fit_min} - {fit_max} '.format(fit_min=fit_min, fit_max=fit_max)) + #pt.AddText('#frac{{{noise:.1%}}}{{{E}}} #oplus #frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit_0mm.GetParameter(0), sqrt="#sqrt{E}", leakage=fit_0mm.GetParameter(1),E="E", noise=fit_0mm.GetParameter(2))) + pt.AddText('#frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit.GetParameter(0), sqrt="#sqrt{E}", leakage=fit.GetParameter(1),E="E")) + pt.Draw() + c_res.Print("SiW_300um_resolution.png") + + lin_plot.SetMarkerStyle(22) + lin_plot.SetTitle("Linearity: ") + lin_plot.GetXaxis().SetTitle("Energy [GeV]") + lin_plot.GetYaxis().SetTitle("Energy Deposited [keV]") + lin_fit = TF1("lin_fit", "pol1", fit_min, fit_max) + lin_plot.Fit(lin_fit, "NR") + lin_fit.SetRange(0,1000) + + c_lin = TCanvas("lin_plot") + lin_plot.Draw("ap") + lin_fit.Draw("same") + pt_lin = TPaveText(0.25,0.7,0.5,0.85, "NDC") + pt_lin.SetBorderSize(0) + pt_lin.SetFillColor(0) + #pt_lin.AddText('Fit Range: {fit_min} - {fit_max} '.format(fit_min, fit_max)) + #pt_lin.AddText('{x2:.4g}x^2 #plus {x:.4g}x #plus {c:.4g} '.format(x2=lin_fit.GetParameter(2), x=lin_fit.GetParameter(1), c=lin_fit.GetParameter(0))) + #pt_lin.AddText(' {x:.4g}x #plus {c:.4g} '.format(x=lin_fit.GetParameter(1), c=lin_fit.GetParameter(0))) + #pt_lin.Draw() + c_lin.Print("SiW_300um_linearity.png") + +closeInput = raw_input("Press ENTER to exit") From 80030f6642318ab27fc6539c19ac6e0581dbae48 Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 21 Nov 2017 10:40:46 +0100 Subject: [PATCH 13/28] code which creates resoltuion plot from DECalAnalysis --- analyse_DEcal_particles.py | 257 +++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 analyse_DEcal_particles.py diff --git a/analyse_DEcal_particles.py b/analyse_DEcal_particles.py new file mode 100644 index 000000000..ffeb131a6 --- /dev/null +++ b/analyse_DEcal_particles.py @@ -0,0 +1,257 @@ +from ROOT import TH1F, TTree, TChain, TFile, TF1, TH2F, TGraphErrors, TCanvas, TPaveText +import os +import numpy as np +from array import array + + +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +ETAMIN = -0.001 +ETAMAX = 0.001 + +p0 = 3.28652e+02 +p1 = 9.89744e+01 +p2 = -1.25638e-02 + +calibration = TF1("calibration", "pol2", 0, 3000) +calibration.SetParameter("p0", p0) +calibration.SetParameter("p1", p1) +calibration.SetParameter("p2", p2) + +gaus = TF1("gaus", "gaus", 0, 3000) + +RESOLUTION_PART = {} +RESOLUTION_PART_SIGMA = {} +LINEARITY_PART = {} +LINEARITY_PART_SIGMA = {} + +RESOLUTION = {} +RESOLUTION_SIGMA = {} +LINEARITY = {} +LINEARITY_SIGMA = {} + +CONFIGS = ["50Layers_2.1mmW_FCCSW0.8"] #[ c for c in os.listdir(FCCSW_DIR+"/batch_eos/") if "50Layers_2.1mmW_50umPixels_18umThick" in c and "Edep" not in c] +print CONFIGS + +for CONFIG in CONFIGS: + print CONFIG + + fout = TFile(CONFIG+".root", "RECREATE") + fout.cd() + partperpixvspix = TH2F("partperpixvspix", ";Pixels per event;Particles / Pixel; Count", 2000,0,120000,100, 0.8,1.4) + + RUNCONFIGS = [ e for e in os.listdir(FCCSW_DIR+"/batch_eos/"+CONFIG) ] + for RUNCONFIG in RUNCONFIGS: + #print "\t",RUNCONFIG + + dir="batch_eos/"+CONFIG+"/"+RUNCONFIG+"/" + #print "\n",dir + + chain = TChain("decal_info") + + if os.path.isdir(dir): + + FILES = [f for f in os.listdir(dir) if "analysis_" in f and "root.root" not in f] + for f in FILES: + temp_file = TFile(dir+f) + if temp_file.IsZombie(): + continue + else: + chain.Add(dir+f) + + if chain.GetEntries() > 0: + + #schain.Print() + + chain.SetBranchStatus("*",0) + chain.SetBranchStatus("particles_tot",1) # this is the number of particles per pixel summed in an event + chain.SetBranchStatus("pixels_tot",1) + chain.SetBranchStatus("particles_l*", 1) + chain.SetBranchStatus("pixels_l*",1) + + truth_energy = float(RUNCONFIG[:RUNCONFIG.find("GeV")]) + + temp_energy = TH1F("energy_"+str(truth_energy)+"GeV", "Reconstructed energy from pol2; E_{truth}; E_{reco}", 2000, 0, 1200) + temp_particles = TH1F("particles_"+str(truth_energy)+"GeV", "Particles per event; Particles per event; Count", 2000, 0, 120000)#20) + temp_pixels = TH1F("pixels_"+str(truth_energy)+"GeV", "Pixels per event; Pixels per event; Count", 2000, 0, 120000) + temp_partvspix = TH2F("partvspix_"+str(truth_energy)+"GeV", ";Pixels per event; Particles per event", 2000,0,120000,2000,0,120000) + temp_partperpix = TH1F("partperpix_"+str(truth_energy)+"GeV", ";Particles / Pixel; Count", 100, 0.8, 1.4) + temp_partperpixvspix = TH2F("partperpixvspix_"+str(truth_energy)+"GeV", ";Pixels per event;Particles / Pixel; Count", 2000,0,120000,100, 0.8, 1.4) + + for i in np.arange(0,chain.GetEntries()): + + chain.GetEntry(i) + pixels_tot = chain.pixels_tot + particles_tot = chain.particles_tot + + temp_particles.Fill(particles_tot) + temp_pixels.Fill(pixels_tot) + temp_partvspix.Fill(pixels_tot,particles_tot) + temp_partperpix.Fill(particles_tot/pixels_tot) + temp_partperpixvspix.Fill(pixels_tot, particles_tot/pixels_tot) + partperpixvspix.Fill(pixels_tot, particles_tot/pixels_tot) + + energy = calibration.GetX(pixels_tot) + temp_energy.Fill(energy) + + #loop through the layers to get particles / pixel + + + #if i == 0 or i%100==0: + # print i, "/", chain.GetEntries() + # print "\t", pixels_tot, energy + + + #temp_partperpix.Draw("") + #temp_ereco.Fit("gaus","N") + + fout.cd() + + # fit info for the particles + gaus.SetRange(0,120000) + temp_particles.Fit("gaus", "NQR") + temp_particles.Write() + mean_particles = gaus.GetParameter(1) + sigma_particles = gaus.GetParameter(2) + + if mean_particles > 0: + + RESOLUTION_PART[str(truth_energy)] = sigma_particles/ mean_particles + RESOLUTION_PART_SIGMA[str(truth_energy)] = pow(pow(gaus.GetParError(1)/gaus.GetParameter(1),2) + pow(gaus.GetParError(2)/gaus.GetParameter(2),2),0.5) * RESOLUTION_PART[str(truth_energy)] + LINEARITY_PART[str(truth_energy)] = mean_particles + LINEARITY_PART_SIGMA[str(truth_energy)] = gaus.GetParError(1) + + # fit info for the pixels + gaus.SetRange(0,120000) + temp_pixels.Fit("gaus", "NQR") + temp_pixels.Write() + mean_pixels = gaus.GetParameter(1) + sigma_pixels = gaus.GetParameter(2) + + if mean_pixels > 0: + + RESOLUTION[str(truth_energy)] = sigma_pixels/ mean_pixels + RESOLUTION_SIGMA[str(truth_energy)] = pow(pow(gaus.GetParError(1)/gaus.GetParameter(1),2) + pow(gaus.GetParError(2)/gaus.GetParameter(2),2),0.5) * RESOLUTION[str(truth_energy)] + LINEARITY[str(truth_energy)] = mean_pixels + LINEARITY_SIGMA[str(truth_energy)] = gaus.GetParError(1) + + # fit info for the calibrated energy + gaus.SetRange(0,3000) + temp_energy.Fit("gaus", "NQR") + temp_energy.Write() + mean_ereco = gaus.GetParameter(1) + sigma_ereco = gaus.GetParameter(2) + + temp_partperpix.Write() + temp_partvspix.Write() + temp_partperpixvspix.Write() + + if mean_particles > 0: + + print "\n\nTruth Energy = ", truth_energy + print "nEvts = ", chain.GetEntries() + print "Particles = ", mean_particles, "+/-", sigma_particles + print "Pixels = ", mean_pixels, "+/-", sigma_pixels + print "Ereco = ", mean_ereco, "+/-", sigma_ereco + # print "Reco Energy = ", mean, "+/-", sigma + # print "Resolution = ", sigma/mean + + + + partperpixvspix.Write() + + res_plot = TGraphErrors(len(RESOLUTION), array("d",[float(x) for x in RESOLUTION.keys()]), + array("d",[float(y) for y in RESOLUTION.values()]), + array("d",[float(0.1) for xe in RESOLUTION.keys()]), + array("d",[float(ye) for ye in RESOLUTION_SIGMA.values()])) + + res_part_plot = TGraphErrors(len(RESOLUTION_PART), array("d",[float(x) for x in RESOLUTION_PART.keys()]), + array("d",[float(y) for y in RESOLUTION_PART.values()]), + array("d",[float(0.1) for xe in RESOLUTION_PART.keys()]), + array("d",[float(ye) for ye in RESOLUTION_PART_SIGMA.values()])) + + lin_plot = TGraphErrors(len(LINEARITY), array("d",[float(x) for x in LINEARITY.keys()]), + array("d",[float(y) for y in LINEARITY.values()]), + array("d",[float(0.1) for xe in LINEARITY.keys()]), + array("d",[float(ye) for ye in LINEARITY_SIGMA.values()])) + + + lin_part_plot = TGraphErrors(len(LINEARITY_PART), array("d",[float(x) for x in LINEARITY_PART.keys()]), + array("d",[float(y) for y in LINEARITY_PART.values()]), + array("d",[float(0.1) for xe in LINEARITY_PART.keys()]), + array("d",[float(ye) for ye in LINEARITY_PART_SIGMA.values()])) + + + c_res = TCanvas("Resolution") + + fit_min = 0 + fit_max = 300 + fit = TF1("fit", "[0]/sqrt(x)+[1]", fit_min, fit_max) + fit_part = TF1("fit_part", "[0]/sqrt(x)+[1]", fit_min, 1000) + + res_plot.SetMarkerStyle(22); + res_plot.SetMaximum(0.08); + res_plot.SetMinimum(0.0); + res_plot.SetTitle("Resolution: 50um Pixels") + res_plot.GetXaxis().SetTitle("Energy [GeV]") + res_plot.GetYaxis().SetTitle("sigma_N / mu_N") + res_plot.Fit(fit, "NR") + fit.SetRange(0,1000); + + res_part_plot.SetMarkerStyle(23); + res_part_plot.SetTitle("Resolution: Particles") + res_part_plot.GetXaxis().SetTitle("Energy [GeV]") + res_part_plot.GetYaxis().SetTitle("sigma_N / mu_N") + res_part_plot.Fit(fit_part, "NR") + fit_part.SetRange(0,1000); + + res_part_plot.Draw("ap") + fit_part.Draw("same") + res_plot.Draw("p") + fit.Draw("same") + + pt = TPaveText(0.55,0.55,0.8,0.85, "NDC") + pt.SetBorderSize(0) + pt.SetFillColor(0) + pt.AddText('Fit Range: {fit_min} - {fit_max} '.format(fit_min=fit_min, fit_max=fit_max)) + pt.AddText('#frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit_part.GetParameter(0), sqrt="#sqrt{E}", leakage=fit_part.GetParameter(1),E="E")) + #pt.AddText('#frac{{{noise:.1%}}}{{{E}}} #oplus #frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit_0mm.GetParameter(0), sqrt="#sqrt{E}", leakage=fit_0mm.GetParameter(1),E="E", noise=fit_0mm.GetParameter(2))) + pt.AddText('#frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit.GetParameter(0), sqrt="#sqrt{E}", leakage=fit.GetParameter(1),E="E")) + pt.Draw() + c_res.Print("DECal_resolution.png") + + lin_plot.SetMarkerStyle(22) + lin_plot.SetTitle("Linearity: ") + lin_plot.GetXaxis().SetTitle("Energy [GeV]") + lin_plot.GetYaxis().SetTitle("Mean particles per event") + lin_fit = TF1("lin_fit", "pol1", fit_min, fit_max) + lin_plot.Fit(lin_fit, "NR") + lin_fit.SetRange(0,1000) + + lin_part_plot.SetMarkerStyle(23) + lin_part_plot.SetTitle("Linearity: ") + lin_part_plot.GetXaxis().SetTitle("Energy [GeV]") + lin_part_plot.GetYaxis().SetTitle("Mean particles per event") + lin_part_fit = TF1("lin_part_fit", "pol1", fit_min, fit_max) + lin_part_plot.Fit(lin_part_fit, "NR") + lin_part_fit.SetRange(0,1000) + + c_lin = TCanvas("lin_plot") + lin_part_plot.Draw("ap") + lin_part_fit.Draw("same") + lin_plot.Draw("p") + lin_fit.Draw("same") + pt_lin = TPaveText(0.25,0.7,0.5,0.85, "NDC") + pt_lin.SetBorderSize(0) + pt_lin.SetFillColor(0) + #pt_lin.AddText('Fit Range: {fit_min} - {fit_max} '.format(fit_min, fit_max)) + #pt_lin.AddText('{x2:.4g}x^2 #plus {x:.4g}x #plus {c:.4g} '.format(x2=lin_fit.GetParameter(2), x=lin_fit.GetParameter(1), c=lin_fit.GetParameter(0))) + #pt_lin.AddText(' {x:.4g}x #plus {c:.4g} '.format(x=lin_fit.GetParameter(1), c=lin_fit.GetParameter(0))) + pt_lin.Draw() + c_lin.Print("DEcal_linearity.png") + + res_plot.Write() + lin_plot.Write() + fout.Write() + fout.Close() + +closeInput = raw_input("Press ENTER to exit") From 12bb45c2ee6fe3ef4d00b7d1bdddc81f3ad34d7c Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 21 Nov 2017 10:41:20 +0100 Subject: [PATCH 14/28] code to submit analogue analysis to lxbatch --- submit_SiWAnalysis.py | 86 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 submit_SiWAnalysis.py diff --git a/submit_SiWAnalysis.py b/submit_SiWAnalysis.py new file mode 100644 index 000000000..3aa4e01de --- /dev/null +++ b/submit_SiWAnalysis.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +import os, re +import commands +import math, time +import sys + +print +print 'START' +print +######## YOU ONLY NEED TO FILL THE AREA BELOW ######### +######## customization area ######### +CONFIG="50Layers_3.4mmPb_450um" +FCCSW_VERSION="FCCSW0.8" +BFIELD = "4" +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +queue = "1nh" +######## customization end ######### + +path = os.getcwd() + +##### loop for creating and sending jobs ##### +#e = 100 +CONFIGS = os.listdir(FCCSW_DIR+"/batch_eos/") +CONFIGS = [ c for c in CONFIGS if CONFIG in c and "300" not in c and "Pixels" not in c] +#for e in ENERGIES: +for CONFIG in CONFIGS: + print CONFIG + for RUNCONFIG in os.listdir(FCCSW_DIR+"/batch_eos/"+CONFIG): + ##### creates directory and file list for job ####### + #RUNCONFIG=str(e)+"GeV_BFIELD"+str(BFIELD)+"T_ETAMIN"+str(ETAMIN)+"_ETAMAX"+str(ETAMAX) + # dir="batch_eos/"+CONFIG+"_"+FCCSW_VERSION+"/"+RUNCONFIG + dir="batch_eos/"+CONFIG+"/"+RUNCONFIG + print dir + + if os.path.isdir(dir): + + files = [ f for f in os.listdir(dir) if "output" in f] + print files + + os.chdir(dir) + + for f in files: + #print "hist_"+f[7:] + #os.chdir(dir) + #os.system('pwd') + #os.system('cp -v '+FCCSW_DIR+'/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal_batch.py run.py') + #os.system("sed -i 's//"+str(CONFIG)+"/' run.py") + #os.system("sed -i 's//"+str(RUNCONFIG)+"/' run.py") + #os.system("sed -i 's//"+f+"/' run.py") + #os.system("sed -i 's//hist_"+f[7:]+"/' run.py") + #os.chdir(path) + #os.system("./run gaudirun.py "+dir+"/run.py") + N = f[f.find("4T")+3:f.find(".root")] + if len(N) == 0: + N = 0 + continue + print f + + with open('analyse'+str(N)+'.sh', 'w') as fout: + fout.write("#!/bin/sh\n") + fout.write("echo\n") + fout.write("echo 'START---------------'\n") + fout.write("echo 'WORKDIR ' ${PWD}\n") + + fout.write('cp -v '+FCCSW_DIR+'/Detector/DetStudies/tests/options/SiWAnalysis_batch.py ana.py\n') + fout.write("sed -i 's//"+str(CONFIG)+"/' ana.py\n") + fout.write("sed -i 's//"+str(RUNCONFIG)+"/' ana.py\n") + fout.write("sed -i 's//"+f+"/' ana.py\n") + fout.write("sed -i 's//analysis_"+f[7:]+"/' ana.py\n") + fout.write("echo\n") + fout.write("cat ana.py\n") + fout.write("echo\n") + fout.write("source "+FCCSW_DIR+"init.sh\n") + fout.write(FCCSW_DIR+"run gaudirun.py ana.py\n") + fout.write("echo 'STOP---------------'\n") + fout.write("echo\n") + fout.write("cp -v *.root "+path+"/"+dir+"\n") + fout.write("echo\n") + + + os.system("chmod 755 analyse"+str(N)+".sh") + os.system("bsub -q "+queue+" analyse"+str(N)+".sh") + + os.chdir(path) + + From 5b427447df5a1eab0f897c59c423acf112765992 Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 21 Nov 2017 10:46:40 +0100 Subject: [PATCH 15/28] Previous commit did not take into account changes to pre-existing code --- .../options/redoSegmentationXYZ_DEcal.py | 30 +- ...hh_DECalBarrel_50Layers_2.1mmW_300umSi.xml | 7 + ...l_50Layers_2.1mmW_50umPixels_18umThick.xml | 17 +- .../FCChh_DECalDefinition_50Layers_2.1mmW.xml | 2 +- .../src/ECalBarrel_geo.cpp | 58 +- .../DetSensitive/DigitalCalorimeterSD.h | 4 +- .../DetSensitive/src/DigitalCalorimeterSD.cpp | 310 +++++------ .../src/components/DECalAnalysis.cpp | 61 ++- .../DetStudies/src/components/DECalAnalysis.h | 12 + .../src/components/DECalLongitudinalTest.cpp | 152 +++--- .../src/components/DECalLongitudinalTest.h | 47 +- .../options/decalAnalysis_DEcal_batch.py | 3 +- .../options/longitudinalAnalysis_DEcal.py | 9 +- .../src/components/CreateCaloCells.cpp | 2 +- Sim/SimG4Components/src/SimG4SaveCalHits.cpp | 7 + analyseDataSet.py | 513 ------------------ analysePads.py | 27 - calculate_nonLinFactor.py | 25 +- geant_batch_temp.py | 53 +- geant_fullsim_ecal_SPG_new.py | 34 +- init.sh | 3 + makeMIPSPerPixelPlot.py | 42 -- makeMultiplicityResolutionPlot.py | 86 --- make_resolution_digital.py | 12 - submit_decalAnalysis.py | 21 +- submit_energy_res_to_lxbatch.py | 77 +-- 26 files changed, 546 insertions(+), 1068 deletions(-) delete mode 100644 analyseDataSet.py delete mode 100644 analysePads.py delete mode 100644 makeMIPSPerPixelPlot.py delete mode 100644 makeMultiplicityResolutionPlot.py delete mode 100644 make_resolution_digital.py diff --git a/Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py b/Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py index cf8bfbf57..2638a7db8 100644 --- a/Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py +++ b/Detector/DetComponents/tests/options/redoSegmentationXYZ_DEcal.py @@ -2,7 +2,7 @@ from Configurables import ApplicationMgr from Configurables import FCCDataSvc -inputfile = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/batch/50Layers_2.1mmW_1mmAir_50umPixels_18umThick_FCCSW0.8pre/1PILEUPEVENTS_BFIELD1/output.root" +inputfile = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/batch_eos/50Layers_2.1mmW_50umPixels_18umThick_FCCSW0.8/100GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001/output_100GeV_BFIELD4T_1.root" podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) from Configurables import PodioInput @@ -10,7 +10,7 @@ from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', - 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml' + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml' ], OutputLevel = DEBUG) @@ -24,24 +24,38 @@ newReadoutName="BarDECal_Pads", OutputLevel = DEBUG) # clusters are needed, with deposit position and cellID in bits -resegment.DataInputs.inhits.Path = "positionedCaloHits" -resegment.DataOutputs.outhits.Path = "newCaloHits" +resegment.inhits.Path = "positionedCaloHits" +resegment.outhits.Path = "newCaloHits" from Configurables import CreateCaloCells createcells = CreateCaloCells("CreateCaloCells", doCellCalibration = False, addCellNoise = False, filterCellNoise = False, OutputLevel = DEBUG) -createcells.DataInputs.hits.Path="newCaloHits" -createcells.DataOutputs.cells.Path="newCaloCells" +createcells.hits.Path="newCaloHits" +createcells.cells.Path="newCaloCells" + +from Configurables import DECalLongitudinalTest +hist = DECalLongitudinalTest("hists", + readoutName = "BarDECal_Readout", + layerFieldName = "layer", + numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + OutputLevel = DEBUG) +hist.deposits.Path="positionedCaloHits" + +THistSvc().Output = ["rec DATAFILE='./hist_test.root' TYP='ROOT' OPT='RECREATE'"] +THistSvc().PrintAll=True +THistSvc().AutoSave=True +THistSvc().AutoFlush=False +THistSvc().OutputLevel=INFO from Configurables import FCCDataSvc, PodioOutput #podiosvc = FCCDataSvc("EventDataSvc") -podioout = PodioOutput("out", filename="testResegmentationXYZ.root") +podioout = PodioOutput("out", filename="/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/batch_eos/50Layers_2.1mmW_50umPixels_18umThick_FCCSW0.8/100GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001/testResegmentationXYZ_100GeV.root") podioout.outputCommands = ["keep *"] ApplicationMgr(EvtSel='NONE', EvtMax=5000, - TopAlg=[podioinput, resegment, createcells, podioout], + TopAlg=[podioinput, resegment, createcells,hist, podioout], ExtSvc = [podiosvc, geoservice], OutputLevel=DEBUG) diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml index 6cd6d5048..988a722df 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml @@ -41,6 +41,13 @@ system:3,active:1,EM_barrel:1,layer:6,x:-18,y:-18,z:-17 + + + + + system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml index f8dbfa021..bb55888b1 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml @@ -18,7 +18,7 @@ - + @@ -30,17 +30,20 @@ - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + + system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 + + - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 + system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11 + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml new file mode 100755 index 000000000..e3b27be7b --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml @@ -0,0 +1,70 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11 + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetStudies/src/components/FilterSiliconEcalHits.cpp b/Detector/DetStudies/src/components/FilterSiliconEcalHits.cpp new file mode 100644 index 000000000..b52141875 --- /dev/null +++ b/Detector/DetStudies/src/components/FilterSiliconEcalHits.cpp @@ -0,0 +1,107 @@ + +#include "FilterSiliconEcalHits.h" + +// FCCSW +#include "DetInterface/IGeoSvc.h" + +// datamodel +#include "datamodel/PositionedCaloHitCollection.h" +#include "datamodel/CaloHitCollection.h" +#include "datamodel/MCParticleCollection.h" + +#include "CLHEP/Vector/ThreeVector.h" +#include "GaudiKernel/ITHistSvc.h" +#include "TH1F.h" +#include "TVector2.h" +#include "TMath.h" +#include "TString.h" +#include "string" + +// DD4hep +#include "DD4hep/LCDD.h" +#include "DD4hep/Readout.h" + +DECLARE_ALGORITHM_FACTORY(FilterSiliconEcalHits) + +FilterSiliconEcalHits::FilterSiliconEcalHits(const std::string& aName, ISvcLocator* aSvcLoc) + : GaudiAlgorithm(aName, aSvcLoc), + m_histSvc("THistSvc", "FilterSiliconEcalHits"), + m_geoSvc("GeoSvc", "FilterSiliconEcalHits") +{ + declareProperty("deposits", m_deposits, "Energy deposits in sampling calorimeter (input)"); + declareProperty("filtered", m_filtered, "Filtered energy deposits (output)"); + +} +FilterSiliconEcalHits::~FilterSiliconEcalHits() {} + +StatusCode FilterSiliconEcalHits::initialize() { + if (GaudiAlgorithm::initialize().isFailure()) { + return StatusCode::FAILURE; + } + // check if readouts exist + if (m_geoSvc->lcdd()->readouts().find(m_padReadoutName) == m_geoSvc->lcdd()->readouts().end()) { + error() << "Readout <<" << m_padReadoutName << ">> does not exist." << endmsg; + return StatusCode::FAILURE; + } + + // if it gets to here then it has registered all histograms + return StatusCode::SUCCESS; +} + +StatusCode FilterSiliconEcalHits::execute() { + // get the decoder for the readout + // this will allow to extract layers etc. + auto decoder = m_geoSvc->lcdd()->readout(m_padReadoutName).idSpec().decoder(); + + // added a little print out to ensure it is still working + if(m_EvtNumber < 10 or m_EvtNumber % 100 == 0) { + info() << "Event Number " << m_EvtNumber << endmsg; + } + + + // set some variables to hold information for an event + int nFilteredHits = 0; + + const auto deposits = m_deposits.get(); + auto filtered = m_filtered.createAndPut(); + + // if looking at digital need to threshold at this point so the merging of cells takes correct deposits + // the analgoue we can keep all hits and sum at a later date + // eventually this will be passed as a parameter but coding quickly now + double m_threshold = 0; + if(m_digitalFlag==1) { + m_threshold = 480*0.0000000036; + } + + for (const auto& hit : *deposits) { + decoder->setValue(hit.core().cellId); + int digital = (*decoder)["digital"]; + if(digital==m_digitalFlag) { + nFilteredHits++; + + if(hit.energy()>m_threshold) { + fcc::PositionedCaloHit filteredHit = filtered->create(); + filteredHit.energy(hit.energy()); + filteredHit.time(hit.time()); + filteredHit.cellId(hit.cellId()); + filteredHit.bits(hit.bits()); + filteredHit.position(hit.position()); + } + } + + } + + info() << "nFilteredHits = " << nFilteredHits << endmsg; + + m_EvtNumber++; + + return StatusCode::SUCCESS; +} + +StatusCode FilterSiliconEcalHits::finalize() { + debug() << "StatusCode FilterSiliconEcalHits::finalize()" << endmsg; + + +return GaudiAlgorithm::finalize(); } + + diff --git a/Detector/DetStudies/src/components/FilterSiliconEcalHits.h b/Detector/DetStudies/src/components/FilterSiliconEcalHits.h new file mode 100644 index 000000000..7d7bc6f93 --- /dev/null +++ b/Detector/DetStudies/src/components/FilterSiliconEcalHits.h @@ -0,0 +1,70 @@ +#ifndef DETSTUDIES_FilterSiliconEcalHits_H +#define DETSTUDIES_FilterSiliconEcalHits_H + +// GAUDI +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ServiceHandle.h" + +// FCCSW +#include "FWCore/DataHandle.h" +#include "TH2F.h" +#include "TTree.h" +#include "TF1.h" +#include "TProfile.h" + +class IGeoSvc; + +// datamodel +namespace fcc { +class PositionedCaloHitCollection; +} + +class ITHistSvc; +/** @class DECalAnalysis DECalAnalysis.h + * + * Histograms of energy deposited in active material and total energy deposited in the calorimeter. + * Passive material needs to be marked as sensitive. It needs to be divided into layers (cells) as active material. + * Layers (cells) are numbered starting at 1 so that energy depoisted in cryostat and bath could be easily recognised. + * Sampling fraction is calculated for each layer as the ratio of energy deposited in active material to energy + * deposited in the layer (also in passive material). + * + * @author Anna Zaborowska + */ + +class FilterSiliconEcalHits : public GaudiAlgorithm { +public: + explicit FilterSiliconEcalHits(const std::string&, ISvcLocator*); + virtual ~FilterSiliconEcalHits(); + /** Initialize. + * @return status code + */ + virtual StatusCode initialize() final; + /** Fills the histograms. + * @return status code + */ + virtual StatusCode execute() final; + /** Finalize. + * @return status code + */ + virtual StatusCode finalize() final; + + +private: + /// Pointer to the interface of histogram service + ServiceHandle m_histSvc; + /// Pointer to the geometry service + ServiceHandle m_geoSvc; + + /// The Pixel analysis + /// Handle for the energy deposits + DataHandle m_deposits{"rec/deposits", Gaudi::DataHandle::Reader, this}; + DataHandle m_filtered{"rec/filtered", Gaudi::DataHandle::Writer, this}; + /// Name of the detector readout + Gaudi::Property m_padReadoutName{this, "readoutName", "", "Name of the detector readout"}; + + Gaudi::Property m_digitalFlag{this, "digitalFlag", 0, "If 1 then filter for digital hits, 0 filter for analgoue hits"}; + + int m_EvtNumber; + +}; +#endif /* DETSTUDIES_FilterSiliconEcalHits_H */ diff --git a/Test/TestGeometry/data/TestDECal_segmentation.xml b/Test/TestGeometry/data/TestDECal_segmentation.xml new file mode 100644 index 000000000..32111e7b0 --- /dev/null +++ b/Test/TestGeometry/data/TestDECal_segmentation.xml @@ -0,0 +1,52 @@ + + + + + + + + + + Simple box to test dd4hep geometry (and segmentation) + + + + + + + + + + + + + + + + + + + + + z:-4,y:-4,x:-4,system:1 + + + + + + + + + + + + + + From 2f7de76c1e41c265315d92722a7077b8db504bdd Mon Sep 17 00:00:00 2001 From: tonypba Date: Wed, 28 Feb 2018 13:27:45 +0100 Subject: [PATCH 18/28] added many things.... --- .../DetComponents/src/RedoSegmentation.cpp | 18 +- Detector/DetComponents/src/RedoSegmentation.h | 2 - ...Layers_3.5mmW_50umPixels_18umThick_RRB.xml | 70 +++ .../src/ECalBarrel_geo.cpp | 528 ++++++++++++++++-- .../DetSensitive/src/DigitalCalorimeterSD.cpp | 5 +- .../src/components/DECalAnalysis.cpp | 9 +- .../DetStudies/src/components/SiWAnalysis.cpp | 12 +- .../tests/options/SiWAnalysis_batch.py | 19 +- .../tests/options/decalAnalysis_DEcal.py | 33 +- .../options/decalAnalysis_DEcal_batch.py | 34 +- .../options/longitudinalAnalysis_DEcal.py | 10 +- .../src/components/CreateCaloCells.cpp | 8 +- .../src/components/CreateCaloCells.h | 5 +- .../tests/options/testcellcountingXYZ.py | 17 +- analyse_DEcal_particles.py | 4 +- analyse_SiW.py | 8 +- submit_SiWAnalysis.py | 6 +- submit_decalAnalysis.py | 6 +- submit_energy_res_to_lxbatch.py | 8 +- 19 files changed, 655 insertions(+), 147 deletions(-) create mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml diff --git a/Detector/DetComponents/src/RedoSegmentation.cpp b/Detector/DetComponents/src/RedoSegmentation.cpp index 62e425e72..789b67881 100644 --- a/Detector/DetComponents/src/RedoSegmentation.cpp +++ b/Detector/DetComponents/src/RedoSegmentation.cpp @@ -85,25 +85,16 @@ StatusCode RedoSegmentation::execute() { // cellID contains the volumeID that needs to be copied to the new id uint64_t oldid = 0; uint debugIter = 0; + + int nhits = 0; for (const auto& hit : *inHits) { -// By Tony 22/11/2017 - // move the Decoder early on so could separate digital flag from SiW Calo work. - // if it doesnt match the type we want then it continues - m_oldDecoder->setValue(hit.cellId()); - // if the string is empty (default value) ignore this to ensure any segmentation without "digital" field still works - if(m_digitalBitName != "") { - int digital = (*m_oldDecoder)[m_digitalBitName]; - // if the digital flag does not match the equest in digitalType then continue - if(digital != m_digitalFlag) { - continue; - } - } - fcc::CaloHit newHit = outHits->create(); newHit.energy(hit.energy()); newHit.time(hit.time()); + + nhits++; if (debugIter < m_debugPrint) { debug() << "OLD: " << m_oldDecoder->valueString() << endmsg; @@ -124,6 +115,7 @@ StatusCode RedoSegmentation::execute() { debugIter++; } } + info() << "nhits = " << nhits << endmsg; return StatusCode::SUCCESS; } diff --git a/Detector/DetComponents/src/RedoSegmentation.h b/Detector/DetComponents/src/RedoSegmentation.h index 67bbc2eb2..57f19ae48 100644 --- a/Detector/DetComponents/src/RedoSegmentation.h +++ b/Detector/DetComponents/src/RedoSegmentation.h @@ -84,7 +84,5 @@ class RedoSegmentation : public GaudiAlgorithm { /// Limit of debug printing Gaudi::Property m_debugPrint{this, "debugPrint", 10, "Limit of debug printing"}; - Gaudi::Property m_digitalBitName{this, "digitalBitName", "", "Field name for extracting DECal digital hits"}; - Gaudi::Property m_digitalFlag{this, "digitalFlag", 0, "Set to 1 to extract digital, 0 for analogue output"}; }; #endif /* DETCOMPONENTS_REDOSEGMENTATION_H */ diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml new file mode 100644 index 000000000..f4d6965bd --- /dev/null +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml @@ -0,0 +1,70 @@ + + + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,x:-17,y:-17,z:-14 + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,x:-15,y:-15,z:-18 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp index 86926d0d0..d918dbde1 100644 --- a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -1,5 +1,9 @@ // DD4hep includes #include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Shapes.h" +#include "DD4hep/Objects.h" + +#include "XML/XMLElements.h" // Gaudi #include "GaudiKernel/ServiceHandle.h" @@ -8,10 +12,23 @@ #include "cmath" +/*ROBBIE +using namespace std; +using namespace dd4hep; +using namespace dd4hep::detail;*/ using DD4hep::Geometry::Volume; using DD4hep::Geometry::DetElement; using DD4hep::XML::Dimension; using DD4hep::Geometry::PlacedVolume; +using DD4hep::Geometry::Trapezoid; +using DD4hep::_toString; +using DD4hep::Geometry::Position; +using DD4hep::Geometry::Box; +using DD4hep::Geometry::Transform3D; +using DD4hep::Geometry::RotationZYX; +using DD4hep::Geometry::Translation3D; + + namespace det { @@ -25,14 +42,16 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm lLog << MSG::DEBUG << "++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endmsg; lLog << MSG::DEBUG << "\t\t\t Building DECAL " << endmsg; lLog << MSG::DEBUG << " +++++++++++++++++++++++++++++++++++++++++++++++++++++" << endmsg; - + + // Getting the detectors various values from the xml file + xml_det_t xmlDet = xmlElement; std::string detName = xmlDet.nameStr(); //Make DetElement DetElement eCal(detName, xmlDet.id()); - + xml_comp_t calo = xmlElement.child(_Unicode(calorimeter)); Dimension calo_dims(calo.dimensions()); std::string calo_name=calo.nameStr(); @@ -62,7 +81,12 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm // here we take the fabs value of padding as if it is negative it goes before the W volume double module_tck = active_tck+substrate_tck+passive_tck+std::fabs(padding_tck); double calo_tck=(active_samples*module_tck) + trkr_tck; - + + //ROBBIE introduce number of staves, modules from the xml file: + int nStaves = calo_dims.numsides(); + int nModules = calo_dims.nmodules(); + int testing = 1; + lLog << MSG::INFO << "Tracker Material Thickness = " << trkr_tck << endmsg; lLog << MSG::INFO << "ECAL Epitaxial Thickness = " << active_tck << endmsg; @@ -74,20 +98,24 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm lLog << MSG::INFO << "nSamplings Layers = " << active_samples << endmsg; lLog << MSG::INFO << "Total Calorimeter thickness = " << calo_tck << endmsg; + //ROBBIE log number of staves/modules in the log file: + lLog << MSG::INFO << "nStaves = " << nStaves << endmsg; + lLog << MSG::INFO << "nModules = " << nModules << endmsg; + // Make volume that envelopes the whole barrel; set material to air Dimension dimensions(xmlDet.dimensions()); - //DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz()); - DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmin()+calo_tck, dimensions.dz()); + DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz()); + //DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmin()+calo_tck, dimensions.dz()); Volume envelopeVolume(detName, envelopeShape, lcdd.air()); // Invisibility seems to be broken in visualisation tags, have to hardcode that std::cout << "dimensions.visStr() = " << dimensions.visStr()<< std::endl; envelopeVolume.setVisAttributes(lcdd, dimensions.visStr()); - // create a lump of air the entire size of the barrel ECAL + // create a lump of air the entire size of the barrel ECAL (Cylindrical) // place it within the ECAL envelope DetElement caloDet(calo_name, calo_id); - DD4hep::Geometry::Tube caloShape(calo_dims.rmin() , calo_dims.rmin()+calo_tck, calo_dims.dz()); - lLog << MSG::DEBUG << "ECAL: Building the calorimeter from " << calo_dims.rmin() << " to " << calo_dims.rmin()+calo_tck << endmsg; + DD4hep::Geometry::Tube caloShape(calo_dims.rmin() , /*calo_dims.rmin()+calo_tck*/calo_dims.rmax(), calo_dims.dz()); + lLog << MSG::INFO/*DEBUG*/ << "ECAL: Building the calorimeter from " << calo_dims.rmin() << " to " << /*calo_dims.rmin()+calo_tck*/calo_dims.rmax() << endmsg; Volume caloVolume(padding_mat, caloShape, lcdd.material(padding_mat)); lLog << MSG::DEBUG << "ECAL: Filling the calorimeter volume with " << padding_mat << endmsg; PlacedVolume placedCalo = envelopeVolume.placeVolume(caloVolume); @@ -109,6 +137,8 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm trkrLayer.setPlacement(placedTrkrLayer); } + + // START OF TONY's STUFF // Calorimeter runs // 1) epitaxial // 2) substrate @@ -131,59 +161,443 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm // | I | B | R | S | I | B | R | S | ... | I | B | R | S | // | | | | | | | | | ... | | | | | - // loop on the sensitive and substrate layers and place within the caloVolume - int l=1; - for (int i=0;i= 0 then need to add in the thickness of the air gap: + if(!(padding_tck < 0)) + { + s_pos_z -= padding_tck; + } + + /*PlacedVolume layer_phv = trap_vol.placeVolume(l_vol, l_pos); + lLog << MSG::INFO << "Placing Layer at " << "(0, 0, " << l_pos_z + l_thickness/2 << ")" << endmsg; + lLog << MSG::INFO << "Layer = " << layernum << endmsg; + if (layernum == 30) { + lLog << MSG::INFO << "PROBLEM! layernum IS TOO DAMN HIGH! IT SHOULD NEVER REACH " << layernum << "!" << endmsg; + }*/ + //lLog << MSG::INFO << "LAYER information dump : " << layer_phv.toString() << endmsg; + //layer_phv.addPhysVolID("layer", layernum); + //layer.setPlacement(layer_phv); + // l_pos_z += l_thickness; + // ++l_num; + + } + + + //ROBBIE Create an overall volume by repeating the trapezium nStaves times + + // double phi = M_PI / nStaves; + // double dphi = 2*phi; + // double mod_y_off = rmin + trd_y; + // lLog << MSG::INFO << "mod_y_off is " << mod_y_off << endmsg; + + + // for (int i=0; i mipsPerPixel[50]; @@ -204,7 +205,7 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { } // if the energy deposited in the cellID is gtreather than threshold then do something - if((*it).second.second->energyDeposit>threshold) { + if((*it).second.second->energyDeposit>=threshold) { pixelsOverThreshold++; // insert the collection to G4 so can be passed on later digi = dynamic_cast ((*it).second.second); diff --git a/Detector/DetStudies/src/components/DECalAnalysis.cpp b/Detector/DetStudies/src/components/DECalAnalysis.cpp index ef1eafdc2..6087708be 100644 --- a/Detector/DetStudies/src/components/DECalAnalysis.cpp +++ b/Detector/DetStudies/src/components/DECalAnalysis.cpp @@ -248,14 +248,7 @@ StatusCode DECalAnalysis::execute() { const auto deposits = m_deposits.get(); for (const auto& hit : *deposits) { decoder->setValue(hit.core().cellId); - int digital = (*decoder)["digital"]; - if(digital==1) { - isdigital++; - } - if(digital==0) { - notdigital++; - continue; - } + // std::cout << digital << std::endl; int layer = (*decoder)[m_layerFieldName]; m_sumPixelsLayers[layer] += 1; diff --git a/Detector/DetStudies/src/components/SiWAnalysis.cpp b/Detector/DetStudies/src/components/SiWAnalysis.cpp index 6aefa3c2b..1fccdd783 100644 --- a/Detector/DetStudies/src/components/SiWAnalysis.cpp +++ b/Detector/DetStudies/src/components/SiWAnalysis.cpp @@ -109,15 +109,7 @@ StatusCode SiWAnalysis::execute() { const auto deposits = m_deposits.get(); for (const auto& hit : *deposits) { decoder->setValue(hit.core().cellId); - int digital = (*decoder)["digital"]; - if(digital==0) { - notdigital++; - - } - if(digital==1) { - isdigital++; - continue; - } + int layer = (*decoder)[m_layerFieldName]; @@ -133,8 +125,6 @@ StatusCode SiWAnalysis::execute() { } } - std::cout << "isdigital = " << isdigital << std::endl; - std::cout << "notdigital = " << notdigital << std::endl; /* m_calPixels = m_calFit->GetX(m_sumPixels); //std::cout << "#### " << m_sumPixels << " " << m_calPixels << std::endl; diff --git a/Detector/DetStudies/tests/options/SiWAnalysis_batch.py b/Detector/DetStudies/tests/options/SiWAnalysis_batch.py index 4f2b8c75f..d7446bf47 100644 --- a/Detector/DetStudies/tests/options/SiWAnalysis_batch.py +++ b/Detector/DetStudies/tests/options/SiWAnalysis_batch.py @@ -23,6 +23,14 @@ ], OutputLevel = INFO) + +from Configurables import FilterSiliconEcalHits +filtered = FilterSiliconEcalHits("FilterSiEcal", + readoutName = "BarDECal_Readout", + digitalFlag = 0) +filtered.deposits.Path="positionedCaloHits" +filtered.filtered.Path="filteredCaloHits" + from Configurables import RedoSegmentation resegment = RedoSegmentation("ReSegmentation", # old bitfield (readout) @@ -31,13 +39,10 @@ oldSegmentationIds = ["x","y","z"], # new bitfield (readout), with new segmentation newReadoutName="BarDECal_Pads", - # field in the segmentation that holds digital readout information ("") = default - digitalBitName="digital", - # split on the digital field. 0 = analogue, 1 = digital - digitalFlag=0, + OutputLevel = INFO) # clusters are needed, with deposit position and cellID in bits -resegment.inhits.Path = "positionedCaloHits" +resegment.inhits.Path = "filteredCaloHits" resegment.outhits.Path = "newCaloHits" from Configurables import CreateCaloCells @@ -76,12 +81,12 @@ from Configurables import FCCDataSvc, PodioOutput #podiosvc = FCCDataSvc("EventDataSvc") -podioout = PodioOutput("out", filename=batch_dir+"/"+det_config+"/"+run_config+"/redoSegmentation_"+file) +podioout = PodioOutput("out", filename=batch_dir+"/"+det_config+"/"+run_config+"/analogue_podio_"+file) podioout.outputCommands = ["keep *"] # ApplicationMgr from Configurables import ApplicationMgr -ApplicationMgr( TopAlg = [podioinput, resegment, createcells, hist],#, podioout], +ApplicationMgr( TopAlg = [podioinput, filtered, resegment, createcells, hist, podioout], EvtSel = 'NONE', # EvtMax = 10, # order is important, as GeoSvc is needed by G4SimSvc diff --git a/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py b/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py index 581aee7ce..6a91225bf 100644 --- a/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py +++ b/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py @@ -4,9 +4,9 @@ from Configurables import FCCDataSvc batch_dir = "/eos/user/t/toprice/private/FCC/FCCSW/v8.0/XYZ/" fccsw_version = "FCCSW0.8" -det_config = "50Layers_2.1mmW_50umPixels_18umThick_FCCSW0.8" -run_config = "0GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001" -file = "0GeV_BFIELD4T_2.root" +det_config = "50Layers_2.1mmW_FCCSW0.8" +run_config = "100GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001" +file = "100GeV_BFIELD4T_0.root" #inputfile = batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/"+file inputfile = batch_dir+"/"+det_config+"/"+run_config+"/output_"+file podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) @@ -22,6 +22,21 @@ ], OutputLevel = INFO) +from Configurables import FilterSiliconEcalHits +filtered = FilterSiliconEcalHits("FilterSiEcal", + readoutName = "BarDECal_Readout", + digitalFlag = 1) +filtered.deposits.Path="positionedCaloHits" +filtered.filtered.Path="filteredCaloHits" + +# add a processor which generates noise hits +# input - noise level +# - threshold level +# - segmentation name + +# add a processor which adds noise event in to genuine hits +# take input of noise hits and genuine hits +# output a combination for the event from Configurables import RedoSegmentation resegment = RedoSegmentation("ReSegmentation", @@ -33,13 +48,13 @@ newReadoutName="BarDECal_Pads", OutputLevel = INFO) # clusters are needed, with deposit position and cellID in bits -resegment.inhits.Path = "positionedCaloHits" +resegment.inhits.Path = "filteredCaloHits" resegment.outhits.Path = "newCaloHits" from Configurables import CreateCaloCells createcells = CreateCaloCells("CreateCaloCells", doCellCalibration = False, - addCellNoise = False, filterCellNoise = False, + addCellNoise = False, filterCellNoise = False, sumPixelsPerCell = False, OutputLevel = INFO) createcells.hits.Path="newCaloHits" createcells.cells.Path="newCaloCells" @@ -51,12 +66,12 @@ layerFieldName = "layer", numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty OutputLevel = INFO) -hist.pixels.Path="positionedCaloHits" +hist.pixels.Path="filteredCaloHits" hist.pads.Path="newCaloCells" hist.truth.Path="GenParticles" #THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] -THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/analysis_"+file+"' TYP='ROOT' OPT='RECREATE'"] +THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/digital_"+file+"' TYP='ROOT' OPT='RECREATE'"] THistSvc().PrintAll=False THistSvc().AutoSave=True THistSvc().AutoFlush=True @@ -76,9 +91,9 @@ # ApplicationMgr from Configurables import ApplicationMgr -ApplicationMgr( TopAlg = [podioinput, resegment, createcells,hist, podioout], +ApplicationMgr( TopAlg = [podioinput, filtered, resegment, createcells,hist, podioout], EvtSel = 'NONE', - # EvtMax = 10, + EvtMax = 10, # order is important, as GeoSvc is needed by G4SimSvc ExtSvc = [podiosvc,geoservice, audsvc], OutputLevel = INFO diff --git a/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py b/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py index 3ff975898..ff614f8dc 100644 --- a/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py +++ b/Detector/DetStudies/tests/options/decalAnalysis_DEcal_batch.py @@ -23,6 +23,23 @@ ], OutputLevel = INFO) + +from Configurables import FilterSiliconEcalHits +filtered = FilterSiliconEcalHits("FilterSiEcal", + readoutName = "BarDECal_Readout", + digitalFlag = 1) +filtered.deposits.Path="positionedCaloHits" +filtered.filtered.Path="filteredCaloHits" + +# add a processor which generates noise hits +# input - noise level +# - threshold level +# - segmentation name + +# add a processor which adds noise event in to genuine hits +# take input of noise hits and genuine hits +# output a combination for the event + from Configurables import RedoSegmentation resegment = RedoSegmentation("ReSegmentation", # old bitfield (readout) @@ -33,13 +50,13 @@ newReadoutName="BarDECal_Pads", OutputLevel = INFO) # clusters are needed, with deposit position and cellID in bits -resegment.inhits.Path = "positionedCaloHits" +resegment.inhits.Path = "filteredCaloHits" resegment.outhits.Path = "newCaloHits" from Configurables import CreateCaloCells createcells = CreateCaloCells("CreateCaloCells", doCellCalibration = False, - addCellNoise = False, filterCellNoise = False, + addCellNoise = False, filterCellNoise = False, sumPixelsPerCell = False, OutputLevel = INFO) createcells.hits.Path="newCaloHits" createcells.cells.Path="newCaloCells" @@ -51,14 +68,12 @@ layerFieldName = "layer", numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty OutputLevel = INFO) -hist.pixels.Path="positionedCaloHits" +hist.pixels.Path="filteredCaloHits" hist.pads.Path="newCaloCells" hist.truth.Path="GenParticles" - - #THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] -THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/analysis_"+file+"' TYP='ROOT' OPT='RECREATE'"] +THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/digital_"+file+"' TYP='ROOT' OPT='RECREATE'"] THistSvc().PrintAll=False THistSvc().AutoSave=True THistSvc().AutoFlush=True @@ -73,16 +88,15 @@ from Configurables import FCCDataSvc, PodioOutput #podiosvc = FCCDataSvc("EventDataSvc") -podioout = PodioOutput("out", filename=batch_dir+"/"+det_config+"/"+run_config+"/redoSegmentation_"+file) +podioout = PodioOutput("out", filename=batch_dir+"/"+det_config+"/"+run_config+"/digital_podio_"+file) podioout.outputCommands = ["keep *"] # ApplicationMgr from Configurables import ApplicationMgr -ApplicationMgr( TopAlg = [podioinput, resegment, createcells, hist, podioout], +ApplicationMgr( TopAlg = [podioinput, filtered, resegment, createcells,hist, podioout], EvtSel = 'NONE', - # EvtMax = 10, + # EvtMax = 10, # order is important, as GeoSvc is needed by G4SimSvc ExtSvc = [podiosvc,geoservice, audsvc], OutputLevel = INFO - ) diff --git a/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py b/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py index d4abef8d2..acb082c44 100644 --- a/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py +++ b/Detector/DetStudies/tests/options/longitudinalAnalysis_DEcal.py @@ -4,9 +4,9 @@ from Configurables import FCCDataSvc batch_dir = "/eos/user/t/toprice/private/FCC/FCCSW/v8.0/XYZ/" fccsw_version = "FCCSW0.8" -det_config = "50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0" -run_config = "100GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001" -file = "output_100GeV_BFIELD4T_0.root" +det_config = "30Layers_3.5mmW_50umPixels_18umThick_RRB" +run_config = "10GeV_BFIELD4T_ETAMIN-0.001_ETAMAX-0.001" +file = "output_10GeV_BFIELD4T_0.root" inputfile = batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/"+file podiosvc = FCCDataSvc("EventDataSvc", input=inputfile) @@ -17,7 +17,7 @@ # DD4hep geometry service from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', - 'file:Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml' + 'file:Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml' ], OutputLevel = INFO) @@ -27,7 +27,7 @@ hist = DECalLongitudinalTest("hists", readoutName = "BarDECal_Readout", layerFieldName = "layer", - numLayers = 50, # one more because index starts at 1 - layer 0 will be always empty + numLayers = 30, # one more because index starts at 1 - layer 0 will be always empty OutputLevel = DEBUG) hist.deposits.Path="positionedCaloHits" diff --git a/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.cpp b/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.cpp index d1236d24a..4ccfee995 100644 --- a/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.cpp +++ b/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.cpp @@ -76,7 +76,13 @@ StatusCode CreateCaloCells::execute() { // If running with noise map already was prepared. Otherwise it is being // created below for (const auto& hit : *hits) { - m_cellsMap[hit.core().cellId] += 1;//hit.core().energy; + + if(m_sumPixelsPerCell) { + m_cellsMap[hit.core().cellId] += 1; + } else { + m_cellsMap[hit.core().cellId] += hit.core().energy; + } + } debug() << "Number of calorimeter cells after merging of hits: " << m_cellsMap.size() << endmsg; diff --git a/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.h b/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.h index f8e421425..67ea0513a 100644 --- a/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.h +++ b/Reconstruction/RecCalorimeter/src/components/CreateCaloCells.h @@ -64,10 +64,13 @@ class CreateCaloCells : public GaudiAlgorithm { /// Save only cells with energy above threshold? Gaudi::Property m_filterCellNoise{this, "filterCellNoise", false, "Save only cells with energy above threshold?"}; + /// Add energy deposit or sum number of pixels in the cell (DECal) + Gaudi::Property m_sumPixelsPerCell{this, "sumPixelsPerCell", false, + "Sum the number of pixels in the cell rather than energy?"}; /// Handle for calo hits (input collection) DataHandle m_hits{"hits", Gaudi::DataHandle::Reader, this}; /// Handle for calo cells (output collection) - DataHandle m_cells{"cells", Gaudi::DataHandle::Writer, this}; + DataHandle m_cells{"cellsm", Gaudi::DataHandle::Writer, this}; /// Name of the detector readout Gaudi::Property m_readoutName{this, "readoutName", "ECalHitsPhiEta", "Name of the detector readout"}; /// Name of active volumes diff --git a/Test/TestReconstruction/tests/options/testcellcountingXYZ.py b/Test/TestReconstruction/tests/options/testcellcountingXYZ.py index d94ca9a28..8b82f3f9a 100644 --- a/Test/TestReconstruction/tests/options/testcellcountingXYZ.py +++ b/Test/TestReconstruction/tests/options/testcellcountingXYZ.py @@ -1,14 +1,21 @@ from Gaudi.Configuration import * from Configurables import ApplicationMgr +#from Configurables import GeoSvc +#geoservice = GeoSvc("GeoSvc", detectors=[ 'Test/TestGeometry/data/TestBoxCaloSD_segmentation.xml'], OutputLevel = DEBUG) + from Configurables import GeoSvc -geoservice = GeoSvc("GeoSvc", detectors=[ 'Test/TestGeometry/data/TestBoxCaloSD_segmentation.xml'], OutputLevel = DEBUG) +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml' +], + OutputLevel = DEBUG) from Configurables import TestCellCounting -cells = TestCellCounting("cells", readoutName="ECalHits", - fieldNames=["system"], - fieldValues=[0], - volumeMatchName="BoxECal", +cells = TestCellCounting("cells", + readoutName="BarDECal_Readout",#ECalHits", + fieldNames=["layer"], + fieldValues=[50], + volumeMatchName="Silicon_sensitive", OutputLevel = DEBUG) # ApplicationMgr ApplicationMgr(EvtSel='NONE', diff --git a/analyse_DEcal_particles.py b/analyse_DEcal_particles.py index ffeb131a6..e31c8d1d7 100644 --- a/analyse_DEcal_particles.py +++ b/analyse_DEcal_particles.py @@ -29,7 +29,7 @@ LINEARITY = {} LINEARITY_SIGMA = {} -CONFIGS = ["50Layers_2.1mmW_FCCSW0.8"] #[ c for c in os.listdir(FCCSW_DIR+"/batch_eos/") if "50Layers_2.1mmW_50umPixels_18umThick" in c and "Edep" not in c] +CONFIGS = ["30Layers_3.5mmW_50umPixels_18umThick_RRB_modules_FCCSW0.8"] #[ c for c in os.listdir(FCCSW_DIR+"/batch_eos/") if "50Layers_2.1mmW_50umPixels_18umThick" in c and "Edep" not in c] print CONFIGS for CONFIG in CONFIGS: @@ -50,7 +50,7 @@ if os.path.isdir(dir): - FILES = [f for f in os.listdir(dir) if "analysis_" in f and "root.root" not in f] + FILES = [f for f in os.listdir(dir) if "digital_" in f and "root.root" not in f] for f in FILES: temp_file = TFile(dir+f) if temp_file.IsZombie(): diff --git a/analyse_SiW.py b/analyse_SiW.py index 4f5f24316..34ae00936 100644 --- a/analyse_SiW.py +++ b/analyse_SiW.py @@ -12,7 +12,7 @@ LINEARITY = {} LINEARITY_SIGMA = {} -CONFIGS = [ c for c in os.listdir(FCCSW_DIR+"/batch_eos/") if "50Layers_3.4mmPb" in c and "Pixels" not in c] +CONFIGS = [ c for c in os.listdir(FCCSW_DIR+"/batch_eos/") if "30Layers" in c and "RRB" in c] print CONFIGS for CONFIG in CONFIGS: @@ -49,14 +49,14 @@ truth_energy = float(RUNCONFIG[:RUNCONFIG.find("GeV")]) - temp_edep = TH1F("edep_"+str(truth_energy)+"GeV", "Energy deposited per event; Energy Deposited [keV]; Count", 2000, 0, 500000) + temp_edep = TH1F("edep_"+str(truth_energy)+"GeV", "Energy deposited per event; Energy Deposited [keV]; Count", 400, 0, 20) for i in np.arange(0,chain.GetEntries()): chain.GetEntry(i) temp_edep.Fill(chain.edep_tot); - gaus = TF1("gaus","gaus",0,500000) + gaus = TF1("gaus","gaus",0,20) temp_edep.Fit("gaus", "NQR") mean = gaus.GetParameter(1) sigma = gaus.GetParameter(2) @@ -84,7 +84,7 @@ c_res = TCanvas("Resolution") - fit_min = 0 + fit_min = 50 fit_max = 1000 fit = TF1("fit", "[0]/sqrt(x)+[1]", fit_min, fit_max) diff --git a/submit_SiWAnalysis.py b/submit_SiWAnalysis.py index 63d7ab5b6..2363cf898 100644 --- a/submit_SiWAnalysis.py +++ b/submit_SiWAnalysis.py @@ -9,7 +9,7 @@ print ######## YOU ONLY NEED TO FILL THE AREA BELOW ######### ######## customization area ######### -CONFIG="50Layers_2.1mmW_450um" +CONFIG="30Layers_3.5mmW_50umPixels_18umThick_RRB_modules" FCCSW_VERSION="FCCSW0.8" BFIELD = "4" FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" @@ -21,7 +21,7 @@ ##### loop for creating and sending jobs ##### #e = 100 CONFIGS = os.listdir(FCCSW_DIR+"/batch_eos/") -CONFIGS = [ c for c in CONFIGS if CONFIG in c and "300" not in c and "Pixels" not in c] +CONFIGS = [ c for c in CONFIGS if CONFIG in c and "300" not in c]# and "Pixels" not in c] #for e in ENERGIES: for CONFIG in CONFIGS: print CONFIG @@ -34,7 +34,7 @@ if os.path.isdir(dir): - files = [ f for f in os.listdir(dir) if "output" in f] + files = [ f for f in os.listdir(dir) if "output" in f and "_0.root" in f] print files os.chdir(dir) diff --git a/submit_decalAnalysis.py b/submit_decalAnalysis.py index 94d9b2662..e7d33c18e 100644 --- a/submit_decalAnalysis.py +++ b/submit_decalAnalysis.py @@ -9,7 +9,7 @@ print ######## YOU ONLY NEED TO FILL THE AREA BELOW ######### ######## customization area ######### -CONFIG="50Layers_2.1mmW" +CONFIG="30Layers_3.5mmW_50umPixels_18umThick_RRB_modules" FCCSW_VERSION="FCCSW0.8" BFIELD = "4" FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" @@ -21,7 +21,7 @@ ##### loop for creating and sending jobs ##### #e = 100 CONFIGS = os.listdir(FCCSW_DIR+"/batch_eos/") -CONFIGS = [ c for c in CONFIGS if CONFIG in c and "300" not in c and "Pixels" not in c] +CONFIGS = [ c for c in CONFIGS if CONFIG in c and "300" not in c]# and "Pixels" not in c] #for e in ENERGIES: for CONFIG in CONFIGS: print CONFIG @@ -34,7 +34,7 @@ if os.path.isdir(dir): - files = [ f for f in os.listdir(dir) if "output" in f] + files = [ f for f in os.listdir(dir) if "output" in f and "_0.root" in f] print files os.chdir(dir) diff --git a/submit_energy_res_to_lxbatch.py b/submit_energy_res_to_lxbatch.py index 2e9311b6e..dfd316abc 100644 --- a/submit_energy_res_to_lxbatch.py +++ b/submit_energy_res_to_lxbatch.py @@ -9,11 +9,11 @@ print ######## YOU ONLY NEED TO FILL THE AREA BELOW ######### ######## customization area ######### -CONFIG="50Layers_3.4mmPb_450um" +CONFIG="50Layers_2.1mmW_50umPixels_18umThick_RRB" FCCSW_VERSION="FCCSW0.8" #ENERGIES = ["10","20","50","70","100","200", "300", "500","700","1000"] -ENERGIES = ["50","100","200", "300", "500","700","1000"] -#ENERGIES = ["1000" ] # number of jobs to be submitted +ENERGIES = ["10", "50","100","200", "300", "500","700","1000"] +#ENERGIES = ["101","501","1001" ] # number of jobs to be submitted #ENERGIES = ["10","20","30","40","60","70","80","90","100","300","500","700","1000" ] # number of jobs to be submitted BFIELD = "4" EVENTS = 100 @@ -21,7 +21,7 @@ ETAMAX = 0.001 NRUNS = 100 FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" -queue = "1nw" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw +queue = "1nd" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw ######## customization end ######### path = os.getcwd() From 1361ac252f92d307c927f58f0340834977c41d60 Mon Sep 17 00:00:00 2001 From: tonypba Date: Fri, 2 Mar 2018 18:49:48 +0100 Subject: [PATCH 19/28] Modified DECal geometry to match with DD4hep-->dd4hep and removed namespaces --- .../src/ECalBarrel_geo.cpp | 188 +++++++++--------- 1 file changed, 95 insertions(+), 93 deletions(-) diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp index d918dbde1..76e9611e9 100644 --- a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -15,25 +15,25 @@ /*ROBBIE using namespace std; using namespace dd4hep; -using namespace dd4hep::detail;*/ -using DD4hep::Geometry::Volume; -using DD4hep::Geometry::DetElement; -using DD4hep::XML::Dimension; -using DD4hep::Geometry::PlacedVolume; -using DD4hep::Geometry::Trapezoid; -using DD4hep::_toString; -using DD4hep::Geometry::Position; -using DD4hep::Geometry::Box; -using DD4hep::Geometry::Transform3D; -using DD4hep::Geometry::RotationZYX; -using DD4hep::Geometry::Translation3D; - +using namespace dd4hep::detail; +using dd4hep::Geometry::Volume; +using dd4hep::Geometry::DetElement; +using dd4hep::XML::Dimension; +using dd4hep::Geometry::PlacedVolume; +using dd4hep::Geometry::Trapezoid; +using dd4hep::_toString; +using dd4hep::Geometry::Position; +using dd4hep::Geometry::Box; +using dd4hep::Geometry::Transform3D; +using dd4hep::Geometry::RotationZYX; +using dd4hep::Geometry::Translation3D; +*/ namespace det { -static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xmlElement, - DD4hep::Geometry::SensitiveDetector sensDet) +static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Handle_t xmlElement, + dd4hep::SensitiveDetector sensDet) { ServiceHandle msgSvc("MessageSvc", "DECalConstruction"); @@ -45,36 +45,38 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm // Getting the detectors various values from the xml file - xml_det_t xmlDet = xmlElement; + dd4hep::xml::DetElement xmlDet = xmlElement; std::string detName = xmlDet.nameStr(); //Make DetElement - DetElement eCal(detName, xmlDet.id()); + dd4hep::DetElement eCal(detName, xmlDet.id()); - xml_comp_t calo = xmlElement.child(_Unicode(calorimeter)); - Dimension calo_dims(calo.dimensions()); + dd4hep::xml::DetElement calo = xmlElement.child(_Unicode(calorimeter)); + dd4hep::xml::Dimension calo_dims(calo.dimensions()); std::string calo_name=calo.nameStr(); double calo_id=calo.id(); - xml_comp_t trkr = calo.child("tracker"); + dd4hep::xml::DetElement trkr = calo.child("tracker"); std::string trkr_mat = trkr.materialStr(); double trkr_tck = trkr.thickness(); - xml_comp_t active = calo.child("active_layers"); + dd4hep::xml::DetElement active = calo.child("active_layers"); std::string active_mat=active.materialStr(); double active_tck=active.thickness(); - int active_samples=active.attr("nSamplings"); - - xml_comp_t substrate = calo.child("substrate_layers"); + //int active_samples=active.attr("nSamplings"); + // need to fix line above as no longer supported + int active_samples = 50; + + dd4hep::xml::DetElement substrate = calo.child("substrate_layers"); std::string substrate_mat=substrate.materialStr(); double substrate_tck=substrate.thickness(); - xml_comp_t passive = calo.child("passive_layers"); + dd4hep::xml::DetElement passive = calo.child("passive_layers"); std::string passive_mat=passive.materialStr(); double passive_tck=passive.thickness(); - xml_comp_t padding = calo.child("between_layers"); + dd4hep::xml::DetElement padding = calo.child("between_layers"); std::string padding_mat=padding.materialStr(); double padding_tck=padding.thickness(); @@ -103,22 +105,22 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm lLog << MSG::INFO << "nModules = " << nModules << endmsg; // Make volume that envelopes the whole barrel; set material to air - Dimension dimensions(xmlDet.dimensions()); - DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz()); + dd4hep::xml::Dimension dimensions(xmlDet.dimensions()); + dd4hep::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz()); //DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmin()+calo_tck, dimensions.dz()); - Volume envelopeVolume(detName, envelopeShape, lcdd.air()); + dd4hep::Volume envelopeVolume(detName, envelopeShape, lcdd.air()); // Invisibility seems to be broken in visualisation tags, have to hardcode that std::cout << "dimensions.visStr() = " << dimensions.visStr()<< std::endl; envelopeVolume.setVisAttributes(lcdd, dimensions.visStr()); // create a lump of air the entire size of the barrel ECAL (Cylindrical) // place it within the ECAL envelope - DetElement caloDet(calo_name, calo_id); - DD4hep::Geometry::Tube caloShape(calo_dims.rmin() , /*calo_dims.rmin()+calo_tck*/calo_dims.rmax(), calo_dims.dz()); + dd4hep::DetElement caloDet(calo_name, calo_id); + dd4hep::Tube caloShape(calo_dims.rmin() , /*calo_dims.rmin()+calo_tck*/calo_dims.rmax(), calo_dims.dz()); lLog << MSG::INFO/*DEBUG*/ << "ECAL: Building the calorimeter from " << calo_dims.rmin() << " to " << /*calo_dims.rmin()+calo_tck*/calo_dims.rmax() << endmsg; - Volume caloVolume(padding_mat, caloShape, lcdd.material(padding_mat)); + dd4hep::Volume caloVolume(padding_mat, caloShape, lcdd.material(padding_mat)); lLog << MSG::DEBUG << "ECAL: Filling the calorimeter volume with " << padding_mat << endmsg; - PlacedVolume placedCalo = envelopeVolume.placeVolume(caloVolume); + dd4hep::PlacedVolume placedCalo = envelopeVolume.placeVolume(caloVolume); placedCalo.addPhysVolID("EM_barrel", calo_id); caloDet.setPlacement(placedCalo); @@ -127,11 +129,11 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm // if we add material for the tracker then it needs to be placed first if(trkr_tck > 0.0) { - DetElement trkrLayer(trkr_mat, 0); - DD4hep::Geometry::Tube trkrShape(calo_dims.rmin(), calo_dims.rmin()+trkr_tck, calo_dims.dz()); + dd4hep::DetElement trkrLayer(trkr_mat, 0); + dd4hep::Tube trkrShape(calo_dims.rmin(), calo_dims.rmin()+trkr_tck, calo_dims.dz()); lLog << MSG::DEBUG << "TRKR: Tracker from " << calo_dims.rmin() << " to " << calo_dims.rmin()+trkr_tck << endmsg; - Volume trkrVolume(trkr_mat, trkrShape, lcdd.material(trkr_mat)); - PlacedVolume placedTrkrLayer = caloVolume.placeVolume(trkrVolume); + dd4hep::Volume trkrVolume(trkr_mat, trkrShape, lcdd.material(trkr_mat)); + dd4hep::PlacedVolume placedTrkrLayer = caloVolume.placeVolume(trkrVolume); //placedTrkrLayer.addPhysVolID("trkr", 0); //placedTrkrLayer.addPhysVolID("layer", 0); trkrLayer.setPlacement(placedTrkrLayer); @@ -172,11 +174,11 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm // 1) place the epitaxial layer double layer_rmin=calo_dims.rmin()+(i*module_tck) + trkr_tck; // thick last part adds on the tracker material infront double layer_rmax=layer_rmin+active_tck; - DetElement epiLayer(active_mat+"_sensitive", i+1); - DD4hep::Geometry::Tube epiShape(layer_rmin , layer_rmax, calo_dims.dz()); + dd4hep::DetElement epiLayer(active_mat+"_sensitive", i+1); + dd4hep::Tube epiShape(layer_rmin , layer_rmax, calo_dims.dz()); lLog << MSG::DEBUG << "\tEpitaxial from " << layer_rmin << " to " << layer_rmax << endmsg; - Volume epiVolume(active_mat+"_sensitive", epiShape, lcdd.material(active_mat)); - PlacedVolume placedEpiLayer = caloVolume.placeVolume(epiVolume); + dd4hep::Volume epiVolume(active_mat+"_sensitive", epiShape, lcdd.material(active_mat)); + dd4hep::PlacedVolume placedEpiLayer = caloVolume.placeVolume(epiVolume); placedEpiLayer.addPhysVolID("layer", i+1); placedEpiLayer.addPhysVolID("digital", 1); l++; @@ -186,11 +188,11 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm // 2) place the substrate layer_rmin = layer_rmax; layer_rmax = layer_rmin+substrate_tck; - DetElement subLayer(substrate_mat+"_substrate", i+1); - DD4hep::Geometry::Tube subShape(layer_rmin , layer_rmax, calo_dims.dz()); + dd4hep::DetElement subLayer(substrate_mat+"_substrate", i+1); + dd4hep::Tube subShape(layer_rmin , layer_rmax, calo_dims.dz()); lLog << MSG::DEBUG << "\tSubstrate from " << layer_rmin << " to " << layer_rmax << endmsg; - Volume subVolume(substrate_mat+"_substrate", subShape, lcdd.material(active_mat)); - PlacedVolume placedSubLayer = caloVolume.placeVolume(subVolume); + dd4hep::Volume subVolume(substrate_mat+"_substrate", subShape, lcdd.material(active_mat)); + dd4hep::PlacedVolume placedSubLayer = caloVolume.placeVolume(subVolume); placedSubLayer.addPhysVolID("layer", 1+i); placedSubLayer.addPhysVolID("digital", 0); subLayer.setPlacement(placedSubLayer); @@ -205,11 +207,11 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm layer_rmin = layer_rmax; } layer_rmax = layer_rmin+passive_tck; - DetElement passiveLayer(passive_mat+"_passive", i+1); - DD4hep::Geometry::Tube passiveShape(layer_rmin , layer_rmax, calo_dims.dz()); + dd4hep::DetElement passiveLayer(passive_mat+"_passive", i+1); + dd4hep::Tube passiveShape(layer_rmin , layer_rmax, calo_dims.dz()); lLog << MSG::DEBUG << "\t" << passive_mat << " from " << layer_rmin << " to " << layer_rmax << endmsg; - Volume passiveVolume(passive_mat, passiveShape, lcdd.material(passive_mat)); - PlacedVolume placedPassiveLayer = caloVolume.placeVolume(passiveVolume); + dd4hep::Volume passiveVolume(passive_mat, passiveShape, lcdd.material(passive_mat)); + dd4hep::PlacedVolume placedPassiveLayer = caloVolume.placeVolume(passiveVolume); passiveLayer.setPlacement(placedPassiveLayer); // 4) the air volume alread exists so don't do anything @@ -218,7 +220,7 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm } } //END OF TONY'S STUFF - + else if (testing == 1) { double hphi = M_PI/nStaves; double rmin = calo_dims.rmin(); @@ -254,21 +256,21 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm double l_dim_x = (s_pos_r * (std::tan(hphi))) - nudge_gap;//72.0; // EPI - std::string epi_name = _toString(layernum, "epi%d"); - Box epi_box(l_dim_x, module_dz/2, active_tck/2); - lLog << MSG::INFO << "EPI BOX LENGTH" << 2*epi_box.x() << endmsg; + std::string epi_name = dd4hep::xml::_toString(layernum, "epi%d"); + dd4hep::Box epi_box(l_dim_x, module_dz/2, active_tck/2); lLog << MSG::INFO << "This means that the epitaxial layer exists between " << epi_box.x() << " and " << -epi_box.x() << " in the x direction" << endmsg; - Volume epi_vol(epi_name, epi_box, lcdd.material(active_mat)); - DetElement epi_slice(epi_name, layernum); + dd4hep::Volume epi_vol(epi_name, epi_box, lcdd.material(active_mat)); + dd4hep::DetElement epi_slice(epi_name, layernum); lLog << MSG::INFO << "Epitaxial thickness is " << active_tck << endmsg; double mod_y_off = s_pos_r + (0.5*active_tck); double m_pos_x = -mod_y_off*std::sin(phi); double m_pos_y = mod_y_off*std::cos(phi); - Transform3D epi_tr(RotationZYX(0, phi, M_PI*0.5), Translation3D(-m_pos_x, -m_pos_y, module_z)); - PlacedVolume epi_phv = caloVolume.placeVolume(epi_vol, epi_tr); - + + dd4hep::Transform3D epi_tr(dd4hep::RotationZYX(0, phi, M_PI*0.5), dd4hep::Translation3D(-m_pos_x, -m_pos_y, module_z)); + dd4hep::PlacedVolume epi_phv = caloVolume.placeVolume(epi_vol, epi_tr); + lLog << MSG::INFO << "The EPI has been placed at (" << -m_pos_x << ", " << -m_pos_y << ", " << module_z << ")" << endmsg; lLog << MSG::INFO << "That means its ends are at (" << -m_pos_x+((epi_box.x())*(std::cos(phi))) << ", " << -m_pos_y+((epi_box.x())*(std::sin(phi))) << ") and (" << -m_pos_x-((epi_box.x())*(std::cos(phi))) << ", " << -m_pos_y-((epi_box.x())*(std::sin(phi))) << ")" << endmsg; lLog << MSG::INFO << "In z, the EPI lies between " << module_z - (epi_box.y()) << " and " << module_z + (epi_box.y()) << endmsg; @@ -287,20 +289,20 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm //SUBSTRATE - std::string sub_name = _toString(layernum, "sub%d"); - Box sub_box(l_dim_x, module_dz/2, substrate_tck/2); + dd4hep::Box sub_box(l_dim_x, module_dz/2, substrate_tck/2); + std::string sub_name = dd4hep::xml::_toString(layernum, "sub%d"); lLog << MSG::INFO << "SUB BOX LENGTH" << 2*sub_box.x() << endmsg; lLog << MSG::INFO << "This means that the substrate layer exists between " << sub_box.x() << " and " << -sub_box.x() << " in the x direction" << endmsg; - Volume sub_vol(sub_name, sub_box, lcdd.material(active_mat)); - DetElement sub_slice(sub_name, layernum); + dd4hep::Volume sub_vol(sub_name, sub_box, lcdd.material(active_mat)); + dd4hep::DetElement sub_slice(sub_name, layernum); lLog << MSG::INFO << "Substrate thickness is " << substrate_tck << endmsg; mod_y_off = s_pos_r + (0.5*substrate_tck); m_pos_x = -mod_y_off*std::sin(phi); m_pos_y = mod_y_off*std::cos(phi); - Transform3D sub_tr(RotationZYX(0, phi, M_PI*0.5), Translation3D(-m_pos_x, -m_pos_y, module_z)); - PlacedVolume sub_phv = caloVolume.placeVolume(sub_vol, sub_tr); + dd4hep::Transform3D sub_tr(dd4hep::RotationZYX(0, phi, M_PI*0.5), dd4hep::Translation3D(-m_pos_x, -m_pos_y, module_z)); + dd4hep::PlacedVolume sub_phv = caloVolume.placeVolume(sub_vol, sub_tr); sub_phv.addPhysVolID("digital", 0); sub_phv.addPhysVolID("layer", layernum); @@ -321,20 +323,20 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm //PASSIVE - std::string pas_name = _toString(layernum, "passive%d"); - Box pas_box(l_dim_x, module_dz/2, passive_tck/2); + std::string pas_name = dd4hep::xml::_toString(layernum, "passive%d"); + dd4hep::Box pas_box(l_dim_x, module_dz/2, passive_tck/2); lLog << MSG::INFO << "PAS BOX LENGTH" << 2*pas_box.x() << endmsg; lLog << MSG::INFO << "This means that the passive layer exists between " << pas_box.x() << " and " << -pas_box.x() << " in the x direction" << endmsg; - Volume pas_vol(pas_name, pas_box, lcdd.material(passive_mat)); - DetElement pas_slice(pas_name, layernum); + dd4hep::Volume pas_vol(pas_name, pas_box, lcdd.material(passive_mat)); + dd4hep::DetElement pas_slice(pas_name, layernum); lLog << MSG::INFO << "Passive thickness is " << passive_tck << endmsg; mod_y_off = s_pos_r + (0.5*passive_tck); m_pos_x = -mod_y_off*std::sin(phi); m_pos_y = mod_y_off*std::cos(phi); - Transform3D pas_tr(RotationZYX(0, phi, M_PI*0.5), Translation3D(-m_pos_x, -m_pos_y, module_z)); - PlacedVolume pas_phv = caloVolume.placeVolume(pas_vol, pas_tr); + dd4hep::Transform3D pas_tr(dd4hep::RotationZYX(0, phi, M_PI*0.5), dd4hep::Translation3D(-m_pos_x, -m_pos_y, module_z)); + dd4hep::PlacedVolume pas_phv = caloVolume.placeVolume(pas_vol, pas_tr); pas_slice.setPlacement(pas_phv); s_pos_r += passive_tck + nudge_gap; @@ -376,7 +378,7 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm lLog << MSG::INFO << "Trapezoid has thickness " << 2*trd_y << " and depth " << 2*trd_z1 << " which should be the same as " << 2*trd_z2 << endmsg; //ROBBIE Create the trapezium volume using the variables above - Trapezoid trd(trd_x_short, + dd4hep::Trapezoid trd(trd_x_short, trd_x_long, trd_z1, trd_z2, @@ -434,9 +436,9 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm double s_pos_z = -trd_y; // recalculate per stave... - std::string stave_name = _toString(stavenum, "stave%d"); - Volume trap_vol(stave_name, trd, lcdd.air()); - DetElement stave_det(stave_name, stavenum); + std::string stave_name = dd4hep::xml::_toString(stavenum, "stave%d"); + dd4hep::Volume trap_vol(stave_name, trd, lcdd.air()); + dd4hep::DetElement stave_det(stave_name, stavenum); l_dim_x = trd_x_long/2; lLog << MSG::INFO << "l_dim_x is starting at" << l_dim_x << " which should be similar to either " << rmin * std::tan(hphi) << " or " << rmax * std::tan(hphi) << endmsg; //ROBBIE Ideally we would like to be able to add the stave number volume ID directly to the stave. For now, it's added to each slice in turn, inside the loop below. @@ -461,15 +463,15 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm //ROBBIE 1) Place the epitaxial slice //double s_pos_z = -(l_thickness/2); - std::string epi_name = _toString(layernum, "epi%d"); - Box epi_box(l_dim_x*2, trd_z1, active_tck/2); + std::string epi_name = dd4hep::xml::_toString(layernum, "epi%d"); + dd4hep::Box epi_box(l_dim_x*2, trd_z1, active_tck/2); lLog << MSG::INFO << "EPI BOX LENGTH" << 2*epi_box.x() << endmsg; lLog << MSG::INFO << "This means that the epitaxial layer exists between " << epi_box.x() << " and " << -epi_box.x() << " in the x direction" << endmsg; - Volume epi_vol(epi_name, epi_box, lcdd.material(active_mat)); - DetElement epi_slice(stave_det, epi_name, layernum); + dd4hep::Volume epi_vol(epi_name, epi_box, lcdd.material(active_mat)); + dd4hep::DetElement epi_slice(stave_det, epi_name, layernum); //lLog << MSG::INFO << "epi_name is " << epi_name << endmsg; lLog << MSG::INFO << "Epitaxial thickness is " << active_tck << endmsg; - PlacedVolume epi_phv = trap_vol.placeVolume(epi_vol, Position(0, 0, /*l_pos_z + l_thickness/2 +*/ s_pos_z + active_tck/2)); + dd4hep::PlacedVolume epi_phv = trap_vol.placeVolume(epi_vol, dd4hep::Position(0, 0, /*l_pos_z + l_thickness/2 +*/ s_pos_z + active_tck/2)); lLog << MSG::INFO << "Placing Epitaxial slice at 0, 0, " << /*l_pos_z + l_thickness/2 +*/ s_pos_z + active_tck/2 << endmsg; lLog << MSG::INFO << "This EPI exists between " << /*l_pos_z + l_thickness/2 +*/ s_pos_z << " and " << /*l_pos_z + l_thickness/2 +*/ s_pos_z + active_tck << " in the z direction." << endmsg; epi_phv.addPhysVolID("digital", 1); @@ -488,13 +490,13 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm //ROBBIE 2) Place the substrate - std::string sub_name = _toString(layernum, "sub%d"); - Box sub_box(l_dim_x*2, trd_z1, substrate_tck/2); - Volume sub_vol(sub_name, sub_box, lcdd.material(active_mat)); - DetElement sub_slice(stave_det, sub_name, layernum); + std::string sub_name = dd4hep::xml::_toString(layernum, "sub%d"); + dd4hep::Box sub_box(l_dim_x*2, trd_z1, substrate_tck/2); + dd4hep::Volume sub_vol(sub_name, sub_box, lcdd.material(active_mat)); + dd4hep::DetElement sub_slice(stave_det, sub_name, layernum); //lLog << MSG::INFO << "sub_name is " << sub_name << endmsg; lLog << MSG::INFO << "Substrate thickness is " << substrate_tck << endmsg; - PlacedVolume sub_phv = trap_vol.placeVolume(sub_vol, Position(0, 0, /*l_pos_z + l_thickness/2 +*/ s_pos_z + substrate_tck/2)); + dd4hep::PlacedVolume sub_phv = trap_vol.placeVolume(sub_vol, dd4hep::Position(0, 0, /*l_pos_z + l_thickness/2 +*/ s_pos_z + substrate_tck/2)); lLog << MSG::INFO << "Placing Substrate slice at 0, 0, " << /*l_pos_z + l_thickness/2 +*/ s_pos_z + substrate_tck/2 << endmsg; lLog << MSG::INFO << "This SUB exists between " << /*l_pos_z + l_thickness/2 +*/ s_pos_z << " and " << /*l_pos_z + l_thickness/2 +*/ s_pos_z + substrate_tck << " in the z direction." << endmsg; sub_phv.addPhysVolID("digital", 0); @@ -514,12 +516,12 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm s_pos_z -= padding_tck; } - std::string pas_name = _toString(layernum, "passive%d"); - Box pas_box(l_dim_x*2, trd_z1, passive_tck/2); - Volume pas_vol(pas_name, pas_box, lcdd.material(passive_mat)); - DetElement pas_slice(stave_det, pas_name, layernum); + std::string pas_name = dd4hep::xml::_toString(layernum, "passive%d"); + dd4hep::Box pas_box(l_dim_x*2, trd_z1, passive_tck/2); + dd4hep::Volume pas_vol(pas_name, pas_box, lcdd.material(passive_mat)); + dd4hep::DetElement pas_slice(stave_det, pas_name, layernum); lLog << MSG::INFO << "Passive thickness is " << passive_tck << endmsg; - PlacedVolume pas_phv = trap_vol.placeVolume(pas_vol, Position(0, 0, s_pos_z + passive_tck/2)); + dd4hep::PlacedVolume pas_phv = trap_vol.placeVolume(pas_vol, dd4hep::Position(0, 0, s_pos_z + passive_tck/2)); lLog << MSG::INFO << "Placing Passive slice at 0, 0, " << /*l_pos_z + l_thickness/2 +*/ s_pos_z + passive_tck/2 << endmsg; lLog << MSG::INFO << "This PAS exists between " << /*l_pos_z + l_thickness/2 +*/ s_pos_z << " and " << /*l_pos_z + l_thickness/2 +*/ s_pos_z + passive_tck << " in the z direction." << endmsg; pas_slice.setPlacement(pas_phv); @@ -571,11 +573,11 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm lLog << MSG::INFO << "m_pos_x is -mod_y_off*sin(phi) = -" << mod_y_off << "sin(" << phi << ") = " << m_pos_x << endmsg; lLog << MSG::INFO << "m_pos_y is mod_y_off*cos(phi) = " << mod_y_off << "cos(" << phi << ") = " << m_pos_y << endmsg; - Transform3D tr(RotationZYX(0, /*3.0*M_PI + */phi, M_PI*0.5), Translation3D(-m_pos_x, -m_pos_y, 0)); + dd4hep::Transform3D tr(dd4hep::RotationZYX(0, /*3.0*M_PI + */phi, M_PI*0.5), dd4hep::Translation3D(-m_pos_x, -m_pos_y, 0)); lLog << MSG::INFO << "Placing stave with rotation " << phi << " and position " << -m_pos_x << ", " << -m_pos_y << ", 0" << endmsg; //Place the staves: - PlacedVolume pv = caloVolume.placeVolume(trap_vol, tr); + dd4hep::PlacedVolume pv = caloVolume.placeVolume(trap_vol, tr); //pv.addPhysVolID("stave", stavenum); double not_phi = (M_PI/2) - phi; double not_rmax = mod_y_off + (2*trd_y); @@ -599,8 +601,8 @@ static DD4hep::Geometry::Ref_t createECal (DD4hep::Geometry::LCDD& lcdd,xml_h xm //Place envelope (or barrel) volume - Volume motherVol = lcdd.pickMotherVolume(eCal); - PlacedVolume placedECal = motherVol.placeVolume(envelopeVolume); + dd4hep::Volume motherVol = lcdd.pickMotherVolume(eCal); + dd4hep::PlacedVolume placedECal = motherVol.placeVolume(envelopeVolume); placedECal.addPhysVolID("system", eCal.id()); eCal.setPlacement(placedECal); return eCal; From 47b2b43796bee8806822028643f5258cf2df45af Mon Sep 17 00:00:00 2001 From: tonypba Date: Sun, 4 Mar 2018 01:30:32 +0100 Subject: [PATCH 20/28] Fixed DD4hep depenacies --- Detector/DetSensitive/src/SDWrapper_TP.cpp | 66 ---------------------- 1 file changed, 66 deletions(-) delete mode 100644 Detector/DetSensitive/src/SDWrapper_TP.cpp diff --git a/Detector/DetSensitive/src/SDWrapper_TP.cpp b/Detector/DetSensitive/src/SDWrapper_TP.cpp deleted file mode 100644 index 925ee5460..000000000 --- a/Detector/DetSensitive/src/SDWrapper_TP.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "DDG4/Factories.h" -#include "DD4hep/LCDD.h" - -#include "DetSensitive/SimpleTrackerSD.h" -#include "DetSensitive/MiddleStepTrackerSD.h" -#include "DetSensitive/SimpleCalorimeterSD.h" -#include "DetSensitive/AggregateCalorimeterSD.h" -#include "DetSensitive/DigitalCalorimeterSD.h" - -namespace DD4hep { -namespace Simulation { - -// All G4VSensitiveDetector are deleted by ~G4SDManager called by ~G4RunManagerKernel -// Factory method to create an instance of SimpleTrackerSD -static G4VSensitiveDetector* create_simple_tracker_sd( - const std::string& aDetectorName, - DD4hep::Geometry::LCDD& aLcdd) { - std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); - return new det::SimpleTrackerSD(aDetectorName, - readoutName, - aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); -} -// Factory method to create an instance of MiddleStepTrackerSD -static G4VSensitiveDetector* create_middle_step_tracker_sd( - const std::string& aDetectorName, - DD4hep::Geometry::LCDD& aLcdd) { - std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); - return new det::MiddleStepTrackerSD(aDetectorName, - readoutName, - aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); -} -// Factory method to create an instance of SimpleCalorimeterSD -static G4VSensitiveDetector* create_simple_calorimeter_sd( - const std::string& aDetectorName, - DD4hep::Geometry::LCDD& aLcdd) { - std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); - return new det::SimpleCalorimeterSD(aDetectorName, - readoutName, - aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); -} -// Factory method to create an instance of AggregateCalorimeterSD -static G4VSensitiveDetector* create_aggregate_calorimeter_sd( - const std::string& aDetectorName, - DD4hep::Geometry::LCDD& aLcdd) { - std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); - return new det::AggregateCalorimeterSD(aDetectorName, - readoutName, - aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); -} - -// Factory method to create an instance of DigitalCalorimeterSD -static G4VSensitiveDetector* create_digital_calorimeter_sd( - const std::string& aDetectorName, - DD4hep::Geometry::LCDD& aLcdd) { - std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); - return new det::DigitalCalorimeterSD(aDetectorName, - readoutName, - aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); -} -} -} -DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(SimpleTrackerSD,DD4hep::Simulation::create_simple_tracker_sd) -DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(MiddleStepTrackerSD,DD4hep::Simulation::create_middle_step_tracker_sd) -DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(SimpleCalorimeterSD,DD4hep::Simulation::create_simple_calorimeter_sd) -DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(AggregateCalorimeterSD,DD4hep::Simulation::create_aggregate_calorimeter_sd) -DECLARE_EXTERNAL_GEANT4SENSITIVEDETECTOR(DigitalCalorimeterSD,DD4hep::Simulation::create_digital_calorimeter_sd) From 06f4b22dc48c4549202ee521da87b078d739b960 Mon Sep 17 00:00:00 2001 From: tonypba Date: Wed, 7 Mar 2018 00:55:05 +0100 Subject: [PATCH 21/28] modified DD4hep/LCCD.h for DD4hep/Detector.h and removed all commented code ready for PR --- .../src/ECalBarrel_geo.cpp | 297 +----------------- .../DetSensitive/DigitalCalorimeterSD.h | 12 +- .../DetSensitive/src/DigitalCalorimeterSD.cpp | 40 +-- Detector/DetSensitive/src/SDWrapper.cpp | 10 +- .../src/components/DECalAnalysis.cpp | 122 +------ .../src/components/DECalLongitudinalTest.cpp | 9 +- .../src/components/FilterSiliconEcalHits.cpp | 2 +- .../DetStudies/src/components/SiWAnalysis.cpp | 7 +- geant_fullsim_ecal_SPG_new.py | 4 +- submit_energy_res_to_lxbatch.py | 12 +- 10 files changed, 60 insertions(+), 455 deletions(-) diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp index 76e9611e9..c3c25954c 100644 --- a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -12,23 +12,6 @@ #include "cmath" -/*ROBBIE -using namespace std; -using namespace dd4hep; -using namespace dd4hep::detail; -using dd4hep::Geometry::Volume; -using dd4hep::Geometry::DetElement; -using dd4hep::XML::Dimension; -using dd4hep::Geometry::PlacedVolume; -using dd4hep::Geometry::Trapezoid; -using dd4hep::_toString; -using dd4hep::Geometry::Position; -using dd4hep::Geometry::Box; -using dd4hep::Geometry::Transform3D; -using dd4hep::Geometry::RotationZYX; -using dd4hep::Geometry::Translation3D; -*/ - namespace det { @@ -64,8 +47,6 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han dd4hep::xml::DetElement active = calo.child("active_layers"); std::string active_mat=active.materialStr(); double active_tck=active.thickness(); - //int active_samples=active.attr("nSamplings"); - // need to fix line above as no longer supported int active_samples = 50; dd4hep::xml::DetElement substrate = calo.child("substrate_layers"); @@ -84,7 +65,7 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han double module_tck = active_tck+substrate_tck+passive_tck+std::fabs(padding_tck); double calo_tck=(active_samples*module_tck) + trkr_tck; - //ROBBIE introduce number of staves, modules from the xml file: + //Introduce number of staves, modules from the xml file: int nStaves = calo_dims.numsides(); int nModules = calo_dims.nmodules(); int testing = 1; @@ -100,14 +81,13 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han lLog << MSG::INFO << "nSamplings Layers = " << active_samples << endmsg; lLog << MSG::INFO << "Total Calorimeter thickness = " << calo_tck << endmsg; - //ROBBIE log number of staves/modules in the log file: + //Log number of staves/modules in the log file: lLog << MSG::INFO << "nStaves = " << nStaves << endmsg; lLog << MSG::INFO << "nModules = " << nModules << endmsg; // Make volume that envelopes the whole barrel; set material to air dd4hep::xml::Dimension dimensions(xmlDet.dimensions()); dd4hep::Tube envelopeShape(dimensions.rmin(), dimensions.rmax(), dimensions.dz()); - //DD4hep::Geometry::Tube envelopeShape(dimensions.rmin(), dimensions.rmin()+calo_tck, dimensions.dz()); dd4hep::Volume envelopeVolume(detName, envelopeShape, lcdd.air()); // Invisibility seems to be broken in visualisation tags, have to hardcode that std::cout << "dimensions.visStr() = " << dimensions.visStr()<< std::endl; @@ -116,8 +96,8 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han // create a lump of air the entire size of the barrel ECAL (Cylindrical) // place it within the ECAL envelope dd4hep::DetElement caloDet(calo_name, calo_id); - dd4hep::Tube caloShape(calo_dims.rmin() , /*calo_dims.rmin()+calo_tck*/calo_dims.rmax(), calo_dims.dz()); - lLog << MSG::INFO/*DEBUG*/ << "ECAL: Building the calorimeter from " << calo_dims.rmin() << " to " << /*calo_dims.rmin()+calo_tck*/calo_dims.rmax() << endmsg; + dd4hep::Tube caloShape(calo_dims.rmin() , calo_dims.rmax(), calo_dims.dz()); + lLog << MSG::INFO << "ECAL: Building the calorimeter from " << calo_dims.rmin() << " to " << calo_dims.rmax() << endmsg; dd4hep::Volume caloVolume(padding_mat, caloShape, lcdd.material(padding_mat)); lLog << MSG::DEBUG << "ECAL: Filling the calorimeter volume with " << padding_mat << endmsg; dd4hep::PlacedVolume placedCalo = envelopeVolume.placeVolume(caloVolume); @@ -134,8 +114,6 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han lLog << MSG::DEBUG << "TRKR: Tracker from " << calo_dims.rmin() << " to " << calo_dims.rmin()+trkr_tck << endmsg; dd4hep::Volume trkrVolume(trkr_mat, trkrShape, lcdd.material(trkr_mat)); dd4hep::PlacedVolume placedTrkrLayer = caloVolume.placeVolume(trkrVolume); - //placedTrkrLayer.addPhysVolID("trkr", 0); - //placedTrkrLayer.addPhysVolID("layer", 0); trkrLayer.setPlacement(placedTrkrLayer); } @@ -163,7 +141,7 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han // | I | B | R | S | I | B | R | S | ... | I | B | R | S | // | | | | | | | | | ... | | | | | - //ROBBIE Leave option for circular geometry if nStaves == 1: + //Leave option for circular geometry if nStaves == 1: if (nStaves == 1) { // loop on the sensitive and substrate layers and place within the caloVolume @@ -219,9 +197,9 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han } } - //END OF TONY'S STUFF + //END OF CIRCULAR GEOMETRY - else if (testing == 1) { + else { double hphi = M_PI/nStaves; double rmin = calo_dims.rmin(); double rmax = calo_dims.rmax(); @@ -241,7 +219,7 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han double module_dz = dz/nModules; double module_z = -trd_z + (module_dz/2); - for (int stavenum=0; stavenum= 0 then need to add in the thickness of the air gap: - if(!(padding_tck < 0)) - { - s_pos_z -= padding_tck; - } - - /*PlacedVolume layer_phv = trap_vol.placeVolume(l_vol, l_pos); - lLog << MSG::INFO << "Placing Layer at " << "(0, 0, " << l_pos_z + l_thickness/2 << ")" << endmsg; - lLog << MSG::INFO << "Layer = " << layernum << endmsg; - if (layernum == 30) { - lLog << MSG::INFO << "PROBLEM! layernum IS TOO DAMN HIGH! IT SHOULD NEVER REACH " << layernum << "!" << endmsg; - }*/ - //lLog << MSG::INFO << "LAYER information dump : " << layer_phv.toString() << endmsg; - //layer_phv.addPhysVolID("layer", layernum); - //layer.setPlacement(layer_phv); - // l_pos_z += l_thickness; - // ++l_num; - - } - - - //ROBBIE Create an overall volume by repeating the trapezium nStaves times - - // double phi = M_PI / nStaves; - // double dphi = 2*phi; - // double mod_y_off = rmin + trd_y; - // lLog << MSG::INFO << "mod_y_off is " << mod_y_off << endmsg; - - - // for (int i=0; i* m_calorimeterCollection; - G4THitsCollection* m_tempCollection; + G4THitsCollection* m_calorimeterCollection; + G4THitsCollection* m_tempCollection; /// Segmentation of the detector used to retrieve the cell Ids - DD4hep::Geometry::Segmentation m_seg; + dd4hep::Segmentation m_seg; std::string m_pixelsOverThresholdFileName; std::ofstream m_pixelsOverThresholdFile; diff --git a/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp b/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp index 0ac2633e2..4787a8aaf 100644 --- a/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp +++ b/Detector/DetSensitive/src/DigitalCalorimeterSD.cpp @@ -26,7 +26,7 @@ namespace det { DigitalCalorimeterSD::DigitalCalorimeterSD(const std::string& aDetectorName, const std::string& aReadoutName, - const DD4hep::Geometry::Segmentation& aSeg) + const dd4hep::Segmentation& aSeg) : G4VSensitiveDetector(aDetectorName), m_seg(aSeg), m_calorimeterCollection(nullptr) { // name of the collection of hits is determined byt the readout name (from XML) collectionName.insert(aReadoutName); @@ -44,12 +44,12 @@ void DigitalCalorimeterSD::Initialize(G4HCofThisEvent* aHitsCollections) // create a collection of hits and add it to G4HCofThisEvent // deleted in ~G4Event m_calorimeterCollection = new G4THitsCollection - (SensitiveDetectorName,collectionName[0]); + (SensitiveDetectorName,collectionName[0]); aHitsCollections->AddHitsCollection(G4SDManager::GetSDMpointer()->GetCollectionID(m_calorimeterCollection), m_calorimeterCollection); //this collection is just a temp and not added to the HitsCollection just used to store raw hits before summing together m_tempCollection = new G4THitsCollection - (SensitiveDetectorName,"temp"); + (SensitiveDetectorName,"temp"); // m_pixelsOverThresholdFile.open("pixelsOverThreshold.txt", std::ios_base::app);. @@ -98,8 +98,8 @@ bool DigitalCalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) } } - DD4hep::Simulation::Position pos(prePos.x(), prePos.y(), prePos.z()); - auto hit = new DD4hep::Simulation::Geant4CalorimeterHit(pos); + dd4hep::Position pos(prePos.x(), prePos.y(), prePos.z()); + auto hit = new dd4hep::sim::Geant4CalorimeterHit(pos); //hit->cellID = segmentation::cellID(m_seg, *aStep); hit->cellID = utils::cellID(m_seg, *aStep); @@ -126,14 +126,14 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { // map.first = cellID // map.second.first = number of particles into the cell // map.second.second = total energy deposited in the cell - std::map > counter; - DD4hep::Simulation::Geant4CalorimeterHit* hit = nullptr; + std::map > counter; + dd4hep::sim::Geant4CalorimeterHit* hit = nullptr; - std::cout << "####" << m_seg->type() << std::endl; + //std::cout << "####" << m_seg->type() << std::endl; // loop through all of the hits in an event and sum the energy deposited per cell for(int i=0; i (m_tempCollection->GetHit(i)); + hit = dynamic_cast (m_tempCollection->GetHit(i)); // this bit of code allows us to check that is incident and that we should count as new particles // we then make the value of energy +ve again for ease of adding @@ -155,7 +155,7 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { // if useMask=false then IsAllowedCellID always returns true if(IsAllowedCellID(cellID)){ - std::map >::iterator it = counter.find(cellID); + std::map >::iterator it = counter.find(cellID); if(counter.find(cellID) != counter.end()) { @@ -171,7 +171,7 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { if(isIncident) { nparts = 1; } - std::pair info = std::make_pair(nparts, hit); + std::pair info = std::make_pair(nparts, hit); counter[cellID] = info; } } @@ -180,7 +180,7 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { // now loop through all the hits and check the Mask. Cannot do it before as may cut out multiple hits to cells bool useMask = false; for(int i=0; i (m_tempCollection->GetHit(i)); + hit = dynamic_cast (m_tempCollection->GetHit(i)); uint64_t cellID = hit->cellID; AddCellIDMask(cellID); } @@ -195,8 +195,8 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { mipsPerPixel[n].clear(); } - DD4hep::Simulation::Geant4CalorimeterHit* digi = nullptr; - std::map >::iterator it; + dd4hep::sim::Geant4CalorimeterHit* digi = nullptr; + std::map >::iterator it; std::map StrixelHitCounter; for(it=counter.begin(); it!=counter.end(); it++) { @@ -208,10 +208,10 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { if((*it).second.second->energyDeposit>=threshold) { pixelsOverThreshold++; // insert the collection to G4 so can be passed on later - digi = dynamic_cast ((*it).second.second); + digi = dynamic_cast ((*it).second.second); // this line overwrites the time parameter with the number of particles per pixel - std::vector conts; - DD4hep::Simulation::Geant4Hit::MonteCarloContrib cont(0,0,0,0); + std::vector conts; + dd4hep::sim::Geant4Hit::MonteCarloContrib cont(0,0,0,0); if(m_countParticlesPerPixel) { //digi->energyDeposit = (*it).second.first; // overwrite the energy deposit with the number of mips in the cell @@ -232,7 +232,7 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { // below this point is DECal chip specific where the readout is reconfidured // not needed for the analogue SiW - /* int strixelHits = StrixelHitCounter.size(); + int strixelHits = StrixelHitCounter.size(); int strixelPixelHits_3 = 0; int strixelPixelHits_7 = 0; int strixelPixelHits_15 = 0; @@ -344,10 +344,10 @@ void DigitalCalorimeterSD::EndOfEvent(G4HCofThisEvent*) { // std::cout << "Total number of unique pads = " << PadHitCounter.size() << std::endl << std::endl; - std::cout << m_incidentParticles << "\t" << counter.size() << "\t" << pixelsOverThreshold << "\t" << strixelHits << "\t" << strixelPixelHits_3 << "\t" << strixelPixelHits_7 << "\t" << strixelPixelHits_15 << "\t" << strixelPixelHits_31 << "\t" << PadHitCounter.size() << std::endl; + std::cout << "Counters\t"<< m_incidentParticles << "\t" << counter.size() << "\t" << pixelsOverThreshold << "\t" << strixelHits << "\t" << strixelPixelHits_3 << "\t" << strixelPixelHits_7 << "\t" << strixelPixelHits_15 << "\t" << strixelPixelHits_31 << "\t" << PadHitCounter.size() << std::endl; -*/ + } diff --git a/Detector/DetSensitive/src/SDWrapper.cpp b/Detector/DetSensitive/src/SDWrapper.cpp index 92db39915..53da0c58e 100644 --- a/Detector/DetSensitive/src/SDWrapper.cpp +++ b/Detector/DetSensitive/src/SDWrapper.cpp @@ -49,13 +49,11 @@ static G4VSensitiveDetector* create_aggregate_calorimeter_sd(const std::string& aDetectorName, readoutName, aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); } // Factory method to create an instance of DigitalCalorimeterSD -static G4VSensitiveDetector* create_digital_calorimeter_sd( - const std::string& aDetectorName, - DD4hep::Geometry::LCDD& aLcdd) { +static G4VSensitiveDetector* create_digital_calorimeter_sd(const std::string& aDetectorName, + dd4hep::Detector& aLcdd) { std::string readoutName = aLcdd.sensitiveDetector(aDetectorName).readout().name(); - return new det::DigitalCalorimeterSD(aDetectorName, - readoutName, - aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); + return new det::DigitalCalorimeterSD( + aDetectorName,readoutName,aLcdd.sensitiveDetector(aDetectorName).readout().segmentation()); } // Factory method to create an instance of GflashCalorimeterSD static G4VSensitiveDetector* create_gflash_calorimeter_sd(const std::string& aDetectorName, diff --git a/Detector/DetStudies/src/components/DECalAnalysis.cpp b/Detector/DetStudies/src/components/DECalAnalysis.cpp index 6087708be..334e21c18 100644 --- a/Detector/DetStudies/src/components/DECalAnalysis.cpp +++ b/Detector/DetStudies/src/components/DECalAnalysis.cpp @@ -18,7 +18,7 @@ #include "string" // DD4hep -#include "DD4hep/LCDD.h" +#include "DD4hep/Detector.h" #include "DD4hep/Readout.h" DECLARE_ALGORITHM_FACTORY(DECalAnalysis) @@ -70,13 +70,7 @@ StatusCode DECalAnalysis::initialize() { for(uint l(0); lBranch(Form("particles_l%i", l), &m_sumParticlesLayers[l]); } - /* m_treeInfo->Branch("fit_E0", &m_fitE0); - m_treeInfo->Branch("fit_a", &m_fita); - m_treeInfo->Branch("fit_b", &m_fitb); - m_treeInfo->Branch("rising50", &m_rising50); - m_treeInfo->Branch("rising90", &m_rising90); - m_treeInfo->Branch("fwhm", &m_fwhm); - */ if(m_histSvc->regTree("/rec/decalInfo", m_treeInfo).isFailure()) { + if(m_histSvc->regTree("/rec/decalInfo", m_treeInfo).isFailure()) { error() << "Couldn't register tree" << endmsg; return StatusCode::FAILURE; } @@ -190,17 +184,7 @@ StatusCode DECalAnalysis::initialize() { m_calFit->SetParameter("p0", m_calP0); m_calFit->SetParameter("p1", m_calP1); m_calFit->SetParameter("p2", m_calP2); - -/* m_fitLongProfile = new TF1("longEnergyDepFit",FitLongProfile , 0.5, 50.0, 3); - m_fitLongProfile->SetParameter(0, 3); - m_fitLongProfile->SetParName(0, "E_0"); - m_fitLongProfile->SetParameter(1, 3.7); - m_fitLongProfile->SetParName(1, "a"); - m_fitLongProfile->SetParameter(2, 0.5); - m_fitLongProfile->SetParName(2, "b"); - m_fitLongProfile->SetLineColor(1); - m_fitLongProfile->SetLineStyle(7); -*/ + // if it gets to here then it has registered all histograms return StatusCode::SUCCESS; } @@ -249,7 +233,6 @@ StatusCode DECalAnalysis::execute() { for (const auto& hit : *deposits) { decoder->setValue(hit.core().cellId); -// std::cout << digital << std::endl; int layer = (*decoder)[m_layerFieldName]; m_sumPixelsLayers[layer] += 1; @@ -280,103 +263,7 @@ StatusCode DECalAnalysis::execute() { std::cout << "isdigital = " << isdigital << std::endl; std::cout << "notdigital = " << notdigital << std::endl; -/* - m_calPixels = m_calFit->GetX(m_sumPixels); - //std::cout << "#### " << m_sumPixels << " " << m_calPixels << std::endl; - - // loop through eta and phi and calculate the mean - for(uint l(1); l maxHits) { - maxHits = m_sumPixelsLayers[l]; - maxLayer = l; - } - } - - // loop through and fill the hitsVsLayer histogram for first N(=100) events - for(uint l=1; lSetBinContent(l+1, m_sumPixelsLayers[l]); - m_hitsVsLayerEvent[m_nEventsFilled+1]->SetBinError(l+1, TMath::Power(m_sumPixelsLayers[l],0.5)); - } - // the 0th element is changed each run to allow fitting in code of the profile - m_hitsVsLayerEvent[0]->SetBinContent(l+1, m_sumPixelsLayers[l]); - m_hitsVsLayerEvent[0]->SetBinError(l+1, TMath::Power(m_sumPixelsLayers[l],0.5)); - } - m_nEventsFilled++; - - // fit the m_hitsVsLayerEvent[0] histogram - /* if(m_hitsVsLayerEvent[0]->GetEntries()>0) { - m_hitsVsLayerEvent[0]->Fit(m_fitLongProfile, "NR"); - m_fitE0 = m_fitLongProfile->GetParameter("E_0"); - m_fita = m_fittLongProfile->GetParameter("a"); - m_fitb = m_fitLongProfile->GetParameter("b"); - - // calculate where function is half the value of max - double fitMax = m_fitLongProfile->GetMaximum(); - double half_lowx = m_fitLongProfile->GetX(fitMax/2, 0, m_fitLongProfile->GetX(fitMax)); - double half_highx = m_fitLongProfile->GetX(fitMax/2,m_fitLongProfile->GetX(fitMax)); - m_fwhm = half_highx-half_lowx; - m_rising50->Fill(half_lowx); - m_rising80->Fill(->GetX(fitMax*0.8, 0, m_fitLongProfile->GetX(fitMax))); - } - - // Fill histograms - m_totalHits->Fill(m_sumPixels); - //debug() << "total hits in event = " << sumHits << endmsg; - for (uint i = 1; i < m_numLayers+1; i++) { - m_totalHitsLayers[i]->Fill(m_sumPixelsLayers[i]); - //debug() << "total hits in layer " << i << " = " << m_sumPixelsLayers[i] << endmsg; - } - - m_hitsInMaxLayer->Fill(maxHits); - m_maxLayer->Fill(maxLayer); - - - // Pads analysis - m_sumPads = 0; - int pixelsPerPadThreshold = 10; - m_sumPadsLayers.assign(m_numLayers+1, 0); - std::vector sumPadsAbovePixelThreshold; - sumPadsAbovePixelThreshold.assign(m_numLayers, 0); - - auto decoder_pad = m_geoSvc->lcdd()->readout(m_padReadoutName).idSpec().decoder(); - const auto pads = m_pads.get(); - for (const auto& hit : *pads) { - decoder_pad->setValue(hit.core().cellId); - uint layer = (*decoder_pad)[m_layerFieldName]; - m_sumPadsLayers[layer] ++; - if (layer > 0) { - m_sumPads++; - double pixelsPerPad = hit.core().energy; - m_totalPixelsPerPadLayers[layer]->Fill(pixelsPerPad); - if(pixelsPerPad > pixelsPerPadThreshold) { - sumPadsAbovePixelThreshold[layer]++; - } - } - } - - - uint totalPadsAbovePixelThreshold = 0; - for( uint i=1; iFill(m_sumPadsLayers[i]); - totalPadsAbovePixelThreshold += sumPadsAbovePixelThreshold[i]; - } - m_totalPads->Fill(m_sumPads); - m_totalPadsAbovePixelThreshold->Fill(totalPadsAbovePixelThreshold); -*/ if(m_sumPixels>0 || m_sumPads>0) { m_treeInfo->Fill(); } @@ -392,8 +279,7 @@ StatusCode DECalAnalysis::finalize() { // count from 1 to avoid the hits in the Trkr volume for (uint i = 1; i < m_numLayers+1; i++) { m_totalHitsVsLayer->SetBinContent(i+1,m_totalHitsLayers[i]->GetMean()); - m_totalPadsVsLayer->SetBinContent(i+1,m_totalPadsLayers[i]->GetMean());//sumPadslayers[i]); - //debug() << "total hits in layer " << i << " = " << m_sumPixelsLayers[i] << endmsg; + m_totalPadsVsLayer->SetBinContent(i+1,m_totalPadsLayers[i]->GetMean()); } return GaudiAlgorithm::finalize(); } diff --git a/Detector/DetStudies/src/components/DECalLongitudinalTest.cpp b/Detector/DetStudies/src/components/DECalLongitudinalTest.cpp index 332b1bf5e..6f73960d5 100644 --- a/Detector/DetStudies/src/components/DECalLongitudinalTest.cpp +++ b/Detector/DetStudies/src/components/DECalLongitudinalTest.cpp @@ -15,7 +15,7 @@ #include "TMath.h" // DD4hep -#include "DD4hep/LCDD.h" +#include "DD4hep/Detector.h" #include "DD4hep/Readout.h" DECLARE_ALGORITHM_FACTORY(DECalLongitudinalTest) @@ -65,7 +65,6 @@ StatusCode DECalLongitudinalTest::initialize() { return StatusCode::FAILURE; } - //m_EtaPhiEvent0 = new TH2F("decal_EtaPhiEvent0", "Eta Phi Positions for Event 0", 222, -0.004, 0.002, 222, -0.8305,-0.8245); m_EtaPhiEvent0 = new TH2F("decal_EtaPhiEvent0", "Eta Phi Positions for Event 0", 2000, -0.04, 0.02, 2000, -4,4); if (m_histSvc->regHist("/rec/decal_EtaPhiEvent0", m_EtaPhiEvent0).isFailure()) { error() << "Couldn't register histogram" << endmsg; @@ -102,8 +101,7 @@ StatusCode DECalLongitudinalTest::execute() { const auto deposits = m_deposits.get(); for (const auto& hit : *deposits) { decoder->setValue(hit.core().cellId); - //debug() << "(*decoder)[m_layerFieldName] = " << (*decoder)[m_layerFieldName] << endmsg; - sumHitslayers[(*decoder)[m_layerFieldName]] += 1; //hit.core().energy; + sumHitslayers[(*decoder)[m_layerFieldName]] += 1; // check if energy was deposited in the calorimeter (active/passive material) // layers are numbered starting from 1, layer == 0 is cryostat/bath std::cout << (*decoder)[m_layerFieldName] << std::endl; @@ -127,10 +125,8 @@ StatusCode DECalLongitudinalTest::execute() { // Fill histograms m_totalHits->Fill(sumHits); - //debug() << "total hits in event = " << sumHits << endmsg; for (uint i = 1; i < m_numLayers; i++) { m_totalHitsLayers[i]->Fill(sumHitslayers[i]); - //debug() << "total hits in layer " << i << " = " << sumHitslayers[i] << endmsg; } return StatusCode::SUCCESS; } @@ -141,7 +137,6 @@ StatusCode DECalLongitudinalTest::finalize() { // count from 1 to avoid the hits in the Trkr volume for (uint i = 1; i < m_numLayers; i++) { m_totalHitsVsLayer->SetBinContent(i+1,m_totalHitsLayers[i]->GetMean()); - //debug() << "total hits in layer " << i << " = " << sumHitslayers[i] << endmsg; } return GaudiAlgorithm::finalize(); } diff --git a/Detector/DetStudies/src/components/FilterSiliconEcalHits.cpp b/Detector/DetStudies/src/components/FilterSiliconEcalHits.cpp index b52141875..dc2d4dc8e 100644 --- a/Detector/DetStudies/src/components/FilterSiliconEcalHits.cpp +++ b/Detector/DetStudies/src/components/FilterSiliconEcalHits.cpp @@ -18,7 +18,7 @@ #include "string" // DD4hep -#include "DD4hep/LCDD.h" +#include "DD4hep/Detector.h" #include "DD4hep/Readout.h" DECLARE_ALGORITHM_FACTORY(FilterSiliconEcalHits) diff --git a/Detector/DetStudies/src/components/SiWAnalysis.cpp b/Detector/DetStudies/src/components/SiWAnalysis.cpp index 1fccdd783..34312c6c2 100644 --- a/Detector/DetStudies/src/components/SiWAnalysis.cpp +++ b/Detector/DetStudies/src/components/SiWAnalysis.cpp @@ -18,7 +18,7 @@ #include "string" // DD4hep -#include "DD4hep/LCDD.h" +#include "DD4hep/Detector.h" #include "DD4hep/Readout.h" DECLARE_ALGORITHM_FACTORY(SiWAnalysis) @@ -125,11 +125,6 @@ StatusCode SiWAnalysis::execute() { } } -/* - m_calPixels = m_calFit->GetX(m_sumPixels); - //std::cout << "#### " << m_sumPixels << " " << m_calPixels << std::endl; -*/ - // Fill histograms m_totalEdep->Fill(m_sumEnergyDep); diff --git a/geant_fullsim_ecal_SPG_new.py b/geant_fullsim_ecal_SPG_new.py index 66adbefad..990fb7fe6 100644 --- a/geant_fullsim_ecal_SPG_new.py +++ b/geant_fullsim_ecal_SPG_new.py @@ -42,10 +42,10 @@ x=random.randrange(1, 384649202, 1) print x -geantservice.G4commands += ["/random/setSeeds "+str(x)+" 0"] #where x is the number you want +#geantservice.G4commands += ["/random/setSeeds "+str(x)+" 0"] #where x is the number you want #range cut -geantservice.G4commands += ["/run/setCut 0.1 mm"] +#geantservice.G4commands += ["/run/setCut 0.1 mm"] # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools diff --git a/submit_energy_res_to_lxbatch.py b/submit_energy_res_to_lxbatch.py index dfd316abc..ea22d6f6b 100644 --- a/submit_energy_res_to_lxbatch.py +++ b/submit_energy_res_to_lxbatch.py @@ -9,17 +9,17 @@ print ######## YOU ONLY NEED TO FILL THE AREA BELOW ######### ######## customization area ######### -CONFIG="50Layers_2.1mmW_50umPixels_18umThick_RRB" -FCCSW_VERSION="FCCSW0.8" +CONFIG="50Layers_2.1mmW_50umPixels_18umThick" +FCCSW_VERSION="FCCSW0.9" #ENERGIES = ["10","20","50","70","100","200", "300", "500","700","1000"] -ENERGIES = ["10", "50","100","200", "300", "500","700","1000"] +#ENERGIES = ["10", "50","100","200", "300", "500","700","1000"] #ENERGIES = ["101","501","1001" ] # number of jobs to be submitted -#ENERGIES = ["10","20","30","40","60","70","80","90","100","300","500","700","1000" ] # number of jobs to be submitted +ENERGIES = ["10","20","30","40","60","70","80","90","100"] # number of jobs to be submitted BFIELD = "4" -EVENTS = 100 +EVENTS = 10 ETAMIN = -0.001 ETAMAX = 0.001 -NRUNS = 100 +NRUNS = 1 FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" queue = "1nd" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw ######## customization end ######### From d295777be55c25f341dd3fed4069e147b66ae98f Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 20 Mar 2018 11:09:48 +0100 Subject: [PATCH 22/28] Changing xml child levels --- ...Layers_2.1mmW_50umPixels_18umThick_RRB.xml | 21 ++++++++++++++----- .../src/ECalBarrel_geo.cpp | 19 ++++++++++------- geant_batch_temp.py | 4 ++-- submit_energy_res_to_lxbatch.py | 6 +++--- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml index e3b27be7b..e8441f6e2 100755 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml @@ -58,11 +58,22 @@ - - - - - + + + + + + + + + + + + + + + + diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp index c3c25954c..6d1756dca 100644 --- a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -35,32 +35,35 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han - dd4hep::xml::DetElement calo = xmlElement.child(_Unicode(calorimeter)); + dd4hep::xml::DetElement calo = xmlDet.child(_Unicode(calorimeter)); dd4hep::xml::Dimension calo_dims(calo.dimensions()); std::string calo_name=calo.nameStr(); double calo_id=calo.id(); - dd4hep::xml::DetElement trkr = calo.child("tracker"); - std::string trkr_mat = trkr.materialStr(); - double trkr_tck = trkr.thickness(); + //dd4hep::xml::DetElement trkr = calo.child(_Unicode(tracker)); + std::string trkr_mat = "Silicon";//trkr.materialStr(); + double trkr_tck = 0;//trkr.thickness(); - dd4hep::xml::DetElement active = calo.child("active_layers"); + dd4hep::xml::DetElement active = calo.child(_Unicode(active)); std::string active_mat=active.materialStr(); double active_tck=active.thickness(); int active_samples = 50; - dd4hep::xml::DetElement substrate = calo.child("substrate_layers"); + dd4hep::xml::DetElement substrate = calo.child(_Unicode(substrate)); std::string substrate_mat=substrate.materialStr(); double substrate_tck=substrate.thickness(); - dd4hep::xml::DetElement passive = calo.child("passive_layers"); + dd4hep::xml::DetElement passive = calo.child(_Unicode(passive)); std::string passive_mat=passive.materialStr(); double passive_tck=passive.thickness(); - dd4hep::xml::DetElement padding = calo.child("between_layers"); + dd4hep::xml::DetElement padding = calo.child(_Unicode(spacing)); std::string padding_mat=padding.materialStr(); double padding_tck=padding.thickness(); + + + // here we take the fabs value of padding as if it is negative it goes before the W volume double module_tck = active_tck+substrate_tck+passive_tck+std::fabs(padding_tck); double calo_tck=(active_samples*module_tck) + trkr_tck; diff --git a/geant_batch_temp.py b/geant_batch_temp.py index fc51c986a..e59118283 100644 --- a/geant_batch_temp.py +++ b/geant_batch_temp.py @@ -45,10 +45,10 @@ import random x=random.randrange(1, 384649202, 1) print "random seed=",x -geantservice.G4commands += ["/random/setSeeds "+str(x)+" 0"] #where x is the number you want +#geantservice.G4commands += ["/random/setSeeds "+str(x)+" 0"] #where x is the number you want #range cut -geantservice.G4commands += ["/run/setCut 0.1 mm"] +#geantservice.G4commands += ["/run/setCut 0.1 mm"] # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools diff --git a/submit_energy_res_to_lxbatch.py b/submit_energy_res_to_lxbatch.py index ea22d6f6b..ccacbdfcd 100644 --- a/submit_energy_res_to_lxbatch.py +++ b/submit_energy_res_to_lxbatch.py @@ -9,19 +9,19 @@ print ######## YOU ONLY NEED TO FILL THE AREA BELOW ######### ######## customization area ######### -CONFIG="50Layers_2.1mmW_50umPixels_18umThick" +CONFIG="50Layers_2.1mmW_50umPixels_18umThick_RRB" FCCSW_VERSION="FCCSW0.9" #ENERGIES = ["10","20","50","70","100","200", "300", "500","700","1000"] #ENERGIES = ["10", "50","100","200", "300", "500","700","1000"] #ENERGIES = ["101","501","1001" ] # number of jobs to be submitted -ENERGIES = ["10","20","30","40","60","70","80","90","100"] # number of jobs to be submitted +ENERGIES = ["10"]#,"20","30","40","60","70","80","90","100"] # number of jobs to be submitted BFIELD = "4" EVENTS = 10 ETAMIN = -0.001 ETAMAX = 0.001 NRUNS = 1 FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" -queue = "1nd" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw +queue = "8nm" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw ######## customization end ######### path = os.getcwd() From a3e14ae9ba4a2f6d07b03050ce0581f4db299dcd Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 20 Mar 2018 11:37:03 +0100 Subject: [PATCH 23/28] Modified XML file to take childs of calorimeter --- ...DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml | 6 ++++-- Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml index e8441f6e2..4abf73d4c 100755 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml @@ -58,9 +58,11 @@ - + + + - + diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp index 6d1756dca..560a2497e 100644 --- a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -47,7 +47,10 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han dd4hep::xml::DetElement active = calo.child(_Unicode(active)); std::string active_mat=active.materialStr(); double active_tck=active.thickness(); - int active_samples = 50; + + + dd4hep::xml::DetElement samples_xml = calo.child(_Unicode(layers)); + int active_samples = samples_xml.repeat(); dd4hep::xml::DetElement substrate = calo.child(_Unicode(substrate)); std::string substrate_mat=substrate.materialStr(); From 8fa4bb73ec927008b5f39b904d902f06e8484fc2 Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 20 Mar 2018 11:44:06 +0100 Subject: [PATCH 24/28] Removed all old xml files --- ...l_30Layers_3.5mmW_50umPixels_18umThick.xml | 67 -- ...Layers_3.5mmW_50umPixels_18umThick_RRB.xml | 70 -- ....5mmW_50umPixels_18umThick_RRB_modules.xml | 70 -- ..._30Layers_5.6mmPb_50umPixels_18umThick.xml | 67 -- .../FCChh_DECalBarrel_50Layers_2.1mmW.xml | 70 -- ..._50Layers_2.1mmW_100umPixels_18umThick.xml | 67 -- ...ers_2.1mmW_1mmAir_50umPixels_18umThick.xml | 67 -- ..._1mmAir_50umPixels_18umThick_TRKR0.3X0.xml | 67 -- ...l_50Layers_2.1mmW_25umPixels_18umThick.xml | 67 -- ...hh_DECalBarrel_50Layers_2.1mmW_300umSi.xml | 68 -- ..._3mmAir_50umPixels_18umThick_TRKR0.3X0.xml | 67 -- ...CChh_DECalBarrel_50Layers_2.1mmW_450um.xml | 70 -- ...l_50Layers_2.1mmW_50umPixels_18umThick.xml | 70 -- ...ayers_2.1mmW_50umPixels_18umThick_Edep.xml | 67 -- ...Layers_2.1mmW_50umPixels_18umThick_RRB.xml | 1009 +++++++++++++++-- ..._2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml | 67 -- ..._2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml | 67 -- ..._5mmAir_50umPixels_18umThick_TRKR0.3X0.xml | 67 -- ...rs_3.4mmPb_3mmAir_25umPixels_18umThick.xml | 61 - ...rs_3.4mmPb_3mmAir_50umPixels_18umThick.xml | 67 -- ...Chh_DECalBarrel_50Layers_3.4mmPb_450um.xml | 70 -- ..._50Layers_3.4mmPb_50umPixels_18umThick.xml | 67 -- .../compact/FCChh_DECalBarrel_Mockup.xml | 60 - .../compact/FCChh_DECalDefinition.xml | 10 - .../FCChh_DECalDefinition_30Layers_3.5mmW.xml | 10 - ...FCChh_DECalDefinition_30Layers_5.6mmPb.xml | 10 - .../FCChh_DECalDefinition_50Layers_2.1mmW.xml | 11 - ...DECalDefinition_50Layers_2.1mmW_1mmAir.xml | 10 - ...finition_50Layers_2.1mmW_1mmAir_SiAirW.xml | 10 - ...DECalDefinition_50Layers_2.1mmW_3mmAir.xml | 10 - ...DECalDefinition_50Layers_2.1mmW_5mmAir.xml | 10 - 31 files changed, 927 insertions(+), 1643 deletions(-) delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB_modules.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml mode change 100755 => 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml delete mode 100644 Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml deleted file mode 100644 index 77c6f8f2a..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml deleted file mode 100644 index f4d6965bd..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,x:-17,y:-17,z:-14 - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,x:-15,y:-15,z:-18 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB_modules.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB_modules.xml deleted file mode 100644 index 872f6379f..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_3.5mmW_50umPixels_18umThick_RRB_modules.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11 - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml deleted file mode 100644 index bf67614ca..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_30Layers_5.6mmPb_50umPixels_18umThick.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml deleted file mode 100644 index b4f87d860..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml deleted file mode 100644 index 3ce4a88fb..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_100umPixels_18umThick.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml deleted file mode 100644 index b133552d7..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml deleted file mode 100644 index 81371510b..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_1mmAir_50umPixels_18umThick_TRKR0.3X0.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml deleted file mode 100644 index ca0a8ffd6..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_25umPixels_18umThick.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-18,y:-18,z:-17 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml deleted file mode 100644 index 988a722df..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_300umSi.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - SiW first design - - - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-18,y:-18,z:-17 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml deleted file mode 100644 index 8e4c8a381..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_3mmAir_50umPixels_18umThick_TRKR0.3X0.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml deleted file mode 100644 index 5d5f5455d..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_450um.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml deleted file mode 100644 index bb55888b1..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml deleted file mode 100644 index 633dcb23b..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_Edep.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,subtype:1,x:-17,y:-17,z:-8 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,subtype:1,x:-17,y:-17,z:-8 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml old mode 100755 new mode 100644 index 4abf73d4c..21de3ec4b --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml @@ -1,83 +1,928 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11 - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FCCSW/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml at master · tonyPbA/FCCSW · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content +
+ + + + + + + + + +
+ +
+ +
+
+ + + +
+
+
+ + + + + + + + +
+
+ + + +

+ + /FCCSW + + + forked from HEP-FCC/FCCSW + +

+ +
+ + + + +
+ +
+
+ + + Permalink + + + +
+ +
+ + +
+ +
+
+ + Switch branches/tags +
+ +
+
+ +
+
+ +
+
+ + + +
+ + +
Nothing to show
+
+ +
+
+
+ +
+ + Find file + + + Copy path + +
+ +
+ + + +
+ Fetching contributors… +
+ +
+ + Cannot retrieve contributors at this time +
+
+ +
+
+
+ +
+ Raw + Blame + History +
+ + + + +
+ +
+ executable file + + 82 lines (69 sloc) + + 3.03 KB +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?xml version="1.0" encoding="UTF-8"?>
<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
<info name="FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick"
title="DECal Barrel Calorimeter"
author="T. Price"
url="no"
status="development"
version="$Id:??$">
<comment>DECal very conceptual design</comment>
</info>
+
<define>
<constant name="BarECalOuterSpacer" value="100*mm"/>
<!-- calorimeter volume -->
<!-- have removed the cryostat as we do not need it! -->
<constant name="EMBarrel_rmin" value="BarECal_rmin+BarECalOuterSpacer"/>
<constant name="EMBarrel_rmax" value="BarECal_rmax-BarECalOuterSpacer"/>
<constant name="EMBarrel_dz" value="100*mm"/><!--BarECal_dz"/-->
+
</define>
+
<display>
<!--vis name="ecal_envelope" r="0.1" g="0.2" b="0.6" alpha="0.1" showDaughers="false" visible="false" /-->
<vis name="ecal_volume" r="0.6" g="0.2" b="0.1" alpha="0.1" showDaughers="false" visible="false" />
<!--vis name="ecal_active" r=".1" g="0.8" b="0.6" alpha="1.0" showDaughers="true" visible="true" /-->
</display>
+
<readouts>
<readout name="BarDECal_Readout">
<!-- layer:7 gives 7 bits (max 128 layers) -->
<!-- x, y segmentation -24 to allow 16777216 pixels -->
<segmentation type="CartesianGridXYZ" grid_size_x="0.05*mm" grid_size_y="0.05*mm" grid_size_z="0.05*mm"/>
<id>system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11</id>
</readout>
+
<readout name="BarDECal_Pads">
<!-- layer:7 gives 7 bits (max 128 layers) -->
<!-- x, y segmentation -24 to allow 16777216 pixels -->
<segmentation type="CartesianGridXYZ" grid_size_x="5*mm" grid_size_y="5*mm" grid_size_z="5*mm"/>
+
<id>system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15</id>
<!-- x:-17,y:-17, no stave-->
+
</readout>
+
<!--readout name="BarDECal_Readout">
<segmentation type="GridPhiEta" grid_size_eta="0.05*mm" phi_bins="300000"/>
<id>system:3,active:1,EM_barrel:1,layer:7,eta:-18,phi:-19</id>
</readout-->
</readouts>
+
+
<detectors>
<detector id="5" name="ECalBarrel" type="EmCaloDigiBarrel" readout="BarDECal_Readout">
<dimensions rmin="EMBarrel_rmin" rmax="EMBarrel_rmax" dz="EMBarrel_dz" vis="ecal_envelope"/>
<calorimeter id="1" name="EM_barrel" >
<dimensions rmin="EMBarrel_rmin" rmax="EMBarrel_rmax" dz="EMBarrel_dz" vis="ecal_volume" numsides="8" nmodules="5"/>
<active thickness="0.018*mm">
<material name="Silicon"/>
<nSamplings="50"/>
</active>
<substrate thickness="0.450*mm">
<material name="Silicon"/>
</substrate>
<passive thickness="2.1*mm">
<material name="Tungsten" />
</passive>
<spacing thickness="0*mm">
<material name="Air" />
</spacing>
<tracker thickness="0.0*cm">
<material name="Silicon"/>
</tracker>
</calorimeter>
</detector>
</detectors>
</lccdd>
+
+ + + +
+ +
+ + + + + +
+ +
+ +
+
+ +
+ + + + + + +
+ + + You can't perform that action at this time. +
+ + + + + + + + + + +
+ + You signed in with another tab or window. Reload to refresh your session. + You signed out in another tab or window. Reload to refresh your session. +
+ + + + + + diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml deleted file mode 100644 index a282eaad4..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.0X0.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml deleted file mode 100644 index 8c4d74cc3..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_TRKR0.3X0.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml deleted file mode 100644 index a7d9cb449..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_5mmAir_50umPixels_18umThick_TRKR0.3X0.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml deleted file mode 100644 index 912dc0dcf..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_25umPixels_18umThick.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - SiW first design - - - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-18,y:-18,z:-17 - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml deleted file mode 100644 index cd040223c..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_3mmAir_50umPixels_18umThick.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml deleted file mode 100644 index ec67bb9c2..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_450um.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - system:3,EM_barrel:1,layer:6,digital:1,x:-19,y:-19,z:-15 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml deleted file mode 100644 index b58476c2d..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_3.4mmPb_50umPixels_18umThick.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml deleted file mode 100644 index ca1cea574..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_Mockup.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - DECal very conceptual design - - - - - - - - - - - - - - - - - - - - - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - system:3,active:1,EM_barrel:1,layer:6,x:-17,y:-17,z:-19 - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml deleted file mode 100644 index f8b8c5d3d..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml deleted file mode 100644 index 9da5b9c78..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_3.5mmW.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml deleted file mode 100644 index f8b8c5d3d..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_30Layers_5.6mmPb.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml deleted file mode 100644 index 8b3688dbf..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml deleted file mode 100644 index 4b279eeb5..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml deleted file mode 100644 index a35162fb8..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_1mmAir_SiAirW.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml deleted file mode 100644 index a0737aa1a..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_3mmAir.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml deleted file mode 100644 index b4d03d3e3..000000000 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalDefinition_50Layers_2.1mmW_5mmAir.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - From b5dfa6a03b7e52911f78b812a345380d77fb5493 Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 20 Mar 2018 11:48:03 +0100 Subject: [PATCH 25/28] Fixed xml file --- ...Layers_2.1mmW_50umPixels_18umThick_RRB.xml | 1008 ++--------------- 1 file changed, 80 insertions(+), 928 deletions(-) diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml index 21de3ec4b..33387c4e5 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml @@ -1,928 +1,80 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FCCSW/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml at master · tonyPbA/FCCSW · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content -
- - - - - - - - - -
- -
- -
-
- - - -
-
-
- - - - - - - - -
-
- - - -

- - /FCCSW - - - forked from HEP-FCC/FCCSW - -

- -
- - - - -
- -
-
- - - Permalink - - - -
- -
- - -
- -
-
- - Switch branches/tags -
- -
-
- -
-
- -
-
- - - -
- - -
Nothing to show
-
- -
-
-
- -
- - Find file - - - Copy path - -
- -
- - - -
- Fetching contributors… -
- -
- - Cannot retrieve contributors at this time -
-
- -
-
-
- -
- Raw - Blame - History -
- - - - -
- -
- executable file - - 82 lines (69 sloc) - - 3.03 KB -
-
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?xml version="1.0" encoding="UTF-8"?>
<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
-
<info name="FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick"
title="DECal Barrel Calorimeter"
author="T. Price"
url="no"
status="development"
version="$Id:??$">
<comment>DECal very conceptual design</comment>
</info>
-
<define>
<constant name="BarECalOuterSpacer" value="100*mm"/>
<!-- calorimeter volume -->
<!-- have removed the cryostat as we do not need it! -->
<constant name="EMBarrel_rmin" value="BarECal_rmin+BarECalOuterSpacer"/>
<constant name="EMBarrel_rmax" value="BarECal_rmax-BarECalOuterSpacer"/>
<constant name="EMBarrel_dz" value="100*mm"/><!--BarECal_dz"/-->
-
</define>
-
<display>
<!--vis name="ecal_envelope" r="0.1" g="0.2" b="0.6" alpha="0.1" showDaughers="false" visible="false" /-->
<vis name="ecal_volume" r="0.6" g="0.2" b="0.1" alpha="0.1" showDaughers="false" visible="false" />
<!--vis name="ecal_active" r=".1" g="0.8" b="0.6" alpha="1.0" showDaughers="true" visible="true" /-->
</display>
-
<readouts>
<readout name="BarDECal_Readout">
<!-- layer:7 gives 7 bits (max 128 layers) -->
<!-- x, y segmentation -24 to allow 16777216 pixels -->
<segmentation type="CartesianGridXYZ" grid_size_x="0.05*mm" grid_size_y="0.05*mm" grid_size_z="0.05*mm"/>
<id>system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11</id>
</readout>
-
<readout name="BarDECal_Pads">
<!-- layer:7 gives 7 bits (max 128 layers) -->
<!-- x, y segmentation -24 to allow 16777216 pixels -->
<segmentation type="CartesianGridXYZ" grid_size_x="5*mm" grid_size_y="5*mm" grid_size_z="5*mm"/>
-
<id>system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15</id>
<!-- x:-17,y:-17, no stave-->
-
</readout>
-
<!--readout name="BarDECal_Readout">
<segmentation type="GridPhiEta" grid_size_eta="0.05*mm" phi_bins="300000"/>
<id>system:3,active:1,EM_barrel:1,layer:7,eta:-18,phi:-19</id>
</readout-->
</readouts>
-
-
<detectors>
<detector id="5" name="ECalBarrel" type="EmCaloDigiBarrel" readout="BarDECal_Readout">
<dimensions rmin="EMBarrel_rmin" rmax="EMBarrel_rmax" dz="EMBarrel_dz" vis="ecal_envelope"/>
<calorimeter id="1" name="EM_barrel" >
<dimensions rmin="EMBarrel_rmin" rmax="EMBarrel_rmax" dz="EMBarrel_dz" vis="ecal_volume" numsides="8" nmodules="5"/>
<active thickness="0.018*mm">
<material name="Silicon"/>
<nSamplings="50"/>
</active>
<substrate thickness="0.450*mm">
<material name="Silicon"/>
</substrate>
<passive thickness="2.1*mm">
<material name="Tungsten" />
</passive>
<spacing thickness="0*mm">
<material name="Air" />
</spacing>
<tracker thickness="0.0*cm">
<material name="Silicon"/>
</tracker>
</calorimeter>
</detector>
</detectors>
</lccdd>
-
- - - -
- -
- - - - - -
- -
- -
-
- -
- - - - - - -
- - - You can't perform that action at this time. -
- - - - - - - - - - -
- - You signed in with another tab or window. Reload to refresh your session. - You signed out in another tab or window. Reload to refresh your session. -
- - - - - - - +dd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + + DECal very conceptual design + + + + + + + + + + + + + + + + + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11 + + + + + + + + system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 57c968cab0726ebabaa9385ecfe26b1afa1c45fc Mon Sep 17 00:00:00 2001 From: tonypba Date: Tue, 20 Mar 2018 11:56:27 +0100 Subject: [PATCH 26/28] Actually fixed XML file this time --- ...CalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml index 33387c4e5..948207af2 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml @@ -1,8 +1,10 @@ -dd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + + +xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> - Date: Wed, 21 Mar 2018 23:57:32 +0100 Subject: [PATCH 27/28] added scripts to submit pile up events --- .../tests/options/testcellcountingXYZ.py | 4 +- geant_pile_up_batch_temp.py | 97 +++++++++++++++++++ submit_pile_up_to_lxbatch.py | 69 +++++++++++++ 3 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 geant_pile_up_batch_temp.py create mode 100644 submit_pile_up_to_lxbatch.py diff --git a/Test/TestReconstruction/tests/options/testcellcountingXYZ.py b/Test/TestReconstruction/tests/options/testcellcountingXYZ.py index 8b82f3f9a..ef2e13a01 100644 --- a/Test/TestReconstruction/tests/options/testcellcountingXYZ.py +++ b/Test/TestReconstruction/tests/options/testcellcountingXYZ.py @@ -5,8 +5,8 @@ #geoservice = GeoSvc("GeoSvc", detectors=[ 'Test/TestGeometry/data/TestBoxCaloSD_segmentation.xml'], OutputLevel = DEBUG) from Configurables import GeoSvc -geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', - 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml' +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW.xml' ], OutputLevel = DEBUG) diff --git a/geant_pile_up_batch_temp.py b/geant_pile_up_batch_temp.py new file mode 100644 index 000000000..8517801c9 --- /dev/null +++ b/geant_pile_up_batch_temp.py @@ -0,0 +1,97 @@ + +### \file +### \ingroup SimulationExamples +### | **input (alg)** | other algorithms | | | | **output (alg)** | +### |-------------------------------|----------------------------------|---------------------------------------------------------|------------------------|----------------------------------|-----------------------------------------------| +### | generating single particle events from a given list of types, with momentum, phi and theta from a given range, saving to HepMC | convert `HepMC::GenEvent` to EDM | geometry parsed from XML (TestHCal.xml) by DD4hep using GeoSvc | FTFP_BERT physics list | saving HCal hits | write the EDM output to ROOT file using PODIO | + +from Gaudi.Configuration import * + +from Configurables import FCCDataSvc +## Data service +podioevent = FCCDataSvc("EventDataSvc") + +### Example of pythia configuration file to generate events +#pythiafile="Generation/data/Pythia_standard.cmd" +pythiafile="/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Generation/data/Pythia_minbias_pp_100TeV.cmd" +# Example of pythia configuration file to read LH event file +#pythiafile="options/Pythia_LHEinput.cmd" + +from Configurables import FCCDataSvc +#### Data service +podioevent = FCCDataSvc("EventDataSvc") + +from Configurables import ConstPileUp + +#pileuptool = ConstPileUp(numPileUpEvents=, Filename="/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Generation/data/Pythia_minbias_pp_100TeV.cmd") + +from Configurables import PythiaInterface, GenAlg +### PYTHIA algorithm +pythia8gentool = PythiaInterface("Pythia8Interface", Filename=pythiafile) +pythia8gen = GenAlg("Pythia8", SignalProvider=pythia8gentool) +pythia8gen.hepmc.Path = "hepmcevent" + +gen = GenAlg("ParticleGun", SignalProvider=pythia8gentool) +gen.hepmc.Path = "hepmc" + +from Configurables import HepMCToEDMConverter +### Reads an HepMC::GenEvent from the data service and writes a collection of EDM Particles +hepmc_converter = HepMCToEDMConverter("Converter") +hepmc_converter.hepmc.Path="hepmc" +hepmc_converter.genparticles.Path="allGenParticles" +hepmc_converter.genvertices.Path="allGenVertices" + +from Configurables import GenParticleFilter +### Filters generated particles +#genfilter = GenParticleFilter("StableParticles") +#genfilter.genparticles_in.Path = "all_genparticles" +#genfilter.genparticles_out.Path = "StableParticles" + + +from Configurables import GeoSvc +## DD4hep geometry service +# Parses the given xml file +geoservice = GeoSvc("GeoSvc", detectors=[ 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', + 'file:/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_.xml' + ], + OutputLevel = INFO) + +from Configurables import SimG4Svc +## Geant4 service +# Configures the Geant simulation: geometry, physics list and user actions +geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", + actions="SimG4FullSimActions") + + +# Magnetic field +from Configurables import SimG4ConstantMagneticFieldTool +field = SimG4ConstantMagneticFieldTool("SimG4ConstantMagneticFieldTool",FieldOn=True,IntegratorStepper="ClassicalRK4",FieldComponentZ="-0.004") + + +from Configurables import SimG4Alg, SimG4SaveCalHits, SimG4PrimariesFromEdmTool +## Geant4 algorithm +saveecaltool = SimG4SaveCalHits("saveECalHits",readoutNames = ["BarDECal_Readout"]) +saveecaltool.positionedCaloHits.Path = "positionedCaloHits" +saveecaltool.caloHits.Path = "ECalHits" + +# next, create the G4 algorithm, giving the list of names of tools ("XX/YY") +particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") +particle_converter.genParticles.Path = "allGenParticles" + +geantsim = SimG4Alg("SimG4Alg", + outputs= ["SimG4SaveCalHits/saveECalHits"], + eventProvider=particle_converter) + +from Configurables import PodioOutput +out = PodioOutput("out", + OutputLevel=DEBUG) +out.outputCommands = ["keep *"] + +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg=[gen, hepmc_converter, geantsim, out], + EvtSel='NONE', + EvtMax=, + ## order is important, as GeoSvc is needed by SimG4Svc + ExtSvc=[podioevent, geoservice, geantservice], + OutputLevel=INFO + ) diff --git a/submit_pile_up_to_lxbatch.py b/submit_pile_up_to_lxbatch.py new file mode 100644 index 000000000..48c10bb7a --- /dev/null +++ b/submit_pile_up_to_lxbatch.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +import os, re +import commands +import math, time +import sys + +print +print 'START' +print +######## YOU ONLY NEED TO FILL THE AREA BELOW ######### +######## customization area ######### +CONFIG="50Layers_2.1mmW_50umPixels_18umThick_RRB" +NPILEUPEVENTS = ["1000"]#,"2","3","4","5","6"] +BFIELD = "1" +EVENTS = "1" +FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" +queue = "8nm" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw +######## customization end ######### + +path = os.getcwd() +print +#print 'do not worry about folder creation:' +#os.system("rm -r tmp") +os.system("mkdir batch") +#os.system("mkdir res") +print + +##### loop for creating and sending jobs ##### +for npu in NPILEUPEVENTS: + ##### creates directory and file list for job ####### + dir="batch_eos/"+CONFIG+"_FCCSW0.9/"+str(npu)+"PILEUPEVENTS" + + os.system("rm -r "+dir) + os.system("mkdir -p "+dir) + os.chdir(dir) + + ##### creates jobs ####### + with open('job.sh', 'w') as fout: + fout.write("#!/bin/sh\n") + fout.write("echo\n") + fout.write("echo 'START---------------'\n") + fout.write("echo 'WORKDIR ' ${PWD}\n") + + fout.write("##### creates steering file #######\n") + fout.write("cp "+FCCSW_DIR+"/geant_pile_up_batch_temp.py run.py\n") + fout.write("sed -i 's//"+str(npu)+"/' run.py\n") + fout.write("sed -i 's//"+str(EVENTS)+"/' run.py\n\n") + fout.write("sed -i 's//"+str(CONFIG)+"/' run.py\n\n") + fout.write("source "+FCCSW_DIR+"init.sh\n") + fout.write(FCCSW_DIR+"run gaudirun.py run.py\n") + fout.write("echo 'STOP---------------'\n") + fout.write("echo\n") + fout.write("cp *.txt "+path+"/"+dir+"\n") + fout.write("cp *.root "+path+"/"+dir+"\n") + fout.write("echo\n") + os.system("chmod 755 job.sh") + + ###### sends bjobs ###### + os.system("bsub -q "+queue+" -o logs job.sh") + print "job nr " + str(npu) + " submitted" + + os.chdir(path) + +print +print "your jobs:" +os.system("bjobs") +print +print 'END' +print From e6c1161326c19be0d339b396734bd5b3cd97200a Mon Sep 17 00:00:00 2001 From: tonypba Date: Sun, 8 Apr 2018 00:34:03 +0200 Subject: [PATCH 28/28] modified pile-up files and hacked geometry to just draw a single stave --- ...Layers_2.1mmW_50umPixels_18umThick_RRB.xml | 8 ++-- .../src/ECalBarrel_geo.cpp | 13 ++++-- .../tests/options/decalAnalysis_DEcal.py | 11 ++++- analyse_DEcal_particles.py | 46 +++++++++++-------- geant_pile_up_batch_temp.py | 4 +- submit_pile_up_to_lxbatch.py | 6 +-- 6 files changed, 56 insertions(+), 32 deletions(-) diff --git a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml index 948207af2..c6048ab9e 100644 --- a/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml +++ b/Detector/DetFCChhECalDigital/compact/FCChh_DECalBarrel_50Layers_2.1mmW_50umPixels_18umThick_RRB.xml @@ -19,7 +19,7 @@ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.x - + @@ -34,7 +34,8 @@ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.x - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-17,y:-17,z:-11 + + system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-17,y:-17,z:-18 @@ -42,7 +43,8 @@ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.x - system:3,active:1,EM_barrel:1,layer:6,digital:1,stave:4,module:3,x:-15,y:-15,z:-15 + + system:3,active:1,EM_barrel:1,layer:6,digital:1,x:-15,y:-15,z:-18 diff --git a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp index 560a2497e..50b374caa 100644 --- a/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp +++ b/Detector/DetFCChhECalDigital/src/ECalBarrel_geo.cpp @@ -222,6 +222,10 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han double nudge_gap = 0.000001; double l_thickness = active_tck + passive_tck + substrate_tck + padding_tck; + // hack by Tony to use 1 stave and 1 module so can run complete length of calorimeter + nStaves = 1; + nModules = 1; + double module_dz = dz/nModules; double module_z = -trd_z + (module_dz/2); @@ -261,8 +265,9 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han epi_phv.addPhysVolID("digital", 1); epi_phv.addPhysVolID("layer", layernum); - epi_phv.addPhysVolID("stave", stavenum); - epi_phv.addPhysVolID("module", modulenum); + // HACK by tony to steal the bits back + //epi_phv.addPhysVolID("stave", stavenum); + //epi_phv.addPhysVolID("module", modulenum); epi_slice.setPlacement(epi_phv); epi_vol.setSensitiveDetector(sensDet); @@ -289,8 +294,8 @@ static dd4hep::detail::Ref_t createECal (dd4hep::Detector& lcdd,dd4hep::xml::Han sub_phv.addPhysVolID("digital", 0); sub_phv.addPhysVolID("layer", layernum); - sub_phv.addPhysVolID("stave", stavenum); - sub_phv.addPhysVolID("module", modulenum); + //sub_phv.addPhysVolID("stave", stavenum); + //sub_phv.addPhysVolID("module", modulenum); sub_slice.setPlacement(sub_phv); sub_vol.setSensitiveDetector(sensDet); diff --git a/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py b/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py index 6a91225bf..bc1e3a453 100644 --- a/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py +++ b/Detector/DetStudies/tests/options/decalAnalysis_DEcal.py @@ -4,7 +4,7 @@ from Configurables import FCCDataSvc batch_dir = "/eos/user/t/toprice/private/FCC/FCCSW/v8.0/XYZ/" fccsw_version = "FCCSW0.8" -det_config = "50Layers_2.1mmW_FCCSW0.8" +det_config = "50Layers_2.1mmW_50umPixels_18umThick_RRB_FCCSW0.8" run_config = "100GeV_BFIELD4T_ETAMIN-0.001_ETAMAX0.001" file = "100GeV_BFIELD4T_0.root" #inputfile = batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/"+file @@ -70,6 +70,13 @@ hist.pads.Path="newCaloCells" hist.truth.Path="GenParticles" +from Configurables import DECalNoiseHits +noise = DECalNoiseHits("DECalNoiseHits", + pixelReadoutName = "BarDECal_Readout", + OutputLevel = INFO) + +noise.pixels.Path="filteredCaloHits" + #THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"_"+fccsw_version+"/"+run_config+"/' TYP='ROOT' OPT='RECREATE'"] THistSvc().Output = ["rec DATAFILE='"+batch_dir+"/"+det_config+"/"+run_config+"/digital_"+file+"' TYP='ROOT' OPT='RECREATE'"] THistSvc().PrintAll=False @@ -91,7 +98,7 @@ # ApplicationMgr from Configurables import ApplicationMgr -ApplicationMgr( TopAlg = [podioinput, filtered, resegment, createcells,hist, podioout], +ApplicationMgr( TopAlg = [podioinput, filtered, resegment, createcells,hist, noise, podioout], EvtSel = 'NONE', EvtMax = 10, # order is important, as GeoSvc is needed by G4SimSvc diff --git a/analyse_DEcal_particles.py b/analyse_DEcal_particles.py index e31c8d1d7..fcf3449f8 100644 --- a/analyse_DEcal_particles.py +++ b/analyse_DEcal_particles.py @@ -50,7 +50,7 @@ if os.path.isdir(dir): - FILES = [f for f in os.listdir(dir) if "digital_" in f and "root.root" not in f] + FILES = [f for f in os.listdir(dir) if "digital_" in f and "500GeV" not in f and "300GeV" not in f and "700GeV" not in f and "1GeV" not in f and "podio" not in f and "root.root" not in f] for f in FILES: temp_file = TFile(dir+f) if temp_file.IsZombie(): @@ -71,20 +71,26 @@ truth_energy = float(RUNCONFIG[:RUNCONFIG.find("GeV")]) temp_energy = TH1F("energy_"+str(truth_energy)+"GeV", "Reconstructed energy from pol2; E_{truth}; E_{reco}", 2000, 0, 1200) - temp_particles = TH1F("particles_"+str(truth_energy)+"GeV", "Particles per event; Particles per event; Count", 2000, 0, 120000)#20) - temp_pixels = TH1F("pixels_"+str(truth_energy)+"GeV", "Pixels per event; Pixels per event; Count", 2000, 0, 120000) + temp_particles = TH1F("particles_"+str(truth_energy)+"GeV", "Particles per event; Particles per event; Count", 2000, 0, 120000) + temp_pixels = TH1F("pixels_"+str(truth_energy)+"GeV", "Pixels per event; Pixels per event; Count", 2000, 0, 1200) temp_partvspix = TH2F("partvspix_"+str(truth_energy)+"GeV", ";Pixels per event; Particles per event", 2000,0,120000,2000,0,120000) temp_partperpix = TH1F("partperpix_"+str(truth_energy)+"GeV", ";Particles / Pixel; Count", 100, 0.8, 1.4) temp_partperpixvspix = TH2F("partperpixvspix_"+str(truth_energy)+"GeV", ";Pixels per event;Particles / Pixel; Count", 2000,0,120000,100, 0.8, 1.4) + + pixels_energy = TF1("cal", "pol2", 0, 1200) + pixels_energy.SetParameter(0, 1.757E02) + pixels_energy.SetParameter(1, 5.754E01) + pixels_energy.SetParameter(2, -8.625E-03) + for i in np.arange(0,chain.GetEntries()): chain.GetEntry(i) pixels_tot = chain.pixels_tot particles_tot = chain.particles_tot + temp_pixels.Fill(pixels_energy.GetX(pixels_tot)) temp_particles.Fill(particles_tot) - temp_pixels.Fill(pixels_tot) temp_partvspix.Fill(pixels_tot,particles_tot) temp_partperpix.Fill(particles_tot/pixels_tot) temp_partperpixvspix.Fill(pixels_tot, particles_tot/pixels_tot) @@ -183,11 +189,13 @@ c_res = TCanvas("Resolution") - fit_min = 0 - fit_max = 300 - fit = TF1("fit", "[0]/sqrt(x)+[1]", fit_min, fit_max) + fit_min = 50 + fit_max = 500 + fit = TF1("fit", "[0]/sqrt(x)+[1]+[2]/x", fit_min, fit_max) fit_part = TF1("fit_part", "[0]/sqrt(x)+[1]", fit_min, 1000) + fit.FixParameter(2, 0) + res_plot.SetMarkerStyle(22); res_plot.SetMaximum(0.08); res_plot.SetMinimum(0.0); @@ -204,26 +212,28 @@ res_part_plot.Fit(fit_part, "NR") fit_part.SetRange(0,1000); - res_part_plot.Draw("ap") - fit_part.Draw("same") - res_plot.Draw("p") + #res_part_plot.Draw("ap") + #fit_part.Draw("same") + res_plot.Draw("ap") fit.Draw("same") pt = TPaveText(0.55,0.55,0.8,0.85, "NDC") pt.SetBorderSize(0) pt.SetFillColor(0) pt.AddText('Fit Range: {fit_min} - {fit_max} '.format(fit_min=fit_min, fit_max=fit_max)) - pt.AddText('#frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit_part.GetParameter(0), sqrt="#sqrt{E}", leakage=fit_part.GetParameter(1),E="E")) - #pt.AddText('#frac{{{noise:.1%}}}{{{E}}} #oplus #frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit_0mm.GetParameter(0), sqrt="#sqrt{E}", leakage=fit_0mm.GetParameter(1),E="E", noise=fit_0mm.GetParameter(2))) - pt.AddText('#frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit.GetParameter(0), sqrt="#sqrt{E}", leakage=fit.GetParameter(1),E="E")) + #pt.AddText('#frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit_part.GetParameter(0), sqrt="#sqrt{E}", leakage=fit_part.GetParameter(1),E="E")) + if fit.GetParameter(2) != 0: + pt.AddText('#frac{{{noise:.1%}}}{{{E}}} #oplus #frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit.GetParameter(0), sqrt="#sqrt{E}", leakage=fit.GetParameter(1),E="E", noise=fit.GetParameter(2))) + else: + pt.AddText('#frac{{{stoch:.1%}}}{{{sqrt}}} #oplus {leakage:.1%} '.format(stoch=fit.GetParameter(0), sqrt="#sqrt{E}", leakage=fit.GetParameter(1),E="E")) pt.Draw() c_res.Print("DECal_resolution.png") lin_plot.SetMarkerStyle(22) lin_plot.SetTitle("Linearity: ") lin_plot.GetXaxis().SetTitle("Energy [GeV]") - lin_plot.GetYaxis().SetTitle("Mean particles per event") - lin_fit = TF1("lin_fit", "pol1", fit_min, fit_max) + lin_plot.GetYaxis().SetTitle("Mean pixels per event") + lin_fit = TF1("lin_fit", "pol2", fit_min, fit_max) lin_plot.Fit(lin_fit, "NR") lin_fit.SetRange(0,1000) @@ -236,9 +246,9 @@ lin_part_fit.SetRange(0,1000) c_lin = TCanvas("lin_plot") - lin_part_plot.Draw("ap") - lin_part_fit.Draw("same") - lin_plot.Draw("p") + #lin_part_plot.Draw("ap") + #lin_part_fit.Draw("same") + lin_plot.Draw("ap") lin_fit.Draw("same") pt_lin = TPaveText(0.25,0.7,0.5,0.85, "NDC") pt_lin.SetBorderSize(0) diff --git a/geant_pile_up_batch_temp.py b/geant_pile_up_batch_temp.py index 8517801c9..cceec0902 100644 --- a/geant_pile_up_batch_temp.py +++ b/geant_pile_up_batch_temp.py @@ -23,7 +23,7 @@ from Configurables import ConstPileUp -#pileuptool = ConstPileUp(numPileUpEvents=, Filename="/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Generation/data/Pythia_minbias_pp_100TeV.cmd") +pileuptool = ConstPileUp(numPileUpEvents=, filename="/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/Generation/data/Pythia_minbias_pp_100TeV.cmd") from Configurables import PythiaInterface, GenAlg ### PYTHIA algorithm @@ -31,7 +31,7 @@ pythia8gen = GenAlg("Pythia8", SignalProvider=pythia8gentool) pythia8gen.hepmc.Path = "hepmcevent" -gen = GenAlg("ParticleGun", SignalProvider=pythia8gentool) +gen = GenAlg("ParticleGun", SignalProvider=pythia8gentool, PileUpTool=pileuptool) gen.hepmc.Path = "hepmc" from Configurables import HepMCToEDMConverter diff --git a/submit_pile_up_to_lxbatch.py b/submit_pile_up_to_lxbatch.py index 48c10bb7a..af59c34d6 100644 --- a/submit_pile_up_to_lxbatch.py +++ b/submit_pile_up_to_lxbatch.py @@ -10,9 +10,9 @@ ######## YOU ONLY NEED TO FILL THE AREA BELOW ######### ######## customization area ######### CONFIG="50Layers_2.1mmW_50umPixels_18umThick_RRB" -NPILEUPEVENTS = ["1000"]#,"2","3","4","5","6"] +NPILEUPEVENTS = ["1","100","1000"] BFIELD = "1" -EVENTS = "1" +EVENTS = "100" FCCSW_DIR = "/afs/cern.ch/user/t/toprice/private/FCC/FCCSW/" queue = "8nm" # give bsub queue -- 8nm (8 minutes), 1nh (1 hour), 8nh, 1nd (1day), 2nd, 1nw (1 week), 2nw ######## customization end ######### @@ -21,7 +21,7 @@ print #print 'do not worry about folder creation:' #os.system("rm -r tmp") -os.system("mkdir batch") +os.system("mkdir batch_eos") #os.system("mkdir res") print