Index: /trunk/Delphes.cpp
===================================================================
--- /trunk/Delphes.cpp	(revision 71)
+++ /trunk/Delphes.cpp	(revision 72)
@@ -95,6 +95,7 @@
 
   //Trigger information
-  //Trigger *TRIG = new Trigger();
-  //TRIG->TriggerReader("data/trigger.dat");
+  TriggerTable *TRIGT = new TriggerTable();
+  TRIGT->TriggerCardReader("data/trigger.dat");
+  TRIGT->PrintTriggerTable(LogName);
 
   //Propagation of tracks in the B field
@@ -336,5 +337,4 @@
 
       //*****************************
-      treeWriter->Fill();
       
       sorted_jets=JETRUN->RunJets(input_particles);
@@ -344,12 +344,43 @@
       // Add here the trigger
       // Should test all the trigger table on the event, based on reconstructed objects
-     
+      treeWriter->Fill();
+    
     } // Loop over all events
 
   treeWriter->Write();
-  
+  delete treeWriter;
+
+  if(DET->DOTRIGGER == 1)
+    {
+      TChain chainT("Analysis");
+      chainT.Add(outputfilename.c_str());
+      ExRootTreeReader *treeReaderT = new ExRootTreeReader(&chainT);
+
+      TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
+      TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
+      TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
+      TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
+      TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
+      TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
+
+      ExRootTreeWriter *treeWriterT = new ExRootTreeWriter(outputfilename, "Trigger");
+      ExRootTreeBranch *branchTrigger = treeWriterT->NewBranch("TrigResult", TRootTrigger::Class());
+
+      Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
+      cout << "** Chain contains " << allEntriesT << " events" << endl;
+      for(entryT = 0; entryT < allEntriesT; ++entryT)
+        {
+          treeWriterT->Clear();
+          treeReaderT->ReadEntry(entryT);
+          TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
+          treeWriterT->Fill();
+        }
+
+      treeWriterT->Write();
+      delete treeWriterT;
+    }
+
   cout << "** Exiting..." << endl;
   
-  delete treeWriter;
   delete treeReader;
   delete DET;
Index: /trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h
===================================================================
--- /trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 71)
+++ /trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 72)
@@ -13,6 +13,6 @@
  *  present in the data members of the Block TRoot class.
  *
- *  $Date: 2008-12-02 19:50:30 $
- *  $Revision: 1.5 $
+ *  $Date: 2008-12-03 11:01:04 $
+ *  $Revision: 1.6 $
  *
  *  
@@ -292,5 +292,5 @@
   TRootTrigger() {};
 
-  bool Accepted; // -1 or 1
+  int Accepted; 
 
   static TCompare *fgCompare; //!
Index: /trunk/data/DataCardDet.dat
===================================================================
--- /trunk/data/DataCardDet.dat	(revision 71)
+++ /trunk/data/DataCardDet.dat	(revision 72)
@@ -62,4 +62,7 @@
 MISTAGGING_L 	 1
 
+#Trigger flag
+DOTRIGGER        1                       //1 to run the trigger else 0
+
 #DeltaR cone definition
 CONERADIUS  	0.7
Index: /trunk/data/trigger.dat
===================================================================
--- /trunk/data/trigger.dat	(revision 71)
+++ /trunk/data/trigger.dat	(revision 72)
@@ -1,3 +1,5 @@
 # list of trigger algorithms
 # trigger_name	algorithm			comments
-SingleElec  >> ELEC1_PT: '20' & ELEC2_PT: '10' & ELEC3_PT: '3' & MUON1_PT '10'                      # requires at least 1 muon with p_t > 3
+SingleElec  >> ELEC1_PT: '10'                  # requires at least 1 muon with p_t > 3
+SingleJet   >> JET1_PT: '10'                  # requires at least 1 muon with p_t > 3
+DoubleElec  >> ELEC1_PT: '10' && ELEC2_PT: '10'                  # requires at least 1 muon with p_t > 3
Index: /trunk/interface/SmearUtil.h
===================================================================
--- /trunk/interface/SmearUtil.h	(revision 71)
+++ /trunk/interface/SmearUtil.h	(revision 72)
@@ -98,4 +98,7 @@
   int MISTAGGING_L; 
   
+  //trigger flag
+  int DOTRIGGER;
+
   double CONERADIUS;
   int JETALGO;
Index: /trunk/interface/TriggerUtil.h
===================================================================
--- /trunk/interface/TriggerUtil.h	(revision 71)
+++ /trunk/interface/TriggerUtil.h	(revision 72)
@@ -14,7 +14,9 @@
 #include <vector>
 #include "TLorentzVector.h"
+#include "TClonesArray.h"
 
 #include "Utilities/ExRootAnalysis/interface/BlockClasses.h"
 #include "Utilities/ExRootAnalysis/interface/TSimpleArray.h"
+#include "Utilities/ExRootAnalysis/interface/ExRootTreeBranch.h"
 
 using namespace std;
@@ -31,12 +33,10 @@
   void PrintTrigCondition(string LogName,int i);
 
-  bool GetResult() {
-    if(!has_been_evaluated) Evaluate(event_i);
-    return Result;
-  };
+  bool GetResult(TClonesArray *branchElecTrig, TClonesArray *branchMuonTrig,
+      TClonesArray *branchJetTrig, TClonesArray *branchTauJetTrig,
+      TClonesArray *branchPhotonTrig,  TClonesArray *branchETmisTrig);
 
  private:
-  bool Evaluate(int event_i); // <- Ã  la fin, mettre has_been_evaluated=true;
-
+  
   vector<float> GetCuts(const vector<string> &Sequences);
   vector<float> ElecValues;
@@ -47,6 +47,4 @@
   vector<float> GammaValues;
   bool Result;
-  int event_i;
-  bool has_been_evaluated;
 };
 
@@ -68,9 +66,7 @@
   // appelle la mÃ©thode TriggerBit::PriniTrigCondition
   
-
-  bool GetGlobalResult() {
-    if (! has_been_evaluated) Evaluate(event_i);
-    return GlobalResult;
-  }
+  bool GetGlobalResult(TClonesArray *branchElecTrig, TClonesArray *branchMuonTrig,
+      TClonesArray *branchJetTrig, TClonesArray *branchTauJetTrig,
+      TClonesArray *branchPhotonTrig, TClonesArray *branchETmisTrig,ExRootTreeBranch *branchTrigger);
 
   void WriteResult();
Index: /trunk/src/SmearUtil.cc
===================================================================
--- /trunk/src/SmearUtil.cc	(revision 71)
+++ /trunk/src/SmearUtil.cc	(revision 72)
@@ -86,4 +86,6 @@
 MISTAGGING_L =    1;
 
+//Trigger flag
+DOTRIGGER    =     1;
 
 CONERADIUS   = 0.7; 	// generic jet radius ; not for tau's !!!
@@ -178,4 +180,5 @@
     else if(strstr(temp_string.c_str(),"TAUJET_pt")){curstring >> varname >> value; TAUJET_pt = value;}
     else if(strstr(temp_string.c_str(),"NTOWERS")){curstring >> varname >> ivalue; NTOWERS = ivalue;}
+    else if(strstr(temp_string.c_str(),"DOTRIGGER")){curstring >> varname >> ivalue; DOTRIGGER = ivalue;}
     else if(strstr(temp_string.c_str(),"TOWER_ETA_EDGES")){
 	curstring >> varname;	for(unsigned int i=0; i<NTOWERS+1; i++) {curstring >> value; TOWER_ETA_EDGES[i] = value;} }
Index: /trunk/src/TriggerUtil.cc
===================================================================
--- /trunk/src/TriggerUtil.cc	(revision 71)
+++ /trunk/src/TriggerUtil.cc	(revision 72)
@@ -65,8 +65,90 @@
 }
 
+bool TriggerTable::GetGlobalResult(TClonesArray *branchElecTrig, TClonesArray *branchMuonTrig,
+      TClonesArray *branchJetTrig, TClonesArray *branchTauJetTrig,
+      TClonesArray *branchPhotonTrig,  TClonesArray *branchETmisTrig, ExRootTreeBranch *branchTrigger) {
+
+  TRootTrigger *elementTrigger;
+  GlobalResult=false;
+  for(unsigned int i=0; i < list_of_trigger_bits.size(); i++) {
+  if(list_of_trigger_bits[i].GetResult(branchElecTrig, branchMuonTrig,  branchJetTrig, branchTauJetTrig, branchPhotonTrig, branchETmisTrig))
+    {
+       GlobalResult=true;
+       int flag=i+1;
+       elementTrigger = (TRootTrigger*) branchTrigger->NewEntry();
+       elementTrigger->Accepted=flag;
+    }
+  }
+  if(GlobalResult)
+    {
+      elementTrigger = (TRootTrigger*) branchTrigger->NewEntry();
+      elementTrigger->Accepted=0;
+    }
+    return GlobalResult;
+
+}
+
 //*************************************************************************
-
 TriggerBit::TriggerBit() {
- has_been_evaluated=false;
+}
+
+bool TriggerBit::GetResult(TClonesArray *branchElecTrig, TClonesArray *branchMuonTrig,
+      TClonesArray *branchJetTrig, TClonesArray *branchTauJetTrig,
+      TClonesArray *branchPhotonTrig,  TClonesArray *branchETmisTrig)
+{
+  int elec_size = ElecValues.size();
+  int muon_size = MuonValues.size();
+  int jet_size = JetValues.size();
+  int taujet_size = TauJetValues.size();
+  int gamma_size = GammaValues.size();
+  int etmis_size = EtmisValues.size();
+
+  Result=false;
+  if(
+     (branchElecTrig->GetEntries() >= elec_size )
+      && (branchMuonTrig->GetEntries() >= muon_size )
+      && (branchJetTrig->GetEntries() >= jet_size )
+      && (branchTauJetTrig->GetEntries() >= taujet_size )
+      && (branchPhotonTrig->GetEntries() >= gamma_size )
+    )
+    {
+      Result=true;
+      if(elec_size!=0){
+        TRootElectron *electron;
+	for(int i=0;i<elec_size;i++){
+           electron = (TRootElectron*)branchElecTrig->At(i);
+           if(electron->PT < ElecValues[i])Result=false;}}
+
+      if(muon_size!=0){
+        TRootMuon *muon;
+        for(int i=0;i<muon_size;i++){
+           muon = (TRootMuon*)branchMuonTrig->At(i);
+           if(muon->PT < MuonValues[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(taujet_size!=0){
+        TRootTauJet *taujet;
+        for(int i=0;i<taujet_size;i++){
+           taujet = (TRootTauJet*)branchTauJetTrig->At(i);
+           if(taujet->PT < TauJetValues[i])Result=false;}}
+
+      if(gamma_size!=0){
+        TRootPhoton *gamma;
+        for(int i=0;i<gamma_size;i++){
+           gamma = (TRootPhoton*)branchPhotonTrig->At(i);
+           if(gamma->PT < GammaValues[i])Result=false;}}
+
+
+      if(etmis_size!=0){
+        TRootETmis *etmis = (TRootETmis*)branchETmisTrig->At(0);
+           if(etmis->ET < EtmisValues[0])Result=false;}
+    
+   }
+  return Result;
 }
 
