00001
00002
00003
00004
00006
00007
00008
00009
00010
00011
00012
00013
00014
00016
00017 #include "TFndHdt.h"
00018
00019
00020
00021
00022 ClassImp(TFndHdt)
00023
00024 TClonesArray *TFndHdt::fgHTof = 0;
00025 TClonesArray *TFndHdt::fgHSilCluster = 0;
00026 TClonesArray *TFndHdt::fgHLmd = 0;
00027 TClonesArray *TFndHdt::fgHStb = 0;
00028
00029
00030 TFndHdt::TFndHdt()
00031 :fRunNumber(),fEvtNum(),
00032 fNoiseLevel(-999)
00033
00034 {
00035 SetSilComMod_meanmaxcount_zero();
00036
00037 fGts = new TFndTrig();
00038 if (!fgHTof) fgHTof = new TClonesArray("TFndHTof",84);
00039 fTofHits = fgHTof;
00040
00041 if (!fgHSilCluster) fgHSilCluster = new TClonesArray("TFndHSilCluster",100);
00042 fSilClusters = fgHSilCluster;
00043
00044 if (!fgHLmd) fgHLmd = new TClonesArray("TFndHLmd",272);
00045 fLmdHits = fgHLmd;
00046
00047 if (!fgHStb) fgHStb = new TClonesArray("TFndHStb",2404);
00048 fStbHits = fgHStb;
00049
00050 }
00051
00052
00053 TFndHdt::~TFndHdt()
00054 {
00055 ClearArrays();
00056 Reset();
00057 delete fGts; fGts = 0;
00058
00059
00060
00061
00062
00063
00064
00065 }
00066
00067
00068 void TFndHdt::ClearArrays(){
00069
00070 fRunNumber = 0;
00071 fEvtNum = 0;
00072 fNoiseLevel = -999;
00073
00074 fGts->Reset();
00075
00076 fTofHits->Clear();
00077
00078 SetSilComMod_meanmaxcount_zero();
00079 fSilClusters->Clear();
00080
00081 fLmdHits->Clear();
00082
00083 fStbHits->Clear();
00084
00085
00086 }
00087
00088
00089 void TFndHdt::Reset(){
00090
00091 fRunNumber = 0;
00092 fEvtNum = 0;
00093 fNoiseLevel = -999;
00094
00095 fGts->Reset();
00096
00097 fTofHits->Delete();
00098
00099 SetSilComMod_meanmaxcount_zero();
00100 fSilClusters->Delete();
00101
00102 fLmdHits->Delete();
00103
00104 fStbHits->Delete();
00105
00106
00107 }
00108
00109
00110 TFndHTof *TFndHdt::Find_Add_TofHit(Int_t channel,Bool_t add_if_missing){
00111
00112 Int_t last_id = fTofHits->GetEntries();
00113 for(Int_t i=0;i<last_id;i++)
00114 if( ((TFndHTof*)fTofHits->At(i))->GetChannel() == channel){
00115
00116 return ((TFndHTof*)fTofHits->At(i));
00117 }
00118
00119 if(!add_if_missing){
00120 Info("Find_Add_TofHit","No hit found for channel %d",channel);
00121 return 0;
00122 }
00123
00124 TClonesArray &tof_hits = *fTofHits;
00125 TFndHTof *th = new(tof_hits[last_id]) TFndHTof(channel);
00126
00127 return th;
00128
00129 }
00130
00131
00132 TFndHSilCluster *TFndHdt::Add_SilCluster(Int_t layer){
00133
00134
00135
00136 Int_t last_id = fSilClusters->GetEntries();
00137
00138 TClonesArray &sil_hits = *fSilClusters;
00139 TFndHSilCluster *sch = new(sil_hits[last_id]) TFndHSilCluster(layer);
00140
00141 return sch;
00142
00143 }
00144
00145
00146 TFndHLmd *TFndHdt::Find_Add_LmdHit(Int_t channel,Bool_t add_if_missing){
00147
00148 Int_t last_id = fLmdHits->GetEntries();
00149 for(Int_t i=0;i<last_id;i++)
00150 if( ((TFndHLmd*)fLmdHits->At(i))->GetChannel() == channel){
00151
00152 return ((TFndHLmd*)fLmdHits->At(i));
00153 }
00154
00155 if(!add_if_missing){
00156 Info("Find_Add_LmdHit","No hit found for channel %d",channel);
00157 return 0;
00158 }
00159
00160 TClonesArray &lmd_hits = *fLmdHits;
00161 TFndHLmd *lh = new(lmd_hits[last_id]) TFndHLmd(channel);
00162
00163 return lh;
00164
00165
00166 }
00167
00168
00169 TFndHStb *TFndHdt::Find_Add_StbHit(Int_t channel,Bool_t add_if_missing){
00170
00171 Int_t last_id = fStbHits->GetEntries();
00172 for(Int_t i=0;i<last_id;i++)
00173 if( ((TFndHStb*) fStbHits->At(i))->GetChannel() == channel){
00174 if(add_if_missing) Warning("Find_Add_StbHit","Hit found at position %d (channel %d)",i,channel);
00175 return ((TFndHStb*) fStbHits->At(i));
00176 }
00177
00178 if(!add_if_missing){
00179 Info("Find_Add_StbHit","No hit found for channel %d",channel);
00180 return 0;
00181 }
00182 TClonesArray &stb_hits = *fStbHits;
00183 TFndHStb *sh = new(stb_hits[last_id]) TFndHStb(channel);
00184
00185 return sh;
00186
00187 }
00188
00189
00190 void TFndHdt::EvalHits(){
00191
00192
00193 for(Int_t ic = 0 ; ic < fTofHits->GetEntries() ; ic++) ( (TFndHTof *)fTofHits->At(ic) )->EvalHit();
00194 for(Int_t ic = 0 ; ic < fSilClusters->GetEntries() ; ic++) ( (TFndHSilCluster *)fSilClusters->At(ic) )->EvalHit();
00195 for(Int_t ic = 0 ; ic < fLmdHits->GetEntries() ; ic++) ( (TFndHLmd*) fLmdHits->At(ic) )->EvalHit();
00196 for(Int_t ic = 0 ; ic < fStbHits->GetEntries() ; ic++) ( (TFndHStb*) fStbHits->At(ic) )->EvalHit();
00197
00198 EvalNoiseLevel();
00199 }
00200
00201
00202 void TFndHdt::EvalNoiseLevel(){
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 const Int_t nsl = K_N_TOFINO_SLABS;
00218
00219 TFndHTof *tmptof = 0;
00221
00222 Bool_t fIsHighMeanTime[nsl];
00223 Bool_t fIsLowMeanTime[nsl];
00224 Bool_t fIsHighAdc[nsl];
00225
00226
00227
00228
00229 Bool_t fIsSelected_A[nsl];
00230 Bool_t fIsSelected_B[nsl];
00231
00232 for(Int_t i=0; i<nsl; i++){
00233 fIsHighMeanTime[i] = kFALSE;
00234 fIsLowMeanTime[i] = kFALSE;
00235 fIsHighAdc[i] = kFALSE;
00236
00237 fIsSelected_A[i] = kFALSE;
00238 fIsSelected_B[i] = kFALSE;
00239 }
00240
00241
00242 Int_t nhits = fTofHits->GetEntries();
00243 for(Int_t nh=0; nh<nhits; nh++){
00244 tmptof = ( (TFndHTof *)fTofHits->At(nh) );
00245 if(!tmptof){
00246 Error("EvalNoiseLevel","Maybe you have just found a BUG!!!");
00247 TerminateFroot();
00248 }
00249 Int_t lay = tmptof->GetLayer();
00250 Int_t slab = tmptof->GetSlab();
00251 if(lay != E_FIN_INNER_LAYER || slab < 1 || slab > nsl) continue;
00252
00253
00254 if(tmptof->GetHighMeanTimer() > -1) fIsHighMeanTime[slab-1] = kTRUE;
00255 if(tmptof->GetLowMeanTimer() > -1) fIsLowMeanTime[slab-1] = kTRUE;
00256
00257
00258
00259 Float_t overchrg = tmptof->GetOverChargeValue();
00260 if( overchrg > 0 ) fIsHighAdc[slab-1] = kTRUE;
00261 }
00262
00263
00264
00265
00266
00267 Int_t nsel = -1;
00268
00269
00270 nsel = 0;
00271 for(Int_t i=0; i<nsl; i++){
00272 if( fIsHighMeanTime[i] ){
00273 fIsSelected_A[i] = kTRUE;
00274 nsel++;
00275 }
00276 else fIsSelected_A[i] = kFALSE;
00277 }
00278
00279 if(nsel < 2){
00280 fNoiseLevel = -1;
00281 return;
00282 }
00283 Bool_t isgood = kFALSE;
00284 if(nsel == 2){
00285 isgood = kTRUE;
00286 }
00287
00288 for(Int_t i=0; i<nsl; i++) fIsSelected_B[i] = kFALSE;
00289 for(Int_t i=0; i<nsl; i++) {
00290 for(Int_t j=0; j<nsl; j++) {
00291 if(i!=j && fIsSelected_A[i] && fIsSelected_A[j] ) {
00292 if( CheckTofinoBtb(i,j)){
00293 fIsSelected_B[i] = kTRUE;
00294 fIsSelected_B[j] = kTRUE;
00295 }
00296 }
00297 }
00298 }
00299
00300
00301 nsel = 0;
00302 for(Int_t i=0; i<K_N_TOFINO_SLABS; i++){
00303 if( fIsSelected_B[i] ) nsel++;
00304 }
00305
00306 if( nsel == 2 ){
00307 fNoiseLevel = (isgood) ? 0 : 1;
00308 return;
00309 }
00310 else if(nsel < 2){
00311 fNoiseLevel = -1;
00312 return;
00313 }
00314
00315 isgood = kFALSE;
00316 nsel = 0;
00317 for(Int_t i=0; i<nsl; i++) {
00318 if( fIsSelected_B[i] && fIsHighAdc[i] ){
00319 fIsSelected_A[i] = kTRUE;
00320 nsel++;
00321 }
00322 else fIsSelected_A[i] = kFALSE;
00323 }
00324
00325 if(nsel < 2){
00326 fNoiseLevel = -2;
00327 return;
00328 }
00329 if(nsel == 2){
00330 isgood = kTRUE;
00331 }
00332
00333 for(Int_t i=0; i<nsl; i++) fIsSelected_B[i] = kFALSE;
00334 for(Int_t i=0; i<nsl; i++) {
00335 for(Int_t j=0; j<nsl; j++) {
00336 if( i !=j && fIsSelected_A[i] && fIsSelected_A[j] ) {
00337 if( CheckTofinoBtb(i,j)){
00338 fIsSelected_B[i] = kTRUE;
00339 fIsSelected_B[j] = kTRUE;
00340 }
00341 }
00342 }
00343 }
00344
00345
00346 nsel = 0;
00347 for(Int_t i=0; i<K_N_TOFINO_SLABS; i++){
00348 if( fIsSelected_B[i] ) nsel++;
00349 }
00350
00351 if( nsel == 2 ){
00352 fNoiseLevel = (isgood) ? 2 : 3;
00353 return;
00354 }
00355 else if(nsel < 2){
00356 fNoiseLevel = -3;
00357 return;
00358 }
00359 fNoiseLevel = 999;
00360
00361
00362 tmptof = 0;
00363 }
00364
00365
00366 void TFndHdt::PrintHits(Int_t dpt_gts,Int_t dpt_tof,Int_t dpt_sil,Int_t dpt_lmd,Int_t dpt_stb) {
00367
00368
00369
00370 TString msg = "";
00371 TString cline = "";
00372
00373 cline.Form("\n\n TFndHdt::PrintHits - run %u , event %u\n",fRunNumber,fEvtNum); msg+=cline;
00374 cline.Form(" -> Print depth level for GTS is: %d \n",dpt_gts); msg+=cline;
00375 cline.Form(" -> Print depth level for TOF is: %d \n",dpt_tof); msg+=cline;
00376 cline.Form(" -> Print depth level for SIL is: %d \n",dpt_sil); msg+=cline;
00377 cline.Form(" -> Print depth level for LMD is: %d \n",dpt_lmd); msg+=cline;
00378 cline.Form(" -> Print depth level for STB is: %d \n",dpt_stb); msg+=cline;
00379
00380 cline.Form(" -> Event evaluated noise level : %d \n",fNoiseLevel); msg+=cline;
00381
00382 Printf(msg);
00383
00384 PrintGts(dpt_gts);
00385 PrintTofHits(dpt_tof);
00386 if(dpt_sil > 3) PrintSilHits(dpt_sil);
00387 PrintSilClusters(dpt_sil);
00388 PrintLmdHits(dpt_lmd);
00389 PrintStbHits(dpt_stb);
00390
00391 Printf("\n TFndHdt::PrintHits - All hits printed for run %u , event %u",fRunNumber,fEvtNum);
00392 }
00393
00394
00395 void TFndHdt::PrintGts(Int_t depth) {
00396
00397 if(depth < 0) return;
00398 Printf("\nTFndHdt::PrintGts - event %u GTS content",fEvtNum);
00399 fGts->PrintTrigger(depth);
00400
00401 }
00402
00403
00404 void TFndHdt::PrintTofHits(Int_t depth) {
00405
00406 if(depth < 0) return;
00407 Int_t entries = fTofHits->GetEntries();
00408 Printf("\nTFndHdt::PrintTofHits - event %u ; number of TOF Hits: %d",fEvtNum,entries);
00409 for(Int_t ic=0;ic<entries; ic++) {
00410 ( (TFndHTof *)fTofHits->At(ic) )->PrintHit(depth);
00411 }
00412
00413 }
00414
00415
00416 void TFndHdt::PrintSilHits(Int_t depth){
00417 if(depth < 0) return;
00418
00419 Printf("\nTFndHdt::PrintSilHits",fEvtNum);
00420 for(Int_t ch=0;ch<K_N_Sil_AdcCha;ch++){
00421 for(Int_t mod=0;mod<K_N_Sil_Modules;mod++){
00422 for(Int_t side=0;side<K_N_Sil_Sides;side++){
00423 Printf(" printing ch %d, mod %d, side %d",ch,mod,side);
00424 Printf(" -> Noise : %d",fSilNoise[ch][mod][side]);
00425 Printf(" -> CM-mean : %d",fSilComMod_mean[ch][mod][side]);
00426
00427
00428 }
00429 }
00430 }
00431
00432 }
00433
00434
00435 void TFndHdt::PrintSilClusters(Int_t depth){
00436
00437 if(depth < 0) return;
00438
00439 Int_t entries = fSilClusters->GetEntries();
00440 Printf("\nTFndHdt::PrintSilClusters - event %u ; number of Sil-clusters: %d",fEvtNum,entries);
00441 for(Int_t ic=0;ic<entries; ic++) {
00442 TFndHSilCluster *hit = (TFndHSilCluster*) fSilClusters->At(ic);
00443 hit->PrintHit(depth);
00444 }
00445
00446
00447 }
00448
00449
00450 void TFndHdt::PrintLmdHits(Int_t depth) {
00451
00452 if(depth < 0) return;
00453 Int_t entries = fLmdHits->GetEntries();
00454 Printf("\nTFndHdt::PrintLmdHits - event %u ; number of Drift Chambers Hits: %d",fEvtNum,entries);
00455 for(Int_t ic=0;ic<entries; ic++) {
00456 TFndHLmd *hit = (TFndHLmd*) fLmdHits->At(ic);
00457 hit->PrintHit(depth);
00458 }
00459
00460 }
00461
00462
00463 void TFndHdt::PrintStbHits(Int_t depth) {
00464
00465 if(depth < 0) return;
00466
00467 Int_t entries = fStbHits->GetEntries();
00468 Printf("\nTFndHdt::PrintStbHits - event %u ; number of Straw Tubes Hits: %d",fEvtNum,entries);
00469 for(Int_t id=0;id<entries; id++) {
00470 TFndHStb *hit = (TFndHStb*) fStbHits->At(id);
00471 hit->PrintHit(depth);
00472 }
00473
00474 }