00001 // $Id: EEeventDst.cxx,v 1.9 2007/05/30 02:38:48 balewski Exp $ 00002 00003 #include <cassert> 00004 #include <TClonesArray.h> 00005 #include <StMessMgr.h> 00006 00007 #include "EEsectorDst.h" 00008 #include "EEeventDst.h" 00009 00010 ClassImp(EEeventDst) 00011 //-------------------------------------------------- 00012 //-------------------------------------------------- 00013 //-------------------------------------------------- 00014 EEeventDst::EEeventDst(){ 00015 // printf("EEeventDst() constructed\n"); 00016 Sec= new TClonesArray("EEsectorDst",1000); 00017 clear(); 00018 } 00019 00020 //-------------------------------------------------- 00021 //-------------------------------------------------- 00022 //-------------------------------------------------- 00023 EEeventDst::~EEeventDst() 00024 { 00025 delete Sec; Sec = 0; 00026 } 00027 00028 //-------------------------------------------------- 00029 //-------------------------------------------------- 00030 //-------------------------------------------------- 00031 int EEeventDst::getNSectors(){return Sec->GetEntries();} 00032 00033 //-------------------------------------------------- 00034 //-------------------------------------------------- 00035 //-------------------------------------------------- 00036 void EEeventDst::clear(){ // only content of sectors, leave sectors 00037 // printf("EEvent Dst-hits cleared in %d sectors\n",Sec->GetEntries()); 00038 00039 ID=-999; 00040 type=kUnknown; 00041 token=-2; 00042 timeStamp=0; 00043 Sec->Delete(); 00044 } 00045 //-------------------------------------------------- 00046 //-------------------------------------------------- 00047 //-------------------------------------------------- 00048 void EEeventDst::Clear(const char*){ clear();} 00049 00050 //------------------------------------------------- 00051 //------------------------------------------------- 00052 //------------------------------------------------- 00053 void EEeventDst::print(int k){ 00054 LOG_INFO<<Form("Event ID=%d, type=%d token=%d nSect=%d time stamp= %d\n",ID,type,token,Sec->GetEntries(),timeStamp)<<endm; 00055 int is; 00056 for(is=0;is<Sec->GetEntriesFast();is++) { 00057 EEsectorDst *sec=(EEsectorDst*)Sec->At(is); 00058 sec->print(k-1); 00059 } 00060 00061 } 00062 00063 00064 //------------------------------------------------- 00065 //------------------------------------------------- 00066 //------------------------------------------------- 00067 EEsectorDst * EEeventDst::addSectorDst(int IDx) { 00068 // To avoid calling the very time consuming operator new for each track, 00069 // the standard but not well know C++ operator "new with placement" 00070 // is called. If tracks[i] is 0, a new Track object will be created 00071 // otherwise the previous Track[i] will be overwritten. 00072 00073 TClonesArray &SEC1 = *Sec; 00074 int nSec=SEC1.GetEntriesFast(); 00075 EEsectorDst *sec= new(SEC1[nSec]) EEsectorDst(IDx);; 00076 sec->clear(); 00077 //printf("Dst-hits add sector %d Array \n",IDx); 00078 //sec->print(); 00079 00080 return sec; 00081 } 00082 00083 //--------------------------------------------------- 00084 //--------------------------------------------------- 00085 //--------------------------------------------------- 00086 EEsectorDst* EEeventDst::getSec(int secID, int create){ 00087 int is; 00088 //printf("EEeventDst::getSec(%d), nSec=%d\n",secID,Sec->GetEntries()); 00089 for(is=0;is<Sec->GetEntries();is++) { 00090 EEsectorDst *sec=(EEsectorDst*)Sec->At(is); 00091 if(sec->getID()==secID) return sec; 00092 } 00093 //printf("EEeventDst() : sector ID=%d not found\n",secID); 00094 if(create==0) return 0; 00095 return addSectorDst(secID); 00096 } 00097 00098 00099 //--------------------------------------------------- 00100 //--------------------------------------------------- 00101 //--------------------------------------------------- 00102 void EEeventDst:: sumRawMC(EEeventDst* eveOut,float minE) { 00103 assert(eveOut); 00104 eveOut->clear(); 00105 eveOut->ID=ID; 00106 eveOut->type=kTrigMC; 00107 00108 int is; 00109 for(is=0;is<Sec->GetEntries();is++) { 00110 00111 // access In & Out sectors with the same ID 00112 00113 EEsectorDst *secIN=(EEsectorDst*)Sec->At(is); 00114 int secID=secIN->getID(); 00115 EEsectorDst *secOut=eveOut->getSec(secID); 00116 if(secOut==0) { // add new sector if needed 00117 secOut= eveOut->addSectorDst(secID); 00118 } 00119 00120 secIN->sumRawMC(secOut,minE); 00121 } 00122 00123 } 00124 00125 00126 // $Log: EEeventDst.cxx,v $ 00127 // Revision 1.9 2007/05/30 02:38:48 balewski 00128 // replace printf -->LOG_XXX 00129 // 00130 // Revision 1.8 2004/04/08 21:34:17 perev 00131 // Leak off 00132 // 00133 // Revision 1.7 2004/04/07 18:54:47 perev 00134 // Cleanup delete in destructor added 00135 // 00136 // Revision 1.6 2003/11/12 19:59:06 balewski 00137 // I forgot what has changed 00138 // 00139 // Revision 1.5 2003/10/02 20:52:45 balewski 00140 // more functionality for print() 00141 // 00142 // Revision 1.4 2003/09/11 19:40:56 zolnie 00143 // updates for gcc3.2 00144 // 00145 // Revision 1.3 2003/07/01 14:13:13 balewski 00146 // no clue 00147 // 00148 // Revision 1.2 2003/02/21 22:21:47 balewski 00149 // time stamp added 00150 // 00151 // Revision 1.1 2003/02/20 05:15:14 balewski 00152 // reorganization 00153 // 00154 // Revision 1.1 2003/01/28 23:16:06 balewski 00155 // start 00156 // 00157 // Revision 1.8 2002/11/30 20:03:15 balewski 00158 // consistent with FeeRawTTree 00159 // 00160 // Revision 1.7 2002/11/12 20:08:29 balewski 00161 // some cleanup 00162 // 00163 // Revision 1.6 2002/11/11 21:22:48 balewski 00164 // EEMC added to StEvent 00165 // 00166 // Revision 1.5 2002/10/01 06:03:15 balewski 00167 // added smd & pre2 to TTree, tof removed 00168 // 00169 // Revision 1.4 2002/09/26 14:48:28 balewski 00170 // biger buffer 00171 // 00172 // Revision 1.3 2002/09/25 16:47:55 balewski 00173 // cleanup , cut in geant time for twoer-like detectors 00174 // 00175 // Revision 1.2 2002/09/20 21:58:13 balewski 00176 // sum of MC hits over activ detectors 00177 // produce total tower energy with weight 1 1 1 1 00178 // 00179 // Revision 1.1.1.1 2002/09/19 18:58:54 zolnie 00180 // Imported sources 00181 // 00182 // Revision 1.1.1.1 2002/08/29 19:32:01 zolnie 00183 // imported sources 00184 // 00185 // Revision 1.2 2002/08/28 01:43:42 zolnie 00186 // version alpha - 2 00187 // 00188 // Revision 1.1 2002/08/26 19:46:12 zolnie 00189 // Initial revision 00190 // 00191
1.5.9