Second most important step in EMC data reduction is to find clusters from EMC data.
Main code performing EMC clustering is located in StRoot/StPreEclMaker and StRoot/StEpcMaker
The main idea behind the BEMC cluster finder is to allow multiple clustering algorithms. With that in mind, any user can develop his/her own finder and plug it in the main cluster finder.
In order to develop a new finder the user should follow the guidelines described in this page.
A Small cluster finder viewer was written for the BEMC detector. In order to run it, use the macro:
$CVSROOT/StRoot/StPreEclMaker/macros/clusterDisplay.C
This macro loops over events in the muDST files, runs the BEMC cluster finder and creates an event by event display of the hits and clusters in the detector. This is an important tool for cluster QA because you can test the cluster parameters and check the results online. It also has a method to do statistical cluster QA over many events.
The commands available are:
This method defines the energy threshold for displaying a detector HIT in the display. The default value in the code is 0.2 GeV. Values should de entered in GeV. The parameters are:
This method displays the next event in the queue.
This method loops over many events in order to fill some clusters QA histograms. The user needs to open a TBrowser n order to access the histograms. The parameters are:
Displays a small help in the screen.
To create a new algorithm it is important to understand how the cluster finder works.
This file defines a simple enumerator for the many possible cluster algorithms. In order to add a new algorithm the user should add a new position in this enumerator
The cluster finder itself (StPreEclMaker) is a very simple maker. This maker is responsible only for creating the finder (in the Init() method) and call some basic functions in the Make() method.
This method just instantiates the finder. In the very beginning of Init() method, the code checks which algorithm is being requested and creates the proper finder.
The Make() method grabs the event (StEvent only) and exits if no event is found. If the event is found it calls 4 methods in the finder. These methods are:
The modifications the user should do in StPreEclMaker.cxx are only to add the possibility of instantiating his/her finder in the StPreEclMaker::Init() method.
Before creating a new cluster algorithm it is important to know the basic idea behind the code. The basic classes are
There is an internal data format for the clusters in the code. The clusters are StEmcPreCluster which are derived from plain ROOT TObject. StEmcPreCluster is more complete than the regular StEvent cluster object (StEmcCluster) because it has methods to add and remove hits, split and merge clusters and well set matching id between different detectors.
This is a placeholder for the StEmcPreCluster objects that are created. This object derives from the regular ROOT TList object. It has methods to create, add, remove and delete StEmcPreClusters. StEmcPreCluster objects that are created or added to the collections are owned by the collection so be careful.
This is the basic finder class. Any cluster algorithm should inherit from this class. It already create the necessary collections for the clusters in each detector.
To create a new finder algorithm you should define a finder class that inherits from the StEmcVirtualFinder and overwrite the method findClusters(StEvent*). Lets suppose you want to create a StEmcMyFinder algorithm. You should create a class with, at least, the following:
StEmcMyFinder.h
#ifndef STAR_StEmcMyFinder
#define STAR_StEmcMyFinder
#include "StEmcVirtualFinder.h"
class StEvent;
class StEmcOldFinder : public StEmcVirtualFinder
{
private:
protected:
public:
StEmcOldFinder();
virtual ~StEmcOldFinder();
virtual Bool_t findClusters(StEvent*);
ClassDef(StEmcMyFinder,1)
};
#endif
StEmcMyFinder.cxx
#include "StEmcMyFinder.h"
#include "StEvent.h"
#include "StEventTypes.h"
ClassImp(StEmcOldFinder)
StEmcMyFinder::StEmcMyFinder():StEmcVirtualFinder()
{
// initialize your stuff in here
}
StEmcMyFinder::~StEmcMyFinder()
{
}
Bool_t StEmcMyFinder::findClusters(StEvent* event)
{
// check if there is an emc collection
StEmcCollection *emc = event->emcCollection();
if(!emc) return kFALSE;
// find your clusters
return kTRUE;
}
The method findClusters(StEvent*) is the method that StPreEclMaker will call in order to find clusters in the event. All the StEmcVirtualFinder methods are available for the user.
The user has 4 pre cluster collections available. They are named
mColl[det-1]
where det =1, 2, 3 and 4 (btow, bprs, bsmde and bsmdp)
Lets suppose you identified a cluster in a given detector. How do I work with StEmcPreCluster objects and the collections? Please look at the code itself to be more familiar with the interface. The next lines will give basic instructions with the most common tools:
To create and add a cluster to the collection for the detector ´det´
StEmcPreCluster *cl = mColl[det-1]->newCluster();
This line creates a cluster in the collection and returns its pointer.
To remove and delete a cluster from a collection
mColl[det-1]->removeCluster(cl); // cl is the pointer to the cluster
or
mColl[det-1]->removeCluster(i); // i is the index of the cluster in the collection
This will remove AND delete the cluster.
To get the number of clusters in a collection
mColl[det-1]->getNClusters();
To add hits to a StEmcPreCluster (pointer to the cluster is called ´cl´)
cl->addHit(hit);
where hit is a pointer to a StEmcRawHit object.
To add the content of a pre cluster ´cl1´ to a cluster ´cl´
cl->addCluster(cl1);
The added cluster ´cl1´ is not deleted. This is very useful if you identified a spitted cluster and would like to merge them.
How to do matching in the cluster finder?
Depending on the cluster finder algorithm one can do clusters in one detector using the information in the other detector as seed. In this sense, it is important do have some kind of matching available in the cluster finder. In the original software scheme, StEpcMaker is the maker responsible for matching the clusters in the BEMC sub detectors. This maker is still in the chain.
Because of StEpcMaker, we CAN NOT create StEmcPoints in the cluster finder. This should be done *ONLY* by StEpcMaker. In order to have a solution for that, StEmcPreCluster object has a member that flags the cluster with matching information. This is done by setting a matching id in the cluster. Use the methods matchingId() and setMatchingId(Int_t).
The matching id is an integer number. If matching id = 0 (default value), no matching was done and the matching will be decided in StEpcMaker. If matching id is not equal to 0, StEpcMaker will create points with clusters with the same matching Id.
Using this procedure, we can develop advanced matching methods in the cluster finder algorithm.
In order to plug your algorithm to the cluster finder you need to change two files in the main finder
EmcClusterAlgorithm.h
This file defines an enumerator with the cluster finders. To add your algorithm in this enumerator add an entry in the enumerator definition, for example:
enum EmcClusterAlgorithm
{ kEmcClNoFinder = 0, kEmcClDefault = 1, kEmcClOld = 2, kEmcMyFinder = 3};
StPreEclMaker.cxx
You should change the Init() method in StPreEclMaker in order to instantiate your finder. To instantiate your StEmcMyFinder object, add, in the Init() method of StPreEclMaker:
if(!mFinder)
{
if(mAlg == kEmcClOld) mFinder = new StEmcOldFinder();
if(mAlg == kEmcMyFinder) mFinder = new StEmcMyFinder();
}
This page describes the original cluster finder algorithm. In order to use this algorithm you should set with the algorithm kEmcClOld.
Salient features of the method implemented in the program are,
Because of the difference in dimension and of readout pattern in different sub detectors, we need to adopt different criterion for obtaining the members of the clusters.
After obtaining the clusters, following properties are obtained for each cluster and they are used as the members of the cluster object.
BSMDE clusters for single photon events
Note: This is a rather old study that I found on BEMC public AFS space and ported into Drupal. I don't know who conducted it or when. -- A. Kocoloski
On the subject of reconstruction made by cluster finder and matching, evaluation has been developed to determine how good is the reconstruction, efficiency, purity, energy and position resolution of reconstructed particles originally generated by simulation data.
Cluster finder is being evaluated at the moment using single particle events, which favors the evaluation of efficiency and purity. In this case, we can define efficiency and purity for single particle events as:
There are other quantities that could be used for evaluation. They are:
All these quantities can be studied as a function of the cluster finder parameters, mSizeMax, mEnergySeed and mEnergyThresholdAll. The results are summarized below.
Nothing was done to evaluate this parameter.
The purity as a function of mEnergySeed gets better and the efficiency goes down as this parameter increases. Some figures (the others parameters were kept as minimum as possible) are shown for for different values of mSizeMax for single photons in the middle of a tower with pt = 1,4,7 and 10 GeV/c.
The following plots were generated using energy seeds of 0.1 GeV (left), 0.5 GeV (middle), and 1.5 GeV (right). Full-size plots are available by clicking on each image:
Phi difference
Number of clusters
Energy ratio
Nothing was done to evaluate this parameter.
Nothing was done to evaluate this parameter.
The purity as a function of mEnergySeed gets better and the efficiency goes down as this parameter increases. Some figures (the others parameters were kept as minimum as possible) are shown for for different values of mSizeMax for single photons in the middle of a tower with pt = 1,4,7 and 10 GeV/c.
The following plots were generated using energy seeds of 0.05 GeV (left), 0.2 GeV (middle), and 0.8 GeV (right). Full-size plots are available by clicking on each image:
Eta difference RMS as a function of photon energy for different seed energies:
Phi Difference (BSMDP only)
Phi difference RMS as a function of photon energy for different seed energies:
BSMDE efficiency and purity as a function of seed energy
BSMDP efficiency and purity as a function of photon energy for different seed energies
The efficiency and purity as a function of mSizeMax get better as this parameter increases but for values greater than 4 there is no difference. Some figures (the others parameters were kept as minimum as possible) are shown for for different values of mSizeMax for single photons in the middle of a tower with pt = 5 GeV/c.
After obtaining the clusters for 4 subdetectors, we need to obtain the information about the incident shower by making the proper matching between clusters from different subdetectors.
It should be mentioned that, because of the better energy resolution and higher depth BEMC is to be used for obtaining the energy of the shower. SMDs on the other hand will be used for obtaining the position of the showers because of their better position resolution.
Currently Preshower detector (PSD) has not been included in the scheme of matching, so we discuss here the details of the method adopted for matching other 3 sub detectors.
Following steps are adopted to obtain proper matching:
Codes for the point maker are found in StRoot/StEpcMaker
The cluster finder can run in many different chains. The basic modes of running it are:
There are some rules a user needs to follow in order to run the cluster finder properly:
The following is an example on how to run the cluster finder in a standard chain:
// include the definitions of the algorithms
#include "StRoot/StPreEclMaker/EmcClusterAlgorithm.h"
class StChain;
StChain *chain=0;
void DoMicroDst(char* list = "./file.lis",
int nFiles = 10, int nevents = 2000)
{
gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
loadSharedLibraries();
gSystem->Load("StDbUtilities");
gSystem->Load("StDbLib");
gSystem->Load("StDbBroker");
gSystem->Load("St_db_Maker");
gSystem->Load("libgeometry_Tables");
gSystem->Load("StDaqLib");
gSystem->Load("StEmcRawMaker");
gSystem->Load("StEmcADCtoEMaker");
// create chain
chain = new StChain("StChain");
// Now we add Makers to the chain...
maker = new StMuDstMaker(0,0,"",list,"",nFiles);
StMuDbReader* db = StMuDbReader::instance();
StMuDst2StEventMaker *m = new StMuDst2StEventMaker();
St_db_Maker *dbMk = new St_db_Maker("StarDb","MySQL:StarDb");
StEmcADCtoEMaker *adc=new StEmcADCtoEMaker();
adc->setPrint(kFALSE);
StPreEclMaker *ecl=new StPreEclMaker(); // instantiate the maker
ecl->setAlgorithm(kEmcClDefault); // set the algorithm
ecl->setPrint(kFALSE); // disables printing
chain->Init();
StEmcOldFinder* finder = (StEmcOldFinder*)ecl->finder(); // gets pointer to the finder
finder->setEnergySeed(1,0.8); // change some setting in the finder
int n=0;
int stat=0;
int count = 1;
TMemStat memory;
while ( (stat==0 || stat==1) && n<nevents)
{
chain->Clear();
stat = chain->Make();
n++;
}
chain->Finish();
}
BEMC data is always available using standard StEvent collections. This is true regardless of whether one is analyzing simulations or real data, or whether the actual input file is in a geant.root, event.root, or mudst.root format. The appropriate BEMC maker (StEmcADCtoEMaker for real data, StEmcSimulatorMaker for simulations) will create an StEvent in-memory if necessary and fill the BEMC collections wth the correct data.
Three different types of calorimeter objects are available:
StEmcRawHit -- a hit for a single detector element (tower, smd strip, or preshower channel)
StEmcCluster -- a cluster is formed from a collection of hits for a single BEMC subdetector (tower / smd-eta / smd-phi / preshower)
StEmcPoint -- a point combines StEmcClusters from the different subdetectors. Typically the SMD clusters are used to determine the position of points, and in the case of e.g. pi0 decay photons they also determine the fraction of the tower cluster energy assigned to each photon. The absolute energy scale is set by the tower cluster energy. Current point-making algorithms do not use the preshower information.
For more information see the StEvent manual.
StEmcAssociationMaker *emcAssoc = GetMaker("EmcAssoc");
if(!emcAssoc) return;
multiEmcTrackCluster *map = emcAssoc->getTrackClusterMap(1);
if(!map) return;
for(multiEmcTrackClusterIter j=map->begin(); j!=map->end(); j++)
{
StMcTrack* track = (StMcTrack*)(*j).first;
StEmcClusterAssociation* value = (StEmcClusterAssociation*)(*j).second;
if(track && value)
{
StEmcCluster *c = (StEmcCluster*) value->getCluster();
if(c)
{
cout <<" McTrack = "<<track<<" GeantId = "<<track->geantId()
<<" pt = "<<track->pt()<<" TReta = "<<track->pseudoRapidity()
<<" Cl = "<<c<<" E = "<<c->energy()<<" eta = "<<c->eta()
<<" phi = "<<c->phi()
<<" FrTr = "<<value->getFractionTrack()
<<" FrCl = "<<value->getFractionCluster()<<endl;
}
}
}
The BEMC makers available in STAR include:
StEmcADCtoEMaker - This maker converts plain ADC values in energy. It subtracts pedestals, applies calibrations and creates the StEmcRawHits in StEvent. This maker also checks for corrupted headers. The input data format for this maker can be ANY of the formats below:
A light version of this maker (StEmcRawMaker) runs during production. StEmcRawMaker uses only DAQ or StEmcRawData format as input.
StPreEclMaker - This maker implements clustering of the BEMC detectors.
StEpcMaker - This maker matches the clusters in the BEMC detectors making what we call an StEmcPoint. It also matches tracks with points, if the input format is StEvent.
StEmcTriggerMaker - This maker simulates the BEMC level 0 trigger response using the plain ADC information from the towers. It works both with real and simulated data and it applies exactly the same trigger algorithm as in the BEMC hardware.
StEmcSimulatorMaker - This is the slow BEMC simulator. It takes an StMcEvent as input and fills the StEmcRawHit collections of StEvent with simulated ADC responses for all subdetectors.
StEmcCalibrationMaker - This is the maker used for BEMC calibration. It has methods to calculate pedestals for all the BEMC detectors as well as detector equalization, based on spectra shape and MIP analysis. This maker runs online as our online pedestal calculator.
StEmcMixerMaker - This maker is the basic BEMC embedding maker. It mixes hits from two StEvent objects in the memory. The hits from the second StEvent are mixed in the first one. It can run in a standard BFC embedding chain or as an afterburner (afterburner mode requires an event.root file from non-BEMC embedding plus a geant.root file containing BEMC information for simulated particles to be embedded).
// if event fulfills trigger return 1 else return 0 problems return -1
int is2005HT1() {return mIs2005HT1;}
int is2005JP1() {return mIs2005JP1;}
// The ID of the candidate HT (JP)
int get2005HT1_ID() {return HT1_ID_2005;}
int get2005JP1_ID() {return JP1_ID_2005;}
// The DSM ADC of the candidate HT (JP)
int get2005HT1_ADC() {return HT1_DSM_2005;}
int get2005JP1_ADC() {return JP1_DSM_2005;}
// The number of towers(patches) and the id’s which fulfill the trigger
void get2005HT1_TOWS(int, int*);//array of tow ids passing HT1_2005 trig
int get2005HT1_NTOWS() {return numHT1_2005;}//# tows passing HT1_2005 trig
void get2005JP1_PATCHES(int, int*);//array of patches passing JP1_2005
int get2005JP1_NPATCHES() {return numJP1_2005;}//# patches passing JP1_2005
//get trigger info
trgMaker=(StEmcTriggerMaker*)GetMaker("StEmcTriggerMaker");
HT1_2005_evt=-1;
HT1_2005_id=-1;
HT1_2005_dsm=-1;
numHT1_2005=0;
HT1_2005_evt=trgMaker->is2005HT1();
HT1_2005_id=trgMaker->get2005HT1_ID();
HT1_2005_dsm=trgMaker->get2005HT1_ADC();
numHT1_2005=trgMaker->get2005HT1_NTOWS();
for (int i=0;i<numHT1_2005;i++){
int towerid=-1;
trgMaker->get2005HT1_TOWS(i,&towerid);
HT1_2005_array[i]=towerid;
}
These are not Makers but codes that prove useful for BEMC analyses. The headings indicate where the codes can be found in the STAR source code repository.
StRoot/StDaqLib
This utility converts the daq indexes for any BEMC detector (crate number, position in the crate, etc) in software ids (softId, module, eta, sub).
It also converts the Level-0 BEMC trigger patches ids in the corresponding tower crate number and index in the crate. It is quite useful to determine the correspondent tower that fired the trigger
StRoot/StEmcUtil
This class is used to convert softId in real eta and phi position in the detector and vice-versa. Also converts softId in module, eta and sub indexes that are used in StEvent.
It has methods to get geometrical information of the BEMC, such as number of channels, radius, etc. This is a very important utility in the BEMC software.
Utility to project tracks in the BEMC detector
Utility to load the database tables and get any information from them. It works only in makers running in the chain and has methods to return pedestal, calibrations, gain and status values for all the BEMC detectors. To use it do, in your maker:
// in the constructor. Supposing you have a private
// member StBemcTables *mTables;
mTables = new StBemcTables();
// in the InitRun() or Make() method
// this method loads all the BEMC tables
// it is necessary to have St_db_Maker running
mTables->loadTables((StMaker*)this);
// Getting information
// for example, getting pedestal and RMS for the
// BTOW Detector softId = 100
float ped = mTables->pedestal(BTOW, 100);
float rms = mTables->pedestalRMS(BTOW, 100);
This class inherits from StBemcTables and is useful for performing all kinds of more advanced BEMC DB operations, including uploading tables if you've got the privileges for it.
I'm not sure if anyone is actually using the rest of these, nor am I confident that they actually work in DEV. Feel free to leave some feedback if you have some experience with them. -- Adam
Utility to subtract hadronic energy from EMC towers. It uses StEmcHadDE to subtract the hadronic energy in the calorimeter in a event by event basis.
Utility to calculate hadronic energy profile in the BEMC. It calculates the amount of energy deposited by a single hadron as a function of its momentum, position in the detector and distance to the center of the tower.
This utility calculates high voltages for the towers for a given absolute gain.
Basic EMC neural network interface.
Event filter for BEMC (StEvent and StMcEvent only)
This utility has a collection of tools to do event filtering in the BEMC. Some of the filters available are: