Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DAnalysisAction.cc
Go to the documentation of this file.
1 #ifdef VTRACE
2 #include "vt_user.h"
3 #endif
4 
5 #include "DAnalysisAction.h"
6 
7 DAnalysisAction::DAnalysisAction(void)
8 {
9 }
10 
11 DAnalysisAction::DAnalysisAction(const DReaction* locReaction, string locActionBaseName, bool locUseKinFitResultsFlag, string locActionUniqueString) :
12 dPerformAntiCut(false), dReaction(locReaction), dActionName(locActionBaseName), dUseKinFitResultsFlag(locUseKinFitResultsFlag), dActionUniqueString(locActionUniqueString)
13 {
14  //locActionBaseName should be defined within the derived class (internally to it)
15  //locActionUniqueString:
16  //if the class deriving from DAnalysisAction creates ROOT objects, AND more than one instance of it is added to the DReaction, then:
17  //locActionUniqueString should be input into the constructor of the derived class, and should be unique to this DReaction
18  //example usage: using the same class type to histogram a mass spectrum before and after a cut
19  //this is so that the ROOT objects for these two actions are created in separate directories (and thus filled separately)
20  //else locActionUniqueString can be = ""
21  if(locActionUniqueString != "")
22  dActionName += string("_") + locActionUniqueString;
23 
24  dOutputFileName = "hd_root.root";
25  if(gPARMS->Exists("OUTPUT_FILENAME"))
26  gPARMS->GetParameter("OUTPUT_FILENAME", dOutputFileName);
27 
28  string locLockName = dActionName;
29  if(dReaction != NULL)
30  locLockName += string("_") + dReaction->Get_ReactionName();
31 
32  dActionLock = japp->ReadLock(locLockName); //will create if doesn't exist, else returns it
33  pthread_rwlock_unlock(dActionLock); //unlock
34 }
35 
37 {
38  //get the directory this action should write ROOT objects to. //MUST LOCK PRIOR TO ENTRY! (not performed in here!)
39  TDirectoryFile* locDirectory;
40  string locReactionName, locActionName, locDirName, locDirTitle;
41 
42  locReactionName = (Get_Reaction() != NULL) ? Get_Reaction()->Get_ReactionName() : "Independent";
43  locActionName = Get_ActionName();
44 
45  //Goto the correct file (in case in a different file!)
47 
48  //Create/goto reaction directory
49  locDirName = locReactionName;
50  locDirTitle = locReactionName;
51  locDirectory = CreateAndChangeTo_Directory("/", locDirName, locDirTitle);
52 
53  //Create/goto action directory
54  locDirName = locActionName;
55  locDirTitle = locActionName;
56  return CreateAndChangeTo_Directory(locDirectory, locDirName, locDirTitle);
57 }
58 
TDirectoryFile * ChangeTo_BaseDirectory(void)
const DReaction * Get_Reaction(void) const
char string[256]
TDirectoryFile * CreateAndChangeTo_Directory(TDirectoryFile *locBaseDirectory, string locDirName, string locDirTitle)
const DReaction * dReaction
TDirectoryFile * CreateAndChangeTo_ActionDirectory(void)
JApplication * japp
TDirectory * locDirectory
string Get_ReactionName(void) const
Definition: DReaction.h:75
pthread_rwlock_t * dActionLock
virtual string Get_ActionName(void) const