Fork me on GitHub

Changeset 1364 in svn for trunk/modules


Ignore:
Timestamp:
Apr 16, 2014, 3:29:31 PM (11 years ago)
Author:
Michele Selvaggi
Message:

new calo module

Location:
trunk/modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/Calorimeter.cc

    r1356 r1364  
    4141
    4242Calorimeter::Calorimeter() :
    43   fECalResolutionFormula(0), fHCalResolutionFormula(0),
     43  fResolutionFormula(0),
    4444  fItParticleInputArray(0), fItTrackInputArray(0),
    4545  fTowerTrackArray(0), fItTowerTrackArray(0)
    4646{
    47   fECalResolutionFormula = new DelphesFormula;
    48   fHCalResolutionFormula = new DelphesFormula;
    49 
     47  fResolutionFormula = new DelphesFormula;
     48 
    5049  fTowerTrackArray = new TObjArray;
    5150  fItTowerTrackArray = fTowerTrackArray->MakeIterator();
     
    5655Calorimeter::~Calorimeter()
    5756{
    58   if(fECalResolutionFormula) delete fECalResolutionFormula;
    59   if(fHCalResolutionFormula) delete fHCalResolutionFormula;
    60 
     57  if(fResolutionFormula) delete fResolutionFormula;
     58 
    6159  if(fTowerTrackArray) delete fTowerTrackArray;
    6260  if(fItTowerTrackArray) delete fItTowerTrackArray;
     
    6866{
    6967  ExRootConfParam param, paramEtaBins, paramPhiBins, paramFractions;
    70   Long_t i, j, k, size, sizeEtaBins, sizePhiBins, sizeFractions;
    71   Double_t ecalFraction, hcalFraction;
     68  Long_t i, j, k, size, sizeEtaBins, sizePhiBins;
     69  Double_t fraction;
    7270  TBinMap::iterator itEtaBin;
    7371  set< Double_t >::iterator itPhiBin;
     
    116114  // set default energy fractions values
    117115  fFractionMap.clear();
    118   fFractionMap[0] = make_pair(0.0, 1.0);
     116  fFractionMap[0] = 1.0;
    119117
    120118  for(i = 0; i < size/2; ++i)
    121119  {
    122120    paramFractions = param[i*2 + 1];
    123     sizeFractions = paramFractions.GetSize();
    124 
    125     ecalFraction = paramFractions[0].GetDouble();
    126     hcalFraction = paramFractions[1].GetDouble();
    127 
    128     fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
     121    fraction = paramFractions[0].GetDouble();
     122    fFractionMap[param[i*2].GetInt()] = fraction;
    129123  }
    130124/*
     
    136130*/
    137131  // read resolution formulas
    138   fECalResolutionFormula->Compile(GetString("ECalResolutionFormula", "0"));
    139   fHCalResolutionFormula->Compile(GetString("HCalResolutionFormula", "0"));
    140 
     132  fResolutionFormula->Compile(GetString("ResolutionFormula", "0"));
     133 
    141134  // import array with output from other modules
    142135  fParticleInputArray = ImportArray(GetString("ParticleInputArray", "ParticlePropagator/particles"));
     
    148141  // create output arrays
    149142  fTowerOutputArray = ExportArray(GetString("TowerOutputArray", "towers"));
    150   fPhotonOutputArray = ExportArray(GetString("PhotonOutputArray", "photons"));
    151  
    152   fEFlowTrackOutputArray = ExportArray(GetString("EFlowTrackOutputArray", "eflowTracks"));
    153   fEFlowPhotonOutputArray = ExportArray(GetString("EFlowPhotonOutputArray", "eflowPhotons"));
    154   fEFlowNeutralHadronOutputArray = ExportArray(GetString("EFlowNeutralHadronOutputArray", "eflowNeutralHadrons"));
    155 
    156 
     143  fEFlowTowerOutputArray = ExportArray(GetString("EFlowTowerOutputArray", "eflowTowers"));
     144 
    157145}
    158146
     
    179167  Int_t number;
    180168  Long64_t towerHit, towerEtaPhi, hitEtaPhi;
    181   Double_t ecalFraction, hcalFraction;
    182   Double_t ecalEnergy, hcalEnergy;
     169  Double_t fraction;
     170  Double_t energy;
    183171  Int_t pdgCode;
    184172
     
    193181  DelphesFactory *factory = GetFactory();
    194182  fTowerHits.clear();
    195   fTowerECalFractions.clear();
    196   fTowerHCalFractions.clear();
    197   fTrackECalFractions.clear();
    198   fTrackHCalFractions.clear();
    199 
     183  fTowerFractions.clear();
     184  fTrackFractions.clear();
     185 
    200186  // loop over all particles
    201187  fItParticleInputArray->Reset();
     
    214200    }
    215201
    216     ecalFraction = itFractionMap->second.first;
    217     hcalFraction = itFractionMap->second.second;
    218 
    219     fTowerECalFractions.push_back(ecalFraction);
    220     fTowerHCalFractions.push_back(hcalFraction);
    221 
    222     if(ecalFraction < 1.0E-9 && hcalFraction < 1.0E-9) continue;
     202    fraction = itFractionMap->second;
     203    fTowerFractions.push_back(fraction);
     204   
     205    if(fraction < 1.0E-9) continue;
    223206
    224207    // find eta bin [1, fEtaBins.size - 1]
     
    260243    }
    261244
    262     ecalFraction = itFractionMap->second.first;
    263     hcalFraction = itFractionMap->second.second;
    264 
    265     fTrackECalFractions.push_back(ecalFraction);
    266     fTrackHCalFractions.push_back(hcalFraction);
    267 
     245    fraction = itFractionMap->second;
     246 
     247    fTrackFractions.push_back(fraction);
     248 
    268249    // find eta bin [1, fEtaBins.size - 1]
    269250    itEtaBin = lower_bound(fEtaBins.begin(), fEtaBins.end(), trackPosition.Eta());
     
    327308      fTowerEdges[3] = (*phiBins)[phiBin];
    328309
    329       fTowerECalEnergy = 0.0;
    330       fTowerHCalEnergy = 0.0;
    331 
    332       fTrackECalEnergy = 0.0;
    333       fTrackHCalEnergy = 0.0;
    334 
    335       fTowerECalTime = 0.0;
    336       fTowerHCalTime = 0.0;
    337 
    338       fTrackECalTime = 0.0;
    339       fTrackHCalTime = 0.0;
    340 
    341       fTowerECalWeightTime = 0.0;
    342       fTowerHCalWeightTime = 0.0;
     310      fTowerEnergy = 0.0;
     311      fTrackEnergy = 0.0;
     312     
     313      fTowerTime = 0.0;
     314      fTrackTime = 0.0;
    343315     
     316      fTowerWeightTime = 0.0;
     317     
    344318      fTowerTrackHits = 0;
    345319      fTowerPhotonHits = 0;
     
    356330      momentum = track->Momentum;
    357331      position = track->Position;
    358 
     332 
     333      energy = momentum.E() * fTrackFractions[number];
    359334     
    360       ecalEnergy = momentum.E() * fTrackECalFractions[number];
    361       hcalEnergy = momentum.E() * fTrackHCalFractions[number];
    362 
    363       fTrackECalEnergy += ecalEnergy;
    364       fTrackHCalEnergy += hcalEnergy;
     335      fTrackEnergy += energy;
    365336     
    366       fTrackECalTime += TMath::Sqrt(ecalEnergy)*position.T();
    367       fTrackHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
    368        
    369       fTrackECalWeightTime += TMath::Sqrt(ecalEnergy);
    370       fTrackHCalWeightTime += TMath::Sqrt(hcalEnergy);
    371 
     337      fTrackTime += TMath::Sqrt(energy)*position.T();
     338      fTrackWeightTime += TMath::Sqrt(energy);
     339   
    372340      fTowerTrackArray->Add(track);
    373341
     
    383351
    384352    // fill current tower
    385     ecalEnergy = momentum.E() * fTowerECalFractions[number];
    386     hcalEnergy = momentum.E() * fTowerHCalFractions[number];
    387 
    388     fTowerECalEnergy += ecalEnergy;
    389     fTowerHCalEnergy += hcalEnergy;
    390 
    391     fTowerECalTime += TMath::Sqrt(ecalEnergy)*position.T();
    392     fTowerHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
    393 
    394     fTowerECalWeightTime += TMath::Sqrt(ecalEnergy);
    395     fTowerHCalWeightTime += TMath::Sqrt(hcalEnergy);
     353    energy = momentum.E() * fTowerFractions[number];
     354   
     355    fTowerEnergy += energy;
    396356   
    397 
     357    fTowerTime += TMath::Sqrt(energy)*position.T();
     358    fTowerWeightTime += TMath::Sqrt(energy);
     359   
    398360    fTower->AddCandidate(particle);
    399361  }
     
    407369void Calorimeter::FinalizeTower()
    408370{
    409   Candidate *track, *tower;
     371  Candidate *tower;
    410372  Double_t energy, pt, eta, phi;
    411   Double_t ecalEnergy, hcalEnergy;
    412   Double_t ecalSigma, hcalSigma;
    413   Double_t ecalTime, hcalTime, time;
     373  Double_t sigma;
     374  Double_t time;
    414375
    415376  if(!fTower) return;
    416377
    417   ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy);
    418 
    419 //  ecalEnergy = gRandom->Gaus(fTowerECalEnergy, ecalSigma);
    420 //  if(ecalEnergy < 0.0) ecalEnergy = 0.0;
    421 
    422   ecalEnergy = LogNormal(fTowerECalEnergy, ecalSigma);
    423   ecalTime = (fTowerECalWeightTime < 1.0E-09 ) ? 0 : fTowerECalTime/fTowerECalWeightTime;
    424 
    425   hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy);
    426 
    427 //  hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, hcalSigma);
    428 //  if(hcalEnergy < 0.0) hcalEnergy = 0.0;
    429 
    430   hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma);
    431   hcalTime = (fTowerHCalWeightTime < 1.0E-09 ) ? 0 : fTowerHCalTime/fTowerHCalWeightTime;
    432 
    433   energy = ecalEnergy + hcalEnergy;
    434   time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy));
    435 
    436 //  eta = fTowerEta;
    437 //  phi = fTowerPhi;
     378  sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerEnergy);
     379
     380//  energy = gRandom->Gaus(fTowerEnergy, sigma);
     381//  if(energy < 0.0) energy = 0.0;
     382
     383  energy = LogNormal(fTowerEnergy, sigma);
     384  time = (fTowerWeightTime < 1.0E-09 ) ? 0 : fTowerTime/fTowerWeightTime;
    438385
    439386  eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
     
    445392  fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time);
    446393  fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
    447   fTower->Eem = ecalEnergy;
    448   fTower->Ehad = hcalEnergy;
    449 
     394 
    450395  fTower->Edges[0] = fTowerEdges[0];
    451396  fTower->Edges[1] = fTowerEdges[1];
     
    455400
    456401  // fill calorimeter towers
     402  if(energy > 0.0) fTowerOutputArray->Add(fTower);
     403
     404 
     405  // fill energy flow candidates
     406  energy -= fTrackEnergy;
     407  if(energy < 0.0) energy = 0.0;
     408   
     409  // save energy excess as an energy flow tower
    457410  if(energy > 0.0)
    458   {
    459     if(fTowerPhotonHits > 0 && fTowerTrackHits == 0)
    460     {
    461       fPhotonOutputArray->Add(fTower);
    462     }
    463    
    464     fTowerOutputArray->Add(fTower);
    465   }
    466 
    467   // fill energy flow candidates
    468 
    469   // save all the tracks as energy flow tracks
    470   fItTowerTrackArray->Reset();
    471   while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
    472   {
    473     fEFlowTrackOutputArray->Add(track);
    474   }
    475 
    476   ecalEnergy -= fTrackECalEnergy;
    477   if(ecalEnergy < 0.0) ecalEnergy = 0.0;
    478 
    479   hcalEnergy -= fTrackHCalEnergy;
    480   if(hcalEnergy < 0.0) hcalEnergy = 0.0;
    481 
    482   energy = ecalEnergy + hcalEnergy;
    483 
    484  
    485   // save ECAL and/or HCAL energy excess as an energy flow tower
    486   if(ecalEnergy > 0.0)
    487411  {
    488412    // create new photon tower
    489413    tower = static_cast<Candidate*>(fTower->Clone());
    490 
    491     pt = ecalEnergy / TMath::CosH(eta);
    492 
    493     tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy);
    494     tower->Eem = ecalEnergy;
    495     tower->Ehad = 0;
    496 
    497     fEFlowPhotonOutputArray->Add(tower);
    498   }
    499 
    500   if(hcalEnergy > 0.0)
    501   {
    502     // create new neutral hadron tower
    503     tower = static_cast<Candidate*>(fTower->Clone());
    504 
    505     pt = hcalEnergy / TMath::CosH(eta);
    506 
    507     tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy);
    508     tower->Eem = 0;
    509     tower->Ehad = hcalEnergy;
    510 
    511     fEFlowNeutralHadronOutputArray->Add(tower);
    512   }
    513 
    514 
    515 
     414    pt = energy / TMath::CosH(eta);
     415
     416    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
     417    fEFlowTowerOutputArray->Add(tower);
     418  }
    516419
    517420}
  • trunk/modules/Calorimeter.h

    r1356 r1364  
    3838private:
    3939
    40   typedef std::map< Long64_t, std::pair< Double_t, Double_t > > TFractionMap; //!
     40  typedef std::map< Long64_t, Double_t > TFractionMap; //!
    4141  typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
    4242
    4343  Candidate *fTower;
    4444  Double_t fTowerEta, fTowerPhi, fTowerEdges[4];
    45   Double_t fTowerECalEnergy, fTowerHCalEnergy;
    46   Double_t fTrackECalEnergy, fTrackHCalEnergy;
     45  Double_t fTowerEnergy;
     46  Double_t fTrackEnergy;
    4747 
    48   Double_t fTowerECalTime, fTowerHCalTime;
    49   Double_t fTrackECalTime, fTrackHCalTime;
     48  Double_t fTowerTime;
     49  Double_t fTrackTime;
    5050   
    51   Double_t fTowerECalWeightTime, fTowerHCalWeightTime;
    52   Double_t fTrackECalWeightTime, fTrackHCalWeightTime;
     51  Double_t fTowerWeightTime;
     52  Double_t fTrackWeightTime;
    5353 
    5454  Int_t fTowerTrackHits, fTowerPhotonHits;
     
    6262  std::vector < Long64_t > fTowerHits;
    6363
    64   std::vector < Double_t > fTowerECalFractions;
    65   std::vector < Double_t > fTowerHCalFractions;
    66 
    67   std::vector < Double_t > fTrackECalFractions;
    68   std::vector < Double_t > fTrackHCalFractions;
    69 
    70   DelphesFormula *fECalResolutionFormula; //!
    71   DelphesFormula *fHCalResolutionFormula; //!
    72 
     64  std::vector < Double_t > fTowerFractions;
     65 
     66  std::vector < Double_t > fTrackFractions;
     67 
     68  DelphesFormula *fResolutionFormula; //!
     69 
    7370  TIterator *fItParticleInputArray; //!
    7471  TIterator *fItTrackInputArray; //!
     
    7875
    7976  TObjArray *fTowerOutputArray; //!
    80   TObjArray *fPhotonOutputArray; //!
    8177 
    82   TObjArray *fEFlowTrackOutputArray; //!
    83   TObjArray *fEFlowPhotonOutputArray; //!
    84   TObjArray *fEFlowNeutralHadronOutputArray; //!
    85 
     78  TObjArray *fEFlowTowerOutputArray; //!
     79 
    8680  TObjArray *fTowerTrackArray; //!
    8781  TIterator *fItTowerTrackArray; //!
Note: See TracChangeset for help on using the changeset viewer.