CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/HLTrigger/special/src/HLTPixelAsymmetryFilter.cc

Go to the documentation of this file.
00001 
00002 //
00003 // HLTPixelAsymmetryFilter
00004 //
00005 // See header file for infos
00006 //
00007 // S.Viret: 12/01/2011 (viret@in2p3.fr)
00008 //
00010 
00011 #include "HLTrigger/special/interface/HLTPixelAsymmetryFilter.h"
00012 
00013 //
00014 // constructors and destructor
00015 //
00016  
00017 HLTPixelAsymmetryFilter::HLTPixelAsymmetryFilter(const edm::ParameterSet& config) :
00018   inputTag_     (config.getParameter<edm::InputTag>("inputTag")),
00019   saveTag_      (config.getUntrackedParameter<bool>("saveTag", false)),
00020   min_asym_ (config.getParameter<double>("MinAsym")),
00021   max_asym_ (config.getParameter<double>("MaxAsym")),
00022   clus_thresh_ (config.getParameter<double>("MinCharge")),
00023   bmincharge_ (config.getParameter<double>("MinBarrel"))
00024 {
00025   LogDebug("") << "Using the " << inputTag_ << " input collection";
00026   LogDebug("") << "Requesting events with a charge repartition asymmetry between " << min_asym_ << " and " << max_asym_;
00027   LogDebug("") << "Mean cluster charge in the barrel should be higher than" << bmincharge_ << " electrons ";
00028   LogDebug("") << "Only clusters with a charge larger than " << clus_thresh_ << " electrons will be used ";
00029 
00030   // register your products
00031   produces<trigger::TriggerFilterObjectWithRefs>();
00032 }
00033 
00034 HLTPixelAsymmetryFilter::~HLTPixelAsymmetryFilter()
00035 {
00036 }
00037 
00038 //
00039 // member functions
00040 //
00041 
00042 // ------------ method called to produce the data  ------------
00043 bool HLTPixelAsymmetryFilter::filter(edm::Event& event, const edm::EventSetup& iSetup)
00044 {
00045   // All HLT filters must create and fill an HLT filter object,
00046   // recording any reconstructed physics objects satisfying (or not)
00047   // this HLT filter, and place it in the Event.
00048 
00049   // The filter object
00050   std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterobject (new trigger::TriggerFilterObjectWithRefs(path(),module()));
00051   if (saveTag_) filterobject->addCollectionTag(inputTag_);
00052 
00053   // get hold of products from Event
00054   edm::Handle<edmNew::DetSetVector<SiPixelCluster> > clusterColl;
00055   event.getByLabel(inputTag_, clusterColl);
00056 
00057   unsigned int clusterSize = clusterColl->dataSize();
00058   LogDebug("") << "Number of clusters accepted: " << clusterSize;
00059 
00060   bool accept = (clusterSize >= 2); // Not necessary to go further in this case
00061 
00062   if (!accept) return accept;
00063 
00064   double asym_pix_1  = -1;
00065   double asym_pix_2  = -1;
00066 
00067   int n_clus[3]   = {0,0,0};
00068   double e_clus[3] = {0.,0.,0.};
00069 
00070   for (edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=clusterColl->begin(); DSViter!=clusterColl->end();DSViter++ ) 
00071   {
00072     edmNew::DetSet<SiPixelCluster>::const_iterator begin=DSViter->begin();
00073     edmNew::DetSet<SiPixelCluster>::const_iterator end  =DSViter->end();
00074     uint32_t detid = DSViter->id();
00075 
00076     bool barrel = DetId(detid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
00077     bool endcap = DetId(detid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
00078 
00079     int detpos = -1;
00080 
00081     // First we look if we are in the endcap or in the barrel PIXELS
00082     // Asymmetry is computed with endcap pixels only
00083 
00084     if (endcap)
00085     {
00086       PixelEndcapName::HalfCylinder position = PixelEndcapName(DetId(detid)).halfCylinder();
00087 
00088       if (position == PixelEndcapName::mI || position == PixelEndcapName::mO) // FPIX-
00089         detpos = 0;
00090 
00091       if (position == PixelEndcapName::pI || position == PixelEndcapName::pO) // FPIX+
00092         detpos = 2;
00093     }
00094 
00095     if (barrel)
00096       detpos = 1;
00097 
00098     if (detpos<0) continue;
00099 
00100     for(edmNew::DetSet<SiPixelCluster>::const_iterator iter=begin;iter!=end;++iter) 
00101     {
00102       if (iter->charge()>clus_thresh_ )
00103       {
00104         ++n_clus[detpos];
00105         e_clus[detpos]+=iter->charge();
00106       }    
00107     }
00108   } // End of cluster loop
00109 
00110   for (int i=0;i<3;++i) 
00111   {
00112     if (n_clus[i])
00113       e_clus[i] /= n_clus[i];
00114   }
00115 
00116   if (e_clus[1] < bmincharge_) return false; // Reject event if the Barrel mean charge is too low
00117 
00118 
00119   if (e_clus[0]+e_clus[2] != 0) // Compute asyms, if applicable
00120   {
00121     asym_pix_1 = e_clus[0]/(e_clus[0]+e_clus[2]);
00122     asym_pix_2 = e_clus[2]/(e_clus[0]+e_clus[2]);
00123   }
00124   else  // Otherwise reject event
00125   {
00126     return false;
00127   }
00128 
00129   bool pkam_1 = (asym_pix_1 <= max_asym_ && asym_pix_1 >= min_asym_);
00130   bool pkam_2 = (asym_pix_2 <= max_asym_ && asym_pix_2 >= min_asym_);
00131 
00132   if (pkam_1 || pkam_2) return accept; // Final selection
00133 
00134   return false;
00135 }