AliPhysics  cda3415 (cda3415)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalCorrectionTask.cxx
Go to the documentation of this file.
1 // AliEmcalCorrectionTask
2 //
3 // Runs the cell and cluster level corrections for the EMCal
4 //
5 
8 
9 #include <vector>
10 #include <set>
11 #include <fstream>
12 #include <sstream>
13 #include <iostream>
14 
15 #include <TChain.h>
16 #include <TSystem.h>
17 #include <TGrid.h>
18 #include <TFile.h>
19 
20 #include "AliVEventHandler.h"
21 #include "AliEMCALGeometry.h"
22 #include "AliVCaloCells.h"
23 #include "AliVCluster.h"
24 #include "AliLog.h"
25 #include "AliMultSelection.h"
26 #include "AliCentrality.h"
27 #include "AliESDEvent.h"
28 #include "AliAnalysisManager.h"
29 
33 
37 
43  AliAnalysisTaskSE("AliEmcalCorrectionTask"),
44  fSuffix(""),
45  fUserConfiguration(),
46  fUserConfigurationFilename(""),
47  fUserConfigurationString(""),
48  fDefaultConfiguration(),
49  fDefaultConfigurationFilename(""),
50  fDefaultConfigurationString(""),
51  fCorrectionComponents(),
52  fIsEsd(false),
53  fForceBeamType(kNA),
54  fRunPeriod("noSetRunPeriod"),
55  fConfigurationInitialized(false),
56  fOrderedComponentsToExecute(),
57  fEventInitialized(false),
58  fCent(0),
59  fCentBin(-1),
60  fMinCent(-999),
61  fMaxCent(-999),
62  fNcentBins(4),
63  fCentEst("V0M"),
64  fUseNewCentralityEstimation(kFALSE),
65  fNVertCont(0),
66  fBeamType(kNA),
67  fNeedEmcalGeom(kTRUE),
68  fGeom(0),
69  fParticleCollArray(),
70  fClusterCollArray(),
71  fCellCollArray(),
72  fOutput(0)
73 {
74  // Default constructor
75  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
76 
77  fVertex[0] = 0;
78  fVertex[1] = 0;
79  fVertex[2] = 0;
80 
81  fParticleCollArray.SetOwner(kTRUE);
82  fClusterCollArray.SetOwner(kTRUE);
83 }
84 
95  AliAnalysisTaskSE(name),
96  fSuffix(""),
97  fUserConfiguration(),
98  fUserConfigurationFilename(""),
99  fUserConfigurationString(""),
100  fDefaultConfiguration(),
101  fDefaultConfigurationFilename(""),
102  fDefaultConfigurationString(""),
103  fCorrectionComponents(),
104  fIsEsd(false),
105  fForceBeamType(kNA),
106  fRunPeriod("noSetRunPeriod"),
107  fConfigurationInitialized(false),
108  fOrderedComponentsToExecute(),
109  fEventInitialized(false),
110  fCent(0),
111  fCentBin(-1),
112  fMinCent(-999),
113  fMaxCent(-999),
114  fNcentBins(4),
115  fCentEst("V0M"),
116  fUseNewCentralityEstimation(kFALSE),
117  fNVertCont(0),
118  fBeamType(kNA),
119  fNeedEmcalGeom(kTRUE),
120  fGeom(0),
121  fParticleCollArray(),
122  fClusterCollArray(),
123  fCellCollArray(),
124  fOutput(0)
125 {
126  // Standard constructor
127  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
128 
129  fVertex[0] = 0;
130  fVertex[1] = 0;
131  fVertex[2] = 0;
132 
133  fParticleCollArray.SetOwner(kTRUE);
134  fClusterCollArray.SetOwner(kTRUE);
135 
136  DefineInput(0, TChain::Class());
137  DefineOutput(1, TList::Class());
138 }
139 
145 {
146  // Destructor
147 }
148 
158 {
159  // Determine file type
160  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
161  if (mgr) {
162  AliVEventHandler *evhand = mgr->GetInputEventHandler();
163  if (evhand) {
164  if (evhand->InheritsFrom("AliESDInputHandler")) {
165  fIsEsd = true;
166  }
167  else {
168  fIsEsd = false;
169  }
170  }
171  else {
172  AliError("Event handler not found!");
173  }
174  }
175  else {
176  AliError("Analysis manager not found!");
177  }
178 
179  // Determine the suffix of the correction task
180  std::string tempName = GetName();
181  std::size_t foundSuffix = tempName.find("_");
182  if (foundSuffix != std::string::npos) {
183  // +1 to skip "_"
184  fSuffix = tempName.substr(foundSuffix + 1).c_str();
185  }
186 
187  // Initialize YAML configuration
189  // Check that the configuration is initialized
190  if (fConfigurationInitialized != true)
191  {
192  AliFatal("YAML configuration must be initialized before running (ie. the AddTask, run macro or wagon)!");
193  }
194 
195  // Determine component execution order
197 
198  // Check for user defined settings that are not in the default file
200 
201  // Setup input objects
202  // Setup Cells
203  // Cannot do this entirely yet because we need input objects
205  // TEMP PRINT
206  AliDebugStream(2) << "Cell info: " << std::endl;
207  for (auto cellInfo : fCellCollArray) {
208  AliDebugStream(2) << "\tName: " << cellInfo->GetName() << "\tBranch: " << cellInfo->GetBranchName() << "\tIsEmbedding:" << cellInfo->GetIsEmbedding() << std::endl;
209  }
210  // END TEMP PRINT
211  // Create cluster input objects
213  // TEMP PRINT
214  fClusterCollArray.Print();
215  // END TEMP PRINT
216  // Create track input objects
218  // TEMP PRINT
219  fParticleCollArray.Print();
220  // END TEMP PRINT
221 
222  // Initialize components
224 }
225 
235 {
236  // Determine file path
238  {
239  // Use the default if nothing is set
240  fDefaultConfigurationFilename = "$ALICE_PHYSICS/PWG/EMCAL/config/AliEmcalCorrectionConfiguration.yaml";
241  }
242 
243  // Setup the YAML files
244  // Default
246 
248  {
249  AliInfo(TString::Format("Using default EMCal corrections configuration located at %s", fDefaultConfigurationFilename.c_str()));
250 
252  // Check for valid file
253  if (fDefaultConfiguration.IsNull() == true)
254  {
255  AliFatal(TString::Format("Could not open the default configuration file \"%s\"!", fDefaultConfigurationFilename.c_str()));
256  }
257  }
258  else
259  {
260  AliFatal(TString::Format("Default file located at \"%s\" does not exist!", fDefaultConfigurationFilename.c_str()));
261  }
262 
263  // User
265 
267  {
268  AliInfo(TString::Format("Using user EMCal corrections configuration located at %s", fUserConfigurationFilename.c_str()));
269 
271  }
272  else
273  {
274  AliInfo(TString::Format("User file at \"%s\" does not exist! All settings will be from the default file!", fUserConfigurationFilename.c_str()));
275  }
276 
277  // Ensure that there is a run period
278  if (fRunPeriod == "noSetRunPeriod")
279  {
280  AliFatal("Must pass a run period to the correction task!");
281  }
282  // Check the user provided run period
283  TString userRunPeriod = "kNoUserFile";
284  // Test if the period exists in the user file
285  if (fUserConfiguration.IsNull() != true)
286  {
287  if (fUserConfiguration["period"])
288  {
289  userRunPeriod = fUserConfiguration["period"].as<std::string>();
290  }
291  else
292  {
293  AliFatal("User must specify a period. Leave the period as an empty string to apply to all periods.");
294  }
295  }
296 
297  AliDebug(3, TString::Format("userRunPeriod: %s", userRunPeriod.Data()));
298  // Normalize the user run period to lower case to ensure that we don't miss any matches
299  userRunPeriod.ToLower();
300  if (userRunPeriod != "knouserfile" && userRunPeriod != fRunPeriod)
301  {
302  AliFatal(TString::Format("User run period \"%s\" does not match the run period of \"%s\" passed to the correction task!", userRunPeriod.Data(), fRunPeriod.Data()));
303  }
304 
305  // "" means the user wants their settings to apply to all periods
306  // Ensure that the user is aware!
307  if (userRunPeriod == "")
308  {
309  AliWarning("User run period is an empty string. Settings apply to all run periods!");
310  }
311 
312  // Save configuration into strings so that they can be streamed
313  // Need the stringstream because YAML implements streamers
314  std::stringstream tempConfiguration;
315  tempConfiguration << fUserConfiguration;
316  fUserConfigurationString = tempConfiguration.str();
317  tempConfiguration.str("");
318  tempConfiguration << fDefaultConfiguration;
319  fDefaultConfigurationString = tempConfiguration.str();
320 
321  //AliInfo(TString::Format("User configuration: %s", fUserConfigurationString.c_str()));
322  //AliInfo(TString::Format("Default configuration: %s", fDefaultConfigurationString.c_str()));
323 
324  // Note that it is initialized properly so that the analysis can proceed
326 }
327 
338 void AliEmcalCorrectionTask::DetermineComponentsToExecute(std::vector <std::string> & correctionComponents)
339 {
340  std::vector <std::string> executionOrder;
341  // executionOrder determines the order of tasks to execute, but it doesn't name the particular tasks
343 
344  // Possible components to create from both the user and default configurations
345  // Use set so that the possible components are not repeated
346  std::set <std::string> possibleComponents;
347  for (auto node : fUserConfiguration) {
348  possibleComponents.insert(node.first.as<std::string>());
349  }
350  for (auto node : fDefaultConfiguration) {
351  possibleComponents.insert(node.first.as<std::string>());
352  }
353 
354  // Determine the correction names associated with the correction task
355  std::string expectedComponentName = "";
356  bool foundSuffixComponent = false;
357  bool foundComponent = false;
358  bool componentEnabled = true;
359 
360  // Execution order determines the order that corrections should be added to our execution list
361  for (auto & execName : executionOrder)
362  {
363  // Construct the expected component name with the suffix
364  expectedComponentName = TString::Format("%s_%s", execName.c_str(), fSuffix.c_str()).Data();
365  foundComponent = false;
366  componentEnabled = false;
367 
368  foundComponent = CheckPossibleNamesForComponentName(expectedComponentName, possibleComponents);
369  if (foundComponent)
370  {
371  // Check if the component is enabled
372  AliEmcalCorrectionComponent::GetProperty("enabled", componentEnabled, fUserConfiguration, fDefaultConfiguration, true, expectedComponentName);
373  // If enabled, then store the name so that it can be executed
374  if (componentEnabled == true) {
375  foundSuffixComponent = true;
376  correctionComponents.push_back(expectedComponentName);
377  }
378  else {
379  AliInfo(TString::Format("Component %s is disabled and will not be run!", expectedComponentName.c_str()));
380  }
381 
382  continue;
383  }
384  else
385  {
386  // Look for the normal component
387  expectedComponentName = execName;
388  foundComponent = CheckPossibleNamesForComponentName(expectedComponentName, possibleComponents);
389  // Check if it is enabled
390  AliEmcalCorrectionComponent::GetProperty("enabled", componentEnabled, fUserConfiguration, fDefaultConfiguration, true, expectedComponentName);
391 
392  if (componentEnabled == true) {
393  if (foundSuffixComponent == true) {
394  AliFatal(TString::Format("Found earlier component %s with suffix \"%s\", but could not found component %s with that same suffix!", correctionComponents.back().c_str(), fSuffix.c_str(), expectedComponentName.c_str()));
395  }
396  else {
397  // Take the normal component and store it to be executed
398  correctionComponents.push_back(expectedComponentName);
399  }
400  }
401  else {
402  AliInfo(TString::Format("Component %s is disabled and will not be run!", expectedComponentName.c_str()));
403  }
404  }
405  }
406 
407  // Need to append "AliEmcalCorrection" to allow the tasks to be found!
408  AliDebug(2, "Found EMCal Correction Components: ");
409  for (auto & component : correctionComponents)
410  {
411  component = "AliEmcalCorrection" + component;
412  AliDebug(2, TString::Format("%s", component.c_str()) );
413  }
414 }
415 
425 {
426  // Names of properties for a particular component in the user and default configurations
427  std::set <std::string> userPropertyNames;
428  std::set <std::string> defaultPropertyNames;
429  // Notes whether a match was found between user and default properties
430  bool foundMatch = false;
431  std::string tempComponentName = "";
432 
433  // Loop over all components
434  for (const auto componentName : fOrderedComponentsToExecute)
435  {
436  // Reset for each loop
437  userPropertyNames.clear();
438  defaultPropertyNames.clear();
439  // We need to remove "AliEmcalCorrection" so that the correction will be found in the configuration
440  // "AliEmcalCorrection" is 18 characters
441  tempComponentName = componentName.substr(componentName.find("AliEmcalCorrection")+18);
442 
443  AliDebugStream(2) << "Checking component " << componentName << " for unmatched user settings" << std::endl;
444 
445  // Get the user property names
446  GetPropertyNamesFromNode(tempComponentName, fUserConfiguration, userPropertyNames, false);
447 
448  // Get the same from default
449  // Not required here because the default configuration may not have the specialized component
450  GetPropertyNamesFromNode(tempComponentName, fDefaultConfiguration, defaultPropertyNames, false);
451 
452  // We need to check the base correction as well to fill out the options
453  if (tempComponentName.find("_") != std::string::npos) {
454  // Get the base user component
455  GetPropertyNamesFromNode(tempComponentName.substr(0, tempComponentName.find("_")), fUserConfiguration, userPropertyNames, false);
456 
457  // Required here because the default must have the base component!
458  GetPropertyNamesFromNode(tempComponentName.substr(0, tempComponentName.find("_")), fDefaultConfiguration, defaultPropertyNames, true);
459  }
460 
461  // Check each property defined in the user file for a match to the properties in the default file
462  for (auto userPropertyName : userPropertyNames)
463  {
464  AliDebugStream(2) << "Checking property " << userPropertyName << std::endl;
465  foundMatch = false;
466  for (auto defaultPropertyName : defaultPropertyNames)
467  {
468  if (userPropertyName == defaultPropertyName) {
469  AliDebugStream(2) << "Found match of " << userPropertyName << " with " << defaultPropertyName << std::endl;
470  foundMatch = true;
471  }
472  }
473  if (foundMatch == false) {
474  AliFatal(TString::Format("Property \"%s:%s\" defined in the user configuration file cannot be found in the default configuration file! Check the spelling in your user file!", tempComponentName.c_str(), userPropertyName.c_str()));
475  }
476  }
477  }
478 }
479 
487 {
488  // Iterate over the ordered components list and create the components
489  AliEmcalCorrectionComponent * component = 0;
490  for (auto componentName : fOrderedComponentsToExecute)
491  {
492  std::string noPrefixComponentName = componentName.substr(0, componentName.find("_" + fSuffix));
493  component = AliEmcalCorrectionComponentFactory::createInstance(noPrefixComponentName);
494  if (!component)
495  {
496  AliFatal(TString::Format("Failed to create requested component %s!", componentName.c_str()));
497  }
498 
499  // For setting names of tasks to differentiate between tasks of the same class
500  component->SetName(componentName.c_str());
501  component->SetTitle(componentName.c_str());
502 
503  // Initialize the YAML configurations in each component
506 
507  // configure needed fields for components to properly initialize
508  component->SetIsESD(fIsEsd);
509 
510  // Add the require containers to the component
511  // Cells must be set during UserExec() because we need to add them as a pointer
513  AddContainersToComponent(component, kTrack);
514 
515  // Initialize each component
516  component->Initialize();
517 
518  if (component)
519  {
520  AliInfo(TString::Format("Successfully added correction task: %s", componentName.c_str()));
521  fCorrectionComponents.push_back(component);
522  }
523  }
524 }
525 
541 {
542  // Get container node
543  std::string inputObjectName = GetInputFieldNameFromInputObjectType(inputObjectType);
544 
545  // Get the user and default input nodes for the object type
546  YAML::Node userInputObjectNode;
547  YAML::Node defaultInputObjectNode;
548  GetNodeForInputObjects(userInputObjectNode, fUserConfiguration, inputObjectName, false);
549  GetNodeForInputObjects(defaultInputObjectNode, fDefaultConfiguration, inputObjectName, true);
550 
551  AliDebugStream(3) << "userInputObjectNode: " << userInputObjectNode << std::endl;
552  AliDebugStream(3) << "defaultInputObjectNode: " << defaultInputObjectNode << std::endl;
553 
554  // Determine which containers we need based on which are requested by the enabled correction tasks
555  std::set <std::string> requestedContainers;
556  std::vector <std::string> componentRequest;
557  for ( const auto & componentName : fOrderedComponentsToExecute )
558  {
559  componentRequest.clear();
560  // Not required because not all components will have all kinds of containers
561  // "AliEmcalCorrection" is 18 characters
562  AliEmcalCorrectionComponent::GetProperty(inputObjectName + "Names", componentRequest, fUserConfiguration, fDefaultConfiguration, false, componentName.substr(componentName.find("AliEmcalCorrection")+18));
563  for ( auto & req : componentRequest )
564  {
565  AliDebugStream(3) << "Component " << componentName << " requested container name " << req << std::endl;
566  requestedContainers.insert(req);
567  }
568  }
569 
570  AliInfoStream() << inputObjectName << " Containers requested by components: " << std::endl;
571  for (auto & str : requestedContainers) {
572  AliInfoStream() << "\t" << str << std::endl;;
573  }
574 
575  // Create all requested containers
576  AliDebug(2, TString::Format("Setting up requested containers!"));
577  SetupContainersFromInputNodes(inputObjectType, userInputObjectNode, defaultInputObjectNode, requestedContainers);
578 }
579 
588 {
589  std::string inputObjectName = GetInputFieldNameFromInputObjectType(inputObjectType);
590  // Need to be of the form "clusterContainersNames"
591  inputObjectName = inputObjectName + "Names";
592 
593  std::vector <std::string> inputObjects;
594  // Not required, because not all components need Clusters or Tracks
595  AliEmcalCorrectionComponent::GetProperty(inputObjectName.c_str(), inputObjects, fUserConfiguration, fDefaultConfiguration, false, component->GetName());
596 
597  //std::cout << "inputObjects.size(): " << inputObjects.size() << std::endl;
598 
599  // If it is not found, then there will be nothing to iterate over, so we don't need to explicitly check the return value
600  for (auto const & str : inputObjects)
601  {
602  // TODO: Generalize to arrays for clusters and tracks...
603  // NOTE: The AliEmcalContainer derived objects operate differently than the cells. The containers should be added during initialization while the cells should be added during ExecOnce()!
604  if (inputObjectType == kCluster)
605  {
606  AliEmcalContainer * cont = GetClusterContainer(str.c_str());
607  AliDebugStream(2) << "Adding cluster container " << str << " of array " << cont->GetArrayName() << " to component " << component->GetName() << std::endl;
608  component->SetClusterContainer(GetClusterContainer(str.c_str()));
609  }
610  else if (inputObjectType == kTrack)
611  {
612  AliEmcalContainer * cont = GetParticleContainer(str.c_str());
613  AliDebugStream(2) << "Adding particle container " << str << " of array " << cont->GetArrayName() << " to component " << component->GetName() << std::endl;
614  component->SetParticleContainer(GetParticleContainer(str.c_str()));
615  }
616  else if (inputObjectType == kCaloCells)
617  {
618  // NOTE: This operates different than the others. This should be executed during run time rather than during initialization!
619  if (inputObjects.size() > 1) {
620  AliFatal(TString::Format("Component %s requested more than one cell branch, but this is not supported! Check the configuration!", component->GetName()));
621  }
622 
623  // If we've made it here, this must be at least one entry
624  AliDebugStream(2) << "Adding calo cells " << GetCellContainer(str)->GetName() << " of branch name " << GetCellContainer(str)->GetBranchName() << "to component " << component->GetName() << std::endl;
625  component->SetCaloCells(GetCellContainer(str)->GetCells());
626  AliDebugStream(3) << "component GetNumberOfCells: " << component->GetCaloCells()->GetNumberOfCells() << std::endl;
627  }
628  }
629 }
630 
639 void AliEmcalCorrectionTask::SetupContainersFromInputNodes(InputObject_t inputObjectType, YAML::Node & userInputObjectNode, YAML::Node & defaultInputObjectNode, std::set <std::string> & requestedContainers)
640 {
641  // Our node contains all of the objects that we will want to create.
642  for(auto & containerName : requestedContainers)
643  {
644  // The section is the container name
645  //std::string containerName = it->first.as<std::string>();
646  // Skip if the particle or cluster container already exists
647  if (GetParticleContainer(containerName.c_str()) || GetClusterContainer(containerName.c_str())) {
648  continue;
649  }
650 
651  AliDebug(2, TString::Format("Processing container %s of inputType %d", containerName.c_str(), inputObjectType));
652  if (inputObjectType == kCluster || inputObjectType == kTrack) {
653  SetupContainer(inputObjectType, containerName, userInputObjectNode, defaultInputObjectNode);
654  }
655  else if (inputObjectType == kCaloCells) {
656  SetupCellsInfo(containerName, userInputObjectNode, defaultInputObjectNode);
657  }
658  }
659 }
660 
671 void AliEmcalCorrectionTask::SetupCellsInfo(std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode)
672 {
673  // Define cell info
675 
676  AliDebugStream(2) << "User: " << std::endl << userNode << std::endl << "default: " << std::endl << defaultNode << std::endl;
677 
678  // Set properties
679  // Cells (object) name
680  cellObj->SetName(containerName);
681  // Branch name
682  std::string tempString = "";
683  AliEmcalCorrectionComponent::GetProperty("branchName", tempString, userNode, defaultNode, true, containerName);
684  if (tempString == "usedefault") {
686  }
687  cellObj->SetBranchName(tempString);
688 
689  // IsEmbedding
690  bool tempBool = false;
691  AliEmcalCorrectionComponent::GetProperty("embedded", tempString, userNode, defaultNode, false, containerName);
692  cellObj->SetIsEmbedding(tempBool);
693 
694  // Add to the array to keep track of it
695  fCellCollArray.push_back(cellObj);
696 }
697 
715 void AliEmcalCorrectionTask::SetupContainer(InputObject_t inputObjectType, std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode)
716 {
717  // Create container
718  AliDebugStream(2) << "Adding container" << std::endl;
719  AliEmcalContainer * cont = AddContainer(inputObjectType, containerName, userNode, defaultNode);
720  AliDebugStream(2) << "Added container" << std::endl;
721 
722  // Set the container properties
723  //
724  // TODO: Consider if this can be converted to a map to function pointers. There are a number of details
725  // which can make it a bit complicated. Those details include inheritance, pointing to member
726  // functions, etc. It should all be possible, but may not be worth all of the extra work and code.
727  // Example ccode:
728  // SetValueInContainer("minPt", &cont::SetMinPt, tempDouble, userNode, defaultNode);
729  // SetValueInContainer("minE", &cont::SetMinE, tempDouble, userNode, defaultNode);
730 
731  // Temporary variables to store requested properties
732  std::string tempString = "";
733  Double_t tempDouble = 0;
734  bool tempBool = false;
735 
736  // AliEmcalContainer properties
737  // Min Pt
738  bool result = AliEmcalCorrectionComponent::GetProperty("minPt", tempDouble, userNode, defaultNode, false, containerName);
739  if (result) {
740  AliDebugStream(2) << cont->GetName() << ": Setting minPt of " << tempDouble << std::endl;
741  cont->SetMinPt(tempDouble);
742  }
743  // Min E
744  result = AliEmcalCorrectionComponent::GetProperty("minE", tempDouble, userNode, defaultNode, false, containerName);
745  if (result) {
746  AliDebugStream(2) << cont->GetName() << ": Setting minE of " << tempDouble << std::endl;
747  cont->SetMinE(tempDouble);
748  }
749  // Eta min, max
750  result = AliEmcalCorrectionComponent::GetProperty("minEta", tempDouble, userNode, defaultNode, false, containerName);
751  if (result) {
752  // Only continue checking if the min is there, since we must set both together
753  Double_t tempDouble2 = 0;
754  result = AliEmcalCorrectionComponent::GetProperty("maxEta", tempDouble, userNode, defaultNode, false, containerName);
755  if (result) {
756  AliDebugStream(2) << cont->GetName() << ": Setting eta limits of " << tempDouble << " to " << tempDouble2 << std::endl;
757  cont->SetEtaLimits(tempDouble, tempDouble2);
758  }
759  }
760  // Phi min, max
761  result = AliEmcalCorrectionComponent::GetProperty("minPhi", tempDouble, userNode, defaultNode, false, containerName);
762  if (result) {
763  // Only continue checking if the min is there, since we must set both together
764  Double_t tempDouble2 = 0;
765  result = AliEmcalCorrectionComponent::GetProperty("maxPhi", tempDouble, userNode, defaultNode, false, containerName);
766  if (result) {
767  AliDebugStream(2) << cont->GetName() << ": Setting phi limits of " << tempDouble << " to " << tempDouble2 << std::endl;
768  cont->SetPhiLimits(tempDouble, tempDouble2);
769  }
770  }
771  // Embedded
772  // TODO: Enable embedded when that branch is committed!
773  /*result = AliEmcalCorrectionComponent::GetProperty("IsEmbedded", tempBool, userNode, defaultNode, false, containerName);
774  if (result) {
775  AliDebugStream(2) << cont->GetName() << ": Setting embedding to " << (tempBool ? "enabled" : "disabled") << std::endl;
776  cont->SetIsEmbedding(tempBool);
777  }*/
778 
779  // Cluster specific properties
780  AliClusterContainer * clusterContainer = dynamic_cast<AliClusterContainer *>(cont);
781  if (clusterContainer) {
782  // Default energy
783  // Probably not needed for the corrections
784  /*result = AliEmcalCorrectionComponent::GetProperty("defaultClusterEnergy", tempString, userNode, defaultNode, false, containerName);
785  if (result) {
786  // Need to get the enumeration
787  AliVCluster::VCluUserDefEnergy_t clusterEnergyType = clusterEnergyTypeMap.at(tempString);
788  AliDebugStream(2) << clusterContainer->GetName() << ": Setting cluster energy type to " << clusterEnergyType << std::endl;
789  clusterContainer->SetDefaultClusterEnergy(clusterEnergyType);
790  }*/
791 
792  // NonLinCorrEnergyCut
793  result = AliEmcalCorrectionComponent::GetProperty("clusNonLinCorrEnergyCut", tempDouble, userNode, defaultNode, false, containerName);
794  if (result) {
795  AliDebugStream(2) << clusterContainer->GetName() << ": Setting clusNonLinCorrEnergyCut of " << tempDouble << std::endl;
796  clusterContainer->SetClusNonLinCorrEnergyCut(tempDouble);
797  }
798 
799  // HadCorrEnergyCut
800  result = AliEmcalCorrectionComponent::GetProperty("clusHadCorrEnergyCut", tempDouble, userNode, defaultNode, false, containerName);
801  if (result) {
802  AliDebugStream(2) << clusterContainer->GetName() << ": Setting clusHadCorrEnergyCut of " << tempDouble << std::endl;
803  clusterContainer->SetClusHadCorrEnergyCut(tempDouble);
804  }
805 
806  // SetIncludePHOS
807  result = AliEmcalCorrectionComponent::GetProperty("includePHOS", tempBool, userNode, defaultNode, false, containerName);
808  if (result) {
809  AliDebugStream(2) << clusterContainer->GetName() << ": Setting Include PHOS to " << (tempBool ? "enabled" : "disabled") << std::endl;
810  clusterContainer->SetIncludePHOS(tempBool);
811  }
812  }
813 
814  // Track specific
815  AliTrackContainer * trackContainer = dynamic_cast<AliTrackContainer *>(cont);
816  if (trackContainer) {
817  // Track selection
818  // AOD Filter bits as a sequence
819  std::vector <UInt_t> filterBitsVector;
820  result = AliEmcalCorrectionComponent::GetProperty("aodFilterBits", filterBitsVector, userNode, defaultNode, false, containerName);
821  if (result){
822  UInt_t filterBits = 0;
823  for (int filterBit : filterBitsVector) {
824  filterBits += filterBit;
825  }
826  AliDebugStream(2) << trackContainer->GetName() << ": Setting filterBits of " << filterBits << std::endl;
827  trackContainer->SetAODFilterBits(filterBits);
828  }
829 
830  // SetTrackFilterType enum
831  result = AliEmcalCorrectionComponent::GetProperty("trackFilterType", tempString, userNode, defaultNode, false, containerName);
832  if (result) {
833  // Need to get the enumeration
834  AliEmcalTrackSelection::ETrackFilterType_t trackFilterType = trackFilterTypeMap.at(tempString);
835  AliDebugStream(2) << trackContainer->GetName() << ": Setting trackFilterType of " << trackFilterType << std::endl;
836  trackContainer->SetTrackFilterType(trackFilterType);
837  }
838 
839  // Track cuts period
840  result = AliEmcalCorrectionComponent::GetProperty("trackCutsPeriod", tempString, userNode, defaultNode, false, containerName);
841  if (result) {
842  // Need to get the enumeration
843  AliDebugStream(2) << trackContainer->GetName() << ": Setting track cuts period to " << tempString << std::endl;
844  trackContainer->SetTrackCutsPeriod(tempString.c_str());
845  }
846  }
847 }
848 
866 AliEmcalContainer * AliEmcalCorrectionTask::AddContainer(InputObject_t contType, std::string & containerName, YAML::Node & userNode, YAML::Node & defaultNode)
867 {
868  // Determine the type of branch to request
869  std::string containerBranch = "";
870  if (contType != kCluster && contType != kTrack){
871  AliFatal("Must specify type of container when requesting branch.");
872  }
873 
874  // Retrieve branch name
875  // YAML::Node() is just an empty node
876  AliDebugStream(2) << "User Node: " << userNode << std::endl;
877  AliDebugStream(2) << "Default Node: " << defaultNode << std::endl;
878  AliEmcalCorrectionComponent::GetProperty("branchName", containerBranch, userNode, defaultNode, true, containerName);
879  // Should be unnecessary, since the user can only do this if done explicitly.
880  /*if (containerBranch == "")
881  {
882  AliFatal(TString::Format("Request %i container, but the container branch is empty!", contType));
883  }*/
884 
885  // Determine proper name if using "usedefault" pattern
886  if (containerBranch == "usedefault") {
887  containerBranch = DetermineUseDefaultName(contType, fIsEsd);
888  }
889 
890  // Create containers and set them to the name of the component
891  AliEmcalContainer * cont = 0;
892  if (contType == kCluster)
893  {
894  cont = new AliClusterContainer(containerBranch.c_str());
895  AdoptClusterContainer(dynamic_cast<AliClusterContainer *>(cont));
896  }
897  else if (contType == kTrack)
898  {
899  if (containerBranch == "mcparticles") {
900  cont = new AliMCParticleContainer(containerBranch.c_str());
901  }
902  else {
903  cont = new AliTrackContainer(containerBranch.c_str());
904  }
905  AdoptParticleContainer(dynamic_cast<AliParticleContainer *>(cont));
906  }
907  cont->SetName(containerName.c_str());
908 
909  return cont;
910 }
911 
921 {
922  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
923 
924  // Check that the configuration is initialized
925  if (fConfigurationInitialized != true)
926  {
927  AliFatal("YAML configuration must be initialized before running (ie. the AddTask, run macro or wagon)!");
928  }
929 
930  // Show the configurations info this is available
931  AliDebugStream(4) << "User configuration string: " << fUserConfigurationString << std::endl;
932  AliDebugStream(4) << "User configuration: " << fUserConfiguration << std::endl;
933  AliDebugStream(4) << "Default configuration string: " << fDefaultConfigurationString << std::endl;
934  AliDebugStream(4) << "Default configuration: " << fDefaultConfiguration << std::endl;
935 
936  // YAML Objects cannot be streamed, so we need to reinitialize them here.
937  // They need reinitialize if they are null
938  if (fUserConfiguration.IsNull() == true && fUserConfigurationString != "")
939  {
940  AliInfo("Reinitializing user configuration from string. Expected if running on grid!");
942  }
943  if (fDefaultConfiguration.IsNull() == true)
944  {
945  AliInfo("Reinitializing default configuration from string. Expected if running on grid!");
947  }
948 
949  // Debug to check that the configuration has been (re)initiailzied has been completed correctly
950  AliDebugStream(4) << "(Re)initialized user configuration: " << fUserConfigurationString << std::endl;
951  AliDebugStream(4) << "(Re)initialized user configuration: " << fUserConfiguration << std::endl;
952  AliDebugStream(4) << "(Re)initialized default configuration: " << fDefaultConfigurationString << std::endl;
953  AliDebugStream(4) << "(Re)initialized default configuration: " << fDefaultConfiguration << std::endl;
954 
955  if (fForceBeamType == kpp)
956  fNcentBins = 1;
957 
958  // Allow for output files
959  OpenFile(1);
960  fOutput = new TList();
961  fOutput->SetOwner();
962 
964 
965  PostData(1, fOutput);
966 }
967 
975 {
976  // Run the initialization for all derived classes.
977  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
978  for (auto component : fCorrectionComponents)
979  {
980  // Set cent bins (usually used for hist creation)
981  // It cannot be set until now because it can be changed after initialization
982  // For instance, by SetForceBeamType()
983  component->SetNcentralityBins(fNcentBins);
984 
985  component->UserCreateOutputObjects();
986 
987  if (component->GetOutputList() != 0)
988  {
989  // Adds a list to the list -- this doesn't work for some unknown reason
990  //fOutput->Add(component->GetOutputList());
991 
992  // iterate through lists for each component, and fill in output
993  TList* t = new TList();
994  t->SetName(component->GetName());
995  fOutput->AddLast(t);
996  t = (TList*)fOutput->Last();
997  TIter next(component->GetOutputList());
998  while (TObject *obj = next()){
999  t->Add(obj);
1000  }
1001 
1002  AliDebug(1, TString::Format("Added output list from task %s to output.", component->GetName()));
1003  }
1004  }
1005 }
1006 
1012 {
1013  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
1014 
1015  // Initialize the event if not intialized
1016  if (!fEventInitialized)
1017  ExecOnce();
1018 
1019  // Only continue if we are initialized successfully
1020  if (!fEventInitialized)
1021  return;
1022 
1023  // Get the objects for each event
1024  if (!RetrieveEventObjects())
1025  return;
1026 
1027  // TODO: Consider adding IsEventSelected()??
1028 
1029  // Call run for each correction
1030  if (!Run())
1031  return;
1032 }
1033 
1045 {
1046  if (!InputEvent()) {
1047  AliError("Could not retrieve event! Returning!");
1048  return;
1049  }
1050 
1051  if (fNeedEmcalGeom) {
1052  fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
1053  if (!fGeom) {
1054  AliFatal("Can not get EMCal geometry instance. If you do not need the EMCal geometry, disable it by setting task->SetNeedEmcalGeometry(kFALSE).");
1055  return;
1056  }
1057  }
1058 
1059  // Load all requested track branches - each container knows name already
1060  for (Int_t i =0; i<fParticleCollArray.GetEntriesFast(); i++) {
1061  AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i));
1063  cont->SetArray(InputEvent());
1064  }
1065 
1066  // Load all requested cluster branches - each container knows name already
1067  for (Int_t i =0; i<fClusterCollArray.GetEntriesFast(); i++) {
1068  AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i));
1070  cont->SetArray(InputEvent());
1071  }
1072 
1073  // Determine the proper pointer for each cell object and save them to the cell contianer
1074  // At this point, they should all be created
1075  for (auto cellObj : fCellCollArray)
1076  {
1078  }
1079 
1080  fEventInitialized = kTRUE;
1081 
1083 }
1084 
1090 {
1091  // Run the initialization for all derived classes.
1092  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
1093  for (auto component : fCorrectionComponents)
1094  {
1095  // Setup geomertry
1096  component->SetEMCALGeometry(fGeom);
1097 
1098  // Add the requested cells to the component
1099  //AliDebugStream(3) << "Adding CaloCells" << std::endl;
1101  //AliDebugStream(3) << "Added CaloCells" << std::endl;
1102 
1103  // Component ExecOnce()
1104  component->ExecOnce();
1105  }
1106 }
1107 
1113 {
1114  fVertex[0] = 0;
1115  fVertex[1] = 0;
1116  fVertex[2] = 0;
1117  fNVertCont = 0;
1118 
1119  const AliVVertex *vert = InputEvent()->GetPrimaryVertex();
1120  if (vert) {
1121  vert->GetXYZ(fVertex);
1122  fNVertCont = vert->GetNContributors();
1123  }
1124 
1125  fBeamType = GetBeamType();
1126 
1127  if (fBeamType == kAA || fBeamType == kpA ) {
1129  AliMultSelection *MultSelection = static_cast<AliMultSelection*>(InputEvent()->FindListObject("MultSelection"));
1130  if (MultSelection) {
1131  fCent = MultSelection->GetMultiplicityPercentile(fCentEst.Data());
1132  }
1133  else {
1134  AliWarning("Could not retrieve centrality information! Assuming 99");
1135  }
1136  }
1137  else { // old centrality estimation < 2015
1138  AliCentrality *aliCent = InputEvent()->GetCentrality();
1139  if (aliCent) {
1140  fCent = aliCent->GetCentralityPercentile(fCentEst.Data());
1141  }
1142  else {
1143  AliWarning("Could not retrieve centrality information! Assuming 99");
1144  }
1145  }
1146 
1147  if (fNcentBins==4) {
1148  if (fCent >= 0 && fCent < 10) fCentBin = 0;
1149  else if (fCent >= 10 && fCent < 30) fCentBin = 1;
1150  else if (fCent >= 30 && fCent < 50) fCentBin = 2;
1151  else if (fCent >= 50 && fCent <= 100) fCentBin = 3;
1152  else {
1153  AliWarning(Form("Negative centrality: %f. Assuming 99", fCent));
1154  fCentBin = fNcentBins-1;
1155  }
1156  }
1157  else if (fNcentBins==5) { // for PbPb 2015
1158  if (fCent >= 0 && fCent < 10) fCentBin = 0;
1159  else if (fCent >= 10 && fCent < 30) fCentBin = 1;
1160  else if (fCent >= 30 && fCent < 50) fCentBin = 2;
1161  else if (fCent >= 50 && fCent <= 90) fCentBin = 3;
1162  else if (fCent > 90) {
1163  fCent = 99;
1164  fCentBin = 4;
1165  }
1166  else {
1167  AliWarning(Form("Negative centrality: %f. Assuming 99", fCent));
1168  fCentBin = fNcentBins-1;
1169  }
1170  }
1171  else {
1172  Double_t centWidth = (fMaxCent-fMinCent)/(Double_t)fNcentBins;
1173  if(centWidth>0.) {
1174  fCentBin = TMath::FloorNint(fCent/centWidth);
1175  }
1176  else {
1177  fCentBin = 0;
1178  }
1179  if (fCentBin>=fNcentBins) {
1180  AliWarning(Form("fCentBin too large: cent = %f fCentBin = %d. Assuming 99", fCent, fCentBin));
1181  fCentBin = fNcentBins-1;
1182  }
1183  }
1184  }
1185  else {
1186  fCent = 99;
1187  fCentBin = 0;
1188  }
1189 
1190  AliEmcalContainer* cont = 0;
1191 
1192  TIter nextPartColl(&fParticleCollArray);
1193  while ((cont = static_cast<AliEmcalContainer*>(nextPartColl()))) cont->NextEvent();
1194 
1195  TIter nextClusColl(&fClusterCollArray);
1196  while ((cont = static_cast<AliEmcalContainer*>(nextClusColl()))) cont->NextEvent();
1197 
1198  return kTRUE;
1199 }
1200 
1206 {
1207  // Run the initialization for all derived classes.
1208  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
1209  for (auto component : fCorrectionComponents)
1210  {
1211  component->SetEvent(InputEvent());
1212  component->SetMCEvent(MCEvent());
1213  component->SetCentralityBin(fCentBin);
1214  component->SetCentrality(fCent);
1215 
1216  component->Run();
1217  }
1218 
1219  PostData(1, fOutput);
1220 
1221  return kTRUE;
1222 }
1223 
1229 {
1230  // Run the initialization for all derived classes.
1231  AliDebug(3, Form("%s", __PRETTY_FUNCTION__));
1232  for (auto component : fCorrectionComponents)
1233  {
1234  component->UserNotify();
1235  }
1236 
1237  return kTRUE;
1238 }
1239 
1248 {
1249  bool returnValue = false;
1250  if (filename != "")
1251  {
1252  if (fConfigurationInitialized == true)
1253  {
1254  std::ofstream outFile(filename);
1255  std::string stringToWrite = userConfig ? fUserConfigurationString : fDefaultConfigurationString;
1256  if (stringToWrite == "") {
1257  AliWarning(TString::Format("%s configuration is empty!", userConfig ? "User" : "Default"));
1258  }
1259  outFile << stringToWrite;
1260  outFile.close();
1261 
1262  returnValue = true;
1263  }
1264  else
1265  {
1266  AliWarning(TString::Format("Configuration not properly initialized! Cannot print %s configuration!", userConfig ? "user" : "default"));
1267  }
1268 
1269  }
1270  else
1271  {
1272  AliWarning("Please pass a valid filename instead of empty quotes!");
1273  }
1274  return returnValue;
1275 }
1276 
1292 std::string AliEmcalCorrectionTask::DetermineUseDefaultName(InputObject_t objType, bool esdMode, bool returnObjectType)
1293 {
1294  std::string returnValue = "";
1295  if (objType == kCluster) {
1296  if (esdMode == true) {
1297  if (returnObjectType == true) {
1298  returnValue = "AliESDCaloCluster";
1299  }
1300  else {
1301  returnValue = "CaloClusters";
1302  }
1303  }
1304  else {
1305  if (returnObjectType == true) {
1306  returnValue = "AliAODCaloCluster";
1307  }
1308  else {
1309  returnValue = "caloClusters";
1310  }
1311  }
1312  }
1313  else if (objType == kTrack) {
1314  if (esdMode == true) {
1315  if (returnObjectType == true) {
1316  returnValue = "AliESDtrack";
1317  }
1318  else {
1319  returnValue = "Tracks";
1320  }
1321  }
1322  else {
1323  if (returnObjectType == true) {
1324  returnValue = "AliAODTrack";
1325  }
1326  else {
1327  returnValue = "tracks";
1328  }
1329  }
1330  }
1331  else if (objType == kCaloCells) {
1332  if (esdMode == true) {
1333  if (returnObjectType == true) {
1334  returnValue = "AliESDCaloCells";
1335  }
1336  else {
1337  returnValue = "EMCALCells";
1338  }
1339  }
1340  else {
1341  if (returnObjectType == true) {
1342  returnValue = "AliAODCaloCells";
1343  }
1344  else {
1345  returnValue = "emcalCells";
1346  }
1347  }
1348  }
1349  else {
1350  // Default to empty if we are given an unrecognized type with "usedefault"
1351  returnValue = "";
1352  }
1353 
1354  return returnValue;
1355 }
1356 
1366 AliVEvent * AliEmcalCorrectionTask::GetEvent(AliVEvent * inputEvent, bool isEmbedding)
1367 {
1368  AliVEvent * event = 0;
1369  if (isEmbedding) {
1370  // TODO: Enable embedded when that branch is committed!
1371  /*const AliAnalysisTaskEmcalEmbeddingHelper* embedding = AliAnalysisTaskEmcalEmbeddingHelper::GetInstance();
1372  if (!embedding) return 0;
1373 
1374  event = embedding->GetExternalEvent();*/
1375  }
1376  else {
1377  event = inputEvent;
1378  }
1379 
1380  return event;
1381 }
1382 
1391 inline bool AliEmcalCorrectionTask::DoesFileExist(const std::string & filename)
1392 {
1393  std::ifstream inFile(filename);
1394  return inFile.good();
1395 }
1396 
1406 {
1407  if (filename != "")
1408  {
1409  // Handle if in AliPhysics and includes $ALICE_PHYSICS
1410  filename = gSystem->ExpandPathName(filename.c_str());
1411 
1412  // Handle grid
1413  if(filename.find("alien://") != std::string::npos)
1414  {
1415  AliDebug(2, TString::Format("Opening file \"%s\" on the grid!", filename.c_str()));
1416  // Initialize alien connection if needed
1417  if (!gGrid) {
1418  TGrid::Connect("alien://");
1419  }
1420 
1421  // Determine the local filename and copy file to local directory
1422  std::string localFilename = gSystem->BaseName(filename.c_str());
1423  // Ensures that the default and user files do not conflict if both are taken from the grid and have the same filename
1424  if (userFile == true) {
1425  localFilename = "user" + localFilename;
1426  }
1427  TFile::Cp(filename.c_str(), localFilename.c_str());
1428 
1429  // yaml-cpp should only open the local file
1430  filename = localFilename;
1431  }
1432  }
1433 }
1434 
1442 {
1443  AliDebugStream(2) << "Retrieving cells object " << cellContainer->GetName() << std::endl;
1444  // Check for embedding and return object
1445  AliVEvent * event = GetEvent(InputEvent(), cellContainer->GetIsEmbedding());
1446 
1447  cellContainer->SetCells(dynamic_cast<AliVCaloCells *>(event->FindListObject(cellContainer->GetBranchName().c_str())));
1448 }
1449 
1459 void AliEmcalCorrectionTask::CheckForContainerArray(AliEmcalContainer * cont, InputObject_t objectType)
1460 {
1461  // TODO: Enable embedded when that branch is committed!
1462  //AliVEvent * event = GetEvent(InputEvent(), cont->GetIsEmbedding());
1463  AliVEvent * event = GetEvent(InputEvent());
1464 
1465  TClonesArray * array = dynamic_cast<TClonesArray *>(event->FindListObject(cont->GetArrayName()));
1466  if (!array) {
1467  AliWarning(TString::Format("Container %s requested branch %s, but it does not exist! Creating it for you! Please check that this the proper action!", cont->GetName(), cont->GetArrayName().Data()));
1468  array = new TClonesArray(DetermineUseDefaultName(objectType, fIsEsd, true).c_str());
1469  array->SetName(cont->GetArrayName());
1470  event->AddObject(array);
1471  }
1472 }
1473 
1482 {
1483  // Get container node
1484  std::string inputObjectName = "";
1485  if (inputObjectType == kCluster) {
1486  inputObjectName = "clusterContainers";
1487  }
1488  else if (inputObjectType == kTrack) {
1489  inputObjectName = "trackContainers";
1490  }
1491  else if (inputObjectType == kCaloCells) {
1492  inputObjectName = "cells";
1493  }
1494  else {
1495  AliFatal(TString::Format("Unrecognized input object type %d", inputObjectType));
1496  }
1497 
1498  return inputObjectName;
1499 }
1500 
1512 bool AliEmcalCorrectionTask::CheckPossibleNamesForComponentName(std::string & name, std::set <std::string> & possibleComponents)
1513 {
1514  bool foundComponent = false;
1515  for (auto & possibleComponent : possibleComponents)
1516  {
1517  if (possibleComponent == name) {
1518  foundComponent = true;
1519  break;
1520  }
1521  }
1522 
1523  return foundComponent;
1524 }
1525 
1533 {
1534  if (fForceBeamType != kNA)
1535  return fForceBeamType;
1536 
1537  AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent());
1538  if (esd) {
1539  const AliESDRun *run = esd->GetESDRun();
1540  TString beamType = run->GetBeamType();
1541  if (beamType == "p-p")
1542  return kpp;
1543  else if (beamType == "A-A")
1544  return kAA;
1545  else if (beamType == "p-A")
1546  return kpA;
1547  else
1548  return kNA;
1549  } else {
1550  Int_t runNumber = InputEvent()->GetRunNumber();
1551  if ((runNumber >= 136851 && runNumber <= 139517) || // LHC10h
1552  (runNumber >= 166529 && runNumber <= 170593)) { // LHC11h
1553  return kAA;
1554  } else if ((runNumber>=188365 && runNumber <= 188366) || // LHC12g
1555  (runNumber >= 195344 && runNumber <= 196608)) { // LHC13b-f
1556  return kpA;
1557  } else {
1558  return kpp;
1559  }
1560  }
1561 }
1562 
1572 void AliEmcalCorrectionTask::GetNodeForInputObjects(YAML::Node & inputNode, YAML::Node & nodeToRetrieveFrom, std::string & inputObjectName, bool requiredProperty)
1573 {
1574  // Get the user input node
1575  AliEmcalCorrectionComponent::GetProperty(inputObjectName.c_str(), inputNode, YAML::Node(), nodeToRetrieveFrom, requiredProperty, "inputObjects");
1576 
1577  // Get the user shared node and add it back to the user node so that shared parameters are available
1578  if (nodeToRetrieveFrom["sharedParameters"]) {
1579  inputNode["sharedParameters"] = nodeToRetrieveFrom["sharedParameters"];
1580  }
1581 }
1582 
1593 void AliEmcalCorrectionTask::GetPropertyNamesFromNode(const std::string & componentName, const YAML::Node & node, std::set <std::string> & propertyNames, const bool nodeRequired)
1594 {
1595  YAML::Node tempNode;
1596  AliEmcalCorrectionComponent::GetProperty(componentName, tempNode, YAML::Node(), node, nodeRequired, "");
1597  for (auto propertyName : tempNode)
1598  {
1599  propertyNames.insert(propertyName.first.as<std::string>());
1600  }
1601 }
1602 
1611 {
1612  if (TString(n).IsNull()) return 0;
1613 
1615 
1616  fParticleCollArray.Add(cont);
1617 
1618  return cont;
1619 }
1620 
1629 {
1630  if (TString(n).IsNull()) return 0;
1631 
1632  AliTrackContainer* cont = new AliTrackContainer(n);
1633 
1634  fParticleCollArray.Add(cont);
1635 
1636  return cont;
1637 }
1638 
1647 {
1648  if (TString(n).IsNull()) return 0;
1649 
1651 
1652  fParticleCollArray.Add(cont);
1653 
1654  return cont;
1655 }
1656 
1665 {
1666  if (TString(n).IsNull()) return 0;
1667 
1669 
1670  fClusterCollArray.Add(cont);
1671 
1672  return cont;
1673 }
1674 
1681 {
1682  if (i<0 || i>fParticleCollArray.GetEntriesFast()) return 0;
1683  AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i));
1684  return cont;
1685 }
1686 
1693 {
1694  if (i<0 || i>fClusterCollArray.GetEntriesFast()) return 0;
1695  AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.At(i));
1696  return cont;
1697 }
1698 
1705 {
1706  AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.FindObject(name));
1707  return cont;
1708 }
1709 
1716 {
1717  AliClusterContainer *cont = static_cast<AliClusterContainer*>(fClusterCollArray.FindObject(name));
1718  return cont;
1719 }
1720 
1728 AliEmcalCorrectionCellContainer * AliEmcalCorrectionTask::GetCellContainer(const std::string & cellsContainerName) const
1729 {
1730  for (auto cellContainer : fCellCollArray)
1731  {
1732  if (cellContainer->GetName() == cellsContainerName) {
1733  return cellContainer;
1734  }
1735  }
1736 
1737  return 0;
1738 }
1739 
Int_t fNcentBins
how many centrality bins
void SetBranchName(std::string branchName)
Set the name of the cells branch (NOT the same as the name!)
std::string fSuffix
Default YAML Configuration.
Steering task for the EMCal correction framework.
AliEMCALGeometry * fGeom
! Emcal geometry
const char * filename
Definition: TestFCM.C:1
return jsonbuilder str().c_str()
void SetTrackCutsPeriod(const char *period)
static bool DoesFileExist(const std::string &filename)
std::string GetName() const
Get the name of the cells object (NOT the same as the branch!)
double Double_t
Definition: External.C:58
AliTrackContainer * AddTrackContainer(const char *n)
void SetClusterContainer(AliClusterContainer *cont)
std::vector< std::string > fOrderedComponentsToExecute
Ordered set of components to execute.
std::string GetInputFieldNameFromInputObjectType(InputObject_t inputObjectType)
AliClusterContainer * GetClusterContainer(Int_t i=0) const
bool CheckPossibleNamesForComponentName(std::string &name, std::set< std::string > &possibleComponents)
std::vector< AliEmcalCorrectionComponent * > fCorrectionComponents
Contains the correction components.
Container with name, TClonesArray and cuts for particles.
TSystem * gSystem
void AdoptClusterContainer(AliClusterContainer *cont)
void SetupConfigurationFilePath(std::string &filename, bool userFile=false)
void UserExec(Option_t *option)
Double_t fMaxCent
max centrality for event selection
Double_t fVertex[3]
! Event vertex
void DetermineComponentsToExecute(std::vector< std::string > &componentsToExecute)
TList * fOutput
! Output for histograms
Wrapper around cells objects for the EMCal Correction Task.
bool fConfigurationInitialized
True if the YAML configuration files are initialized.
Container for particles within the EMCAL framework.
AliEmcalContainer * AddContainer(InputObject_t contType, std::string &containerName, YAML::Node &userNode, YAML::Node &defaultNode)
void SetUserConfiguration(YAML::Node &node)
Make copy to ensure that the nodes do not point to each other (?)
void AddContainersToComponent(AliEmcalCorrectionComponent *component, InputObject_t inputObjectType)
void SetParticleContainer(AliParticleContainer *cont)
bool fEventInitialized
If the event is initialized properly.
void Load()
Definition: UnfoldingHF.C:238
TString fCentEst
name of V0 centrality estimator
void SetAODFilterBits(UInt_t bits)
int Int_t
Definition: External.C:63
std::string fUserConfigurationFilename
! User YAML configruation filename
unsigned int UInt_t
Definition: External.C:33
std::string fDefaultConfigurationString
Store the default YAML configuration as a string so that it can be streamed.
void SetClusNonLinCorrEnergyCut(Double_t cut)
TString fRunPeriod
Run period (passed by user)
void SetCells(AliVCaloCells *cells)
Sets the Pointer to the actual CaloCells object.
Double_t fCent
! Event centrality
Base class for correction components in the EMCal correction framework.
BeamType
Switch for the beam type.
AliMCParticleContainer * AddMCParticleContainer(const char *n)
std::map< std::string, AliEmcalTrackSelection::ETrackFilterType_t > trackFilterTypeMap
Relates string to the track filter enumeration for YAML configuration.
void SetupContainersFromInputNodes(InputObject_t inputObjectType, YAML::Node &userInputObjectNode, YAML::Node &defaultInputObjectNode, std::set< std::string > &requestedContainers)
void SetIncludePHOS(Bool_t b)
static std::string DetermineUseDefaultName(InputObject_t contType, bool esdMode, bool returnObjectType=false)
void SetupContainer(InputObject_t inputObjectType, std::string containerName, YAML::Node &userNode, YAML::Node &defaultNode)
bool WriteConfigurationFile(std::string filename, bool userConfig=false)
Bool_t fNeedEmcalGeom
whether or not the task needs the emcal geometry
std::string GetBranchName() const
Get the name of the cells branch (NOT the same as the name!)
void SetCellsObjectInCellContainerBasedOnProperties(AliEmcalCorrectionCellContainer *cellContainer)
Bool_t fUseNewCentralityEstimation
Use new centrality estimation (for 2015 data)
bool GetIsEmbedding() const
True if the cells are located in the event that is being embedded.
void CheckForContainerArray(AliEmcalContainer *cont, InputObject_t objectType)
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
AliEmcalCorrectionCellContainer * GetCellContainer(const std::string &cellsContainerName) const
std::string fDefaultConfigurationFilename
! Default YAML configuration filename
void GetNodeForInputObjects(YAML::Node &inputNode, YAML::Node &nodeToRetrieveFrom, std::string &inputObjectName, bool requiredProperty)
TObjArray fParticleCollArray
Particle/track collection array.
TObjArray fClusterCollArray
Cluster collection array.
static AliVEvent * GetEvent(AliVEvent *inputEvent, bool isEmbedding=false)
void SetDefaultConfiguration(YAML::Node &node)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
AliParticleContainer * GetParticleContainer(Int_t i=0) const
void AdoptParticleContainer(AliParticleContainer *cont)
void SetIsEmbedding(bool isEmbedded)
Set to true if the cells are located in the event that is being embedded.
void SetCaloCells(AliVCaloCells *cells)
BeamType fBeamType
! Event beam type
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
void SetTrackFilterType(ETrackFilterType_t f)
const char Option_t
Definition: External.C:48
YAML::Node fDefaultConfiguration
User YAML Configuration.
void SetupCellsInfo(std::string containerName, YAML::Node &userNode, YAML::Node &defaultNode)
Int_t fNVertCont
! Event vertex number of contributors
static AliEmcalCorrectionComponent * createInstance(std::string const &s)
Creates an instance of an object based on the name if the name is registered in the map...
void SetName(std::string name)
Set the name of the cells object (NOT the same as the branch!)
bool Bool_t
Definition: External.C:53
Int_t fCentBin
! Event centrality bin
Double_t fMinCent
min centrality for event selection
AliClusterContainer * AddClusterContainer(const char *n)
std::vector< AliEmcalCorrectionCellContainer * > fCellCollArray
Cells collection array.
AliParticleContainer * AddParticleContainer(const char *n)
Container structure for EMCAL clusters.
Container for MC-true particles within the EMCAL framework.
std::string fUserConfigurationString
Store the user YAML configuration as a string so that it can be streamed.
void GetPropertyNamesFromNode(const std::string &componentName, const YAML::Node &node, std::set< std::string > &propertyNames, const bool nodeRequired)
InputObject_t
Type of input object to be created
TList * OpenFile(const char *fname)
Definition: DrawAnaELoss.C:65
void SetClusHadCorrEnergyCut(Double_t cut)
bool GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.
BeamType fForceBeamType
forced beam type
void CreateInputObjects(InputObject_t inputObjectType)