/////////////////////////////////////////////////////////////////////////// // // CPS_L1ClusterChunk.cpp /////////////////////////////////////////////////////////////////////////// // // Created: JUN-99: A. Lucotte // // Purpose: L1 CPS Cluster Finder code // - Form FPS clusters as defined in CPS_L1Cluster Class // - Count total number of CPS clusters found // History: JUL-99 A.L. // - completed the modification due to the use of // CPS_L1Cluster Class // - used packing/unpacking function by Mrinmoy // SEP-99 A.L. // - got rid of packing/unpacking functions // - switched to M. Fortner Format in his new class // D0MCH::CTTClusterChannel --still incomplete // /////////////////////////////////////////////////////////////////////////// #include "tsim_l1ft/CPS_L1Cluster.hpp" #include "tsim_l1ft/CPS_L1ClusterChunk.hpp" #include "cps_util/CPSCellID.hpp" #include "cpsdigi_evt/CPSDigiChunk.hpp" #include "edm/TKey.hpp" #include "edm/THandle.hpp" #include "edm/Event.hpp" #include // Constructor: CPS_L1ClusterChunk::CPS_L1ClusterChunk( int _count, edm::Event& event ) { _l1cpsClusterCount = 0; for( int cand=0; cand < 512; cand++ ){ CPS_L1Cluster cps_l1cluster; _cps_l1cluster[ cand ] = cps_l1cluster; } CPS_L1ClusterChunkForm( event ) ; } // Destructor: CPS_L1ClusterChunk::~CPS_L1ClusterChunk(){} // Accessor: int CPS_L1ClusterChunk::Get_L1ClusterCount( edm::Event& event ){ return _l1cpsClusterCount;} //=================================================================== // Method: void CPS_L1ClusterChunk::CPS_L1ClusterChunkForm //=================================================================== // Created : JUL-99 A.L. // Purpose : Form cluster chunk of cps_l1clusters. // Modified: SEP-99 A.L. // - Change names of methods // - Accomodate for CTTClusterChannel Class format // SEP-99 A.L. // - debug for CPSDigiChunk //=================================================================== void CPS_L1ClusterChunk::CPS_L1ClusterChunkForm(edm::Event& event){ cout << " CPSCluster Chunk " << endl; // (1) Extract DigiChunk from the event: const edm::TKey digiKey; // Initialization of geometrical parameters const int strip_max = 1280 ; const int strip_min = -1280; const int sectAX_max = 80 ; // 2x80 sectors (Sides..) const int sectUV_max = 5; const int noctant = 8; // Initialization of #clusters arrays for every event const int nmax = 512; int _l1cpsAxialCount = 0; int _FEAxialCount[ sectAX_max ]; int _COLAxialCount[ noctant ]; int iclus = 0; int iclusx = 0; // Thresholds (in GeV) float Thigh = 0.005; float Tlow = 0.003; // Initializaition of UV cluster arrays int cluster_high[ nmax ]; int cluster_lowt[ nmax ]; int cluster_side[ nmax ]; int cluster_sect[ nmax ]; int cluster_addr[ nmax ]; int cluster_widt[ nmax ]; int cluster_orie[ nmax ]; // aXial arrays of clusters -- special treatment int clusterx_high[ nmax ]; int clusterx_lowt[ nmax ]; int clusterx_side[ nmax ]; int clusterx_sect[ nmax ]; int clusterx_addr[ nmax ]; int clusterx_widt[ nmax ]; int clusterx_orie[ nmax ]; // (2) Loop over Digi Chunk List item: edm::THandle digichk = digiKey.find(event); float digiLay1(0), digiLay2(0), digiLay3(0); int cpshits = 0; if( digichk.isValid()){ CPSDigiChunk* digi_ptr = digichk.ptr(); mapdigicount = digi_ptr->get_Map(); if(digicount.size() > 0)++cpshits; for(map::const_iterator icps = digicount.begin(); icps != digicount.end() ; ++icps){ int strip_index = (*icps).first.strip_No(); int layer_index = (*icps).first.layer_No(); float strip_energy = (*icps).second; bool proceed = ( strip_index <= 1280 ) && ( layer_index <= 3) && ( strip_energy <= 100.0 ); //Fill cluster arrays: if( proceed ){ if( layer_index ==1 ){ int refer = -9999; int width = 0; if( strip_energy >= Tlow ){ if( strip_index != refer ){ if( strip_index != refer+1 ){ iclusx++; _l1cpsAxialCount++; refer = strip_index; } else{ width++; refer = strip_index; } } } if( iclusx <= 24 ){ // Note: North and South are ORed in the same sector if( strip_index < 0 )clusterx_side[iclusx] = 0; if( strip_index < 0 )clusterx_side[iclusx] = 1; clusterx_sect[iclusx] = int( abs(strip_index) / 80) + 1 ; int isec = clusterx_sect[iclusx]; _FEAxialCount[ isec ]++; clusterx_high[iclusx] = 0; // arbitrary clusterx_lowt[iclusx] = 1; clusterx_orie[iclusx] = layer_index ; clusterx_addr[iclusx] = strip_index + int(width/2); clusterx_widt[iclusx] = width; } } // ------------- Layer 2 (U)---------------------- if( layer_index == 2 ){ int refer = -9999; int width = 0; if( strip_energy >= Tlow ){ if( strip_index != refer ){ if( strip_index != refer ){ iclus++; refer = strip_index; } else{ width++; refer = strip_index; } } } if( strip_index < 0 )cluster_side[iclus] = 0; if( strip_index < 0 )cluster_side[iclus] = 1; cluster_sect[iclus] = int( strip_index / 5) + 1 ; cluster_high[iclus] = 0; // arbitrary cluster_lowt[iclus] = 1; cluster_orie[iclus] = layer_index ; cluster_addr[iclus] = strip_index + int(width/2); cluster_widt[iclus] = width; } if( layer_index == 2 ){ int refer = -9999; int width = 0; if( strip_energy >= Tlow ){ if( strip_index != refer ){ if( strip_index != refer ){ iclus++; refer = strip_index; } else{ width++; refer = strip_index; } } if( strip_index < 0 )cluster_side[iclus] = 0; if( strip_index < 0 )cluster_side[iclus] = 1; } cluster_sect[iclus] = int( strip_index / 5) + 1 ; cluster_high[iclus] = 0; // arbitrary cluster_lowt[iclus] = 1; cluster_orie[iclus] = layer_index ; cluster_addr[iclus] = strip_index + int(width/2); cluster_widt[iclus] = width; } CPS_L1Cluster cps_l1cluster( cluster_high[iclus], cluster_lowt[iclus], cluster_side[iclus], cluster_sect[iclus], cluster_addr[iclus], cluster_widt[iclus], cluster_orie[iclus]); _cps_l1cluster[ iclus ] = cps_l1cluster; } } } // Troncation scheme for Octant (Axial) info: // Maximum of 24 clusters starting with higher indices / sectors for( int isec=1; isec <= 80; isec++){ if( _FEAxialCount[ isec ] >= 8 )_FEAxialCount[ isec ] = 8; } for(int ioct=1; ioct<=8; ioct++){ _COLAxialCount[ ioct ] =_FEAxialCount[ 10*ioct-9 ]+ _FEAxialCount[ 10*ioct-8 ]+ _FEAxialCount[ 10*ioct-7 ]+ _FEAxialCount[ 10*ioct-6 ]+ _FEAxialCount[ 10*ioct-5 ]+ _FEAxialCount[ 10*ioct-4 ]+ _FEAxialCount[ 10*ioct-3 ]+ _FEAxialCount[ 10*ioct-2 ]+ _FEAxialCount[ 10*ioct-1 ]+ _FEAxialCount[ 10*ioct ]; if( _COLAxialCount[ ioct ] >= 24 )_COLAxialCount[ ioct ] = 24; } } //============================================================================= // Method: CPS_L1ClusterChunk::create_cpsl1Chunk(edm::Event&, D0MCH::SysID ) //============================================================================= // // Created: SEP-99 A.L. // // Purpose: Fill cps_l1chunk using standard format CTTClusterChannel // History: SEP-22 A.L. Wait for Mike Fortner's update: // - setOrientation(), setType() do not exist yet in CTTClusterChannel // - setThreshold, setAddress still need to be modified // - temporary fixes -- see Kin //============================================================================== std::vector CPS_L1ClusterChunk::create_cpsl1Chunk(){ int version = 1 ; // set arbitrarily std::vector cps_l1chunk; int modid = 3 ; // CPS == ??? // Loop over CPS Clusters for ( int iobj = 0; iobj < _l1cpsClusterCount ; iobj++ ){ D0MCH::CTTClusterChannel chan; chan.setID( modid, iobj+1 ); chan.setThreshold( _cps_l1cluster[iobj].Get_ClusterLow() ); // _cps_l1cluster[iobj].Get_ClusterHig() ); // Temporary Fixes for: // Address = 1000*sector + Strip index int adress = 1000*_cps_l1cluster[iobj].Get_ClusterSect() + _cps_l1cluster[iobj].Get_ClusterAddr(); chan.setAddress( adress ); chan.setWidth(_cps_l1cluster[iobj].Get_ClusterWidt() ); //chan.setOrientation( _cps_l1cluster[iobj].Get_ClusterOrie() ); chan.setError( 0 ); cps_l1chunk.push_back( chan ) ; } return cps_l1chunk; }