2 // $Id: AliHLTMCGeneratorComponent.cxx $
3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTMCGeneratorComponent.cxx
20 @author Jochen Thaeder
22 @brief Component for generating MC events
23 @note The class is used in Offline (AliRoot) context
26 #include "AliHLTMCGeneratorComponent.h"
28 #if !defined(__CINT__) || defined(__MAKECINT__)
29 #include <Riostream.h>
31 #include <TStopwatch.h>
34 #include <TDatabasePDG.h>
35 #include <TParticle.h>
38 #include "AliGenerator.h"
40 #include "AliRunLoader.h"
43 #include "AliHeader.h"
44 #include "AliGenPythia.h"
45 #include "AliPythia.h"
48 #include "TPythia6Calls.h"
51 /** ROOT macro for the implementation of ROOT specific class methods */
52 ClassImp(AliHLTMCGeneratorComponent)
55 * ---------------------------------------------------------------------------------
56 * Constructor / Destructor
57 * ---------------------------------------------------------------------------------
60 // #################################################################################
61 AliHLTMCGeneratorComponent::AliHLTMCGeneratorComponent() :
73 fRunType(kPythia6Jets104_125),
84 // see header file for class documentation
86 // refer to README to build package
88 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
91 // #################################################################################
92 AliHLTMCGeneratorComponent::~AliHLTMCGeneratorComponent() {
93 // see header file for class documentation
95 // file list and file name list are owner of their objects and
96 // delete all the objects
100 * ---------------------------------------------------------------------------------
101 * Initialize static const
102 * ---------------------------------------------------------------------------------
105 //##################################################################################
106 const Char_t *AliHLTMCGeneratorComponent::fgkPprRunName[] = {
107 "kPythia6Jets20_24", "kPythia6Jets24_29", "kPythia6Jets29_35",
108 "kPythia6Jets35_42", "kPythia6Jets42_50", "kPythia6Jets50_60",
109 "kPythia6Jets60_72", "kPythia6Jets72_86", "kPythia6Jets86_104",
110 "kPythia6Jets104_125", "kPythia6Jets125_150", "kPythia6Jets150_180",
111 "kPyJetJet", "kPyGammaJetPHOS"
115 * ---------------------------------------------------------------------------------
116 * Public functions to implement AliHLTComponent's interface.
117 * These functions are required for the registration process
118 * ---------------------------------------------------------------------------------
121 // #################################################################################
122 const Char_t* AliHLTMCGeneratorComponent::GetComponentID() {
123 // see header file for class documentation
124 return "MCGenerator";
127 // #################################################################################
128 AliHLTComponentDataType AliHLTMCGeneratorComponent::GetOutputDataType() {
129 // see header file for class documentation
131 return kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT;
134 // #################################################################################
135 void AliHLTMCGeneratorComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
136 // see header file for class documentation
139 inputMultiplier = 1.0;
142 // #################################################################################
143 AliHLTComponent* AliHLTMCGeneratorComponent::Spawn() {
144 // see header file for class documentation
145 return new AliHLTMCGeneratorComponent;
149 * ---------------------------------------------------------------------------------
150 * Protected functions to implement AliHLTComponent's interface.
151 * These functions provide initialization as well as the actual processing
152 * capabilities of the component.
153 * ---------------------------------------------------------------------------------
156 // #################################################################################
157 Int_t AliHLTMCGeneratorComponent::DoInit(int argc, const char** argv) {
158 // see header file for class documentation
161 Int_t bMissingParam=0;
165 // -- Loop over all arguments
166 for ( Int_t iter = 0; iter<argc && iResult>=0; iter++) {
168 if (argument.IsNull()) continue;
171 if ( !argument.CompareTo("-seed") ) {
172 if ((bMissingParam=(++iter>=argc))) break;
174 TString parameter(argv[iter]);
175 parameter.Remove(TString::kLeading, ' ');
177 if ( parameter.IsDigit() ) {
178 fSeed = parameter.Atoi();
182 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
188 else if ( !argument.CompareTo("-runtype") ) {
189 if ((bMissingParam=(++iter>=argc))) break;
191 TString parameter(argv[iter]);
192 parameter.Remove(TString::kLeading, ' ');
194 Bool_t found = kFALSE;
196 if ( parameter.IsDigit() ) {
197 Int_t idx = parameter.Atoi();
198 if ( idx < kRunMax ) {
199 fRunType = (PprRun_t) idx;
204 for ( Int_t iRun = 0; iRun < kRunMax && !found; iRun++ ) {
205 if ( ! parameter.CompareTo(fgkPprRunName[iRun]) ) {
206 fRunType = (PprRun_t) iRun;
212 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
218 else if ( !argument.CompareTo("-nevents") ) {
219 if ((bMissingParam=(++iter>=argc))) break;
221 TString parameter(argv[iter]);
222 parameter.Remove(TString::kLeading, ' ');
224 if ( parameter.IsDigit() ) {
225 fNEvents = parameter.Atoi();
229 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
235 else if ( !argument.CompareTo("-coneRadius") ) {
236 if ((bMissingParam=(++iter>=argc))) break;
238 TString parameter(argv[iter]);
239 parameter.Remove(TString::kLeading, ' ');
241 if ( parameter.IsFloat() ) {
242 fJetConeRadius = parameter.Atof();
245 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
251 else if ( !argument.CompareTo("-jetCutMinEt") ) {
252 if ((bMissingParam=(++iter>=argc))) break;
254 TString parameter(argv[iter]);
255 parameter.Remove(TString::kLeading, ' ');
257 if ( parameter.IsFloat() ) {
258 fJetEtMin = parameter.Atof();
261 HLTError("Wrong parameter %s for argument %s.", parameter.Data(), argument.Data());
266 // -- Argument not known
268 HLTError("Unknown argument %s.", argument.Data());
272 } // for ( Int iter = 0; iter<argc && iResult>=0; iter++) {
274 // -- Check if parameter is missing
275 if ( bMissingParam ) {
276 HLTError("Missing parameter for argument %s.", argument.Data());
280 // -- Check if seed and nevents has been specified
281 if ( !fSeed || !fNEvents ) {
282 HLTError("-seed and -nevents need to be specified.");
286 // -- Set Random Number seed
287 gRandom->SetSeed( fSeed );
291 AliPDG::AddParticlesToPdgDataBase();
293 fRunLoader = AliRunLoader::Open("galice.root","FASTRUN","recreate");
294 if (fRunLoader == NULL ) {
295 // gAlice->Fatal("AliHLTMCGeneratorComponent","Can not instatiate the Run Loader");
296 HLTFatal("Can not instatiate the Run Loader");
300 fRunLoader->SetCompressionLevel(2);
301 fRunLoader->SetNumberOfEventsPerFile(fNEvents);
302 fRunLoader->LoadKinematics("RECREATE");
303 fRunLoader->MakeTree("E");
304 gAlice->SetRunLoader(fRunLoader);
307 fRunLoader->MakeStack();
309 // -- Create and Initialize Generator
310 fGenerator = GeneratorFactory();
311 fGenerator->SetStack(fRunLoader->Stack());
314 HLTInfo("MC Generator setup with : %s", fComment.Data() );
319 // #################################################################################
320 Int_t AliHLTMCGeneratorComponent::DoDeinit() {
321 // see header file for class documentation
334 // #################################################################################
335 Int_t AliHLTMCGeneratorComponent::GetEvent( const AliHLTComponentEventData& /*evtData*/,
336 AliHLTComponentTriggerData& /*trigData*/,
337 AliHLTUInt8_t* /*outputPtr*/,
338 AliHLTUInt32_t& size,
339 vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) {
340 // see header file for class documentation
342 if ( !IsDataEvent() )
348 AliStack* stack = fRunLoader->Stack();
349 AliHeader* header = fRunLoader->GetHeader();
351 // -- Initialize event
352 header->Reset(0,fCurrentEvent);
358 fGenerator->Generate();
361 header->SetNprimary(stack->GetNprimary());
362 header->SetNtrack(stack->GetNtrack());
365 stack->FinishEvent();
366 header->SetStack(stack);
368 // -- Create HLT MC Event
371 fpHLTMC = new AliHLTMCEvent();
373 // -- Fill HLT MC event
374 iResult = fpHLTMC->FillMCEvent( stack, header );
376 // -- Send HLT MC event
377 if ( fpHLTMC && !iResult )
378 PushBack( fpHLTMC, kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT, 0 );
385 // #################################################################################
386 AliGenerator* AliHLTMCGeneratorComponent::GeneratorFactory() {
388 // -- Configuration for hard QCD processes generation with PYTHIA
389 // ----------------------------------------------------------------
390 AliGenPythia * gener = new AliGenPythia(-1);
392 gener->SetEnergyCMS(fEcms); // Centre of mass energy
393 gener->SetGluonRadiation(1,1);
394 gener->SetForceDecay(kAll); // Decay type
396 // -- Final state kinematic cuts
397 gener->SetJetEtaRange(fJetEtaMin, fJetEtaMax);
398 gener->SetJetPhiRange(0., 360.);
399 gener->SetJetEtRange(fJetEtMin, fJetEtMax);
400 // gener->SetMomentumRange(0,99999999);
402 // -- Structure function
403 gener->SetStrucFunc(kCTEQ4L);
405 /************************************************************************
406 * void AliGenPythia::SetPycellParameters()
407 * Float_t etamax -- fPycellEtaMax -- PARU(51) -- +/- eta max of detector
408 * Int_t neta -- fPycellNEta -- MSTU(51) -- N cells in eta
409 * Int_t nphi -- fPycellNPhi -- MSTU(52) -- N cells in phi
410 * Float_t thresh -- fPycellThreshold -- PARU(58) -- cells with Et below treshold are discared
411 * Float_t etseed -- fPycellEtSeed -- PARU(52) -- Et threshold for seed cells
412 * Float_t minet -- fPycellMinEtJet -- PARU(53) -- Min Et for jets
413 * Float_t r -- fPycellMaxRadius -- PARU(54) -- cone radius
414 ************************************************************************/
415 gener->SetPycellParameters(fJetEtaMax, 274, 432, 0., 4., fJetEtMin, fJetConeRadius);
417 // gener->SetPtKick(5.); // set the intrinsic kt to 5 GeV/c
420 gener->SetQuench(fQuenching);
421 if( fQuenching == 1){
422 Float_t k = 6e5*(fQhat/1.7) ; // qhat=1.7, k = 6e5, default value
423 AliPythia::Instance()->InitQuenching(0.,0.1,k,0,0.95,6);
427 case kPythia6Jets20_24:
429 fComment = fComment.Append(":Pythia jets 20-24 GeV @ 14 TeV");
430 gener->SetProcess(kPyJets);// Process type
431 gener->SetPtHard(20., 24.);// Pt transfer of the hard scattering
435 case kPythia6Jets24_29:
437 fComment = fComment.Append(":Pythia jets 24-29 GeV @ 14 TeV");
438 gener->SetProcess(kPyJets);// Process type
439 gener->SetPtHard(24., 29.);// Pt transfer of the hard scattering
443 case kPythia6Jets29_35:
445 fComment = fComment.Append(":Pythia jets 29-35 GeV @ 14 TeV");
446 gener->SetProcess(kPyJets);// Process type
447 gener->SetPtHard(29., 35.);// Pt transfer of the hard scattering
451 case kPythia6Jets35_42:
453 fComment = fComment.Append(":Pythia jets 35-42 GeV @ 14 TeV");
454 gener->SetProcess(kPyJets);// Process type
455 gener->SetPtHard(35., 42.);// Pt transfer of the hard scattering
459 case kPythia6Jets42_50:
461 fComment = fComment.Append(":Pythia jets 42-50 GeV @ 14 TeV");
462 gener->SetProcess(kPyJets);// Process type
463 gener->SetPtHard(42., 50.);// Pt transfer of the hard scattering
467 case kPythia6Jets50_60:
469 fComment = fComment.Append(":Pythia jets 50-60 GeV @ 14 TeV");
470 gener->SetProcess(kPyJets);// Process type
471 gener->SetPtHard(50., 60.);// Pt transfer of the hard scattering
475 case kPythia6Jets60_72:
477 fComment = fComment.Append(":Pythia jets 60-72 GeV @ 14 TeV");
478 gener->SetProcess(kPyJets);// Process type
479 gener->SetPtHard(60., 72.);// Pt transfer of the hard scattering
483 case kPythia6Jets72_86:
485 fComment = fComment.Append(":Pythia jets 72-86 GeV @ 14 TeV");
486 gener->SetProcess(kPyJets);// Process type
487 gener->SetPtHard(72., 86.);// Pt transfer of the hard scattering
491 case kPythia6Jets86_104:
493 fComment = fComment.Append(":Pythia jets 86-104 GeV @ 14 TeV");
494 gener->SetProcess(kPyJets);// Process type
495 gener->SetPtHard(86., 104.);// Pt transfer of the hard scattering
499 case kPythia6Jets104_125:
501 fComment = fComment.Append(":Pythia jets 104-125 GeV @ 14 TeV");
502 gener->SetProcess(kPyJets);// Process type
503 gener->SetPtHard(104., 125.);// Pt transfer of the hard scattering
507 case kPythia6Jets125_150:
509 fComment = fComment.Append(":Pythia jets 125-150 GeV @ 14 TeV");
510 gener->SetProcess(kPyJets);// Process type
511 gener->SetPtHard(125., 150.);// Pt transfer of the hard scattering
515 case kPythia6Jets150_180:
517 fComment = fComment.Append(":Pythia jets 150-180 GeV @ 14 TeV");
518 gener->SetProcess(kPyJets);// Process type
519 gener->SetPtHard(150., 180.);// Pt transfer of the hard scattering
525 fComment = fComment.Append(" Jet-jet @ 14 TeV");
526 gener->SetProcess(kPyJets);
527 gener->SetPtHard(fPtHardMin,fPtHardMax);
528 gener->SetEventListRange(0,1); // XXXX
531 case kPyGammaJetPHOS:
533 fComment = fComment.Append(" pp->jet + Gamma over PHOS @ 14 TeV");
534 gener->SetProcess(kPyDirectGamma);
535 gener->SetPtHard(fPtHardMin,fPtHardMax);
536 //gener->SetYHard(-1.0,1.0);
537 gener->SetGammaEtaRange(-0.13,0.13);
538 gener->SetGammaPhiRange(218.,322.); //Over 5 modules +-2 deg
539 gener->SetEventListRange(0,1); // XXXX