Fork me on GitHub

Changeset a0b6d15 in git


Ignore:
Timestamp:
Sep 28, 2014, 10:16:15 PM (10 years ago)
Author:
Christophe Delaere <christophe.delaere@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
1d42548
Parents:
bf6ed57
Message:

Made the configuration more flexible

The names of modules used in the tcl files are now optionnally set when
loading the cfg. It allows to read the FCC file despites it being quite
different.
Still, for now only one calorimeter can be displayed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/geometry.C

    rbf6ed57 ra0b6d15  
    2727     ~Delphes3DGeometry() {}
    2828
    29      void readFile(const char* filename);
     29     void readFile(const char* filename, const char* ParticlePropagator="ParticlePropagator",
     30                                         const char* TrackingEfficiency="ChargedHadronTrackingEfficiency",
     31                                         const char* MuonEfficiency="MuonEfficiency",
     32                                         const char* Calorimeters="Calorimeter");
    3033
    3134     void setContingency(Double_t contingency) { contingency_ = contingency; }
     
    5760     Double_t tk_radius_;
    5861     Double_t tk_length_;
     62     Double_t tk_etamax_;
    5963     Double_t calo_endcap_etamax_;
    6064     Double_t muonSystem_etamax_;
     
    98102   tk_radius_ = 120.;
    99103   tk_length_ = 150.;
     104   tk_etamax_ = 3.0;
    100105   calo_endcap_etamax_ = 2.6;
    101106   muonSystem_etamax_  = 2.4;
    102107}
    103108
    104 void Delphes3DGeometry::readFile(const char *configFile) {
     109void Delphes3DGeometry::readFile(const char *configFile,
     110                                 const char* ParticlePropagator, const char* TrackingEfficiency,
     111                                 const char* MuonEfficiency, const char* Calorimeters) {
    105112
    106113   ExRootConfReader *confReader = new ExRootConfReader;
    107114   confReader->ReadFile(configFile);
    108115
    109    tk_radius_ = confReader->GetDouble("ParticlePropagator::Radius", 1.0)*100;           // tk_radius
    110    tk_length_ = confReader->GetDouble("ParticlePropagator::HalfLength", 3.0)*100;       // tk_length
    111 
    112    TString muonEffFormula = confReader->GetString("MuonEfficiency::EfficiencyFormula","abs(eta)<2.0");
     116   tk_radius_ = confReader->GetDouble(Form("%s::Radius",ParticlePropagator), 1.0)*100;          // tk_radius
     117   tk_length_ = confReader->GetDouble(Form("%s::HalfLength",ParticlePropagator), 3.0)*100;      // tk_length
     118
     119   {
     120   TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",TrackingEfficiency),"abs(eta)<3.0");
     121   tkEffFormula.ReplaceAll("pt","x");
     122   tkEffFormula.ReplaceAll("eta","y");
     123   tkEffFormula.ReplaceAll("phi","0.");
     124   TF2* tkEffFunction = new TF2("tkEff",tkEffFormula,0,1000,-10,10);
     125   TH1F etaHisto("eta","eta",100,5.,-5.);
     126   Double_t pt,eta;
     127   for(int i=0;i<1000;++i) {
     128     tkEffFunction->GetRandom2(pt,eta);
     129     etaHisto.Fill(eta);
     130   }
     131   Int_t bin = -1;
     132   bin = etaHisto.FindFirstBinAbove(0.5);
     133   Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
     134   bin = etaHisto.FindLastBinAbove(0.5);
     135   Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
     136   tk_etamax_ = TMath::Max(fabs(etamin),fabs(etamax));                                          // tk_etamax
     137   delete tkEffFunction;
     138   }
     139
     140   {
     141   TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",MuonEfficiency),"abs(eta)<2.0");
    113142   muonEffFormula.ReplaceAll("pt","x");
    114143   muonEffFormula.ReplaceAll("eta","y");
    115144   muonEffFormula.ReplaceAll("phi","0.");
    116145   TF2* muEffFunction = new TF2("muEff",muonEffFormula,0,1000,-10,10);
    117    TH1F etaHisto("eta","eta",100,5.,-5.);
     146   TH1F etaHisto("eta2","eta2",100,5.,-5.);
    118147   Double_t pt,eta;
    119148   for(int i=0;i<1000;++i) {
     
    128157   muonSystem_etamax_ = TMath::Max(fabs(etamin),fabs(etamax));                          // muonSystem_etamax
    129158   delete muEffFunction;
     159   }
    130160       
    131161   caloBinning_.clear();                                                                // calo binning
    132162   ExRootConfParam paramEtaBins, paramPhiBins;
    133    ExRootConfParam param = confReader->GetParam("Calorimeter::EtaPhiBins");
     163   ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",Calorimeters));
    134164   Int_t size = param.GetSize();
    135165   for(int i = 0; i < size/2; ++i) {
     
    140170   }
    141171
    142    calo_endcap_etamax_ = TMath::Max(fabs(caloBinning_.begin()->first),fabs(caloBinning_.rbegin()->first)); // calo_endcap_etamax_
    143  
     172   if (size>0) calo_endcap_etamax_ = TMath::Max(fabs(caloBinning_.begin()->first),fabs(caloBinning_.rbegin()->first)); // calo_endcap_etamax_
     173
    144174   delete confReader;
    145175
     
    157187   TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, 1500, 1500, 2300); // determine the size from what we know about the detector TODO
    158188   addTracker(top);
    159    addCalorimeters(top);
     189   addCalorimeters(top); // TODO: allow for more than one calo
    160190   addMuonDets(top);
    161191   if (withTowers) {
     
    165195}
    166196
     197//TODO: there should be a cut by two cones to limit the acceptance in eta
     198//typically from ChargedHadronTrackingEfficiency
    167199void Delphes3DGeometry::addTracker(TGeoVolume *top) {
    168200   // tracker: a cylinder
     
    311343}
    312344
    313 void geometry(const char* filename = "delphes_card_CMS.tcl")
     345void geometry(const char* filename = "delphes_card_CMS.tcl", const char* ParticlePropagator="ParticlePropagator",
     346                                                             const char* TrackingEfficiency="ChargedHadronTrackingEfficiency",
     347                                                             const char* MuonEfficiency="MuonEfficiency",
     348                                                             const char* Calorimeters="Calorimeter")
    314349{
    315350   gSystem->Load("libGeom");
     
    323358   // build the detector
    324359   Delphes3DGeometry det3D;
    325    det3D.readFile(filename);
     360   det3D.readFile(filename,ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters);
    326361   top->AddNode(det3D.getDetector(true),1);
    327362
Note: See TracChangeset for help on using the changeset viewer.