Ticket #80: event-selector.patch
File event-selector.patch, 4.3 KB (added by , 14 years ago) |
---|
-
SHERPA/Tools/Input_Output_Handler.C
34 34 #ifdef USING__HEPMC2 35 35 p_hepmc2(NULL), 36 36 #endif 37 p_hepevt(NULL) 37 p_hepevt(NULL), 38 p_eventhandler(NULL), p_mehandler(NULL) 38 39 { 39 40 InitialiseOutput(dr); 40 41 } … … 167 168 bool Input_Output_Handler::OutputToFormat(ATOOLS::Blob_List *const blobs) 168 169 { 169 170 double weight=blobs->Weight(); 170 weight/=p_mehandler->TotalXS()*rpa.Picobarn();171 if (p_mehandler) weight/=p_mehandler->TotalXS()*rpa.Picobarn(); 171 172 172 double xs(p_eventhandler->TotalXS()), xserr(p_eventhandler->TotalErr()); 173 double xs(1.0), xserr(0.0); 174 if (p_eventhandler) { 175 xs=p_eventhandler->TotalXS(); 176 xserr=p_eventhandler->TotalErr(); 177 } 173 178 for (map<string,Output_Base *>::iterator oit=m_outmap.begin(); 174 179 oit!=m_outmap.end();oit++) { 175 180 oit->second->SetXS(xs, xserr); … … 178 183 179 184 m_evtnumber++; 180 185 m_evtcount++; 181 186 182 187 if (m_evtcount%m_filesize==0) { 183 188 m_evtcount = 0; 184 189 string number(ToString(int(m_evtnumber/m_filesize))); -
AddOns/Analysis/Observables/Event_Output.C
1 #include "AddOns/Analysis/Observables/Primitive_Observable_Base.H" 2 #include "ATOOLS/Org/MyStrStream.H" 3 #include "ATOOLS/Org/Data_Reader.H" 4 #include "ATOOLS/Org/Exception.H" 5 6 #include "SHERPA/Tools/Input_Output_Handler.H" 7 #include "AddOns/Analysis/Main/Primitive_Analysis.H" 8 9 using namespace ANALYSIS; 10 using namespace ATOOLS; 11 using namespace SHERPA; 12 13 namespace ANALYSIS { 14 15 class Event_Output : public Primitive_Observable_Base { 16 Input_Output_Handler* p_io; 17 std::string m_inlist; 18 public: 19 20 Event_Output(Input_Output_Handler* io, const std::string& inlist) : 21 Primitive_Observable_Base(), p_io(io), m_inlist(inlist) 22 { 23 } 24 25 ~Event_Output() 26 { 27 if (p_io) delete p_io; p_io=NULL; 28 } 29 30 31 void Evaluate(const ATOOLS::Blob_List & blobs, double value, double ncount) 32 { 33 if (!p_io) return; 34 Particle_List * pl=p_ana->GetParticleList(m_inlist); 35 if (pl->empty()) return; 36 Blob_List* blobsptr=const_cast<Blob_List*>(&blobs); 37 p_io->OutputToFormat(blobsptr); 38 } 39 40 41 Primitive_Observable_Base * Copy() const 42 { 43 // don't duplicate event output 44 return new Event_Output(NULL, ""); 45 } 46 47 };// end of class Event_Output 48 49 } 50 51 52 53 DECLARE_GETTER(Event_Output_Getter,"Event_Output", 54 Primitive_Observable_Base,Argument_Matrix); 55 56 Primitive_Observable_Base * 57 Event_Output_Getter::operator()(const Argument_Matrix ¶meters) const 58 { 59 Data_Reader reader(" ",";","!","="); 60 reader.AddComment("#"); 61 reader.AddWordSeparator("\t"); 62 std::string inlist=""; 63 for (size_t i=0; i<parameters.size(); ++i) { 64 std::string line = ""; 65 for (size_t j=0; j<parameters[i].size(); ++j) { 66 line += parameters[i][j]+" "; 67 } 68 reader.AddFileContent(line); 69 if (parameters[i][0]=="InList" && parameters[i].size()>1) inlist=parameters[i][1]; 70 } 71 72 if (inlist=="") { 73 THROW(fatal_error, "You didn't specify an InList for Event_Output"); 74 } 75 return new Event_Output(new Input_Output_Handler(&reader), inlist); 76 } 77 78 void Event_Output_Getter::PrintInfo(std::ostream &str,const size_t width) const 79 { 80 str<<"{\n" 81 <<std::setw(width+7)<<" "<<"InList <triggeroutlist>\n" 82 <<std::setw(width+7)<<" "<<"# event output settings cf. manual, e.g.:\n" 83 <<std::setw(width+7)<<" "<<"HEPMC2_GENEVENT_OUTPUT <filename>\n" 84 <<std::setw(width+7)<<" "<<"FILE_SIZE <n>\n" 85 <<std::setw(width+7)<<" "<<"EVT_FILE_PATH <path>\n" 86 <<std::setw(width+4)<<" "<<"}"; 87 } -
AddOns/Analysis/Observables/Makefile.am
5 5 endif 6 6 7 7 ANAOBS_SOURCES = \ 8 Event_Output.C \ 8 9 $(EXTRAOBS) \ 9 10 Global_Calculator.C \ 10 11 Primitive_Observable_Base.C \