Fork me on GitHub

source: svn/trunk/src/TriggerUtil.cc@ 54

Last change on this file since 54 was 52, checked in by severine ovyn, 16 years ago

util for trigger

File size: 2.7 KB
Line 
1/*
2 * ---- Delphes ----
3 * A Fast Simulator for general purpose LHC detector
4 * S. Ovyn ~~~~ severine.ovyn@uclouvain.be
5 *
6 * Center for Particle Physics and Phenomenology (CP3)
7 * Universite Catholique de Louvain (UCL)
8 * Louvain-la-Neuve, Belgium
9 * */
10
11// \brief Trigger class, and some generic definitions
12
13#include "interface/TriggerUtil.h"
14#include "TRandom.h"
15
16#include <iostream>
17#include <sstream>
18#include <fstream>
19#include <iomanip>
20#include <cstring>
21
22using namespace std;
23
24Trigger::Trigger() {}
25
26vector<int> Trigger::GetCuts(const vector<string> &Sequences)
27{
28 vector<int> OrderedValue;
29 string ptVal;
30 Int_t PtVal=0;
31 for(unsigned int i=0; i < Sequences.size(); i++) {
32 ptVal = Sequences[i].substr( Sequences[i].find("'")+1) ;
33 PtVal = atoi( ptVal.c_str() );
34 OrderedValue.push_back(PtVal);
35 }
36 return OrderedValue;
37
38}
39
40void Trigger::getTrigCondition(const string& trigger_algorithm) {
41
42 vector<string> ElecSequences;
43 vector<string> MuonSequences;
44 vector<string> JetSequences;
45 vector<string> TauJetSequences;
46 vector<string> EtmisSequences;
47 vector<string> GammaSequences;
48
49 char *result = NULL;
50 result = strtok( (char*) trigger_algorithm.c_str(),"&");
51 while( result != NULL )
52 {
53 if(strstr (result,"ELEC"))ElecSequences.push_back(result);
54 if(strstr (result,"MUON"))MuonSequences.push_back(result);
55 if(strstr (result,"JET"))JetSequences.push_back(result);
56 if(strstr (result,"TAUJET"))TauJetSequences.push_back(result);
57 if(strstr (result,"ETMIS"))EtmisSequences.push_back(result);
58 if(strstr (result,"GAMMA"))GammaSequences.push_back(result);
59 result = strtok( NULL,"&");
60 }
61
62 vector<int> ElecValues = GetCuts(ElecSequences);
63 vector<int> MuonValues = GetCuts(MuonSequences);
64 vector<int> JetValues = GetCuts(JetSequences);
65 vector<int> TauJetValues = GetCuts(TauJetSequences);
66 vector<int> EtmisValues = GetCuts(EtmisSequences);
67 vector<int> GammaValues = GetCuts(GammaSequences);
68
69}
70
71void Trigger::TriggerReader(const string filename) {
72 ifstream trigger_file(filename.c_str());
73 if( !trigger_file.good() ) {
74 cout << "ERROR: Trigger input file "<< filename << " not found. Exiting.\n";
75 return;
76 }
77
78 string temp_string, temp_string_no_comment, trigger_name, trigger_algorithm;
79 while ( getline(trigger_file,temp_string) ) {
80 string temp_string_no_comment = temp_string.substr(0,temp_string.find("#")); //remove comments
81 if(temp_string_no_comment.size()<2) continue; // avoid empty lines
82 istringstream temp_stream(temp_string_no_comment);
83
84 temp_stream >> trigger_name;
85 trigger_algorithm = temp_string_no_comment.substr( temp_string_no_comment.find(">>")+2) ;
86
87 getTrigCondition(trigger_algorithm);
88 }
89}
90
Note: See TracBrowser for help on using the repository browser.