Index: trunk/Delphes.cpp
===================================================================
--- trunk/Delphes.cpp	(revision 262)
+++ trunk/Delphes.cpp	(revision 264)
@@ -31,5 +31,5 @@
 
 /// \file Delphes.cpp
-/// \brief executable for the Delphes
+/// \brief Executable for Delphes
 
 #include "TChain.h"
@@ -41,4 +41,5 @@
 #include "ExRootTreeWriter.h"
 #include "ExRootTreeBranch.h"
+#include "ExRootProgressBar.h"
 
 #include "DataConverter.h"
@@ -48,4 +49,5 @@
 
 #include "SmearUtil.h"
+#include "CaloUtil.h"
 #include "BFieldProp.h"
 #include "TriggerUtil.h"
@@ -56,6 +58,4 @@
 #include <vector>
 #include <iostream>
-
-#include "Utilities/ExRootAnalysis/interface/ExRootProgressBar.h"
 
 using namespace std;
@@ -77,4 +77,6 @@
 int main(int argc, char *argv[])
 {
+unsigned int nnnn=0, mmmm=0;
+
   int appargc = 2;
   char *appName= new char[20];
@@ -86,5 +88,4 @@
   delete [] appName;
   delete [] appOpt;
-
 
   if(argc != 3 && argc != 4 && argc != 5) {
@@ -242,13 +243,10 @@
   //Propagation of tracks in the B field
   TrackPropagation *TRACP = new TrackPropagation(DET); 
-  //TrackPropagation *TRACP = new TrackPropagation(DetDatacard); 
   
   //Jet information
   JetsUtil *JETRUN = new JetsUtil(DET);
-  //JetsUtil *JETRUN = new JetsUtil(DetDatacard);
   
   //VFD information
   VeryForward * VFD = new VeryForward(DET);
-  //VeryForward * VFD = new VeryForward(DetDatacard);
  
   // data converters
@@ -299,5 +297,6 @@
   ExRootTreeBranch *branchMuon = treeWriter->NewBranch("Muon", TRootMuon::Class());
   ExRootTreeBranch *branchPhoton = treeWriter->NewBranch("Photon", TRootPhoton::Class());
-  ExRootTreeBranch *branchTracks = treeWriter->NewBranch("Tracks", TRootTracks::Class());
+  //ExRootTreeBranch *branchTracks = treeWriter->NewBranch("Tracks", TRootTracks::Class());
+  ExRootTreeBranch *branchTrack = treeWriter->NewBranch("Tracks", D_Track::Class());
   ExRootTreeBranch *branchETmis = treeWriter->NewBranch("ETmis", TRootETmis::Class());
   ExRootTreeBranch *branchCalo = treeWriter->NewBranch("CaloTower", TRootCalo::Class());
@@ -306,10 +305,9 @@
   ExRootTreeBranch *branchFP420 = treeWriter->NewBranch("FP420hits", TRootRomanPotHits::Class());
   
-  TRootGenParticle *particle; 
   TRootETmis *elementEtmis;
   TRootElectron *elementElec;
   TRootMuon *elementMu;
   TRootPhoton *elementPhoton;
-  TRootTracks *elementTracks;
+  D_Track * elementTrack;
   TRootCalo *elementCalo;
   
@@ -323,11 +321,32 @@
   vector<TLorentzVector> TrackCentral;  
   vector<PhysicsTower> towers;
-  vector<ParticleUtil> electron;
-  vector<ParticleUtil> muon;
-  vector<ParticleUtil> gamma;
+  //vector<ParticleUtil> electron;
+  vector<D_Particle> electron;
+  //vector<ParticleUtil> muon;
+  vector<D_Particle> muon;
+  //vector<ParticleUtil> gamma;
+  vector<D_Particle> gamma;
 
   TSimpleArray<TRootGenParticle> NFCentralQ;
-  float iPhi=0,iEta=0;
-
+
+D_CaloList list_of_calorimeters;
+D_CaloElement CentralCalo("centralcalo", 
+	-DET->CEN_max_calo_cen, DET->CEN_max_calo_cen,
+	 DET->ELG_Ccen,  DET->ELG_Ncen,  DET->ELG_Scen,
+         DET->HAD_Chcal, DET->HAD_Nhcal, DET->HAD_Shcal);
+D_CaloElement ForwardCalo("forwardcalo",
+	 DET->CEN_max_calo_cen, DET->CEN_max_calo_fwd, 
+         DET->ELG_Cfwd,  DET->ELG_Nfwd,  DET->ELG_Sfwd,
+         DET->HAD_Chf,   DET->HAD_Nhf,   DET->HAD_Shf  );
+D_CaloElement BackwardCalo("backwardcalo",
+	-DET->CEN_max_calo_fwd, -DET->CEN_max_calo_cen,
+         DET->ELG_Cfwd,  DET->ELG_Nfwd,  DET->ELG_Sfwd,
+         DET->HAD_Chf,   DET->HAD_Nhf,   DET->HAD_Shf  );
+//D_CaloElement CastorCalo("castor",5.5,6.6,1,0,0,1,0,0);
+list_of_calorimeters.addElement(CentralCalo);
+list_of_calorimeters.addElement(ForwardCalo);
+list_of_calorimeters.addElement(BackwardCalo);
+//list_of_calorimeters.addElement(CastorCalo);
+list_of_calorimeters.sortElements();
 
 
@@ -360,9 +379,13 @@
       towers.clear();
       input_particles.clear();
-      
+
+
+/*
+if(0) { // OLD SMEARING ALGORITHM without energy flow
       // 2.1 Loop over all particles in event
       itGen.Reset();
       while( (particle = (TRootGenParticle*) itGen.Next()) ) {
           int pid = abs(particle->PID);
+          float iPhi=0,iEta=0;
 
 	
@@ -381,5 +404,5 @@
 	  // the ordering of conditions have been optimised for speed : put first the STATUS condition
           if( (particle->Status == 1)    &&
-	      ((pid != pNU1) && (pid != pNU2) && (pid != pNU3)) &&
+	      (pid != pNU1) && (pid != pNU2) && (pid != pNU3) &&
               (fabs(particle->Eta) < DET->CEN_max_calo_fwd)
 	      ) 
@@ -431,9 +454,9 @@
 	      if(genMomentumBfield.E() !=0 && pid != pMU) {
 		// in case the Bfield is not simulated, checks that charged particles have enough pt to reach the calos
-		if ( !DET->FLAG_bfield && charge!=0 && genMomentumBfield.Pt() <= DET->TRACK_ptmin ) { /* particules do not reach calos */ }
+		if ( !DET->FLAG_bfield && charge!=0 && genMomentumBfield.Pt() <= DET->TRACK_ptmin ) {}// particules do not reach calos 
 		else { // particles reach calos	
 	  	  // applies the calo segmentation and returns iEta & iPhi
 		  DET->BinEtaPhi(genMomentumBfield.Phi(), genMomentumBfield.Eta(), iPhi, iEta); 
-                  if(iEta != -100 && iPhi != -100) { 
+                  if(iEta != UNDEFINED && iPhi != UNDEFINED) { 
                       momentumCaloSegmentation.SetPtEtaPhiE(genMomentumBfield.Pt(),iEta,iPhi,genMomentumBfield.E());
                       elementCalo = (TRootCalo*) branchCalo->NewEntry();
@@ -441,8 +464,8 @@
 		      PhysicsTower Tower(LorentzVector(momentumCaloSegmentation.Px(),momentumCaloSegmentation.Py(),momentumCaloSegmentation.Pz(),momentumCaloSegmentation.E()));
                       towers.push_back(Tower);
-                  } // if iEta != -100
+                  } // if iEta != UNDEFINED
 		} // else : when particles reach the calos
 	      } // 2.1.2.3 calotowers
-	      
+
 
 	      // 2.1.2.4 ********************* central detector: tracks
@@ -451,5 +474,5 @@
 		 (genMomentumBfield.E()!=0) &&
 		 (fabs(genMomentumBfield.Eta()) < DET->CEN_max_tracker) && 
-		 (DET->FLAG_bfield || ( !DET->FLAG_bfield && genMomentumBfield.Pt() > DET->TRACK_ptmin )) &&     
+		 (DET->FLAG_bfield || ( !DET->FLAG_bfield && genMomentum.Pt() > DET->TRACK_ptmin )) &&     
 			// if bfield not simulated, pt should be high enough to be taken into account
 		 ((rand()%100) < DET->TRACK_eff)  &&
@@ -475,11 +498,199 @@
 	     VFD->RomanPots(treeWriter,branchRP220,branchFP420,particle);
 	  }
-	  
-       } // 2.1 while : loop on all particles of the event.
-     
+} // IF OLD ALGORITHM (= no energy flow )
+
+
+
+
+else // IF NEW ALGORITHM with energy flow              
+*/
+{
+      D_CaloTowerList list_of_active_towers; 
+      D_CaloTowerList list_of_towers_with_photon; // to speed up the code: will only look in interesting towers for gamma candidates
+
+      // 2.1a Loop over all particles in event, to fill the towers
+      itGen.Reset();
+      TRootGenParticle *particle; 
+      while( (particle = (TRootGenParticle*) itGen.Next()) ) {
+	  int pid = abs(particle->PID);
+	  particle->Charge=Charge(pid);
+	  particle->setFractions(); // init
+
+
+	  // 2.1a.1********************* preparation for the b-tagging
+	  //// This subarray is needed for the B-jet algorithm
+	  // optimization for speed : put first PID condition, then ETA condition, then either pt or status
+	  if( (pid <= pB || pid == pGLUON) &&// is it a light quark or a gluon, i.e. is it one of these : u,d,c,s,b,g ?
+              fabs(particle->Eta) < DET->CEN_max_tracker &&
+              particle->Status != 1 &&
+              particle->PT > DET->PT_QUARKS_MIN ) {
+            NFCentralQ.Add(particle);
+          }
+
+	  // 2.1a.2********************* visible particles only
+	  if( (particle->Status == 1) && (pid != pNU1) && (pid != pNU2) && (pid != pNU3) ){
+
+            // 2.1a.2.1 Central solenoidal magnetic field 
+	    TRACP->bfield(particle); // fills in particle->EtaCalo et particle->PhiCalo
+	    particle->SetEtaPhi(particle->EtaCalo,particle->PhiCalo); // ???? check this line
+
+	    // 2.1a.2.2 Filling the calorimetric towers -- includes also forward detectors ?
+	    // first checks if the charged particles reach the calo!
+	    if( DET->FLAG_bfield || 
+                particle->getCharge()==0 ||
+                (!DET->FLAG_bfield && particle->getCharge()!=0 && particle->PT > DET->TRACK_ptmin)) 
+	    if(
+		(particle->EtaCalo > list_of_calorimeters.getEtamin() ) &&
+		(particle->EtaCalo < list_of_calorimeters.getEtamax() )
+              ) {
+		float iEta=UNDEFINED, iPhi=UNDEFINED;
+		DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
+		if (iEta != UNDEFINED && iPhi != UNDEFINED) 
+                {
+		  D_CaloTower tower(iEta,iPhi);	                               // new tower
+		  tower.Set_Eem_Ehad_E_ET(particle->E*particle->getFem() , particle->E*particle->getFhad() );
+		
+		  list_of_active_towers.addTower(tower);
+		  // this list may contain several times the same calotower, as several particles 
+		  // may leave some energy in the same calotower
+		  // After the loop on particles, identical cells in the list should be merged 
+		} // iEta and iPhi must be defined
+	    }
+
+ 	    // 2.1a.2.3 charged particles in tracker: energy flow
+	    // if bfield not simulated, pt should be high enough to be taken into account
+	    // it is supposed here that DET->MAX_calo > DET->CEN_max_tracker > DET->CEN_max_mu > 0
+	    if( particle->getCharge() !=0 &&
+	        fabs(particle->EtaCalo)< DET->CEN_max_tracker && // stays in the tracker -> track available
+	       ( DET->FLAG_bfield || 
+                  (!DET->FLAG_bfield && particle->PT > DET->TRACK_ptmin)
+                )
+              ) {	
+		// 2.1a.2.3.1 Filling the particle properties + smearing
+		   // Hypothesis: the final eta/phi are the ones from the generator, thanks to the track reconstruction
+		   // This is the EnergyFlow hypothesis
+		   particle->SetEtaPhi(particle->Eta,particle->Phi);
+		   float sET=UNDEFINED; // smeared ET, computed from the smeared E -> needed for the tracks
+
+		   // 2.1a.2.3.2 Muons
+		   if (pid == pMU && fabs(particle->EtaCalo)< DET->CEN_max_mu && particle->PT > DET->PTCUT_muon ) {
+                        TLorentzVector p;
+                        float sPT = gRandom->Gaus(particle->PT, DET->MU_SmearPt*particle->PT );
+			if (sPT > 0 && sPT > DET->PTCUT_muon) {
+                           p.SetPtEtaPhiE(sPT,particle->Eta,particle->Phi,sPT*cosh(particle->Eta));
+                           muon.push_back(D_Particle(p,pMU,particle->EtaCalo,particle->PhiCalo));
+                        }
+			sET = (sPT >0)? sPT : 0;
+                   }  
+		   // 2.1a.2.3.3 Electrons
+		   else if (pid == pE) {
+		     // Finds in which calorimeter the particle has gone, to know its resolution
+
+		     D_CaloElement currentCalo = list_of_calorimeters.getElement(particle->EtaCalo);
+		     if(currentCalo.getName() == dummyCalo.getName()) {
+			cout << "** Warning: the calo coverage behind the tracker is not complete! **" << endl; }
+
+		     // final smeared EM energy   // electromagnetic fraction F_em =1 for electrons;
+	             float sE  = currentCalo.getElectromagneticResolution().Smear(particle->E);
+		     if (sE>0) {
+ 		       sET = sE/cosh(particle->Eta); 
+		       // NB: ET is found via the calorimetry and not via the track curvature
+
+		       TLorentzVector p;
+		       p.SetPtEtaPhiE(sET,particle->Eta,particle->Phi,sE);
+		       if (sET > DET->PTCUT_elec)
+		         electron.push_back(D_Particle(p,particle->PID,particle->EtaCalo,particle->PhiCalo));
+                     } else { sET=0;} // if negative smeared energy -- needed for the tracks
+		   }  
+		   // 2.1a.2.3.4 Other charged particles : smear them for the tracks!
+		   else {  //other particles
+			D_CaloElement currentCalo = list_of_calorimeters.getElement(particle->EtaCalo);
+			float sEem  = currentCalo.getElectromagneticResolution().Smear(particle->E * particle->getFem());
+			float sEhad = currentCalo.getHadronicResolution().Smear(particle->E * particle->getFhad());
+			float sE = ( (sEem>0)? sEem : 0 ) + ( (sEhad>0)? sEhad : 0 );
+			sET = sE/cosh(particle->EtaCalo);
+		   }
+
+		   // 2.1a.2.3.5 Tracks
+		   if( (rand()%100) < DET->TRACK_eff && sET!=0) {
+   		     elementTrack = (D_Track*) branchTrack->NewEntry();
+		     elementTrack->Set(particle->Eta, particle->Phi, particle->EtaCalo, particle->PhiCalo, sET);
+		     TrackCentral.push_back(elementTrack->GetFourVector()); // tracks at vertex!
+		     // TODO!!! associates the tracks to the calo where it points to
+		     // TODO!!! apply a smearing on the position of the origin of the track
+		     // TODO!!! elementTracks->SetPositionOut(Xout,Yout,Zout);
+		   }
+            } // 2.1a.2.3 : if tracker/energy-flow
+ 	    // 2.1a.2.4 Photons
+               // stays in the tracker -> track available -> gamma ID
+	    else if( (pid == pGAMMA) && fabs(particle->EtaCalo)< DET->CEN_max_tracker ) {
+		float iEta=UNDEFINED, iPhi=UNDEFINED;
+                DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
+                D_CaloTower tower(iEta,iPhi); 
+		// stores the list of towers where to apply the photon ID algorithm. Just a trick for a faster search
+		list_of_towers_with_photon.addTower(tower); 
+	    }
+	    // 2.1a.2.5 : very forward detectors
+	    else if (DET->FLAG_vfd==1) {
+		// for the moment, only protons are transported
+		// BUT !!! could be a beam of other particles! (heavy ions?)
+		// BUT ALSO !!! if very forward muons, or others!
+              VFD->RomanPots(treeWriter,branchRP220,branchFP420,particle);
+              VFD->ZDC(treeWriter,branchZDC,particle);
+	    }
+	    // 2.1a.2.6: Zero degree calorimeter
+	    //else if(DET->FLAG_zdc==1) {
+              //VFD->ZDC(treeWriter,branchZDC,particle);
+	    //}
+
+          } // 2.1a.2 : if visible particle
+      } // loop on all particles 2.1a
+	
+
+      // 2.1b loop on all (activated) towers
+      // at this stage, list_of_active_towers may contain several times the same tower
+      // first step is to merge identical towers, by matching their (iEta,iPhi)  
+      list_of_active_towers.mergeDuplicates();
+      // Calotower smearing 
+      list_of_active_towers.smearTowers(list_of_calorimeters);
+
+      for(unsigned int i=0; i<list_of_active_towers.size(); i++) {
+	float iEta = list_of_active_towers[i].getEta();
+	float iPhi = list_of_active_towers[i].getPhi();
+	float e = list_of_active_towers[i].getE(); 
+	if(iEta != UNDEFINED && iPhi != UNDEFINED && e!=0) {
+           elementCalo = (TRootCalo*) branchCalo->NewEntry();
+	   elementCalo->set(list_of_active_towers[i]);
+           // not beautiful : should be improved!
+	   TLorentzVector p;
+	   p.SetPtEtaPhiE(list_of_active_towers[i].getET(), iEta, iPhi, e );
+           PhysicsTower Tower(LorentzVector(p.Px(),p.Py(),p.Pz(),p.E()));
+           towers.push_back(Tower);
+	}
+      } // loop on towers
+
+      // 2.1c photon ID
+      // list_of_towers_with_photon is the list of towers with photon candidates
+      // already smeared !
+      // sorts the vector and smears duplicates 
+      list_of_towers_with_photon.mergeDuplicates(); 
+
+      for(unsigned int i=0; i<list_of_towers_with_photon.size(); i++) {
+	  float eta = list_of_towers_with_photon[i].getEta(); 
+	  float phi = list_of_towers_with_photon[i].getPhi();
+	  D_CaloTower cal(list_of_active_towers.getElement(eta,phi));
+	  if(cal.getEta() != UNDEFINED && cal.getPhi() != UNDEFINED &&  cal.getE() > 0) {
+  	    TLorentzVector p;
+            p.SetPtEtaPhiE(cal.getET(), eta,phi,cal.getE() );
+	    if (cal.getET() > DET->PTCUT_gamma) { gamma.push_back(D_Particle(p,pGAMMA,p.Eta(),p.Phi())); }
+          }
+      } // for -- list of photons
+
+}  // IF NEW ALGORITHM with energy flow
+
+
 
 
       // 2.2 ********** Output preparation & complex objects  ***********
- 
       // 2.2.1 ********************* sorting collections by decreasing pt
       DET->SortedVector(electron); 
@@ -487,4 +698,6 @@
         elementElec = (TRootElectron*) branchElectron->NewEntry();
         elementElec->Set(electron[i].Px(),electron[i].Py(),electron[i].Pz(),electron[i].E());
+        elementElec->EtaCalo = electron[i].EtaCalo(); 
+        elementElec->PhiCalo = electron[i].PhiCalo();
         elementElec->Charge = sign(electron[i].PID());
         elementElec->IsolFlag = DET->Isolation(electron[i].Phi(),electron[i].Eta(),TrackCentral,2.0);//isolation based on tracks
@@ -495,4 +708,6 @@
         elementMu->Charge = sign(muon[i].PID());
         elementMu->Set(muon[i].Px(),muon[i].Py(),muon[i].Pz(),muon[i].E());
+        elementMu->EtaCalo = muon[i].EtaCalo(); 
+        elementMu->PhiCalo = muon[i].PhiCalo();
         elementMu->IsolFlag = DET->Isolation(muon[i].Phi(),muon[i].Eta(),TrackCentral,2.0);
       }
@@ -501,4 +716,6 @@
 	elementPhoton = (TRootPhoton*) branchPhoton->NewEntry();
 	elementPhoton->Set(gamma[i].Px(),gamma[i].Py(),gamma[i].Pz(),gamma[i].E());
+        elementPhoton->EtaCalo = gamma[i].EtaCalo();
+        elementPhoton->PhiCalo = gamma[i].PhiCalo();
       }
       
@@ -522,5 +739,5 @@
       elementEtmis->Py = (-PTmis).Py();
       
-      // 2.2.3 ************* B-tag, tau jets
+      // 2.2.3 ************* jets, B-tag, tau jets
       sorted_jets=JETRUN->RunJets(input_particles);
       JETRUN->RunJetBtagging(treeWriter, branchJet,sorted_jets,NFCentralQ);
@@ -529,5 +746,6 @@
       treeWriter->Fill();
     } // 2. Loop over all events ('for' loop)
- 
+
+
   cout <<"**                                                                 **"<< endl;
   cout <<"**                 Exiting detector simulation...                  **"<< endl;
@@ -649,5 +867,5 @@
   delete treeReader;
   delete DET;
-//  delete TRIGT;
+  delete TRIGT;
   delete TRACP;
   delete JETRUN;
Index: trunk/Examples/Trigger_Only.cpp
===================================================================
--- trunk/Examples/Trigger_Only.cpp	(revision 262)
+++ trunk/Examples/Trigger_Only.cpp	(revision 264)
@@ -94,5 +94,5 @@
 
   //read the datacard input file
-  string TrigDatacard("");
+  string TrigDatacard("data/trigger.dat");
   if(argc==3)  TrigDatacard =argv[2];
 
Index: trunk/Examples/src/Analysis_Ex.cc
===================================================================
--- trunk/Examples/src/Analysis_Ex.cc	(revision 262)
+++ trunk/Examples/src/Analysis_Ex.cc	(revision 264)
@@ -155,5 +155,5 @@
           D1       = gen->D1;       // particle 1st daughter 
           D2       = gen->D2;       // particle 2nd daughter 
-          Charge = gen->Charge;   // electrical charge
+          Charge = gen->getCharge();   // electrical charge
 	  
           T      = gen->T;        // particle vertex position (t component)
@@ -334,5 +334,5 @@
      for(Int_t i=0;i < numElec; i++)Lept[i].SetPxPyPzE(el[i]->Px,el[i]->Py,el[i]->Pz,el[i]->E);
      for(Int_t k = numElec; k < (numElec+mu.GetEntries()); k++)Lept[k].SetPxPyPzE(mu[k-numElec]->Px,mu[k-numElec]->Py,mu[k-numElec]->Pz,mu[k-numElec]->E);
-    
+    cout<<"normalement il y a quelque chose... "<<endl;
      //Example how to white a branch in the output file
      inv_mass=(TRootInvm*) INVMASS->NewEntry();
Index: trunk/README
===================================================================
--- trunk/README	(revision 262)
+++ trunk/README	(revision 264)
@@ -104,3 +104,4 @@
  - dans ParticleUtil
 	eta,phi et eta_calo,phi_calo
+ - TRootParticle::SetEtaPhiEET : pas fini
 
Index: trunk/Resolutions.cpp
===================================================================
--- trunk/Resolutions.cpp	(revision 262)
+++ trunk/Resolutions.cpp	(revision 264)
@@ -1,32 +1,14 @@
-/***********************************************************************
-**                                                                    **
-**          /----------------------------------------------\          **
-**         |  Delphes, a framework for the fast simulation  |         **
-**         |       of a  generic collider experiment        |         **
-**          \----------------------------------------------/          **
-**                                                                    **
-**                                                                    **
-**   This package uses:                                               **
-**   ------------------                                               **
-**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
-**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
-**   FROG: [hep-ex/0901.2718v1]                                       **
-**                                                                    **
-** ------------------------------------------------------------------ **
-**                                                                    **
-**   Main authors:                                                    **
-**   -------------                                                    **
-**                                                                    **
-**                Severine Ovyn                Xavier Rouby           ** 
-**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
-**                                                                    ** 
-**         Center for Particle Physics and Phenomenology (CP3)        ** 
-**                Universite catholique de Louvain (UCL)              **       
-**                     Louvain-la-Neuve, Belgium                      **            
-**                                                                    **
-**                      Copyright (C) 2008-2009,                      **
-**                        All rights reserved.                        **  
-**                                                                    **
-***********************************************************************/
+/*
+  ---- FastSim ----
+  A Fast Simulator for general purpose LHC detector
+  S. Ovyn ~~~~ severine.ovyn@uclouvain.be
+
+  Center for Particle Physics and Phenomenology (CP3)
+  Universite Catholique de Louvain (UCL)
+  Louvain-la-Neuve, Belgium
+*/
+
+/// \file Smearing.cpp
+/// \brief executable for the FastSim
 
 #include "TChain.h"
@@ -47,4 +29,7 @@
 #include "JetsUtil.h"
 #include "BFieldProp.h"
+
+//#include "PseudoJet.hh"
+//#include "ClusterSequence.hh"
 
 #include<vector>
@@ -75,13 +60,11 @@
        if(abs(gen1->PID)==15)
          {
-cout<<"au moins on a un tau "<<endl;
             int d1=gen1->D1;
             int d2=gen1->D2;
-cout<<"il a des filles? "<<endl;
             if((d1 < array.GetEntries()) && (d1 > 0) && (d2 < array.GetEntries()) && (d2 > 0))
                {
                  tauhad=true;
                  for(int d=d1; d < d2+1; d++)
-                    {cout<<abs(array[d]->PID)<<"  "<<endl;
+                    {
                       if(abs(array[d]->PID)== pE || abs(array[d]->PID)== pMU)tauhad=false;
                     }
@@ -115,5 +98,5 @@
    {
       TLorentzVector Att;
-      Att.SetPxPyPzE(jet->Px,jet->Py,jet->Pz,jet->E);
+      Att.SetPtEtaPhiE(jet->PT,jet->Eta,jet->Phi,jet->E);
       if(DeltaR(JET.Phi(),JET.Eta(),Att.Phi(),Att.Eta()) < deltaRtest)
         {
@@ -137,5 +120,5 @@
    {
       TLorentzVector Att;
-      Att.SetPxPyPzE(elec->Px,elec->Py,elec->Pz,elec->E);
+      Att.SetPtEtaPhiE(elec->PT,elec->Eta,elec->Phi,elec->E);
       if(DeltaR(ELEC.Phi(),ELEC.Eta(),Att.Phi(),Att.Eta()) < deltaRtest)
         {
@@ -313,5 +296,5 @@
                  case pE: // all electrons with eta < DET->MAX_CALO_FWD
                     PairingElec(recoMomentum,genMomentum,branchElec);
-                    if(recoMomentum.Pt()>1){
+                    if(recoMomentum.E()!=0){
                      elementElec=(RESOLELEC*) branchelec->NewEntry();
                      elementElec->E = genMomentum.E();
@@ -331,5 +314,5 @@
 
 	} // while
-      
+     
       //compute missing transverse energy from calo towers    
       TIter itCalo((TCollection*)branchTowers);
@@ -340,14 +323,14 @@
       while( (calo = (TRootCalo*) itCalo.Next()) )
            {
-          //Att.SetPxPyPzE(towers[i].fourVector.px, towers[i].fourVector.py, towers[i].fourVector.pz, towers[i].fourVector.E);
-          Att.SetPtEtaPhiE(calo->PT,calo->Eta,calo->Phi,calo->E);
-          towers.push_back(Att);
-          if(fabs(Att.Eta()) < DET->CEN_max_calo_fwd)
-            {
-               ScalarEt = ScalarEt + Att.Et();
-               PTmisReco = PTmisReco + Att;
-            }
-        }
-      
+             if(calo->E !=0){
+             Att.SetPtEtaPhiE(calo->getET(),calo->Eta,calo->Phi,calo->E);
+             towers.push_back(Att);
+             if(fabs(Att.Eta()) < DET->CEN_max_calo_fwd)
+               {
+                  ScalarEt = ScalarEt + calo->getET();
+                  PTmisReco = PTmisReco + Att;
+               }
+           }  
+      }
       elementEtmis= (ETMIS*) branchetmis->NewEntry();
       elementEtmis->Et = (PTmisGEN).Pt();
@@ -363,5 +346,4 @@
 
       TSimpleArray<TRootGenParticle> TausHadr = TauHadr(branchGen);
-cout<<"nombre de tau-jets "<<TausHadr.GetEntries()<<endl;
 
       TLorentzVector JETreco(0,0,0,0);
@@ -397,5 +379,4 @@
                     if( (EnergySmallCone(towers,JETT.Eta(),JETT.Phi(),DET->TAU_energy_scone,DET->JET_seed)/JETT.E()) > 0.95 
                      &&  (NumTracks(branchTracks,DET->TAU_track_pt,JETT.Eta(),JETT.Phi(),DET->TAU_track_scone))==1)numTauRec++;
-                    
                  }
               }
@@ -404,11 +385,12 @@
 	
       } // for itJet : loop on all jets
+//cout<<"i"<<endl;
       
       treeWriter->Fill();
     } // Loop over all events
   treeWriter->Write();
-  float frac = numTauRec/numTau;  
-  cout<<numTauRec<<endl;
-  cout<<numTau<<endl;
+float frac = numTauRec/numTau;  
+cout<<numTauRec<<endl;
+cout<<numTau<<endl;
 
   cout << "** Exiting..." << endl;
Index: trunk/TODO
===================================================================
--- trunk/TODO	(revision 262)
+++ trunk/TODO	(revision 264)
@@ -18,4 +18,6 @@
  - copy constructors des classes ; passage par reference ; gprof tool <-> option -gp
  - valgrind <-> -g <-> definitely lost / probably lost
- - include .cpp de frog???
+ - pourquoi doit-on inclure les fichiers.cpp de frog???
  - TreeClassesLinkDef ???
+ - libHector.so = libUtilities.so !!!!!
+ - FLAG_zdc <-> pas complet, notamment dans le fichier log
Index: trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h
===================================================================
--- trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 262)
+++ trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 264)
@@ -13,6 +13,6 @@
  *  present in the data members of the Block TRoot class.
  *
- *  $Date: 2009-02-02 11:32:12 $
- *  $Revision: 1.11 $
+ *  $Date: 2009-02-11 09:19:14 $
+ *  $Revision: 1.12 $
  *
  *  
@@ -24,4 +24,6 @@
 #include "TObject.h"
 #include "BlockCompare.h"
+#include "interface/D_Constants.h"
+#include "interface/CaloUtil.h"
 
 class TSortableObject: public TObject
@@ -147,12 +149,25 @@
   float Pz; // particle momentum vector (z component) in GeV
 
-  float PT; // particle transverse momentum in GeV
   float Eta; // particle pseudorapidity  
   float Phi; // particle azimuthal angle in rad 
 
+  float EtaCalo; // particle pseudorapidity when entering the calo, 
+  float PhiCalo; // particle azimuthal angle in rad when entering the calo
+
   void Set(const TLorentzVector& momentum);
   void Set(const float px, const float py, const float pz, const float e);
-  static TCompare *fgCompare; //!
-  const TCompare *GetCompare() const { return fgCompare; }
+  void SetEtaPhi(const float eta, const float phi) {Eta=eta; Phi=phi;};
+  void SetEtaPhiCalo(const float eta, const float phi) {EtaCalo=eta; PhiCalo=phi;};
+  void SetEtaPhiEET(const float eta, const float phi, const float e, const float et);
+  static TCompare *fgCompare; //!
+  const TCompare *GetCompare() const { return fgCompare; }
+  //void SetEem_Ehad(const float sE_em, const float sE_had) {} ; // sets E_em and E_had, computes E and ET
+  float PT; // particle transverse momentum in GeV
+  //const float getEtaGen() const {return _EtaGen;}
+  //const float getPhiGen() const {return _PhiGen;}
+
+
+//protected:
+  //float EGen, _EtaGen, _PhiGen; // from the generator: energy, eta, phi
 
   ClassDef(TRootParticle, 1)
@@ -165,5 +180,5 @@
 
 public:
-  TRootGenParticle() {};
+  TRootGenParticle() {_initialised=false;}
   int PID; // particle HEP ID number [RawHepEventParticle::pid()]
   int Status; // particle status [RawHepEventParticle::status()]
@@ -172,5 +187,4 @@
   int D1; // particle 1st daughter [RawHepEventParticle::daughter1() - 1]
   int D2; // particle 2nd daughter [RawHepEventParticle::daughter2() - 1]
-  float Charge; // electrical charge
 
   float T; // particle vertex position (t component) [RawHepEventParticle::t()]
@@ -179,8 +193,18 @@
   float Z; // particle vertex position (z component) [RawHepEventParticle::z()]
   float M;
-  static TCompare *fgCompare; //!
-
+  void setFractions();
+  const float getCharge() const {return Charge;};
+  const float getFem()  {if(!_initialised) setFractions(); return _Fem;}
+  const float getFhad() {if(!_initialised) setFractions(); return _Fhad;}
+
+  float Charge;      // electrical charge
+
+  static TCompare *fgCompare; //!
+ protected:
+  float _Fem, _Fhad; // fractions of energy deposit
+  bool _initialised;
   ClassDef(TRootGenParticle, 1)
 };
+
 
 //------------------------------------------------------------------------------
@@ -225,13 +249,51 @@
 //---------------------------------------------------------------------------
 
-class TRootTracks: public TRootParticle
-{
-public:
-  TRootTracks() : Etaout(0), Phiout(0) {};
-  static TCompare *fgCompare; //!
- 
+class D_Track : public TSortableObject {
+//class D_Track : public TRootParticle {
+ public:
+    D_Track(); // needed for storage in ExRootAnalysis
+    D_Track(const D_Track& track);
+    D_Track(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt);
+    D_Track& operator=(const D_Track& track);
+    void Set(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt);
+    const TLorentzVector GetFourVector() const;
+    const float getEta() const {return Eta;}
+    const float getPhi() const {return Phi;}
+    const float getEtaOuter() const {return EtaOuter;}
+    const float getPhiOuter() const {return PhiOuter;}
+    const float getE() const {return E;}
+    const float getPx() const {return Px;}
+    const float getPy() const {return Py;}
+    const float getPz() const {return Pz;}
+    const float getPT() const {return PT;}
+
+  static TCompare *fgCompare; //!
+  const TCompare *GetCompare() const { return fgCompare; }
+ protected:
+    float Eta, Phi; // (eta,phi) at the beginning of the track
+    float EtaOuter, PhiOuter; // (eta,phi) at the end of the track
+    float PT, E, Px, Py, Pz;  // transverse momentum
+ ClassDef(D_Track, 1)
+};
+
+
+class TRootTracks: public TRootParticle  {
+public:
+  TRootTracks() {} // : Etaout(0), Phiout(0) {};
+  static TCompare *fgCompare; //!
+  TRootTracks(const D_Track& track);
+  float E;  // particle energy in GeV
+  float Px; // particle momentum vector (x component) in GeV
+  float Py; // particle momentum vector (y component) in GeV
+  float Pz; // particle momentum vector (z component) in GeV
+
+  float Eta; // particle pseudorapidity
+  float Phi; // particle azimuthal angle in rad
+
+  float EtaCalo; // particle pseudorapidity when entering the calo,
+  float PhiCalo; // particle azimuthal angle in rad when entering the calo 
 //  float X, Y, Z; // coordinates of the beginning of the track
 //  float Xout, Yout, Zout; // coordinates of the end of the track
-  float Etaout, Phiout; // coordinates of the end of the track
+  //float Etaout, Phiout; // coordinates of the end of the track
 //  void SetPosition(const float x, const float y, const float z) {X=x; Y=y; Z=z;}
 //  void SetPositionOut(const float x, const float y, const float z) {Xout=x; Yout=y; Zout=z;}
@@ -241,6 +303,5 @@
 //---------------------------------------------------------------------------
 
-class TRootCalo: public TRootParticle
-{
+/*class TRootCalo: public TRootParticle
 public:
   TRootCalo() {};
@@ -248,4 +309,24 @@
 
   ClassDef(TRootCalo, 1)
+};
+*/
+
+//class TRootCalo: public TSortableObject {
+class TRootCalo: public TRootParticle {
+ public:
+   TRootCalo() ;
+   TRootCalo(const TRootCalo& cal);
+   TRootCalo& operator=(const TRootCalo& cal);
+   void set(const D_CaloTower&  cal);
+   static TCompare *fgCompare; //!
+ //  const TCompare *GetCompare() const { return fgCompare; }
+   const float getET() const {return ET;}
+ 
+ protected:
+    //float Eta, Phi;    // segmented eta, phi
+    float E_em, E_had; // electromagnetic and hadronic components of the tower energy
+    //float E;
+    float ET;       // total energy and transverse energy   
+   ClassDef(TRootCalo, 1)
 };
 
@@ -340,6 +421,4 @@
 };
 
-//---------------------------------------------------------------------------
-
 #endif // BLOCKCLASSES_H
 
Index: trunk/Utilities/ExRootAnalysis/src/BlockClasses.cc
===================================================================
--- trunk/Utilities/ExRootAnalysis/src/BlockClasses.cc	(revision 262)
+++ trunk/Utilities/ExRootAnalysis/src/BlockClasses.cc	(revision 264)
@@ -11,6 +11,6 @@
  *  to preserve mother-dautherlinks between particles.
  *
- *  $Date: 2009-02-02 11:32:01 $
- *  $Revision: 1.7 $
+ *  $Date: 2009-02-11 09:19:14 $
+ *  $Revision: 1.8 $
  *
  *  
@@ -22,4 +22,5 @@
 #include "BlockCompare.h"
 #include "TLorentzVector.h"
+#include <cmath>
 
 TCompare *TRootGenParticle::fgCompare = 0;
@@ -38,4 +39,6 @@
 TCompare *TRootRomanPotHits::fgCompare =0;
 TCompare *TRootTrigger::fgCompare =0;
+//TCompare *D_CaloTower::fgCompare=0;
+TCompare *D_Track::fgCompare=0;
 
 void TRootParticle::Set(const TLorentzVector& momentum) {
@@ -61,3 +64,98 @@
 }
 
+void TRootParticle::SetEtaPhiEET(const float eta, const float phi, const float e, const float et) {
+   Eta = eta; Phi = phi; E = e; PT = et;
+   //float theta = 2* atan(exp(-Eta);
+   Px = PT*cos(Phi);
+   Py = PT*sin(Phi);
+}
 
+
+void TRootGenParticle::setFractions() {
+  switch(abs(PID)) {
+    default:  _Fem = 0; _Fhad=1; break;
+    case(pE):
+    case(pGAMMA):
+    case(pPI0):
+        _Fem = 1; _Fhad=0; break;
+    case(pNU1):
+    case(pNU2):
+    case(pNU3):
+    case(pMU):
+        _Fem =0; _Fhad=0; break;
+    case(pK0S):
+    case(pLAMBDA):
+	_Fem=0.3; _Fhad=0.7; break;
+  }
+  _initialised=true;
+}
+
+    float Eta, Phi; // (eta,phi) at the beginning of the track
+    float EtaOuter, PhiOuter; // (eta,phi) at the end of the track
+    float PT, E, Px, Py, Pz; 
+
+D_Track::D_Track() :
+	Eta(UNDEFINED), Phi(UNDEFINED), EtaOuter(UNDEFINED), PhiOuter(UNDEFINED), 
+        PT(UNDEFINED), E(UNDEFINED), Px(UNDEFINED), Py(UNDEFINED), Pz(UNDEFINED) {}
+
+D_Track::D_Track(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt) :
+	Eta(inEta), Phi(inPhi), EtaOuter(outEta), PhiOuter(outPhi), 
+        PT(pt) {
+	TLorentzVector p; p.SetPtEtaPhiE(PT,Eta,Phi,PT*cosh(Eta));
+        Px = p.Px(); Py = p.Py(); Pz = p.Pz();  E=p.E();
+}
+
+D_Track::D_Track(const D_Track& track) :
+	Eta(track.Eta), Phi(track.Phi), 
+        EtaOuter(track.EtaOuter), PhiOuter(track.PhiOuter), 
+	PT(track.PT), E(track.E), Px(track.Px), Py(track.Py), Pz(track.Pz) {}
+
+D_Track& D_Track::operator=(const D_Track& track) {
+  if(this == &track) return *this;
+	Eta = track.Eta;             Phi = track.Phi; 
+        EtaOuter = track.EtaOuter;   PhiOuter = track.PhiOuter; 
+        PT = track.PT; E = track.E;  Px = track.Px;  Py= track.Py; Pz =track.Pz; 
+  return *this;
+}
+
+void D_Track::Set(const float inEta, const float inPhi, const float outEta, const float outPhi, const float pt) {
+	Eta= inEta; Phi=inPhi;  EtaOuter=outEta; PhiOuter=outPhi; PT=pt; 
+	TLorentzVector p; p.SetPtEtaPhiE(PT,Eta,Phi,PT*cosh(Eta));
+	Px = p.Px(); Py = p.Py(); Pz = p.Pz();  E=p.E();
+}
+
+const TLorentzVector D_Track::GetFourVector() const {
+	TLorentzVector v;
+	v.SetPtEtaPhiE(PT,Eta,Phi,PT*cosh(Eta));
+	return TLorentzVector(v);
+}
+
+TRootCalo::TRootCalo() :
+	E_em(UNDEFINED), E_had(UNDEFINED), ET(UNDEFINED) {}
+	//Eta(UNDEFINED), Phi(UNDEFINED), E_em(UNDEFINED), E_had(UNDEFINED), E(UNDEFINED), ET(UNDEFINED) {}
+
+TRootCalo::TRootCalo(const TRootCalo& cal) {
+        E_em=cal.E_em; E_had=cal.E_had;  ET=cal.ET;
+        //Eta =cal.Eta;  Phi=cal.Phi; E_em=cal.E_em; E_had=cal.E_had;  E=cal.E;   ET=cal.ET;
+}
+
+TRootCalo& TRootCalo::operator=(const TRootCalo& cal) {
+   if(this==&cal) return *this;
+        Eta =cal.Eta;  Phi=cal.Phi; E_em=cal.E_em; E_had=cal.E_had;  E=cal.E;   ET=cal.ET;
+   return *this;
+}
+
+void TRootCalo::set(const D_CaloTower& cal) {
+	Eta =cal.getEta(); Phi=cal.getPhi(); 
+        E_em=cal.getEem(); E_had=cal.getEhad();
+        E   =cal.getE();   ET   =cal.getET();
+	EtaCalo = cal.getEta();
+	PhiCalo = cal.getPhi();
+}
+
+
+TRootTracks::TRootTracks(const D_Track& track) :
+   E(track.getE()), Px(track.getPx()), Py(track.getPy()), Pz(track.getPz()),
+   Eta(track.getEta()), Phi(track.getPhi()),
+   /*Etaout(track.getEtaOuter()),*/ EtaCalo(track.getEtaOuter()), /*Phiout(track.getPhiOuter()),*/ PhiCalo(track.getPhiOuter()) {}
+
Index: trunk/Utilities/ExRootAnalysis/src/BlockClassesLinkDef.h
===================================================================
--- trunk/Utilities/ExRootAnalysis/src/BlockClassesLinkDef.h	(revision 262)
+++ trunk/Utilities/ExRootAnalysis/src/BlockClassesLinkDef.h	(revision 264)
@@ -4,6 +4,6 @@
  *  Lists classes to be included in cint dicitonary
  *
- *  $Date: 2008-12-02 11:14:45 $
- *  $Revision: 1.2 $
+ *  $Date: 2009-02-11 09:19:14 $
+ *  $Revision: 1.3 $
  *
  *  
@@ -13,4 +13,5 @@
 
 #include "Utilities/ExRootAnalysis/interface/BlockClasses.h"
+#include "interface/D_Constants.h"
 
 #ifdef __CINT__
@@ -39,4 +40,6 @@
 #pragma link C++ class TRootLHEFEvent+;
 #pragma link C++ class TRootLHEFParticle+;
+#pragma link C++ class D_Track+;
+//#pragma link C++ class D_CaloTower+;
 
 
Index: trunk/Utilities/FROG/config.txt
===================================================================
--- trunk/Utilities/FROG/config.txt	(revision 262)
+++ trunk/Utilities/FROG/config.txt	(revision 264)
@@ -3,5 +3,5 @@
 InputVisFile ={../../DelphesToFrog.vis};
 
-GeomToDisplay = {910000000,920000000,930000000,940000000};
+//GeomToDisplay = {910000000,920000000,930000000,940000000};
 EventToDisplay = {21000000};
 
Index: trunk/Utilities/Hector/src/H_AbstractBeamLine.cc
===================================================================
--- trunk/Utilities/Hector/src/H_AbstractBeamLine.cc	(revision 262)
+++ trunk/Utilities/Hector/src/H_AbstractBeamLine.cc	(revision 264)
@@ -485,5 +485,5 @@
 	/// @param offset In meters
 
-	extern int relative_energy;
+	extern bool relative_energy;
 	if(!relative_energy) {
 		vector<H_OpticalElement*>::iterator element_i;
Index: trunk/VERSION
===================================================================
--- trunk/VERSION	(revision 262)
+++ trunk/VERSION	(revision 264)
@@ -1,1 +1,1 @@
-1.4beta
+x.y
Index: trunk/data/DataCardDet.dat
===================================================================
--- trunk/data/DataCardDet.dat	(revision 262)
+++ trunk/data/DataCardDet.dat	(revision 264)
@@ -11,17 +11,17 @@
 ELG_Scen          0.05              // S term for central ECAL
 ELG_Ncen          0.25              // N term for central ECAL
-ELG_Ccen          0.005             // C term for central ECAL
-ELG_Sfwd          2.084             // S term for FCAL
-ELG_Nfwd          0.0               // N term for FCAL
-ELG_Cfwd          0.107             // C term for FCAL
+ELG_Ccen          0.005              // C term for central ECAL
+ELG_Cfwd          0.107             // S term for forward ECAL
+ELG_Sfwd          2.084             // C term for forward ECAL
+ELG_Nfwd          0.0               // N term for central ECAL
 
 # Energy resolution for hadrons in ecal/hcal/hf
 # \sigma/E = C + N/E + S/\sqrt{E}, E in GeV
-HAD_Shcal         1.5               // S term for central HCAL 
+HAD_Shcal         1.5               // S term for central HCAL // hadronic calorimeter
 HAD_Nhcal         0.                // N term for central HCAL
 HAD_Chcal         0.05              // C term for central HCAL
-HAD_Shf           2.7               // S term for FCAL
-HAD_Nhf           0.                // N term for FCAL
-HAD_Chf           0.13              // C term for FCAL
+HAD_Shf           2.7               // S term for HF // forward calorimeter
+HAD_Nhf           0.                // N term for HF
+HAD_Chf           0.13              // C term for HF
 
 # Muon smearing
@@ -29,5 +29,5 @@
 
 # Tracking efficiencies
-TRACK_ptmin       0.9               // minimal pt needed to reach the calorimeter in GeV
+TRACK_ptmin       0.0               // minimal pt needed to reach the calorimeter in GeV
 TRACK_eff         100               // efficiency associated to the tracking (%)
 
@@ -48,9 +48,9 @@
 
 # Thresholds for reconstructed objetcs, Pt in GeV
-PTCUT_elec       10.0
-PTCUT_muon       10.0
-PTCUT_jet        20.0
-PTCUT_gamma      10.0
-PTCUT_taujet     10.0
+PTCUT_elec       0.0
+PTCUT_muon       0.0
+PTCUT_jet        0.0
+PTCUT_gamma      0.0
+PTCUT_taujet     0.0
 
 # General jet variable
@@ -65,5 +65,5 @@
 
 # FLAGS
-FLAG_bfield      1                       //1 to run the bfield propagation else 0
+FLAG_bfield      0                       //1 to run the bfield propagation else 0
 FLAG_vfd         1                       //1 to run the very forward detectors else 0
 FLAG_trigger     1                       //1 to run the trigger selection else 0
@@ -88,8 +88,4 @@
 RP_420_s          420                   // distance of the RP to the IP, in meters
 RP_420_x          0.004                 // distance of the RP to the beam, in meters
-RP_beam1Card      data/LHCB1IR5_v6.500.tfs
-RP_beam2Card      data/LHCB2IR5_v6.500.tfs
-RP_IP_name        IP5
-
 
 # In case FROG event display allowed
Index: trunk/data/DataCardDet_CMS.dat
===================================================================
--- trunk/data/DataCardDet_CMS.dat	(revision 262)
+++ trunk/data/DataCardDet_CMS.dat	(revision 264)
@@ -29,5 +29,5 @@
 
 # Tracking efficiencies
-TRACK_ptmin       0.9               // minimal pt needed to reach the calorimeter in GeV
+TRACK_ptmin       0.0               // minimal pt needed to reach the calorimeter in GeV
 TRACK_eff         100               // efficiency associated to the tracking (%)
 
@@ -67,6 +67,6 @@
 FLAG_bfield      1                       //1 to run the bfield propagation else 0
 FLAG_vfd         1                       //1 to run the very forward detectors else 0
-FLAG_trigger     1                       //1 to run the trigger selection else 0
-FLAG_frog        1                       //1 to run the FROG event display
+FLAG_trigger     0                       //1 to run the trigger selection else 0
+FLAG_frog        0                       //1 to run the FROG event display
 
 # In case BField propagation allowed
Index: trunk/data/trigger.dat
===================================================================
--- trunk/data/trigger.dat	(revision 262)
+++ trunk/data/trigger.dat	(revision 264)
@@ -1,3 +1,3 @@
-TRIGGER CARD      # DO NOT REMOVE THIS IS A TAG!
+#TRIGGER CARD      # DO NOT REMOVE THIS IS A TAG!
 
 
Index: trunk/interface/BFieldProp.h
===================================================================
--- trunk/interface/BFieldProp.h	(revision 262)
+++ trunk/interface/BFieldProp.h	(revision 264)
@@ -53,7 +53,7 @@
 
     // Propagation and bfield are very similar. At the end, after code cleaning,
-    // onle bfield will remain in this class 
+    // only bfield will remain in this class 
     void Propagation(const TRootGenParticle *Part,TLorentzVector &genMomentum);
-    void bfield(const TRootGenParticle *Part, float& etacalo, float& phicalo);
+    void bfield(TRootGenParticle *Part); // fills in Part->EtaCalo and Part->PhiCalo
 
 
Index: trunk/interface/CaloUtil.h
===================================================================
--- trunk/interface/CaloUtil.h	(revision 264)
+++ trunk/interface/CaloUtil.h	(revision 264)
@@ -0,0 +1,143 @@
+#ifndef _CALOUTIL_H_
+#define _CALOUTIL_H_
+
+/*
+  ---- Delphes ----
+  A Fast Simulator for general purpose LHC detector
+  S. Ovyn ~~~~ severine.ovyn@uclouvain.be
+  
+  Center for Particle Physics and Phenomenology (CP3)
+  Universite Catholique de Louvain (UCL)
+  Louvain-la-Neuve, Belgium
+*/
+
+/// \file D_CaloUtil.h
+/// \brief D_CaloElement, D_CaloResolution and D_CaloList classes
+
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+#include "D_Constants.h"
+using namespace std;
+
+
+class D_CaloResolution {
+ public:
+   D_CaloResolution(const float cterm, const float nterm, const float sterm) : _c(cterm), _n(nterm), _s(sterm) {};
+   D_CaloResolution(const D_CaloResolution& resolution) : _c(resolution._c), _n(resolution._n), _s(resolution._s) {};
+   D_CaloResolution& operator=(const D_CaloResolution& resolution);
+   const float getC() const {return _c;}
+   const float getN() const {return _n;}
+   const float getS() const {return _s;}
+   const float Smear(const float energy) const;
+   void print() const;
+ private:
+   float _c, _n, _s;
+};
+
+
+
+class D_CaloElement {
+ public:
+   D_CaloElement(const string& name, const float etamin, const float etamax, const float c_em, const float n_em, const float s_em, const float c_had, const float n_had, const float s_had) : _name(name), _etamin(min(etamin,etamax)), _etamax(max(etamin,etamax)), _resol_em(c_em,n_em,s_em), _resol_had(c_had,n_had,s_had) {};
+   D_CaloElement(const D_CaloElement& calo) : _name(calo._name), _etamin(calo._etamin), _etamax(calo._etamax), _resol_em(calo._resol_em), _resol_had(calo._resol_had) {};
+   D_CaloElement& operator=(const D_CaloElement& calo);
+   const D_CaloResolution& getElectromagneticResolution() const {return _resol_em;}
+   const D_CaloResolution& getHadronicResolution() const {return _resol_had;}
+   const string& getName() const {return _name;}
+   const float getEtamin() const {return _etamin;}
+   const float getEtamax() const {return _etamax;}
+   ///     Ordering operator acting on eta
+   inline const bool operator>(const D_CaloElement& tocomp) const {if(_etamin > tocomp._etamin) { return true; } else { return false; }};
+   ///     Ordering operator acting on eta
+   inline const bool operator<(const D_CaloElement& tocomp) const {if(_etamin < tocomp._etamin) { return true; } else { return false; }};
+
+ private:
+   string _name;
+   float _etamin, _etamax;
+   D_CaloResolution _resol_em; 
+   D_CaloResolution _resol_had;
+};
+
+
+
+class D_CaloList {
+ public:
+   D_CaloList() : _calorimeters(), _etamin(UNDEFINED), _etamax(UNDEFINED), _sorted(false) {};
+   D_CaloList(const D_CaloList& list) : 
+        _calorimeters(list._calorimeters), _etamin(list._etamin), _etamax(list._etamax), _sorted(list._sorted) {};
+   D_CaloList& operator=(const D_CaloList& list);
+   const D_CaloElement& getElement(const float eta) const; // returns the pointer to the calorimeter lying in eta
+   void  addElement(const D_CaloElement & calo);
+   void  sortElements(); // sorts the list with respect to the eta
+   const float getEtamax() {if(!_sorted) sortElements(); return _etamax;}
+   const float getEtamin() {if(!_sorted) sortElements(); return _etamin;}
+   void print() const;
+ private:
+   vector<D_CaloElement> _calorimeters;
+   float _etamin; 
+   float _etamax;
+   bool _sorted; 
+   struct ordering{ bool operator()(const D_CaloElement& el1, const D_CaloElement& el2) const { return (el1 < el2);}};
+};
+
+const D_CaloElement dummyCalo("not found calo",UNDEFINED,UNDEFINED+1,1,0,0,1,0,0);
+
+
+
+class D_CaloTower {
+ public:
+    //D_CaloTower(); risk that _eta and _phi not initialised before using Set_Eem_Ehad_E_ET!
+    D_CaloTower(const float iEta, const float iPhi);
+    D_CaloTower(const D_CaloTower& tower);
+    D_CaloTower& operator=(const D_CaloTower& tower);
+    void Set_Eta_Phi(const float iEta, const float iPhi) {_eta=iEta; _phi=iPhi;}
+    void Set_Eem_Ehad_E_ET(const float eem, const float ehad) { _Eem = eem ; _Ehad = ehad; _E = _Eem + _Ehad; _ET = _E/cosh(_eta);}
+    const float getEta() const {return _eta;}
+    const float getPhi() const {return _phi;}
+    const float getE() const {return _E;}
+    const float getET() const {return _ET;}
+    const float getEem() const {return _Eem;}
+    const float getEhad() const {return _Ehad;}
+    ///     Ordering operator acting on eta
+    const bool operator>(const D_CaloTower& tocomp) const;
+    ///     Ordering operator acting on eta
+    const bool operator<(const D_CaloTower& tocomp) const;
+    ///	Egality testing if eta/phi are equal
+    const bool operator==(const D_CaloTower& el) const;
+
+ private:
+    float _eta, _phi;    // segmented eta, phi
+    float _Eem, _Ehad; // electromagnetic and hadronic components of the tower energy
+    float _E, _ET;       // total tower energy and transverse energy
+};
+
+const D_CaloTower dummyTower(UNDEFINED,UNDEFINED);
+
+
+
+class D_CaloTowerList {
+ public:
+    D_CaloTowerList() : _calotowers(), _sorted(true), _merged(true) {}
+    D_CaloTowerList(const D_CaloTowerList& list) : _calotowers(list._calotowers), _sorted(list._sorted), _merged(list._merged) {}
+    D_CaloTowerList& operator=(const D_CaloTowerList& list);
+    D_CaloTower& operator[](const unsigned int i) {return _calotowers[i];}
+    const D_CaloTower& getElement(const float eta, const float phi) ;
+    void addTower(const D_CaloTower& tower);
+    // sorts the elements with respect to their eta
+    void sortElements();
+    // merges the CaloTowers with the same eta and the same phi
+    void mergeDuplicates();
+    void smearTowers(const D_CaloList& list_of_calorimeters);
+    void print() const;
+    const unsigned int size() const {return _calotowers.size();}
+    //void pop_back() {_calotowers.pop_back();}
+ private:
+    vector<D_CaloTower> _calotowers;
+    bool _sorted;
+    bool _merged;
+    struct ordering{ bool operator()(const D_CaloTower& el1, const D_CaloTower& el2) const { return (el1 < el2); }};
+};
+
+#endif
Index: trunk/interface/D_Constants.h
===================================================================
--- trunk/interface/D_Constants.h	(revision 264)
+++ trunk/interface/D_Constants.h	(revision 264)
@@ -0,0 +1,49 @@
+#ifndef _D_CONSTANTS_H_
+#define _D_CONSTANTS_H_
+
+/*
+  ---- Delphes ----
+  A Fast Simulator for general purpose LHC detector
+  S. Ovyn ~~~~ severine.ovyn@uclouvain.be
+  
+  Center for Particle Physics and Phenomenology (CP3)
+  Universite Catholique de Louvain (UCL)
+  Louvain-la-Neuve, Belgium
+*/
+
+/// \file D_Constants.h
+/// \brief List of constants 
+#ifndef __PI__
+#define __PI__
+const float pi = 3.14159265358979312;
+#endif
+
+// particles PID (PDG ID)
+const int pU   = 1;    // c quark
+const int pD   = 2;    // b quark
+const int pS   = 3;    // s quark
+const int pC   = 4;    // c quark
+const int pB   = 5;    // b quark
+const int pE   = 11;   // e
+const int pNU1 = 12;   // nu_e
+const int pMU  = 13;   // mu
+const int pNU2 = 14;   // nu_mu
+const int pTAU = 15;   // tau
+const int pNU3 = 16;   // nu_tau
+const int pGLUON = 21; // gluon
+const int pGAMMA = 22; // gamma
+const int pW   = 24;   // W
+const int pP   = 2212; // proton
+const int pN   = 2112; // neutron
+const int pPI0 = 111;  // pi_0
+const int pK0L = 130;  // K^0_L
+const int pK0S = 310;  // K^0_S
+const int pLAMBDA = 3122; // Lambda
+const int pSIGMA0 = 3212;  // Sigma^0
+const int pDELTA0 = 2114;  // Delta^0
+
+const double speed_of_light = 299792458; // m/s
+const float UNDEFINED=-9999.;
+const int iUNDEFINED=-9999;
+
+#endif
Index: trunk/interface/FrogUtil.h
===================================================================
--- trunk/interface/FrogUtil.h	(revision 262)
+++ trunk/interface/FrogUtil.h	(revision 264)
@@ -34,4 +34,7 @@
 
 
+/// \file FrogUtil.h
+/// \brief FrogDisplay class
+
 #include "SmearUtil.h"
 #include "FROG_Events.h"
Index: trunk/interface/SmearUtil.h
===================================================================
--- trunk/interface/SmearUtil.h	(revision 262)
+++ trunk/interface/SmearUtil.h	(revision 264)
@@ -40,4 +40,6 @@
 #include "TLorentzVector.h"
 
+#include "D_Constants.h"
+#include "CaloUtil.h"
 #include "BlockClasses.h"
 #include "TSimpleArray.h"
@@ -46,30 +48,31 @@
 using namespace std;
 
-class ParticleUtil {
+class D_Particle {
 
  public:
-  ParticleUtil(const TLorentzVector &genMomentum, int pid);
-
-  float E() {return _e;}    // particle energy [GeV]
-  float Px() {return _px;}  // horizontal coordinate of momentum [GeV]
-  float Py() {return _py;}  // vertical coordinate of momentum [GeV]
-  float Pz() {return _pz;}  // longitudinal coordinate of momentum [GeV]
-  float Pt() {return _pt;}  // transverse momentum [GeV]
-  float EtaCalo() {return _etaCalo;}  // pseudorapidity 
-  float Eta() {return _eta;}  // pseudorapidity 
-  float PhiCalo() {return _phiCalo;}  // azimuthal angle 
-  float Phi() {return _phi;}  // azimuthal angle 
-  int PID() {return _pid;}  // particle energy in [GeV]
+  D_Particle(const TLorentzVector & p, const int pid, const float etacalo, const float phicalo) : 
+	_fourmomentum(p), _pid(pid), _etaCalo(etacalo), _phiCalo(phicalo) {}
+  //D_Particle(const float e, const float eta, const float phi, const float pt, const int pid) : 
+  //    _pid(pid), _etaCalo(UNDEFINED), _phiCalo(UNDEFINED) { TLorentzVector p; p.SetPtEtaPhiE(pt,eta,phi,e); _fourmomentum = p; }
+  D_Particle(const float px, const float py, const float pz, const float e, const int pid) :
+	_fourmomentum(px,py,pz,e), _pid(pid), _etaCalo(UNDEFINED), _phiCalo(UNDEFINED) {}
+
+  const float E() const {return _fourmomentum.E();}    // particle energy [GeV]
+  const float Px() const {return _fourmomentum.Px();}  // horizontal coordinate of momentum [GeV]
+  const float Py() const {return _fourmomentum.Py();}  // vertical coordinate of momentum [GeV]
+  const float Pz() const {return _fourmomentum.Pz();}  // longitudinal coordinate of momentum [GeV]
+  const float Pt() const {return _fourmomentum.Pt();}  // transverse momentum [GeV]
+  const float EtaCalo() const {return _etaCalo;}  // pseudorapidity 
+  const float Eta() const {return _fourmomentum.Eta();}  // pseudorapidity 
+  const float PhiCalo() const {return _phiCalo;}  // azimuthal angle 
+  const float Phi() const  {return _fourmomentum.Phi();}  // azimuthal angle 
+  const int PID() const {return _pid;}  // particle energy in [GeV]
+  const TLorentzVector& getFourMomentum() const {return _fourmomentum;}
 
  private:
-  float _e, _px, _py, _pz, _pt;
-  float _eta, _etaCalo, _phi, _phiCalo; 
+  TLorentzVector _fourmomentum;
   int _pid;
+  float _etaCalo, _phiCalo; 
 };
-
-#ifndef __PI__
-#define __PI__
-extern const float pi = 3.14159265358979312;
-#endif 
 
 class RESOLution
@@ -93,8 +96,8 @@
   float VFD_s_zdc;   // distance of the Zero Degree Calorimeter, from the Interaction poin, in [m]
 
-  float  RP_220_s; // distance of the RP to the IP, in meters
-  float  RP_220_x; // distance of the RP to the beam, in meters
-  float  RP_420_s; // distance of the RP to the IP, in meters
-  float  RP_420_x; // distance of the RP to the beam, in meters
+  float RP_220_s; // distance of the RP to the IP, in meters
+  float RP_220_x; // distance of the RP to the beam, in meters
+  float RP_420_s; // distance of the RP to the IP, in meters
+  float RP_420_x; // distance of the RP to the beam, in meters
   string RP_beam1Card; // 
   string RP_beam2Card; // 
@@ -186,4 +189,5 @@
  int FLAG_bfield;               //flag for bfield propagation
  int FLAG_vfd;                  //flag for very forward detector
+ int FLAG_zdc;                  //flag for very forward detector
  
  int NEvents_Frog;
@@ -191,5 +195,6 @@
 
   // to sort a vector
-  void SortedVector(vector<ParticleUtil> &vect);
+  //void SortedVector(vector<ParticleUtil> &vect);
+  void SortedVector(vector<D_Particle> &vect);
 
   /// Reads the data card for the initialisation of the parameters 
@@ -227,33 +232,4 @@
 
 };
-
-
-// particles PID (PDG ID)
-const int pU   = 1;    // c quark
-const int pD   = 2;    // b quark
-const int pS   = 3;    // s quark
-const int pC   = 4;    // c quark
-const int pB   = 5;    // b quark
-const int pE   = 11;   // e
-const int pNU1 = 12;   // nu_e
-const int pMU  = 13;   // mu
-const int pNU2 = 14;   // nu_mu
-const int pTAU = 15;   // tau
-const int pNU3 = 16;   // nu_tau
-const int pGLUON = 21; // gluon
-const int pGAMMA = 22; // gamma
-const int pW   = 24;   // W
-const int pP   = 2212; // proton
-const int pN   = 2112; // neutron
-const int pPI0 = 111;  // pi_0
-const int pK0L = 130;  // K^0_L
-const int pK0S = 310;  // K^0_S
-const int pLAMBDA = 3122; // Lambda
-const int pSIGMA0 = 3212;  // Sigma^0
-const int pDELTA0 = 2114;  // Delta^0
-
-const double speed_of_light = 299792458; // m/s
-const float UNDEFINED=-9999.;
-
 
 // ** returns the sign (+1 or -1) or an integer
Index: trunk/interface/TreeClasses.h
===================================================================
--- trunk/interface/TreeClasses.h	(revision 262)
+++ trunk/interface/TreeClasses.h	(revision 264)
@@ -1,4 +1,36 @@
 #ifndef TreeClasses_h
 #define TreeClasses_h
+
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+**                                                                    **
+***********************************************************************/
+
 
 #include "TObject.h"
Index: trunk/interface/TriggerUtil.h
===================================================================
--- trunk/interface/TriggerUtil.h	(revision 262)
+++ trunk/interface/TriggerUtil.h	(revision 264)
@@ -47,5 +47,5 @@
  public:
 
-  TriggerBit(){}; 
+  TriggerBit(); 
   TriggerBit(const TriggerBit& tb);
   TriggerBit& operator=(const TriggerBit& tb);
@@ -87,5 +87,12 @@
 
   void TriggerCardReader(const string& filename="data/trigger.dat");
+  // avant, Ã§a s'appellait TriggerReader
+  // appelle la mÃ©thode TriggerBit::GetTrigCondition
+
+  
   void PrintTriggerTable(const string& LogName);
+  // fait un cout des triggers bits, c'est toujours pratique
+  // appelle la mÃ©thode TriggerBit::PriniTrigCondition
+  
   bool GetGlobalResult(TClonesArray *branchElecTrig, TClonesArray *branchMuonTrig,
       TClonesArray *branchJetTrig, TClonesArray *branchTauJetTrig,
@@ -93,10 +100,19 @@
 
   void WriteResult();
+    // sauve dans le TTree
+    // ce nom est stupide, faut le changer
     
  private:
+  //bool Evaluate( int event_i );
+  // boucle sur list_of_trigger_bits, comme on a dit
+  // appelle la methode TriggerBit::Evaluate ou TriggerBit::GetResult (Ã  voir)
+  // renvoie la rÃ©ponse globale du trigger
+  // Ã  la fin, mettre has_been_evaluated = true;
+  // voir le NB ci-dessous
   
   vector<TriggerBit> list_of_trigger_bits;
   bool has_been_evaluated;
   bool GlobalResult;
+  int event_i;
 
 };
Index: trunk/routines/plot_performances.C
===================================================================
--- trunk/routines/plot_performances.C	(revision 262)
+++ trunk/routines/plot_performances.C	(revision 264)
@@ -1,2 +1,34 @@
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+**                                                                    **
+***********************************************************************/
+
+
 #include "interface/FuncDef.h"
 #include "TGraph.h"
Index: trunk/routines/resolutions.C
===================================================================
--- trunk/routines/resolutions.C	(revision 262)
+++ trunk/routines/resolutions.C	(revision 264)
@@ -328,10 +328,10 @@
 void General()
 {
-  //JetResol();
-  //ElecResol();
-  //ETmisResol();
-  TauJetInfo();
-  
-}
-
-
+  JetResol();
+  ElecResol();
+  ETmisResol();
+  //TauJetInfo();
+  
+}
+
+
Index: trunk/src/BFieldProp.cc
===================================================================
--- trunk/src/BFieldProp.cc	(revision 262)
+++ trunk/src/BFieldProp.cc	(revision 264)
@@ -36,4 +36,5 @@
 
 //------------------------------------------------------------------------------
+extern const float UNDEFINED;
 
 TrackPropagation::TrackPropagation(){
@@ -315,9 +316,11 @@
 
 
-void TrackPropagation::bfield(const TRootGenParticle *Part, float& etacalo, float& phicalo) {
+void TrackPropagation::bfield(TRootGenParticle *Part) {
 
   // initialisation, valid for z_max==0, R_max==0 and q==0
-  etacalo = Part->Eta;
-  phicalo = -atan2(Part->Px,Part->Py);
+  Part->EtaCalo = Part->Eta;
+  Part->PhiCalo = Part->Phi;//-atan2(Part->Px,Part->Py);
+
+  if (!DET->FLAG_bfield ) return;
 
   q  = Charge(Part->PID);
@@ -386,5 +389,5 @@
 	      Eta_t = - log(tan(Theta_t/2.));
       } else{
-		Theta_t=0; Eta_t = 9999;
+		Theta_t=0; Eta_t = UNDEFINED;
       }
 /*	Not needed here. but these formulae are correct -------
@@ -399,6 +402,6 @@
         momentum.SetPxPyPzE(Px_t,Py_t,Pz_t,E_t);
 */
-	etacalo = Eta_t;
-	phicalo = Phi_t;
+	Part->EtaCalo = Eta_t;
+	Part->PhiCalo = Phi_t;
 	return;
 // test zone ---
@@ -436,5 +439,5 @@
 
   } else { // if B_x or B_y are non zero: longer computation
-
+//cout << "bfield de loic\n";
   float Xvertex1 = Part->X;
   float Yvertex1 = Part->Y;
@@ -511,6 +514,6 @@
   if(x!=0 && y!=0 && z!=0) {
           Theta = atan2(sqrt(r2),z);
-          etacalo  = -log(tan(Theta/2.));
-	  phicalo = atan2(y,x);
+          Part->EtaCalo  = -log(tan(Theta/2.));
+	  Part->PhiCalo = atan2(y,x);
 	  //momentum.SetPtEtaPhiE(Part->PT,eta,phi,Part->E);
   }
Index: trunk/src/CaloUtil.cc
===================================================================
--- trunk/src/CaloUtil.cc	(revision 264)
+++ trunk/src/CaloUtil.cc	(revision 264)
@@ -0,0 +1,217 @@
+/*
+  ---- Delphes ----
+  A Fast Simulator for general purpose LHC detector
+  S. Ovyn ~~~~ severine.ovyn@uclouvain.be
+  
+  Center for Particle Physics and Phenomenology (CP3)
+  Universite Catholique de Louvain (UCL)
+  Louvain-la-Neuve, Belgium
+*/
+
+/// \file D_CaloUtil.cc
+/// \brief Implementation of D_CaloElement, D_CaloResolution and D_CaloList classes
+
+#include "CaloUtil.h"
+#include <cmath>
+#include <algorithm>
+#include <iostream>
+#include "TRandom.h"
+
+D_CaloElement& D_CaloElement::operator=(const D_CaloElement& calo) {
+  if(this == &calo) return *this;
+   _name   = calo._name;
+   _etamin = calo._etamin;
+   _etamax = calo._etamax;
+   _resol_em = calo._resol_em;
+   _resol_had= calo._resol_had;
+  return *this;
+}
+
+D_CaloResolution& D_CaloResolution::operator=(const D_CaloResolution& resolution) {
+  if(this == &resolution) return *this;
+  _c = resolution._c;
+  _n = resolution._n;
+  _s = resolution._s;
+  return *this;
+}
+
+void D_CaloResolution::print() const {
+  std::cout << "C: " << _c << "  N:" << _n << "  S:" << _s << std::endl;
+}
+
+const D_CaloElement& D_CaloList::getElement(const float eta) const {
+   for (unsigned int i=0; i<_calorimeters.size(); i++) {
+      if(_calorimeters[i].getEtamin() < eta && eta < _calorimeters[i].getEtamax()) return _calorimeters[i];
+   } 
+   // if not found
+   return dummyCalo;
+}
+
+void D_CaloList::addElement(const D_CaloElement & calo) {
+  _sorted = false;
+  _calorimeters.push_back(calo);
+}
+
+void D_CaloList::sortElements() {
+  // here: it sorts the elements with respect to their eta
+  sort(_calorimeters.begin(),_calorimeters.end(),ordering());
+ 
+   for (unsigned int i=0; i<_calorimeters.size()-1; i++) {
+	if(_calorimeters[i].getEtamax() > _calorimeters[i+1].getEtamin() ) {
+		_etamin = UNDEFINED;
+		_etamax = UNDEFINED;
+		cerr << "** Error: the calorimeter list should never contain overlapping    **"<< endl;
+		cerr << "**    calorimeters.                                                **"<< endl;
+		return;
+	}		
+   }
+  _etamin = _calorimeters[0].getEtamin();
+  _etamax = _calorimeters[_calorimeters.size()-1].getEtamax();
+  _sorted = true;
+}
+
+D_CaloList& D_CaloList::operator=(const D_CaloList& list) {
+  if(this == &list) return *this;
+    _calorimeters = list._calorimeters;
+    _etamin       = list._etamin;
+    _etamax       = list._etamax;
+    _sorted       = list._sorted;
+  return *this;
+}
+
+void D_CaloList::print() const {
+  if(_sorted) cout << "The list has been sorted\n"; 
+  else cout << "The list has not been sorted\n";
+
+  for (unsigned int i=0; i<_calorimeters.size(); i++) {
+	std::cout << _calorimeters[i].getName() << " " << _calorimeters[i].getEtamin() << 
+                                                   " " << _calorimeters[i].getEtamax() << std::endl;	  
+        _calorimeters[i].getElectromagneticResolution().print();
+        _calorimeters[i].getHadronicResolution().print();
+  }
+
+}
+
+
+
+
+
+
+
+
+D_CaloTower::D_CaloTower(const float iEta, const float iPhi) : 
+	_eta(iEta), _phi(iPhi), _Eem(UNDEFINED), _Ehad(UNDEFINED), _E(UNDEFINED), _ET(UNDEFINED) {}
+
+D_CaloTower::D_CaloTower(const D_CaloTower& tower) : 
+	_eta(tower._eta), _phi(tower._phi), _Eem(tower._Eem), 
+        _Ehad(tower._Ehad), _E(tower._E), _ET(tower._ET) {}
+
+D_CaloTower& D_CaloTower::operator=(const D_CaloTower& tower) {
+   if(this==&tower) return *this;
+	_eta  = tower._eta; 	_phi  = tower._phi; 
+        _Eem  = tower._Eem; 	_Ehad = tower._Ehad;
+        _E    = tower._E; 	_ET   = tower._ET;
+   return *this;
+}
+
+
+const float D_CaloResolution::Smear(const float energy) const {
+    float sE = gRandom->Gaus(energy,
+           sqrt( pow(_n,2) +
+                 pow(_c*energy,2) +
+                 pow(_s*sqrt(energy),2) ));
+    return (sE>0)? sE : 0;
+}
+
+const bool D_CaloTower::operator==(const D_CaloTower& el) const { if (this == &el) return true; return this->_eta==el._eta && this->_phi == el._phi;}
+
+void D_CaloTowerList::addTower(const D_CaloTower& tower) {
+  _calotowers.push_back(tower);
+  _sorted = false;
+  _merged = false;
+}
+
+D_CaloTowerList& D_CaloTowerList::operator=(const D_CaloTowerList& list) {
+  if(this==&list) return *this;
+     _calotowers = list._calotowers;
+     _sorted = list._sorted;
+     _merged = list._merged;
+  return *this;
+}
+
+void D_CaloTowerList::sortElements() {
+  _sorted = true;
+  if(_calotowers.size()==0) return;
+  sort(_calotowers.begin(),_calotowers.end(),ordering());
+}
+
+void D_CaloTowerList::mergeDuplicates() {
+  if(!_sorted) sortElements();
+  _merged = true;
+  if (_calotowers.size() ==0) { return;}
+ 
+ vector<D_CaloTower> temp;
+ temp.push_back(_calotowers[0]);
+ for (unsigned int i=1; i<_calotowers.size(); i++) {
+
+   if(temp[temp.size()-1] == _calotowers[i]) { 
+        //i.e. if towers have the same eta/phi
+	float em = temp[temp.size()-1].getEem() + _calotowers[i].getEem();
+        float had= temp[temp.size()-1].getEhad()+ _calotowers[i].getEhad();
+        temp[temp.size()-1].Set_Eem_Ehad_E_ET(em,had);
+   }
+   else temp.push_back(_calotowers[i]); 
+
+ } 
+   _calotowers = temp;
+}
+
+void D_CaloTowerList::print() const {
+  for (unsigned int i=0; i<_calotowers.size(); i++) {
+      std::cout << _calotowers[i].getEta() << " " <<
+              _calotowers[i].getPhi() << " " <<
+              _calotowers[i].getEem() << " " <<
+              _calotowers[i].getEhad() << std::endl;
+  }
+}
+
+void D_CaloTowerList::smearTowers(const D_CaloList& list_of_calorimeters) {
+   for (unsigned int i=0; i<_calotowers.size(); i++) {
+         // first, finds in which calo the tower is, in order to have its resolution em /had
+         D_CaloElement currentCalo = list_of_calorimeters.getElement(_calotowers[i].getEta() );
+         // then, smears separately the em and had parts
+         float sEem  = currentCalo.getElectromagneticResolution().Smear( _calotowers[i].getEem() );
+         float sEhad = currentCalo.getHadronicResolution().Smear( _calotowers[i].getEhad() );
+         // finally, sets the tower smeared energy
+         _calotowers[i].Set_Eem_Ehad_E_ET(sEem,sEhad);
+   }
+}
+
+
+const bool D_CaloTower::operator>(const D_CaloTower& tocomp) const {
+        if(_eta == tocomp._eta) {
+                if(_phi > tocomp._phi) return true;
+                else return false;
+        }
+        else if(_eta > tocomp._eta)  return true;
+             else  return false;
+};
+
+const bool D_CaloTower::operator<(const D_CaloTower& tocomp) const {
+        if(_eta == tocomp._eta) {
+                if(_phi < tocomp._phi) return true;
+                else return false;
+        }
+        else if(_eta < tocomp._eta)  return true;
+             else  return false;
+};
+
+const D_CaloTower& D_CaloTowerList::getElement(const float eta, const float phi) {
+  if(!_sorted) sortElements();
+  for (unsigned int i=0; i< _calotowers.size(); i++) {
+	if(_calotowers[i].getEta() == eta &&
+	   _calotowers[i].getPhi() == phi )
+		return _calotowers[i];
+  }
+  return dummyTower; // if not found
+}
Index: trunk/src/D_Constants.cc
===================================================================
--- trunk/src/D_Constants.cc	(revision 264)
+++ trunk/src/D_Constants.cc	(revision 264)
@@ -0,0 +1,1 @@
+#include "D_Constants.h"
Index: trunk/src/HEPEVTConverter.cc
===================================================================
--- trunk/src/HEPEVTConverter.cc	(revision 262)
+++ trunk/src/HEPEVTConverter.cc	(revision 264)
@@ -1,2 +1,34 @@
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+**                                                                    **
+***********************************************************************/
+
+
 #include <iostream>
 #include <utility>
Index: trunk/src/LHEFConverter.cc
===================================================================
--- trunk/src/LHEFConverter.cc	(revision 262)
+++ trunk/src/LHEFConverter.cc	(revision 264)
@@ -1,2 +1,34 @@
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+**                                                                    **
+***********************************************************************/
+
+
 #include <iostream>
 #include <fstream>
Index: trunk/src/STDHEPConverter.cc
===================================================================
--- trunk/src/STDHEPConverter.cc	(revision 262)
+++ trunk/src/STDHEPConverter.cc	(revision 264)
@@ -1,11 +1,33 @@
-/*
-  ---- Delphes ----
-  A Fast Simulator for general purpose LHC detector
-  S. Ovyn ~~~~ severine.ovyn@uclouvain.be
-
-  Center for Particle Physics and Phenomenology (CP3)
-  Universite Catholique de Louvain (UCL)
-  Louvain-la-Neuve, Belgium
-*/
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+**                                                                    **
+***********************************************************************/
+
 
 #include <iostream>
Index: trunk/src/SmearUtil.cc
===================================================================
--- trunk/src/SmearUtil.cc	(revision 262)
+++ trunk/src/SmearUtil.cc	(revision 264)
@@ -30,4 +30,5 @@
 ***********************************************************************/
 
+
 /// \file SmearUtil.cc
 /// \brief RESOLution class, and some generic definitions
@@ -42,18 +43,4 @@
 #include <iomanip>
 using namespace std;
-
-
-ParticleUtil::ParticleUtil(const TLorentzVector &genMomentum, int pid) {
-  _pid=pid;
-  _e = genMomentum.E();
-  _px = genMomentum.Px();
-  _py = genMomentum.Py();
-  _pz = genMomentum.Pz();
-  _pt = genMomentum.Pt();
-
-  //_e, _px, _py, _pz, _pt;
-  //float _eta, _etaCalo, _phi, _phiCalo;
-  //int _pid;
-}
 
 //------------------------------------------------------------------------------
@@ -78,8 +65,8 @@
   // Energy resolution for hadrons in ecal/hcal/hf
   // \sigma/E = C + N/E + S/\sqrt{E}
-  HAD_Shcal         = 1.5;               // S term for central HCAL 
+  HAD_Shcal         = 1.5;               // S term for central HCAL
   HAD_Nhcal         = 0.;                // N term for central HCAL
   HAD_Chcal         = 0.05;              // C term for central HCAL
-  HAD_Shf           = 2.7;               // S term for FCAL
+  HAD_Shf           = 2.7;               // S term for FCAL 
   HAD_Nhf           = 0.;                // N term for FCAL
   HAD_Chf           = 0.13;              // C term for FCAL
@@ -128,4 +115,5 @@
   FLAG_bfield      = 1;                       //1 to run the bfield propagation else 0
   FLAG_vfd         = 1;                       //1 to run the very forward detectors else 0
+  FLAG_zdc         = 1;                       //1 to run the zero degree calorimeter else 0
   FLAG_trigger     = 1;                       //1 to run the trigger selection else 0
   FLAG_frog        = 1;                       //1 to run the FROG event display
@@ -186,6 +174,4 @@
   RP_cross_y        = 0.0;
   RP_cross_ang      = 142.5;
-
-
   
 }
@@ -250,4 +236,5 @@
   FLAG_bfield      = DET.FLAG_bfield;
   FLAG_vfd         = DET.FLAG_vfd;
+  FLAG_zdc         = DET.FLAG_zdc;
   FLAG_trigger     = DET.FLAG_trigger;
   FLAG_frog        = DET.FLAG_frog;
@@ -279,5 +266,4 @@
   RP_IP_name        = DET.RP_IP_name;
 
-
   // In case FROG event display allowed
   NEvents_Frog      = DET.NEvents_Frog;
@@ -364,4 +350,5 @@
   FLAG_bfield      = DET.FLAG_bfield;
   FLAG_vfd         = DET.FLAG_vfd;
+  FLAG_zdc         = DET.FLAG_zdc;
   FLAG_trigger     = DET.FLAG_trigger;
   FLAG_frog        = DET.FLAG_frog;
@@ -504,4 +491,5 @@
 
     else if(strstr(temp_string.c_str(),"FLAG_vfd"))         {curstring >> varname >> ivalue; FLAG_vfd         = ivalue;}
+    else if(strstr(temp_string.c_str(),"FLAG_zdc"))         {curstring >> varname >> ivalue; FLAG_zdc         = ivalue;}
     else if(strstr(temp_string.c_str(),"FLAG_trigger"))     {curstring >> varname >> ivalue; FLAG_trigger     = ivalue;}
     else if(strstr(temp_string.c_str(),"FLAG_frog"))        {curstring >> varname >> ivalue; FLAG_frog        = ivalue;}
@@ -604,5 +592,5 @@
   if(FLAG_vfd==1){
     f_out<<"#**********************************                                  *"<<"\n";
-    f_out<<"# Very forward detector switches on                                  *"<<"\n";
+    f_out<<"# Very forward detector switched on                                  *"<<"\n";
     f_out<<"#**********************************                                  *"<<"\n";
     f_out<<"*                                                                    *"<<"\n";
@@ -639,10 +627,9 @@
     f_out << left << setw(44) <<"* Angle of  beam crossing:"<<""
           << left << setw(6) <<RP_cross_ang           <<""<< right << setw(20)<<"! not in datacard  *"<<"\n";
-
     f_out<<"*                                                                    *"<<"\n";
   }
   else {
     f_out<<"#***********************************                                 *"<<"\n";
-    f_out<<"# Very forward detector switches off                                 *"<<"\n";
+    f_out<<"# Very forward detector switched off                                 *"<<"\n";
     f_out<<"#***********************************                                 *"<<"\n";
     f_out<<"*                                                                    *"<<"\n";
@@ -692,5 +679,5 @@
   if(FLAG_bfield==1){
     f_out<<"#***************************                                         *"<<"\n";
-    f_out<<"# Magnetic field switches on                                         *"<<"\n";
+    f_out<<"# Magnetic field switched on                                         *"<<"\n";
     f_out<<"#***************************                                         *"<<"\n";
     f_out<<"*                                                                    *"<<"\n";
@@ -713,5 +700,5 @@
   else {
     f_out<<"#****************************                                        *"<<"\n";
-    f_out<<"# Magnetic field switches off                                        *"<<"\n";
+    f_out<<"# Magnetic field switched off                                        *"<<"\n";
     f_out<<"#****************************                                        *"<<"\n";
     f_out << left << setw(55) <<"* Minimal pT needed to reach the calorimeter [GeV]: "<<""
@@ -953,5 +940,6 @@
 //******************************************************************************************
 
-void RESOLution::SortedVector(vector<ParticleUtil> &vect)
+//void RESOLution::SortedVector(vector<ParticleUtil> &vect)
+void RESOLution::SortedVector(vector<D_Particle> &vect)
 {
   int i,j = 0;
@@ -966,5 +954,6 @@
           if ( vect[j].Pt() > vect[j-1].Pt() )
              {
-               ParticleUtil tmp = vect[j-1];
+               //ParticleUtil tmp = vect[j-1];
+               D_Particle tmp = vect[j-1];
                vect[j-1] = vect[j];
                vect[j] = tmp;
@@ -1062,6 +1051,6 @@
   //********** returns a segmented value for eta and phi, for calo towers *****
 void RESOLution::BinEtaPhi(const float phi, const float eta, float& iPhi, float& iEta){
-   iEta = -100; 
-   int index=-100;
+   iEta = UNDEFINED; 
+   int index= iUNDEFINED;
    for (unsigned int i=1; i< TOWER_number+1; i++) {
 	if(fabs(eta)>TOWER_eta_edges[i-1] && fabs(eta)<TOWER_eta_edges[i]) {
@@ -1072,6 +1061,6 @@
 	}
    }
-   if(index==-100) return; 
-   iPhi = -100;
+   if(index==UNDEFINED) return; 
+   iPhi = UNDEFINED;
    float dphi = TOWER_dphi[index]*pi/180.; 
    for (unsigned int i=1; i < 360/TOWER_dphi[index]; i++ ) {
@@ -1085,4 +1074,6 @@
    if (phi > pi-dphi) iPhi = pi-dphi;
 }
+
+
 
 //**************************** Returns the delta Phi ****************************
Index: trunk/src/TreeClasses.cc
===================================================================
--- trunk/src/TreeClasses.cc	(revision 262)
+++ trunk/src/TreeClasses.cc	(revision 264)
@@ -1,2 +1,34 @@
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+**                                                                    **
+***********************************************************************/
+
+
 #include "TreeClasses.h"
 
Index: trunk/src/TreeClassesLinkDef.h
===================================================================
--- trunk/src/TreeClassesLinkDef.h	(revision 262)
+++ trunk/src/TreeClassesLinkDef.h	(revision 264)
@@ -1,2 +1,34 @@
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+**                                                                    **
+***********************************************************************/
+
+
 #include "interface/TreeClasses.h"
 
Index: trunk/src/TriggerUtil.cc
===================================================================
--- trunk/src/TriggerUtil.cc	(revision 262)
+++ trunk/src/TriggerUtil.cc	(revision 264)
@@ -132,4 +132,6 @@
 
 //*************************************************************************
+TriggerBit::TriggerBit() {
+}
 
 TriggerBit::~TriggerBit() {
@@ -143,5 +145,4 @@
 	EtmisValues.clear();
 	GammaValues.clear();
-
 }
 
@@ -153,5 +154,4 @@
         IElecValues.push_back(tb.IElecValues[i]);
 
-
   for(unsigned int i=0; i<tb.MuonValues.size(); i++)
 	MuonValues.push_back(tb.MuonValues[i]);
@@ -165,5 +165,4 @@
   for(unsigned int i=0; i<tb.BjetValues.size(); i++)
         BjetValues.push_back(tb.BjetValues[i]);
-
 
   for(unsigned int i=0; i<tb.TauJetValues.size(); i++)
@@ -218,9 +217,8 @@
       TClonesArray *branchPhotonTrig,  TClonesArray *branchETmisTrig)
 {
-
   TSimpleArray<TRootJet> bjets=SubArrayBjets(branchJetTrig);
   TSimpleArray<TRootElectron> Ielectron=SubArrayIElec(branchElecTrig);
   TSimpleArray<TRootMuon> Imuon=SubArrayIMuon(branchMuonTrig);
- 
+
   int elec_size = ElecValues.size();
   int Ielec_size = IElecValues.size();
@@ -263,5 +261,4 @@
         }
 
-
       if(muon_size!=0){
         TRootMuon *muon;
@@ -287,10 +284,4 @@
            if(jet->PT < JetValues[i])Result=false;}}
 
-      if(jet_size!=0){
-        TRootJet *jet;
-        for(int i=0;i<jet_size;i++){
-           jet = (TRootJet*)branchJetTrig->At(i);
-           if(jet->PT < JetValues[i])Result=false;}}
-
       if(bjet_size!=0)
         {
@@ -304,5 +295,4 @@
         }
 
-
       if(taujet_size!=0){
         TRootTauJet *taujet;
@@ -338,5 +328,4 @@
   vector<string> BjetSequences;
 
-///  char *result =NULL;
   char * result = new char[256];
   result = strtok( (char*) trigger_algorithm.c_str(),"&");
@@ -354,5 +343,5 @@
        result = strtok( NULL,"&");
      }
-  delete result;
+  delete [] result;
 
   ElecValues = GetCuts(ElecSequences);
@@ -368,4 +357,5 @@
 }
 
+
 void TriggerBit::PrintTrigCondition(const string& LogName,const int i) 
 {
@@ -379,5 +369,5 @@
   int etmis_size = TriggerBit::EtmisValues.size();
   int bjets_size = TriggerBit::BjetValues.size();
-  
+
   ofstream f_out(LogName.c_str(),ios::app);
 
@@ -439,4 +429,5 @@
    }
   return OrderedValue;
+
 }
 
@@ -480,3 +471,2 @@
 }
 
-
